Simple turtle graphics: Difference between revisions

m
syntax highlighting fixup automation
m (→‎{{header|Phix}}: factored out some common code for the 3D version)
m (syntax highlighting fixup automation)
Line 16:
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<langsyntaxhighlight Actionlang="action!">INCLUDE "D2:TURTLE.ACT" ;from the Action! Tool Kit
 
PROC Rectangle(INT w,h)
Line 104:
DO UNTIL CH#$FF OD
CH=$FF
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Simple_turtle_graphics.png Screenshot from Atari 8-bit computer]
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters; use Ada.Characters;
Line 279:
New_Line;
end main;
</syntaxhighlight>
</lang>
 
=={{header|J}}==
Line 285:
 
Prerequisites (requires a network connection or, for a non-networked system, significant technical savvy), and assumes user is running the a recent version of J's qtide (perhaps J 9.3):
<langsyntaxhighlight Jlang="j"> ;install each cut 'gl2 gles github:zerowords/tgsjo'</langsyntaxhighlight>
 
Implementation (note that this is meant to be copied and pasted to a file which J will load, rather than being typed in line by line -- manual typing would work if no errors were made, but that would be a painstaking approach):
 
<langsyntaxhighlight Jlang="j">load'zerowords/tgsjo'
rotR 0 0 _90
translate 0 0 _40
Line 346:
forward 10
left 270
pen 1</langsyntaxhighlight>
 
Opens a window with the indicated content. House is red, barchart is blue.
Line 355:
{{trans|Wren}}
Outputs a PNG file.
<langsyntaxhighlight lang="julia">using Luxor, Colors
 
function house(🐢, x, y, siz)
Line 415:
 
testturtle()
</syntaxhighlight>
</lang>
 
=={{header|Logo}}==
Line 421:
{{trans|Quackery}}
 
<langsyntaxhighlight Logolang="logo">to rectangle :width :height
repeat 2 [
forward :height
Line 471:
pendown
barchart [ 0.5 0.33333 2 1.3 0.5 ] 200
left 90 back 10 right 90</langsyntaxhighlight>
 
{{out}}
Line 479:
=={{header|Perl}}==
Added octangle window to house attic.
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Simple_turtle_graphics
Line 615:
pendown;
graph( 400, 2,7,4,5,1,8,6 );
}</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 622:
You can run this online [http://phix.x10.mx/p2js/simpleturtlegraphics.htm here].<br>
I factored out some common code for the 2D and 3D versions (or started to, distributed version contains some additional diag aids)
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\turtle.e</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 637:
<span style="color: #000000;">pen_down</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">false</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<!--</langsyntaxhighlight>-->
 
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Simple_turtle_graphics.exw
Line 789:
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</langsyntaxhighlight>-->
 
=={{header|Python}}==
{{trans|Quackery}}
 
<langsyntaxhighlight Pythonlang="python">from turtle import *
 
def rectangle(width, height):
Line 838:
penup()
back(10)
pendown()</langsyntaxhighlight>
 
{{out}}
Line 846:
=={{header|Quackery}}==
 
<langsyntaxhighlight Quackerylang="quackery"> [ $ "turtleduck.qky" loadfile ] now!
 
[ behead do
Line 897:
10 1 fly
' [ [ 1 2 ] [ 1 3 ] [ 2 1 ] [ 13 10 ] [ 1 2 ] ] 200 1 barchart
-10 1 fly</langsyntaxhighlight>
 
{{output}}
Line 906:
{{libheader|DOME}}
{{libheader|Wren-turtle}}
<langsyntaxhighlight lang="ecmascript">import "dome" for Window
import "graphics" for Canvas, Color
import "./turtle" for Turtle
Line 991:
}
 
var Game = Main.new(600, 600)</langsyntaxhighlight>
 
{{out}}
Line 1,000:
=={{header|Yabasic}}==
{{trans|Python}}
<langsyntaxhighlight Yabasiclang="yabasic">// Rosetta Code problem: http://rosettacode.org/wiki/Simple_turtle_graphics
// Adapted from Python to Yabasic by Galileo, 01/2022
 
Line 1,067:
move(10)
pen(true)
barchart("0.5 0.333 2 1.3 0.5", 200)</langsyntaxhighlight>
10,327

edits