How to resolve the algorithm Fractal tree step by step in the Amazing Hopper programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Fractal tree step by step in the Amazing Hopper programming language
Table of Contents
Problem Statement
Generate and draw a fractal tree.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Fractal tree step by step in the Amazing Hopper programming language
Source code in the amazing programming language
/*
Execute with:
$ hopper jm/tree.jambo -x -o bin/tree
$ rxvt -g 280x250 -fn "xft:FantasqueSansMono-Regular:pixelsize=1" -e ./bin/tree
*/
#include
Main
Set '25, 0.76, 160, 100, 10' Init 'Spread, Scale, SizeX, SizeY, Depth'
Color back '22', Cls
Color back '15'
Set '{SizeX} Mul by (2), -30, Div(SizeY,2), 90, Depth' Gosub 'Branch'
Pause
End
Subrutines
Define 'Branch, x1, y1, size, angle, depth'
x2=0, y2=0
Let ( x2 := #(x1 + size * cos(d2r(angle))) )
Let ( y2 := #(y1 + size * sin(d2r(angle))) )
Draw a line ( #(180-y1), #(180-x1), #(180-y2), #(180-x2))
If ( #( depth > 0) )
Set (x2, y2, {size} Mul by 'Scale', {angle} Minus 'Spread',\
Minus one(depth)) Gosub 'Branch'
Set (x2, y2, {size} Mul by 'Scale', {angle} Plus 'Spread',\
Minus one(depth)) Gosub 'Branch'
End If
Return
You may also check:How to resolve the algorithm Include a file step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the Dc programming language
You may also check:How to resolve the algorithm Empty directory step by step in the Lingo programming language
You may also check:How to resolve the algorithm Bitwise operations step by step in the 6502 Assembly programming language
You may also check:How to resolve the algorithm Abundant odd numbers step by step in the Lobster programming language