GARDEN.BAS
I found this code written by Kevin Savetz for Atari TurboBasic XL here: https://atariaction.tumblr.com/post/183733607962/garden-basic-tenliners-contest-2019-entry
It draws "flowers" on the screen and keeps redrawing new ones. The flower's petals are comprised of ellipses rotated about their center point. The rotation code in the Atari basic version comes from Bruce Artwik's book 'Microcomputer Displays, Graphics and Animation'
I've converted the Atari basic to Basic Engine and added some comments. Just starting to get my feet wet with the Basic Engine so this was a fun exercise. Some of the things that needed changed from the Atari version:
-added a THEN statement after the IF statements
-added variables XSTART and YSTART to hold the coordinates of the beginning of the line segment (the Atari Basic language has an odd way of drawing lines where you give it a start point with PLOT X,Y and then DRAWTO X,Y. Adding the new variables was a workaround, there could well be a better way to handle it)
-replaced the code which used lines to erase previous flowers with the rect command instead
10 CLS
20 SCREEN 1
30 COL=85 'DRAW COLOR
40 MAXX=459:MAXY=223
50 W=4:H=12.5 'SIZE OF ELLIPSE (PETAL)
60 DO
70 FOR YAXIS=40 TO MAXY-W STEP 30
80 FOR XAXIS=40 TO MAXX-H STEP 30
90 IF (RND(10)=0) THEN 'RANDOMLY PICK NEW LOCATION TO DRAW FLOWER
100 X=XAXIS:Y=YAXIS
110 X1=X+W:Y1=Y+H
120 RECT XAXIS-H,YAXIS-H,XAXIS+H,YAXIS+H,0,0 'ERASE PREVIOUS FLOWER
130 FOR ANGLE=0 TO 157.5 STEP 22.5 'MAX NUMBER OF PETALS IS 7 - LOOP THROUGH EACH
140 IF (RND(2)=0) THEN 'MAYBE WE DRAW THIS PETAL, MAYBE NOT
150 RADANG=ANGLE*0.01745 'CONVERT DEGREES TO RADIANS
160 FOR A=0 TO 6.28318 STEP 2/H 'DIVIDE PETAL INTO A SERIES OF POINTS
170 X1=X+COS(A)*W 'CALCULATE PETAL GEOMETRY
180 Y1=Y+SIN(A)*H 'CALCULATE PETAL GEOMETRY
190 ROTX=XAXIS+((X1-XAXIS)*COS(RADANG)-(Y1-YAXIS)*SIN(RADANG)) 'ROTATION CODE FROM BRUCE ARTWIK'S BOOK
200 ROTY=YAXIS+((X1-XAXIS)*SIN(RADANG)+(Y1-YAXIS)*COS(RADANG)) 'MICROCOMPUTER DISPLAYS, GRAPHICS AND ANIMATION
210 IF (A=0) THEN
220 XSTART=ROTX:YSTART=ROTY 'FIRST LINE SEGMENT COORDINATES, SAVED AS STARTX AND STARTY
230 IX=ROTX:IY=ROTY 'SAVE START POINT FOR OUR LAST LINE END POINT COORDINATES
240 ELSE
250 LINE XSTART,YSTART,ROTX,ROTY,COL 'DRAW LINE SEGMENT
260 XSTART=ROTX:YSTART=ROTY 'LINE END POINT SAVED AS START POINT FOR NEXT LINE SEGMENT
270 ENDIF
280 NEXT A
290 LINE ROTX,ROTY,IX,IY,COL 'FINAL LINE SEGMENT OF PETAL
300 ENDIF
310 NEXT ANGLE 'DRAW NEXT PETAL
320 ENDIF
330 NEXT XAXIS
340 NEXT YAXIS
350 LOOP