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,94 @@
with Ada.Numerics.Elementary_Functions;
with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Rectangles;
with SDL.Events.Events;
procedure Pentagram is
Width : constant := 600;
Height : constant := 600;
Offset : constant := 300.0;
Radius : constant := 250.0;
use SDL.Video.Rectangles;
use SDL.C;
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL.Events.Events.Events;
type Node_Id is mod 5;
Nodes : array (Node_Id) of Point;
procedure Calculate is
use Ada.Numerics.Elementary_Functions;
begin
for I in Nodes'Range loop
Nodes (I) := (X => int (Offset + Radius * Sin (Float (I), Cycle => 5.0)),
Y => int (Offset - Radius * Cos (Float (I), Cycle => 5.0)));
end loop;
end Calculate;
function Orient_2D (A, B, C : Point) return int is
((B.X - A.X) * (C.Y - A.Y) - (B.Y - A.Y) * (C.X - A.X));
procedure Fill is
Count : Natural;
begin
for Y in int (Offset - Radius) .. int (Offset + Radius) loop
for X in int (Offset - Radius) .. int (Offset + Radius) loop
Count := 0;
for Node in Nodes'Range loop
Count := Count +
(if Orient_2D (Nodes (Node), Nodes (Node + 2), (X, Y)) > 0 then 1 else 0);
end loop;
if Count in 4 .. 5 then
Renderer.Draw (Point => (X, Y));
end if;
end loop;
end loop;
end Fill;
procedure Draw_Outline is
begin
for Node in Nodes'Range loop
Renderer.Draw (Line => (Nodes (Node), Nodes (Node + 2)));
end loop;
end Draw_Outline;
procedure Wait is
use type SDL.Events.Event_Types;
begin
loop
SDL.Events.Events.Wait (Event);
exit when Event.Common.Event_Type = SDL.Events.Quit;
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 => "Pentagram",
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));
Calculate;
Renderer.Set_Draw_Colour ((50, 50, 150, 255));
Fill;
Renderer.Set_Draw_Colour ((0, 220, 0, 255));
Draw_Outline;
Window.Update_Surface;
Wait;
Window.Finalize;
SDL.Finalise;
end Pentagram;

View file

@ -1,4 +1,4 @@
#Include Gdip.ahk ; https://autohotkey.com/boards/viewtopic.php?f=6&t=6517
#Include Gdip.ahk ; https://autohotkey.com/boards/viewtopic.php?f=6&t=6517
Width :=A_ScreenWidth, Height := A_ScreenHeight
Gui, 1: +E0x20 +Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA
@ -7,9 +7,9 @@ OnExit, Exit
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start.
. Please ensure you have gdiplus on your system
ExitApp
MsgBox, 48, gdiplus error!, Gdiplus failed to start.
. Please ensure you have gdiplus on your system
ExitApp
}
hbm := CreateDIBSection(Width, Height)
@ -17,8 +17,8 @@ hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0xFF6495ED)
pPen := Gdip_CreatePen(0xff000000, 3)
pBrush := Gdip_BrushCreateSolid(0xFF6495ED)
pPen := Gdip_CreatePen(0xff000000, 3)
;---------------------------------
LL := 165
@ -28,23 +28,23 @@ phi := 54
;---------------------------------
loop, 5
{
theta := abs(180-144-phi)
p1x := Floor(Cx + LL * Cos(phi * 0.01745329252))
p1y := Floor(Cy + LL * Sin(phi * 0.01745329252))
p2x := Floor(Cx - LL * Cos(theta * 0.01745329252))
p2y := Floor(Cy - LL * Sin(theta * 0.01745329252))
phi+= 72
Gdip_FillPolygon(G, pBrush, p1x "," p1y "|" Cx "," Cy "|" p2x "," p2y)
theta := abs(180-144-phi)
p1x := Floor(Cx + LL * Cos(phi * 0.01745329252))
p1y := Floor(Cy + LL * Sin(phi * 0.01745329252))
p2x := Floor(Cx - LL * Cos(theta * 0.01745329252))
p2y := Floor(Cy - LL * Sin(theta * 0.01745329252))
phi+= 72
Gdip_FillPolygon(G, pBrush, p1x "," p1y "|" Cx "," Cy "|" p2x "," p2y)
}
loop, 5
{
theta := abs(180-144-phi)
p1x := Floor(Cx + LL * Cos(phi * 0.01745329252))
p1y := Floor(Cy + LL * Sin(phi * 0.01745329252))
p2x := Floor(Cx - LL * Cos(theta * 0.01745329252))
p2y := Floor(Cy - LL * Sin(theta * 0.01745329252))
phi+= 72
Gdip_DrawLines(G, pPen, p1x "," p1y "|" p2x "," p2y ) ; "|" Cx "," Cy )
theta := abs(180-144-phi)
p1x := Floor(Cx + LL * Cos(phi * 0.01745329252))
p1y := Floor(Cy + LL * Sin(phi * 0.01745329252))
p2x := Floor(Cx - LL * Cos(theta * 0.01745329252))
p2y := Floor(Cy - LL * Sin(theta * 0.01745329252))
phi+= 72
Gdip_DrawLines(G, pPen, p1x "," p1y "|" p2x "," p2y ) ; "|" Cx "," Cy )
}
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
Gdip_DeleteBrush(pBrush)

View file

@ -5,59 +5,59 @@
#define pi M_PI
int main(){
char colourNames[][14] = { "BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA", "BROWN", "LIGHTGRAY", "DARKGRAY",
"LIGHTBLUE", "LIGHTGREEN", "LIGHTCYAN", "LIGHTRED", "LIGHTMAGENTA", "YELLOW", "WHITE" };
int stroke=0,fill=0,back=0,i;
double centerX = 300,centerY = 300,coreSide,armLength,pentaLength;
printf("Enter core pentagon side length : ");
scanf("%lf",&coreSide);
printf("Enter pentagram arm length : ");
scanf("%lf",&armLength);
printf("Available colours are :\n");
for(i=0;i<16;i++){
printf("%d. %s\t",i+1,colourNames[i]);
if((i+1) % 3 == 0){
printf("\n");
}
}
while(stroke==fill && fill==back){
printf("\nEnter three diffrenet options for stroke, fill and background : ");
scanf("%d%d%d",&stroke,&fill,&back);
}
pentaLength = coreSide/(2 * tan(pi/5)) + sqrt(armLength*armLength - coreSide*coreSide/4);
initwindow(2*centerX,2*centerY,"Pentagram");
setcolor(stroke-1);
setfillstyle(SOLID_FILL,back-1);
bar(0,0,2*centerX,2*centerY);
floodfill(centerX,centerY,back-1);
setfillstyle(SOLID_FILL,fill-1);
for(i=0;i<5;i++){
line(centerX + coreSide*cos(i*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5)/(2*sin(pi/5)),centerX + coreSide*cos((i+1)*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin((i+1)*2*pi/5)/(2*sin(pi/5)));
line(centerX + coreSide*cos(i*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5)/(2*sin(pi/5)),centerX + pentaLength*cos(i*2*pi/5 + pi/5),centerY + pentaLength*sin(i*2*pi/5 + pi/5));
line(centerX + coreSide*cos((i+1)*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin((i+1)*2*pi/5)/(2*sin(pi/5)),centerX + pentaLength*cos(i*2*pi/5 + pi/5),centerY + pentaLength*sin(i*2*pi/5 + pi/5));
floodfill(centerX + coreSide*cos(i*2*pi/5 + pi/10)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5 + pi/10)/(2*sin(pi/5)),stroke-1);
}
floodfill(centerX,centerY,stroke-1);
getch();
closegraph();
char colourNames[][14] = { "BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA", "BROWN", "LIGHTGRAY", "DARKGRAY",
"LIGHTBLUE", "LIGHTGREEN", "LIGHTCYAN", "LIGHTRED", "LIGHTMAGENTA", "YELLOW", "WHITE" };
int stroke=0,fill=0,back=0,i;
double centerX = 300,centerY = 300,coreSide,armLength,pentaLength;
printf("Enter core pentagon side length : ");
scanf("%lf",&coreSide);
printf("Enter pentagram arm length : ");
scanf("%lf",&armLength);
printf("Available colours are :\n");
for(i=0;i<16;i++){
printf("%d. %s\t",i+1,colourNames[i]);
if((i+1) % 3 == 0){
printf("\n");
}
}
while(stroke==fill && fill==back){
printf("\nEnter three diffrenet options for stroke, fill and background : ");
scanf("%d%d%d",&stroke,&fill,&back);
}
pentaLength = coreSide/(2 * tan(pi/5)) + sqrt(armLength*armLength - coreSide*coreSide/4);
initwindow(2*centerX,2*centerY,"Pentagram");
setcolor(stroke-1);
setfillstyle(SOLID_FILL,back-1);
bar(0,0,2*centerX,2*centerY);
floodfill(centerX,centerY,back-1);
setfillstyle(SOLID_FILL,fill-1);
for(i=0;i<5;i++){
line(centerX + coreSide*cos(i*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5)/(2*sin(pi/5)),centerX + coreSide*cos((i+1)*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin((i+1)*2*pi/5)/(2*sin(pi/5)));
line(centerX + coreSide*cos(i*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5)/(2*sin(pi/5)),centerX + pentaLength*cos(i*2*pi/5 + pi/5),centerY + pentaLength*sin(i*2*pi/5 + pi/5));
line(centerX + coreSide*cos((i+1)*2*pi/5)/(2*sin(pi/5)),centerY + coreSide*sin((i+1)*2*pi/5)/(2*sin(pi/5)),centerX + pentaLength*cos(i*2*pi/5 + pi/5),centerY + pentaLength*sin(i*2*pi/5 + pi/5));
floodfill(centerX + coreSide*cos(i*2*pi/5 + pi/10)/(2*sin(pi/5)),centerY + coreSide*sin(i*2*pi/5 + pi/10)/(2*sin(pi/5)),stroke-1);
}
floodfill(centerX,centerY,stroke-1);
getch();
closegraph();
}

View file

@ -8,14 +8,14 @@
/g { .7 setgray } def
/t { 100 exch translate } def
/p {
180 90 n div sub rotate
0 0 moveto
n { 0 160 rlineto 180 180 n div sub rotate } repeat
closepath
180 90 n div sub rotate
0 0 moveto
n { 0 160 rlineto 180 180 n div sub rotate } repeat
closepath
} def
s 570 t p s g eofill r stroke r % even-odd fill
s 370 t p s g fill r stroke r % non-zero fill
s 570 t p s g eofill r stroke r % even-odd fill
s 370 t p s g fill r stroke r % non-zero fill
s 170 t p s 2 setlinewidth stroke r g fill r % non-zero, but hide inner strokes
%%EOF

View file

@ -12,16 +12,16 @@
/line { rotate 0 rlineto } def
/star { gsave
/n minpoint 2 maxpoint rndi def
/r maxradius rnd def
/a 180 180 n div sub def
/b 360 a n mul sub n div def
/n minpoint 2 maxpoint rndi def
/r maxradius rnd def
/a 180 180 n div sub def
/b 360 a n mul sub n div def
400 rnd 400 rnd translate 360 rnd rotate
0 0 moveto n { r a line r b line } repeat closepath
rnd1 rnd1 rnd1 3 { 2 index 1 exch sub } repeat
gsave setrgbcolor fill grestore setrgbcolor stroke
grestore } def
400 rnd 400 rnd translate 360 rnd rotate
0 0 moveto n { r a line r b line } repeat closepath
rnd1 rnd1 rnd1 3 { 2 index 1 exch sub } repeat
gsave setrgbcolor fill grestore setrgbcolor stroke
grestore } def
0 setlinewidth 2000 {star} repeat showpage
%%EOF

View file

@ -0,0 +1,33 @@
Rebol [
title: "Rosetta code: Pentagram"
file: %Pentagram.r3
url: https://rosettacode.org/wiki/Pentagram
needs: blend2d ;= for the draw command
]
canvas: 500x500
center: canvas / 2
radius: 200
points: collect [
repeat vertex 10 [
angle: vertex * 36 + 18 ;-- +18 is required for pentagram rotation
either vertex % 2 = 1 [
keep as-pair
(cosine angle) * radius + center/x
(sine angle) * radius + center/y
][
keep as-pair
(cosine angle) * radius * 0.382 + center/x
(sine angle) * radius * 0.382 + center/y
]
]
]
img: draw canvas compose/deep [
fill-pen mint
polygon (points)
line-width 3
line (points/1) (points/5) (points/9) (points/3) (points/7) (points/1)
]
try [save %pentagram.png img]
try [view img]

View file

@ -1,7 +1,7 @@
Red [
Source: https://github.com/vazub/rosetta-red
Tabs: 4
Needs: 'View
Source: https://github.com/vazub/rosetta-red
Tabs: 4
Needs: 'View
]
canvas: 500x500
@ -9,23 +9,23 @@ center: as-pair canvas/x / 2 canvas/y / 2
radius: 200
points: collect [
repeat vertex 10 [
angle: vertex * 36 + 18 ;-- +18 is required for pentagram rotation
either vertex // 2 = 1 [
keep as-pair (cosine angle) * radius + center/x (sine angle) * radius + center/y
][
keep as-pair (cosine angle) * radius * 0.382 + center/x (sine angle) * radius * 0.382 + center/y
]
]
repeat vertex 10 [
angle: vertex * 36 + 18 ;-- +18 is required for pentagram rotation
either vertex // 2 = 1 [
keep as-pair (cosine angle) * radius + center/x (sine angle) * radius + center/y
][
keep as-pair (cosine angle) * radius * 0.382 + center/x (sine angle) * radius * 0.382 + center/y
]
]
]
view [
title "Pentagram"
base canvas white
draw compose/deep [
fill-pen mint
polygon (points)
line-width 3
line (points/1) (points/5) (points/9) (points/3) (points/7) (points/1)
]
title "Pentagram"
base canvas white
draw compose/deep [
fill-pen mint
polygon (points)
line-width 3
line (points/1) (points/5) (points/9) (points/3) (points/7) (points/1)
]
]

View file

@ -48,12 +48,12 @@ func draw
for n = 1 to 5
theta = fabs(180-144-phi)
p1x = floor(cx + nn * cos(phi * 0.01745329252))
p1y = floor(cy + nn * sin(phi * 0.01745329252))
p2x = floor(cx - nn * cos(theta * 0.01745329252))
p2y = floor(cy - nn * sin(theta * 0.01745329252))
phi+= 72
drawpolygon([[p1x,p1y],[cx,cy],[p2x,p2y]],0)
p1x = floor(cx + nn * cos(phi * 0.01745329252))
p1y = floor(cy + nn * sin(phi * 0.01745329252))
p2x = floor(cx - nn * cos(theta * 0.01745329252))
p2y = floor(cy - nn * sin(theta * 0.01745329252))
phi+= 72
drawpolygon([[p1x,p1y],[cx,cy],[p2x,p2y]],0)
next
endpaint()

View file

@ -1,4 +1,4 @@
package require Tk 8.6 ;# lmap is new in Tcl/Tk 8.6
package require Tk 8.6 ;# lmap is new in Tcl/Tk 8.6
set pi [expr 4*atan(1)]