3d turtle graphics: Difference between revisions
Content added Content deleted
(Created page with "Create a 3d representation of a house and bar chart, similar to that of Simple turtle graphics, but * Use a cube and an equilateral square pyramid for the house, and * u...") |
m (→{{header|J}}) |
||
Line 6: | Line 6: | ||
=={{header|J}}== |
=={{header|J}}== |
||
Assumes qtide and a "recent" (2022) version of J. |
|||
<lang J>NB. pre-requisites: |
<lang J>NB. pre-requisites: |
||
NB. ;install each cut 'gl2 gles github:zerowords/tgsjo' |
NB. ;install each cut 'gl2 gles github:zerowords/tgsjo' |
Revision as of 22:37, 26 February 2022
Create a 3d representation of a house and bar chart, similar to that of Simple turtle graphics, but
- Use a cube and an equilateral square pyramid for the house, and
- use columns with a square cross section for the bar chart.
J
Assumes qtide and a "recent" (2022) version of J. <lang J>NB. pre-requisites: NB. ;install each cut 'gl2 gles github:zerowords/tgsjo' load'zerowords/tgsjo' stop clearscreen createTurtle 0 0 0
EYE_tgsjo_=: 0 0 _90 rotR 180+94 10 0
column=: {{
4 repeats {{'height width'=. y 2 repeats {{'height width'=. y forward width pitch 90 forward height pitch 90 }} y forward width right 90 }} y
}}
cube=: Template:Column y,y
codihedral=: 180p_1*_3 o.%%:2 pyramid=: {{
4 repeats {{ roll codihedral pitch triangle y roll-codihedral forward y left 90 }} y
}}
triangle=: {{
3 repeats (u {{ forward y u 120 }}) y
}}
house=: {{
cube y roll 180 pyramid y
}}
barchart=: {{'lst size'=. y
if.#lst do. scale=. size%>./lst width=. size%#lst for_j. lst do. column (j * scale),width forward width end. back size end.
}}
penColor Red house 150 pen 0 back 30 right 180 pen 1 penColor Blue barchart 0.5 0.3333 2 1.3 0.5; 200 pen 0 left 180 forward 30 roll 180</lang>