Polyspiral: Difference between revisions

Content added Content deleted
(Added Processing implementation)
m (syntax highlighting fixup automation)
Line 37: Line 37:
{{libheader|Action! Tool Kit}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:REALMATH.ACT"
<syntaxhighlight lang="action!">INCLUDE "H6:REALMATH.ACT"


INT ARRAY SinTab=[
INT ARRAY SinTab=[
Line 116: Line 116:
DO UNTIL CH#$FF OD
DO UNTIL CH#$FF OD
CH=$FF
CH=$FF
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Polyspiral.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Polyspiral.png Screenshot from Atari 8-bit computer]
Line 122: Line 122:
=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
Requires [https://www.autohotkey.com/boards/viewtopic.php?t=6517 Gdip Library]
Requires [https://www.autohotkey.com/boards/viewtopic.php?t=6517 Gdip Library]
<lang AutoHotkey>If !pToken := Gdip_Startup()
<syntaxhighlight lang="autohotkey">If !pToken := Gdip_Startup()
{
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
Line 189: Line 189:
ExitApp
ExitApp
Return
Return
;----------------------------------------------------------------</lang>
;----------------------------------------------------------------</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
Straightforward implementation of the pseudocode, incr and angle are integers and incr is incremented by 5 instead of 0.05 as the % operation in C is not defined for non-integers. Requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library.
Straightforward implementation of the pseudocode, incr and angle are integers and incr is incremented by 5 instead of 0.05 as the % operation in C is not defined for non-integers. Requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library.
<syntaxhighlight lang="c">
<lang C>
#include<graphics.h>
#include<graphics.h>
#include<math.h>
#include<math.h>
Line 240: Line 240:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
{{trans|Java}}
{{trans|Java}}
<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;
using System.Drawing;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Drawing2D;
Line 306: Line 306:
}
}
}
}
}</lang>
}</syntaxhighlight>


=={{header|C++}}==
=={{header|C++}}==
This Windows programm has no animation, it will simply save 100 bitmaps onto your harddrive
This Windows programm has no animation, it will simply save 100 bitmaps onto your harddrive
<lang cpp>
<syntaxhighlight lang="cpp">
#include <windows.h>
#include <windows.h>
#include <sstream>
#include <sstream>
Line 454: Line 454:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>


=={{header|Ceylon}}==
=={{header|Ceylon}}==
Be sure to import javafx.graphics and ceylon.numeric in your module.ceylon file.
Be sure to import javafx.graphics and ceylon.numeric in your module.ceylon file.
<lang ceylon>import javafx.application {
<syntaxhighlight lang="ceylon">import javafx.application {
Application
Application
}
}
Line 538: Line 538:
primaryStage.show();
primaryStage.show();
}
}
}</lang>
}</syntaxhighlight>




=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>#include "fbgfx.bi"
<syntaxhighlight lang="freebasic">#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
#if __FB_LANG__ = "fb"
Using FB '' Scan code constants are stored in the FB namespace in lang FB
Using FB '' Scan code constants are stored in the FB namespace in lang FB
Line 572: Line 572:
Sleep 500
Sleep 500
Cls
Cls
Loop Until Multikey(SC_ESCAPE)</lang>
Loop Until Multikey(SC_ESCAPE)</syntaxhighlight>




Line 588: Line 588:
===Plotting a polyspiral file-function for the load command===
===Plotting a polyspiral file-function for the load command===
'''plotpoly.gp''' file for the load command is the only possible imitation of the fine function in the '''gnuplot'''.
'''plotpoly.gp''' file for the load command is the only possible imitation of the fine function in the '''gnuplot'''.
<lang gnuplot>
<syntaxhighlight lang="gnuplot">
## plotpoly.gp 1/10/17 aev
## plotpoly.gp 1/10/17 aev
## Plotting a polyspiral and writing to the png-file.
## Plotting a polyspiral and writing to the png-file.
Line 604: Line 604:
plot [0:c] t*cos(d*t), t*sin(d*t) lt rgb @clr
plot [0:c] t*cos(d*t), t*sin(d*t) lt rgb @clr
set output
set output
</lang>
</syntaxhighlight>


===Plotting many versions of a polyspiral.===
===Plotting many versions of a polyspiral.===
Line 615: Line 615:
[[File:PS6gp.png|right|thumb|Output PS6gp.png]]
[[File:PS6gp.png|right|thumb|Output PS6gp.png]]


<lang gnuplot>
<syntaxhighlight lang="gnuplot">
## PSpirals.gp 1/10/17 aev
## PSpirals.gp 1/10/17 aev
## Plotting many polyspiral pictures.
## Plotting many polyspiral pictures.
Line 718: Line 718:
## Continue plotting starting with a range rng=110 to 400+ step 10 to discover new figures.
## Continue plotting starting with a range rng=110 to 400+ step 10 to discover new figures.
## END ##
## END ##
</lang>
</syntaxhighlight>
{{Output}}
{{Output}}
<pre>
<pre>
Line 727: Line 727:
===Plotting a polyspiral file-function for the load command (for animation)===
===Plotting a polyspiral file-function for the load command (for animation)===
'''plotpolya.gp''' file for the load command is the only possible imitation of the fine function in the '''gnuplot'''.
'''plotpolya.gp''' file for the load command is the only possible imitation of the fine function in the '''gnuplot'''.
<lang gnuplot>
<syntaxhighlight lang="gnuplot">
## plotpolya.gp 1/19/17 aev
## plotpolya.gp 1/19/17 aev
## Plotting a polyspiral and writing to the png-file. Simple plot for animation.
## Plotting a polyspiral and writing to the png-file. Simple plot for animation.
Line 742: Line 742:
plot [0:c] t*cos(d*t), t*sin(d*t) lt rgb @clr
plot [0:c] t*cos(d*t), t*sin(d*t) lt rgb @clr
set output
set output
</lang>
</syntaxhighlight>


===Plotting many polyspiral and other pictures for animation.===
===Plotting many polyspiral and other pictures for animation.===
'''Note:''' No generated pictures here on RC.
'''Note:''' No generated pictures here on RC.
<lang gnuplot>
<syntaxhighlight lang="gnuplot">
## PSpirals4a.gp 1/19/17 aev
## PSpirals4a.gp 1/19/17 aev
## Plotting many polyspiral and other pictures for animation
## Plotting many polyspiral and other pictures for animation
Line 802: Line 802:
##PS14 Not a polyspiral, but has many short secondary spirals.
##PS14 Not a polyspiral, but has many short secondary spirals.
rng=700; d=-1; clr = '"navy"'; filename = "PS14"; load "plotpolya.gp";
rng=700; d=-1; clr = '"navy"'; filename = "PS14"; load "plotpolya.gp";
</lang>
</syntaxhighlight>
{{Output}}
{{Output}}
<pre>
<pre>
Line 814: Line 814:
[[File:NiceFigsAnim.gif|right|thumb|Output NiceFigsAnim.gif]]
[[File:NiceFigsAnim.gif|right|thumb|Output NiceFigsAnim.gif]]


<lang gnuplot>
<syntaxhighlight lang="gnuplot">
## Animation for polyspirals PS0 - PS6
## Animation for polyspirals PS0 - PS6
reset
reset
Line 836: Line 836:
do for [i=8:14]{plot 'PS'.i.'.png' binary filetype=png with rgbimage}
do for [i=8:14]{plot 'PS'.i.'.png' binary filetype=png with rgbimage}
set output
set output
</lang>
</syntaxhighlight>
{{Output}}
{{Output}}
<pre>
<pre>
Line 844: Line 844:
===Showing 2 animated gif-files.===
===Showing 2 animated gif-files.===
Create 2 the following html-files and envoke them in browser.
Create 2 the following html-files and envoke them in browser.
<lang html>
<syntaxhighlight lang="html">
<!-- PolySpirsAnim.html -->
<!-- PolySpirsAnim.html -->
<html><body>
<html><body>
Line 851: Line 851:
<img src="PolySpirsAnim.gif">
<img src="PolySpirsAnim.gif">
</body></html>
</body></html>
</lang>
</syntaxhighlight>
<lang html>
<syntaxhighlight lang="html">
<!-- NiceFigsAnim.html -->
<!-- NiceFigsAnim.html -->
<html><body>
<html><body>
Line 859: Line 859:
<img src="NiceFigsAnim.gif">
<img src="NiceFigsAnim.gif">
</body></html>
</body></html>
</lang>
</syntaxhighlight>
{{Output}}
{{Output}}
<pre>
<pre>
Line 875: Line 875:
$ eog polyspiral2.gif
$ eog polyspiral2.gif
</pre>
</pre>
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 987: Line 987:
log.Fatal(err2)
log.Fatal(err2)
}
}
}</lang>
}</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Line 994: Line 994:
This implementation compiles to javascript that runs in the browser using the [https://github.com/ghcjs/ghcjs ghcjs compiler ] . The [https://github.com/reflex-frp/reflex-dom reflex-dom ] library is used to help with svg rendering and animation.
This implementation compiles to javascript that runs in the browser using the [https://github.com/ghcjs/ghcjs ghcjs compiler ] . The [https://github.com/reflex-frp/reflex-dom reflex-dom ] library is used to help with svg rendering and animation.


<lang haskell>{-# LANGUAGE OverloadedStrings #-}
<syntaxhighlight lang="haskell">{-# LANGUAGE OverloadedStrings #-}
import Reflex
import Reflex
import Reflex.Dom
import Reflex.Dom
Line 1,076: Line 1,076:
elSvgns t m ma = do
elSvgns t m ma = do
(el, val) <- elDynAttrNS' (Just "http://www.w3.org/2000/svg") t m ma
(el, val) <- elDynAttrNS' (Just "http://www.w3.org/2000/svg") t m ma
return val</lang>
return val</syntaxhighlight>


Link to live demo: https://dc25.github.io/rosettaCode__Polyspiral_haskell/
Link to live demo: https://dc25.github.io/rosettaCode__Polyspiral_haskell/


=={{header|IS-BASIC}}==
=={{header|IS-BASIC}}==
<lang IS-BASIC>100 PROGRAM "PolySp.bas"
<syntaxhighlight lang="is-basic">100 PROGRAM "PolySp.bas"
110 OPTION ANGLE DEGREES
110 OPTION ANGLE DEGREES
120 LET CH=2
120 LET CH=2
Line 1,105: Line 1,105:
320 LET D=740
320 LET D=740
330 CONTINUE
330 CONTINUE
340 END HANDLER</lang>
340 END HANDLER</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==
Line 1,111: Line 1,111:
{{trans|java}}
{{trans|java}}


<lang J>require 'gl2 trig media/imagekit'
<syntaxhighlight lang="j">require 'gl2 trig media/imagekit'
coinsert 'jgl2'
coinsert 'jgl2'
Line 1,160: Line 1,160:
)
)
poly_run''</lang>
poly_run''</syntaxhighlight>


Note that we're using a lot of [[j:Guides/Window_Driver/Command_Reference|wd]] commands here. You'll need to be running [[j:System/Installation|jqt]] for this to work.
Note that we're using a lot of [[j:Guides/Window_Driver/Command_Reference|wd]] commands here. You'll need to be running [[j:System/Installation|jqt]] for this to work.
Line 1,167: Line 1,167:
[[File:Polyspiral_java2.png|300px|thumb|right]]
[[File:Polyspiral_java2.png|300px|thumb|right]]
{{works with|Java|8}}
{{works with|Java|8}}
<lang java>import java.awt.*;
<syntaxhighlight lang="java">import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.*;
Line 1,228: Line 1,228:
});
});
}
}
}</lang>
}</syntaxhighlight>


=={{header|JavaScript}}==
=={{header|JavaScript}}==
Line 1,239: Line 1,239:
* An image uploading is still blocked. But you have a browser!? So, copy/paste/save this page and double click it.
* An image uploading is still blocked. But you have a browser!? So, copy/paste/save this page and double click it.
{{Works with|Chrome}} (or any other browser supporting Canvas tag)
{{Works with|Chrome}} (or any other browser supporting Canvas tag)
<lang html>
<syntaxhighlight lang="html">
<!-- Polyspiral.html -->
<!-- Polyspiral.html -->
<html>
<html>
Line 1,300: Line 1,300:
</body>
</body>
</html>
</html>
</syntaxhighlight>
</lang>
{{Output}}
{{Output}}
<pre>
<pre>
Line 1,310: Line 1,310:
===Version #2 - Animated===
===Version #2 - Animated===
{{trans|Java}}
{{trans|Java}}
<lang javascript><!DOCTYPE html>
<syntaxhighlight lang="javascript"><!DOCTYPE html>
<html lang="en">
<html lang="en">
<head>
<head>
Line 1,391: Line 1,391:


</body>
</body>
</html></lang>
</html></syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>using Gtk, Graphics, Colors
<syntaxhighlight lang="julia">using Gtk, Graphics, Colors


const can = @GtkCanvas()
const can = @GtkCanvas()
Line 1,454: Line 1,454:
sleep(0.5)
sleep(0.5)
end
end
</syntaxhighlight>
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Java}}
{{trans|Java}}
<lang scala>// version 1.1.0
<syntaxhighlight lang="scala">// version 1.1.0


import java.awt.*
import java.awt.*
Line 1,512: Line 1,512:
f.setVisible(true)
f.setVisible(true)
}
}
}</lang>
}</syntaxhighlight>


=={{header|Lua}}==
=={{header|Lua}}==
{{libheader|LÖVE}}
{{libheader|LÖVE}}
LÖVE defaults to animating at sixty frames per second, so the patterns become very complex very quickly.
LÖVE defaults to animating at sixty frames per second, so the patterns become very complex very quickly.
<lang Lua>function love.load ()
<syntaxhighlight lang="lua">function love.load ()
love.window.setTitle("Polyspiral")
love.window.setTitle("Polyspiral")
incr = 0
incr = 0
Line 1,539: Line 1,539:
angle = (angle + incr) % 360
angle = (angle + incr) % 360
end
end
end</lang>
end</syntaxhighlight>
[[File:love2dPolyspiral.jpg]]
[[File:love2dPolyspiral.jpg]]


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>linedata = {};
<syntaxhighlight lang="mathematica">linedata = {};
Dynamic[Graphics[Line[linedata], PlotRange -> 1000]]
Dynamic[Graphics[Line[linedata], PlotRange -> 1000]]
Do[
Do[
Line 1,550: Line 1,550:
,
,
{\[Theta], Subdivide[0.1, 1, 100]}
{\[Theta], Subdivide[0.1, 1, 100]}
]</lang>
]</syntaxhighlight>
{{out}}
{{out}}
Outputs an animating graphic with a spiral with changing angle.
Outputs an animating graphic with a spiral with changing angle.
Line 1,558: Line 1,558:
As Julia, we use Gtk/Cairo to draw the polyspirals. So, the drawing part is taken, with some modifications, from Julia solution.
As Julia, we use Gtk/Cairo to draw the polyspirals. So, the drawing part is taken, with some modifications, from Julia solution.


<lang Nim># Pendulum simulation.
<syntaxhighlight lang="nim"># Pendulum simulation.


import math, random
import math, random
Line 1,670: Line 1,670:
let app = newApplication(Application, "Rosetta.polyspiral")
let app = newApplication(Application, "Rosetta.polyspiral")
discard app.connect("activate", activate)
discard app.connect("activate", activate)
discard app.run()</lang>
discard app.run()</syntaxhighlight>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
Line 1,680: Line 1,680:
You can find a few others on [http://oeis.org/wiki/User:Anatoly_E._Voevudko/VoeLib.gp#Plotting_helper_functions OEIS Wiki] and here on RC Wiki.
You can find a few others on [http://oeis.org/wiki/User:Anatoly_E._Voevudko/VoeLib.gp#Plotting_helper_functions OEIS Wiki] and here on RC Wiki.


<lang parigp>
<syntaxhighlight lang="parigp">
\\ Plot the line from x1,y1 to x2,y2.
\\ Plot the line from x1,y1 to x2,y2.
plotline(x1,y1,x2,y2,w=0)={plotmove(w, x1,y1);plotrline(w,x2-x1,y2-y1);}
plotline(x1,y1,x2,y2,w=0)={plotmove(w, x1,y1);plotrline(w,x2-x1,y2-y1);}
Line 1,688: Line 1,688:
cartes2(r,a,rndf=0)={my(v,x,y); x=r*cos(a); y=r*sin(a);
cartes2(r,a,rndf=0)={my(v,x,y); x=r*cos(a); y=r*sin(a);
if(rndf==0, return([x,y]), return(round([x,y])))}
if(rndf==0, return([x,y]), return(round([x,y])))}
</syntaxhighlight>
</lang>


===Version #1. Polyspiral (a spiral made of multiple line segments).===
===Version #1. Polyspiral (a spiral made of multiple line segments).===
Line 1,701: Line 1,701:
[[File:Polyspiral4.png|100px|right|thumb|Output Polyspiral4.png]]
[[File:Polyspiral4.png|100px|right|thumb|Output Polyspiral4.png]]


<lang parigp>
<syntaxhighlight lang="parigp">
\\Polyspiral (a spiral made of multiple line segments)
\\Polyspiral (a spiral made of multiple line segments)
\\ 4/15/16 aev
\\ 4/15/16 aev
Line 1,736: Line 1,736:
polyspiral(100000,100000,0.03,3,2);\\Polyspiral4.png
polyspiral(100000,100000,0.03,3,2);\\Polyspiral4.png
}
}
</lang>
</syntaxhighlight>


{{Output}}
{{Output}}
Line 1,768: Line 1,768:
[[File:Spiralz1.png|100px|right|thumb|Output Spiralz.png]]
[[File:Spiralz1.png|100px|right|thumb|Output Spiralz.png]]


<lang parigp>
<syntaxhighlight lang="parigp">
\\ plotpspiralz() Multi-spiral figure translated from zkl using my own ploting functions.
\\ plotpspiralz() Multi-spiral figure translated from zkl using my own ploting functions.
\\ 4/15/16 aev
\\ 4/15/16 aev
Line 1,805: Line 1,805:
Spiralz(640,2,3.0,3.0,128); \\Spiralz1.png
Spiralz(640,2,3.0,3.0,128); \\Spiralz1.png
}
}
</lang>
</syntaxhighlight>


{{Output}}
{{Output}}
Line 1,817: Line 1,817:
Click Start button to run, then runs continuously.
Click Start button to run, then runs continuously.
It takes just a little over four minutes to complete a full 360 degree cycle.
It takes just a little over four minutes to complete a full 360 degree cycle.
<lang perl>
<syntaxhighlight lang="perl">
#!/usr/bin/perl
#!/usr/bin/perl


Line 1,865: Line 1,865:
$c->createLine( @pts );
$c->createLine( @pts );
$mw->after($wait => \&step);
$mw->after($wait => \&step);
}</lang>
}</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,875: Line 1,875:
{{libheader|Phix/pGUI}}
{{libheader|Phix/pGUI}}
{{libheader|Phix/online}}
{{libheader|Phix/online}}
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Polyspiral.exw
-- demo\rosetta\Polyspiral.exw
Line 1,968: Line 1,968:
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->


=={{header|Processing}}==
=={{header|Processing}}==
{{trans|C}}
{{trans|C}}
<lang java>
<syntaxhighlight lang="java">
//Aamrun, 2nd July 2022
//Aamrun, 2nd July 2022


Line 2,009: Line 2,009:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|Python}}==
=={{header|Python}}==
{{libheader|Pygame}}
{{libheader|Pygame}}
<lang Python>import math
<syntaxhighlight lang="python">import math


import pygame
import pygame
Line 2,052: Line 2,052:


pygame.display.flip()
pygame.display.flip()
</syntaxhighlight>
</lang>


=={{header|Racket}}==
=={{header|Racket}}==
Uses the *universe* animation
Uses the *universe* animation


<lang racket>#lang racket
<syntaxhighlight lang="racket">#lang racket


(require 2htdp/universe pict racket/draw)
(require 2htdp/universe pict racket/draw)
Line 2,081: Line 2,081:
width height)))
width height)))


(animate (polyspiral 400 400 2 1000))</lang>
(animate (polyspiral 400 400 2 1000))</syntaxhighlight>


See the output for yourself!
See the output for yourself!
Line 2,092: Line 2,092:
Sort of an ersatz animation. Write updates to a svg file, most modern viewers will update as the content changes.
Sort of an ersatz animation. Write updates to a svg file, most modern viewers will update as the content changes.


<lang perl6>use SVG;
<syntaxhighlight lang="raku" line>use SVG;
my $w = 600;
my $w = 600;
my $h = 600;
my $h = 600;
Line 2,135: Line 2,135:
}
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
See [https://github.com/thundergnat/rc/blob/master/img/polyspiral-perl6.gif polyspiral-perl6.gif] (offsite animated gif image)
See [https://github.com/thundergnat/rc/blob/master/img/polyspiral-perl6.gif polyspiral-perl6.gif] (offsite animated gif image)
Line 2,142: Line 2,142:
Uses the same basic algorithm but fully animated. Use the up / down arrow keys to speed up / slow down the update speed. Use PgUp / PgDn keys to increment / decrement animation speed by large amounts. Use left / right arrow keys to reverse the "direction" of angle change. Press Space bar to toggle animation / reset to minimum speed. Left Control key to toggle stationary / rotating center. Use + / - keys to add remove line segments.
Uses the same basic algorithm but fully animated. Use the up / down arrow keys to speed up / slow down the update speed. Use PgUp / PgDn keys to increment / decrement animation speed by large amounts. Use left / right arrow keys to reverse the "direction" of angle change. Press Space bar to toggle animation / reset to minimum speed. Left Control key to toggle stationary / rotating center. Use + / - keys to add remove line segments.


<lang perl6>use SDL2::Raw;
<syntaxhighlight lang="raku" line>use SDL2::Raw;


my $width = 900;
my $width = 900;
Line 2,254: Line 2,254:
}
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</lang>
}</syntaxhighlight>


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
# Project : Polyspiral
# Project : Polyspiral


Line 2,313: Line 2,313:
}
}
label1 { setpicture(p1) show() }
label1 { setpicture(p1) show() }
</syntaxhighlight>
</lang>
Output:
Output:


Line 2,320: Line 2,320:
=={{header|Scala}}==
=={{header|Scala}}==
===Java Swing Interoperability===
===Java Swing Interoperability===
<lang Scala>import java.awt._
<syntaxhighlight lang="scala">import java.awt._
import java.awt.event.ActionEvent
import java.awt.event.ActionEvent


Line 2,374: Line 2,374:
)
)


}</lang>
}</syntaxhighlight>


=={{header|SPL}}==
=={{header|SPL}}==
<lang spl>width,height = #.scrsize()
<syntaxhighlight lang="spl">width,height = #.scrsize()
#.angle(#.degrees)
#.angle(#.degrees)
#.scroff()
#.scroff()
Line 2,398: Line 2,398:
<
<
#.scr()
#.scr()
<</lang>
<</syntaxhighlight>


=={{header|SVG}}==
=={{header|SVG}}==
Line 2,408: Line 2,408:
It requires building up layers, animated over a rotation transformation. This is verbose, so the code below has been truncated, and the [https://codepen.io/shephero/full/xxbaWXb demo] uses another language ([https://codepen.io/shephero/full/xxbaWXb Pug]) to generate the source.
It requires building up layers, animated over a rotation transformation. This is verbose, so the code below has been truncated, and the [https://codepen.io/shephero/full/xxbaWXb demo] uses another language ([https://codepen.io/shephero/full/xxbaWXb Pug]) to generate the source.


<lang html>
<syntaxhighlight lang="html">
<svg viewBox="0 0 100 100" stroke="#000" stroke-width="0.3">
<svg viewBox="0 0 100 100" stroke="#000" stroke-width="0.3">
<g>
<g>
Line 2,426: Line 2,426:
</g>
</g>
</svg>
</svg>
</syntaxhighlight>
</lang>


=={{header|Wren}}==
=={{header|Wren}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
{{libheader|DOME}}
{{libheader|DOME}}
<lang ecmascript>import "graphics" for Canvas, Color
<syntaxhighlight lang="ecmascript">import "graphics" for Canvas, Color
import "dome" for Window
import "dome" for Window
import "math" for Math
import "math" for Math
Line 2,478: Line 2,478:
}
}


var Game = Polyspiral.new(640, 640)</lang>
var Game = Polyspiral.new(640, 640)</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
Line 2,484: Line 2,484:
trig functions because they handle argument angles outside 0 to 360
trig functions because they handle argument angles outside 0 to 360
degrees (2 Pi radians).
degrees (2 Pi radians).
<syntaxhighlight lang="xpl0">
<lang XPL0>
def Width=640., Height=480.;
def Width=640., Height=480.;
def Deg2Rad = 3.141592654/180.;
def Deg2Rad = 3.141592654/180.;
Line 2,507: Line 2,507:
Clear;
Clear;
until KeyHit;
until KeyHit;
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}
Line 2,518: Line 2,518:
=={{header|Yabasic}}==
=={{header|Yabasic}}==
{{trans|Python}}
{{trans|Python}}
<lang Yabasic>w = 1024 : h = 600
<syntaxhighlight lang="yabasic">w = 1024 : h = 600
open window w, h
open window w, h
color 255,0,0
color 255,0,0
Line 2,542: Line 2,542:
next
next
pause 1
pause 1
end while</lang>
end while</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
Line 2,549: Line 2,549:


Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
<lang zkl>w,h:=640,640;
<syntaxhighlight lang="zkl">w,h:=640,640;
bitmap:=PPM(w,h,0xFF|FF|FF); // White background
bitmap:=PPM(w,h,0xFF|FF|FF); // White background
angleIncrement:=(3.0).toRad();
angleIncrement:=(3.0).toRad();
Line 2,567: Line 2,567:
angleIncrement=(angleIncrement + 0.05);
angleIncrement=(angleIncrement + 0.05);
Atomic.sleep(3);
Atomic.sleep(3);
}</lang>
}</syntaxhighlight>