Κυριακή 4 Αυγούστου 2024

Draw USA FLAG (updated)

A demo program to draw USA flag, using draw commands, passing the X and Y upper left point and the Height of flag (the width is 1.9 times the height).

The demo draw three flags of various sizes, plus one converting to EMF and plaxe it roated 36 degrees.

The new version draw star using Polygon (old version use draw and floodfill, but flood fill not worked for EMF)






Run M2000 interpreter

Write Edit A

Press Enter

Copy this program

Press Esc

Write A and press enter to run module A

Write Save USAflag and press enter to save this module

cls, 0


module USA_flag (Xorigin, Yorigin, A) {
white=#ffffff
red=#b31942
blue=#0a3161
// from 3100
if A<3100 then A=3100
B=1.9*A
D=B*2/5
L=A/13
C=A*7/13
F=C/10
G=D/12
K=L*4/5

move Xorigin, Yorigin
for i=1 to 6
DrawStrip(Red)
DrawStrip(white)
next
DrawStrip(Red)
move Xorigin, Yorigin
pen blue {
polygon blue, D, 0, 0, L*7-twipsX, -D, 0, 0, -L*7+twipsX
}
for J=F TO C STEP F*2
for I=0 TO 5
move Xorigin+G*I*2+G, Yorigin+J
drawStar(K/2)
next
next
for J=2*F TO C-F STEP F*2
for I=1 TO 5
move Xorigin+G*I*2, Yorigin+J
drawStar(K/2)
next
next
sub drawStar(d)
local dd=d*tan(36), k=pi/10
step 0, -d
pen 15 {polygon 15, angle 3*pi/2+k, dd,0, dd, -k*3-pi/2, dd, 3*pi/2+k, dd, -2*k+pi, dd, -k*3-pi/2, dd, pi/2-k, dd, -2*k+pi, dd,0, dd, pi/2-k, dd}
step 0, d
end sub
sub DrawStrip(col)
pen col {
polygon col, B, 0, 0, L, -B, 0, 0, -L
}
step 0, L
end sub
}
report 2, "USA FLAG"
USA_flag  0,300, scale.y*2/3
USA_flag 18000, 1200, 4000
USA_flag 14000, 8000, 6000
drawing {
USA_flag 0, 0, 9000
} as USA_flag
move 6000,14000
image USA_flag, 6000,,36
A$=KEY$


Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.