Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,2 +1,3 @@
---
from: http://rosettacode.org/wiki/Julia_set
note: Fractals

View file

@ -1,93 +0,0 @@
with Ada.Numerics.Generic_Complex_Types;
with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
with SDL.Events.Events;
procedure Julia_Set is
Width : constant := 1_200;
Height : constant := 900;
type Real is new Float;
package Complex_Real is
new Ada.Numerics.Generic_Complex_Types (Real);
use Complex_Real;
Iter : constant := 100;
C : constant Complex := (Re => -0.70000, Im => 0.27015);
Move : constant Complex := (Re => 0.000, Im => 0.000);
Zoom : constant := 0.800;
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL.Events.Events.Events;
function Map (Width, Height : in Integer;
X, Y : in Integer) return Complex
is
C : Complex;
L : constant Real := Real (Integer'Max (Width, Height));
begin
C := (2.0 * Real (X - Width / 2) / (L * Zoom),
2.0 * Real (Y - Height / 2) / (L * Zoom));
return C + Move;
end Map;
procedure Draw_Julia_Set is
use type SDL.C.int;
use SDL.Video.Palettes;
Z : Complex;
begin
for Y in 0 .. Height loop
for X in 0 .. Width loop
Z := Map (Width, Height, X, Y);
for N in 1 .. Iter loop
Z := Z ** 2 + C;
if abs (Z) > 2.0 then
Renderer.Set_Draw_Colour ((Red => 2 * Colour_Component (N),
Green => 255 - 2 * Colour_Component (N),
Blue => 150, Alpha => 255));
Renderer.Draw (Point => (X => SDL.C.int (X),
Y => SDL.C.int (Y)));
exit;
end if;
end loop;
end loop;
end loop;
end Draw_Julia_Set;
procedure Wait is
use type SDL.Events.Event_Types;
begin
loop
while SDL.Events.Events.Poll (Event) loop
if Event.Common.Event_Type = SDL.Events.Quit then
return;
end if;
end loop;
end loop;
end Wait;
begin
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
return;
end if;
SDL.Video.Windows.Makers.Create (Win => Window,
Title => "Julia set",
Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
Size => SDL.Positive_Sizes'(Width, Height),
Flags => 0);
SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
Renderer.Set_Draw_Colour ((0, 0, 0, 255));
Renderer.Fill (Rectangle => (0, 0, Width, Height));
Draw_Julia_Set;
Window.Update_Surface;
Wait;
Window.Finalize;
SDL.Finalise;
end Julia_Set;

View file

@ -1,59 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. JULIA-SET-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COMPLEX-CONSTANT.
05 C-REAL PIC S9V999.
05 C-IMAGINARY PIC S9V999.
01 WS-ARGAND-PLANE.
05 X PIC S9(9)V999.
05 Y PIC S9(9)V999.
01 WS-COMPLEX-VARIABLE.
05 Z-REAL PIC S9(9)V999.
05 Z-IMAGINARY PIC S9(9)V999.
01 WS-TEMPORARY-RESULTS.
05 X-SQUARED PIC S9(9)V999.
05 Y-SQUARED PIC S9(9)V999.
05 X-TIMES-Y PIC S9(9)V999.
05 Z-REAL-SQUARED PIC S9(9)V999.
01 WS-LOOP-COUNTERS.
05 HORIZONTAL PIC 999.
05 VERTICAL PIC 999.
05 ITERATIONS PIC 99.
77 WS-PLOT-CHARACTER PIC X.
PROCEDURE DIVISION.
INPUT-COMPLEX-CONSTANT-PARAGRAPH.
ACCEPT C-REAL FROM CONSOLE.
ACCEPT C-IMAGINARY FROM CONSOLE.
CONTROL-PARAGRAPH.
PERFORM OUTER-LOOP-PARAGRAPH VARYING VERTICAL FROM 1 BY 10
UNTIL VERTICAL IS GREATER THAN 320.
STOP RUN.
OUTER-LOOP-PARAGRAPH.
PERFORM COMPUTATION-PARAGRAPH VARYING HORIZONTAL FROM 1 BY 10
UNTIL HORIZONTAL IS GREATER THAN 560.
DISPLAY '' UPON CONSOLE.
COMPUTATION-PARAGRAPH.
SUBTRACT 280 FROM HORIZONTAL GIVING X.
SUBTRACT 160 FROM VERTICAL GIVING Y.
DIVIDE X BY 200 GIVING X.
DIVIDE Y BY 100 GIVING Y.
MOVE '#' TO WS-PLOT-CHARACTER.
PERFORM COMPLEX-MULTIPLICATION-PARAGRAPH
VARYING ITERATIONS FROM 1 BY 1
UNTIL ITERATIONS IS GREATER THAN 50
OR WS-PLOT-CHARACTER IS EQUAL TO SPACE.
DISPLAY WS-PLOT-CHARACTER UPON CONSOLE WITH NO ADVANCING.
COMPLEX-MULTIPLICATION-PARAGRAPH.
MULTIPLY X BY X GIVING X-SQUARED.
MULTIPLY Y BY Y GIVING Y-SQUARED.
SUBTRACT Y-SQUARED FROM X-SQUARED GIVING Z-REAL.
ADD C-REAL TO Z-REAL.
MULTIPLY X BY Y GIVING X-TIMES-Y.
MULTIPLY X-TIMES-Y BY 2 GIVING Z-IMAGINARY.
ADD C-IMAGINARY TO Z-IMAGINARY.
MULTIPLY Z-REAL BY Z-REAL GIVING Z-REAL-SQUARED.
IF Z-REAL-SQUARED IS GREATER THAN 10000 THEN
MOVE SPACE TO WS-PLOT-CHARACTER.
MOVE Z-REAL TO X.
MOVE Z-IMAGINARY TO Y.

View file

@ -1,17 +1,22 @@
cx = -0.7
cy = 0.27015
for y = 0 to 299 : for x = 0 to 299
zx = (x - 150) / 100
zy = (y - 150) / 150
gcolor3 0 0 0
for iter = 0 to 127
if zx * zx + zy * zy > 4
gcolor3 iter * 5 0 0
break 1
.
h = zx * zx - zy * zy + cx
zy = 2 * zx * zy + cy
zx = h
fastfunc getiter x y .
cx = -0.7
cy = 0.27015
while iter < 127
if x * x + y * y > 4 : return iter
h = x * x - y * y + cx
y = 2 * x * y + cy
x = h
iter += 1
.
.
gbackground 0
for y = 10 step 0.3 to 90
for x = 0 step 0.3 to 100
gcolor3 0 0 0
iter = getiter ((x - 50) / 33) ((y - 50) / 33)
if iter < 128
gcolor3 iter * 0.05 0 0
.
grect x y 0.4 0.4
.
grect x / 3 y / 3 0.4 0.4
.

View file

@ -1,55 +0,0 @@
; === Graphical Julia set display in Emacs =====================
(setq julia-size (cons 300 200))
(setq xmin -1.5)
(setq xmax 1.5)
(setq ymin -1)
(setq ymax 1)
(setq julia0 (cons -0.512511498387847167 0.521295573094847167))
(setq max-iter 100)
(defun julia-iter-point (x y)
"Run the actual iteration for each point."
(let ((xp x)
(yp y)
(it 0)
(xt 0))
(while (and (< (+ (* xp xp) (* yp yp)) 4) (< it max-iter))
(setq xt (+ (* xp xp) (* -1 yp yp) (car julia0)))
(setq yp (+ (* 2 xp yp) (cdr julia0)))
(setq xp xt)
(setq it (1+ it)))
it))
(defun julia-iter (p)
"Return string for point based on whether inside/outside the set."
(let ((it (julia-iter-point (car p) (cdr p))))
(if (= it max-iter) "*" (if (cl-oddp it) "+" "-"))))
(defun julia-pos (x y)
"Convert screen coordinates to input coordinates."
(let ((xp (+ xmin (* (- xmax xmin) (/ (float x) (car julia-size)))))
(yp (+ ymin (* (- ymax ymin) (/ (float y) (cdr julia-size))))))
(cons xp yp)))
(defun string-to-image (str)
"Convert image data string to XPM image with three colors."
(create-image (concat (format "/* XPM */
static char * julia[] = {
\"%i %i 3 1\",
\"+ c #ff0000\",
\"- c #0000ff\",
\"* c #000000\"," (car julia-size) (cdr julia-size))
str "};") 'xpm t))
(defun julia-pic ()
"Plot the Julia set in color."
(setq all "")
(dotimes (y (cdr julia-size))
(setq line "")
(dotimes (x (car julia-size))
(setq line (concat line (julia-iter (julia-pos x y)))))
(setq all (concat all "\"" line "\",\n")))
(insert-image (string-to-image all)))
(julia-pic)

View file

@ -1,21 +0,0 @@
'ASCII Julia set. Translated from lua. Run with CScript
'Console should be 135x50 to avoid wrapping and scroll
sub pause() wscript.stdout.write "Press Enter to Continue":wscript.stdin.readline: end sub
cmap=array(" ", ".", ":", "-", "=", "+", "*", "#", "%", "$", "@" )
for y = -1.0 to 1.0 step 0.05
for x = -1.5 to 1.5 step 0.025
zr=x
zi=y
i=0
do while i < 100
zr1 = zr*zr - zi*zi - 0.79
zi=zr * zi * 2 + 0.15
zr=zr1
if (zr*zr + zi*zi) > 4. then exit do
i = i + 1
loop
wscript.stdout.write cmap(i\10)
next
wscript.stdout.write vbcrlf
Next
pause