RosettaCodeData/Task/Plasma-effect/XPL0/plasma-effect.xpl0

20 lines
701 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
func real Dist(X1, Y1, X2, Y2);
int X1, Y1, X2, Y2;
return sqrt( float((X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2)) );
int Time, X, Y, Color;
real Value;
[SetVid($112); \640x480x24
repeat Time:= GetTime/50_000;
for Y:= 0 to 256-1 do
for X:= 0 to 256-1 do
[Value:= Sin(Dist(X+Time, Y, 128, 128) / 8.0) +
Sin(Dist(X, Y, 64, 64) / 8.0) +
Sin(Dist(X, Y+Time/7, 192, 64) / 7.0) +
Sin(Dist(X, Y, 192, 100) / 8.0);
Color:= fix((4.0+Value) * 31.875); \[0..255]
Point(X, Y, Color<<16 + ((Color*2)&$FF)<<8 + (255-Color));
];
until KeyHit;
]