Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,45 +0,0 @@
|
|||
pragma Ada_2022;
|
||||
with Ada.Numerics; use Ada.Numerics;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
|
||||
with Easy_Graphics; use Easy_Graphics;
|
||||
|
||||
procedure Chaos_Game is
|
||||
Img : Easy_Image := New_Image ((1, 1), (512, 512), WHITE);
|
||||
|
||||
procedure Chaos (Image : in out Easy_Image;
|
||||
Vertex_Count : Positive;
|
||||
Radius : Float;
|
||||
Iters : Positive) is
|
||||
type Vertex_Array is array (1 .. Vertex_Count) of Point;
|
||||
Vertices : Vertex_Array;
|
||||
subtype Vertex_Range is Integer range 1 .. Vertex_Count;
|
||||
package Rand_V is new Ada.Numerics.Discrete_Random (Vertex_Range);
|
||||
use Rand_V;
|
||||
Gen : Generator;
|
||||
Half_X : constant Integer := X_Last (Image) / 2;
|
||||
Half_Y : constant Integer := Y_Last (Image) / 2;
|
||||
Half_Pi : constant Float := Float (Pi) / 2.0;
|
||||
Two_Pi : constant Float := Float (Pi) * 2.0;
|
||||
V : Integer;
|
||||
X : Integer := Half_X;
|
||||
Y : Integer := Half_Y;
|
||||
begin
|
||||
for V in 1 .. Vertex_Count loop
|
||||
Vertices (V).X := Half_X + Integer (Float (Half_X) *
|
||||
Cos (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count)));
|
||||
Vertices (V).Y := Half_Y - Integer (Float (Half_Y) *
|
||||
Sin (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count)));
|
||||
end loop;
|
||||
for I in 1 .. Iters loop
|
||||
V := Random (Gen);
|
||||
X := X + Integer (Radius * Float (Vertices (V).X - X));
|
||||
Y := Y + Integer (Radius * Float (Vertices (V).Y - Y));
|
||||
Plot (Image, (X, Y), BLACK);
|
||||
end loop;
|
||||
end Chaos;
|
||||
|
||||
begin
|
||||
Chaos (Img, 3, 0.5, 250_000);
|
||||
Write_GIF (Img, "chaos_game.gif");
|
||||
end Chaos_Game;
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
; Chaos game
|
||||
|
||||
(defun make-array (size)
|
||||
"Create an empty array with size*size elements."
|
||||
(setq m-array (make-vector size nil))
|
||||
(dotimes (i size)
|
||||
(setf (aref m-array i) (make-vector size 0)))
|
||||
m-array)
|
||||
|
||||
(defun chaos-next (p)
|
||||
"Return the next coordinates."
|
||||
(let* ((points (list (cons 1 0) (cons -1 0) (cons 0 (sqrt 3))))
|
||||
(v (elt points (random 3)))
|
||||
(x (car p))
|
||||
(y (cdr p))
|
||||
(x2 (car v))
|
||||
(y2 (cdr v)))
|
||||
(setq nx (/ (+ x x2) 2.0))
|
||||
(setq ny (/ (+ y y2) 2.0))
|
||||
(cons nx ny)))
|
||||
|
||||
(defun chaos-lines (arr size)
|
||||
"Turn array into a string for XPM conversion."
|
||||
(setq all "")
|
||||
(dotimes (y size)
|
||||
(setq line "")
|
||||
(dotimes (x size)
|
||||
(setq line (concat line (if (= (elt (elt arr y) x) 1) "*" "."))))
|
||||
(setq all (concat all "\"" line "\",\n")))
|
||||
all)
|
||||
|
||||
(defun chaos-show (arr size)
|
||||
"Convert size*size array to XPM image and show it."
|
||||
(insert-image (create-image (concat (format "/* XPM */
|
||||
static char * chaos[] = {
|
||||
\"%i %i 2 1\",
|
||||
\". c #000000\",
|
||||
\"* c #00ff00\"," size size)
|
||||
(chaos-lines arr size) "};") 'xpm t)))
|
||||
|
||||
(defun chaos (size scale max-iter)
|
||||
"Play the chaos game."
|
||||
(let ((arr (make-array size))
|
||||
(p (cons 0 0)))
|
||||
(dotimes (it max-iter)
|
||||
(setq p (chaos-next p))
|
||||
(setq x (round (+ (/ size 2) (* scale (car p)))))
|
||||
(setq y (round (+ (- size 10) (* -1 scale (cdr p)))))
|
||||
(setf (elt (elt arr y) x) 1))
|
||||
(chaos-show arr size)))
|
||||
|
||||
(chaos 400 180 50000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue