Polyspiral: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
No edit summary
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(5 intermediate revisions by 4 users not shown)
Line 543:
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
[[File:DelphiSpiralAnimaion.png|frame|none]]
 
 
Line 594 ⟶ 596:
</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 678 ⟶ 703:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Polyspiral}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''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]]
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Polyspiral 07.png]]
In '''[https://formulae.org/?example=Polyspiral this]''' page you can see the program(s) related to this task and their results.
 
=={{header|Gnuplot}}==
Line 2,556 ⟶ 2,595:
{{trans|Kotlin}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
import "math" for Math
Line 2,668 ⟶ 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,476

edits