Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,13 @@
FOR yi FROM -100 BY 5 TO 100 DO # draw an ASCII art Julia set, translation of Lua #
REAL y = yi / 100;
FOR xi FROM -1500 BY 25 TO 1500 DO
REAL zr := xi / 1000; REAL zi := y; INT i := 0; BOOL again := TRUE;
WHILE again AND i < 100 DO
REAL zrp = zr, zip = zi;
zr := zrp*zrp - zip*zip - 0.79; zi := zrp * zip * 2 + 0.15;
IF zr*zr + zi*zi > 4 THEN # break # again := FALSE ELSE i +:= 1 FI
OD;
print( ( " .:-=+*#%$@"[ 1 + i OVER 10 ] ) )
OD;
print( ( newline ) )
OD

View file

@ -0,0 +1,93 @@
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

@ -0,0 +1,59 @@
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

@ -0,0 +1,55 @@
; === 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

@ -0,0 +1,23 @@
MODULE JuliaSet; (* Draw an ASCII art Julia set - translation of Lua *)
IMPORT Out;
VAR cmap : ARRAY 12 OF CHAR; (* 11 characters + trailing nul *)
y, zr, zi, zrp, zip : REAL;
i, xi, yi : INTEGER;
again : BOOLEAN;
BEGIN
cmap := " .:-=+*#%$@";
FOR yi := -100 TO 100 BY 5 DO
y := FLT( yi ) / 100.0;
FOR xi := -1500 TO 1500 BY 25 DO
zr := FLT( xi ) / 1000.0; zi := y; i := 0; again := TRUE;
WHILE again & ( i < 100 ) DO
zrp := zr; zip := zi;
zr := zrp*zrp - zip*zip - 0.79; zi := zrp * zip * 2.0 + 0.15;
IF zr*zr + zi*zi > 4.0 THEN (*break*) again := FALSE ELSE INC( i, 1 ) END
END;
Out.Char(cmap[ i DIV 10 ])
END;
Out.Ln
END
END JuliaSet.

View file

@ -0,0 +1,32 @@
require "bitmap"
local max_iters = 300
local zoom = 1
local move_x = 0
local move_y = 0
local cx = -0.7
local cy = 0.27015
local w = 800
local h = 600
local bmp = bitmap.of(w, h, color.black, "Julia set")
local function create_julia()
for x = 0, w - 1 do
for y = 0, h - 1 do
local zx = 1.5 * (x - w / 2) / (0.5 * zoom * w) + move_x
local zy = (y - h / 2) / (0.5 * zoom * h) + move_y
local i = max_iters
while zx * zx + zy * zy < 4 and i > 0 do
local tmp = zx * zx - zy * zy + cx
zy = 2 * zx * zy + cy
zx = tmp
i -= 1
end
local c = bitmap.rgbColor(i % 256, i % 256, (i * 8) % 256)
bmp:set(x, y, c)
end
end
end
create_julia()
bmp:view()

View file

@ -1,58 +1,63 @@
# Project : Julia Set
# Author: Gal Zsolt (CalmoSoft)
load "guilib.ring"
new qapp
{
win1 = new qwidget() {
setwindowtitle("Julia set")
setgeometry(100,100,500,400)
label1 = new qlabel(win1) {
setgeometry(10,10,400,400)
settext("")
}
new qpushbutton(win1) {
setgeometry(150,300,100,30)
settext("draw")
setclickevent("draw()")
}
show()
}
exec()
see "Working..." + nl
p1 = null
new qapp {
win1 = new qwidget() {
setwindowtitle("Julia Set - CalmoSoft")
setgeometry(100,100,600,600)
lbl = new qlabel(win1) {
setgeometry(0,0,600,600)
setstylesheet("background-color: black;")
}
func draw
p1 = new qpicture()
color = new qcolor() {
setrgb(0,0,255,255)
}
pen = new qpen() {
setcolor(color)
setwidth(1)
}
paint = new qpainter() {
begin(p1)
setpen(pen)
# Create a 600x600 image
p1 = new qpixmap2(600,600)
p1.fill(new qcolor() { setrgb(0,0,0,255) })
creal=-0.8
cimag=0.156
for v=-16 to 16
for h=-64 to 64
x=h/40
y=v/20
for i=1 to 50
flag = 1
zreal=x*x-y*y+creal
zimag=x*y*2+cimag
if zreal*zreal>1000 flag = 0 loop ok
x=zreal
y=zimag
next
if flag = 1
drawpoint(h+100,150-v)
ok
next
next
endpaint()
painter = new qpainter() {
begin(p1)
# Use a nice cyan color for the fractal
setpen(new qpen() {
setcolor(new qcolor() { setrgb(0,255,255,255) })
setwidth(1)
})
creal = -0.8
cimag = 0.156
# Loop through all 600x600 pixels
# Note: If it's slow, change 'step 1' to 'step 2'!
for py = 0 to 599 step 1
for px = 0 to 599 step 1
# Scaling for 600 pixels: (px - center) / (zoom)
x = (px - 300) / 200
y = (py - 300) / 200
flag = 1
for i = 1 to 40 # Iteration count for details
nx = x*x - y*y + creal
ny = 2*x*y + cimag
x = nx
y = ny
if (x*x + y*y) > 4 flag = 0 exit ok
next
if flag = 1
drawpoint(px, py)
ok
next
next
endpaint()
}
label1 { setpicture(p1) show() }
lbl.setpixmap(p1)
show()
}
see "Done..."
exec()
}

View file

@ -0,0 +1,21 @@
'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