Polyspiral: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(3 intermediate revisions by 3 users not shown)
Line 595:
 
</pre>
 
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=bU/LCsMgELz7FXtMKwTzKvSQjxFjU8GskIQ2/n13jekDenLGmR1mTPBhhmvbCu/QPt2w3kGVjQgIGt2kVysAwHirZwYOzQw9FOmV5FTdCaYwQHNRrG8VqV2C8QO9xZFye6iYaRy9JcIZzKfwsHwYk3qjOo6tsAao9nsOrumPTBJMWHLEOQdnS2RLZMvi8L+FN3JUrI9YLrkdLFV+a7m1zLW/mhc7kGnCz/5SlOIF Run it]
 
<syntaxhighlight lang="easylang">
color 944
linewidth 0.3
on animate
clear
incr = (incr + 0.05) mod 360
x1 = 50
y1 = 50
length = 1
angle = incr
move x1 y1
for i = 1 to 150
x2 = x1 + cos angle * length
y2 = y1 + sin angle * length
line x2 y2
x1 = x2
y1 = y2
length += 1
angle = (angle + incr) mod 360
.
.
</syntaxhighlight>
 
=={{header|FreeBASIC}}==
Line 628 ⟶ 655:
Cls
Loop Until Multikey(SC_ESCAPE)</syntaxhighlight>
 
 
 
=={{header|FutureBasic}}==
Line 679 ⟶ 704:
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Polyspiral}}
 
'''Solution'''
 
[[File:Fōrmulæ - Polyspiral 01.png]]
 
'''Test cases'''
 
[[File:Fōrmulæ - Polyspiral 02.png]]
 
[[File:Fōrmulæ - Polyspiral 03.png]]
 
[[File:Fōrmulæ - Polyspiral 04.png]]
 
[[File:Fōrmulæ - Polyspiral 05.png]]
 
[[File:Fōrmulæ - Polyspiral 06.png]]
 
[[File:Fōrmulæ - Polyspiral 07.png]]
 
=={{header|Gnuplot}}==
Line 2,552 ⟶ 2,595:
{{trans|Kotlin}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
import "math" for Math
Line 2,664 ⟶ 2,707:
pause 1
end while</syntaxhighlight>
 
=={{header|Zig}}==
{{works with|Zig|0.11.0}} {{works with|raylib|4.6-dev}}
{{libheader|raylib}}
<syntaxhighlight lang="zig">
const std = @import("std");
const rl = @cImport({
@cInclude("raylib.h");
@cInclude("raymath.h");
});
 
const SCREEN_WIDTH = 640;
const SCREEN_HEIGHT = 480;
var incr: f32 = 0;
 
pub fn main() void {
rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE | rl.FLAG_VSYNC_HINT);
rl.SetTargetFPS(60);
 
rl.InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Polyspiral");
 
while (!rl.WindowShouldClose())
updateDrawFrame();
 
rl.CloseWindow();
}
 
fn updateDrawFrame() void {
rl.BeginDrawing();
 
rl.ClearBackground(rl.BLACK);
 
incr = @mod(incr + 0.001, 360);
 
drawSpiral(5, std.math.degreesToRadians(f32, incr));
 
rl.EndDrawing();
}
 
fn drawSpiral(_length: f32, _angle: f32) void {
const width = rl.GetScreenWidth();
const height = rl.GetScreenHeight();
var point0 = rl.Vector2{ .x = @as(f32, @floatFromInt(width)) / 2, .y = @as(f32, @floatFromInt(height)) / 2 };
var length = _length;
var angle = _angle;
for (0..150) |_| {
const line_vector = rl.Vector2Rotate(rl.Vector2{ .x = length, .y = 0 }, angle);
const point1 = rl.Vector2Add(point0, line_vector);
rl.DrawLineV(point0, point1, rl.LIME);
point0 = point1;
length += 3;
angle += incr;
angle = @mod(angle, comptime @as(f32, (2.0 * std.math.pi)));
}
}
</syntaxhighlight>
 
=={{header|zkl}}==
9,485

edits