Τρίτη 20 Αυγούστου 2024

Union Flag (updated)


The updated example show the use of drawing to an EMF in memory and then drawing the EMF using rotation 30 degree.

This example show the use of  masking the graphic output by using a path, a surface too place graphics. We need that because we have the slope bands on union flag. Check the flag without using the Path  {} instruction. Paths reset using Path {}; statement or using CLS statement.

Also this example use polar coordinates for specific parts, using absolute direction in radians, and distance in twips (we can use negative values also). Step, Draw and Polygon  use the ANGLE variation (Curve also has ANGLE variation, but not used here).

We see the module which use parameters with initial vsalue, if we didn't provide the parameter. Although we can use this for modules and functions, for modules there is a risk, if we didn't clear the stack of values, before the call, and there are some values on it, it seems for interpretr that we pass some values as arguments. How to not use the remain values of a stack: 1) We use a Stack { } block providing temporary a new empty stack object, we put the call inside the block. 2) We place ? when we use to quide the interpreter to use the initial value. If we didn't provide one we get an error (Variable X can't initialised),



 

Run m2000.exe (the M2000 Interpreter), write Edit A and then copy this program. Press Esc and write Save UnionFlag to save it, Now write A and press enter to execute,

We get Union |Flag at 3/5 and 1/2 ratio.

// https://en.wikipedia.org/wiki/Flag_of_the_United_Kingdom
// https://www.flagcolorcodes.com/united-kingdom
CLS 5,0


module UnionFlag(X1=3000, Y1=1000, z=10000, RATIO=.6) {
RED=#C8102E
BLUE=#012169
WHITE=#FFFFFF
z50=z div 50
z1=int(z*RATIO)
z130=z1 div 30


MOVE X1,Y1
PATH {
POLYGON 0, z+twipsX, 0, 0, z1+twipsY, -z-twipsX, 0, 0,-z1-twipsY
};
PEN BLUE {POLYGON BLUE, z+twipsX, 0, 0, z1+twipsY, -z-twipsX, 0, 0,-z1-twipsY}
MOVE X1+Z/2,Y1+Z1/2
P=ATN(Z1/Z)/180*PI
Z2=SQRT(Z1**2+Z**2)
STEP ANGLE P, -Z2/2
STEP ANGLE P+PI/2, -Z130*3
PEN WHITE {POLYGON WHITE, ANGLE P, Z2, P+PI/2, Z130*6, P, -Z2, P+PI/2, -Z130*6}
STEP ANGLE P+PI/2, Z130
PEN RED {POLYGON RED, ANGLE P, Z2/2, P+PI/2, Z130*2, P, -Z2/2, P+PI/2, -Z130*2}
STEP ANGLE P+PI/2, Z130*2
STEP ANGLE P, Z2/2
PEN RED {POLYGON RED, ANGLE P, Z2/2, P+PI/2, Z130*2, P, -Z2/2, P+PI/2, -Z130*2}
MOVE X1+Z/2,Y1+Z1/2
oldp=p
p=pi/2-p
STEP ANGLE P-PI/2, -Z2/2
STEP ANGLE P, Z130*3
PEN WHITE {POLYGON WHITE, ANGLE P+pi/2, -Z2, P, -Z130*6, P+pi/2,Z2, P, Z130*6}
STEP ANGLE P, -Z130*3
PEN RED {POLYGON RED, ANGLE P+pi/2, -Z2/2, P, -Z130*2, P+pi/2,Z2/2, P, Z130*2}
STEP ANGLE P, Z130*2
STEP ANGLE P+PI/2, -Z2/2
PEN RED {POLYGON RED, ANGLE P+pi/2, -Z2/2, P, -Z130*2, P+pi/2,Z2/2, P, Z130*2}
p=oldp
MOVE X1+Z/2,Y1+Z1/2


STEP -z50*5, -z1/2
PEN white {POLYGON white, z50*10, 0, 0,z1, -z50*10, 0, 0, -z1}
STEP z50*5-z/2, z1/2
STEP 0, -z130*5
PEN white {POLYGON white, z, 0, 0, 10*z130, -z, 0, 0, -10*z130}
STEP z/2, z130*5


STEP -z50*3, -z1/2
PEN red {POLYGON red, z50*6, 0, 0,z1, -z50*6, 0, 0, -z1}
STEP z50*3-z/2, z1/2
STEP 0, -z130*3
PEN red {POLYGON red, z, 0, 0, 6*z130, -z, 0, 0, -6*z130}
STEP z/2, z130*3
path {};
}
unionFlag 1000,8100, 15000, 0.5
unionFlag
unionFlag 16000,1000, 8000
unionFlag 18000,9000, 8000, 0.5
drawing {
unionFlag
} as unionFlag
move 8000,10000
image unionFlag, 9000,,30
a$=key$



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

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

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