Παρασκευή 10 Φεβρουαρίου 2023

Creating an EMF part for drawing from M2000

 


The code:

pen 0
cls 15
form 80, 45
a=1800
b=a*3/4
c=1.5*b
x=6000
y=6000
rem {
Width 8 {
move 0+x,  a+y
draw b, 0
draw 0, -a
draw c,a`
draw -c, a
draw 0, -a
step c, -a
draw 0, 2*a
step 0, -a
draw b,0
}
cls
}
drawing 4.6*a,2.8*a {
width 24 {
move 0+a*.3, a+a*.3
draw b, 0
draw 0, -a
draw c,a
draw -c, a
draw 0, -a
step c, -a
draw 0, 2*a
step 0, -a
draw b,0
}
} as emf


move 8000, 6000
image emf, 2000
move 8000, 8000
image emf, 2000,,45
move 8000, 8000
image emf, 2000,,-45
move 8000, 8000
image emf, 2000,,-60
move 8000, 10000
image emf, 2000,,-45
move 10000, 8000
image emf, 2000,,-60
move 6000, 8000
image emf, 2000,,45


clipboard  emf as "emf"
open "part.emf" for output as #n
put #n, emf
close #n

Using the code above I do my experiments to adjust the part at different angles, to find the proper offset for the center of the drawing. The difficulty was by the rendering procedure which take account the drawing size from the width, height we give at Drawing structure (we can leave it blank, and the image "centered" to where the rendering procedure find as the center point). Also we have lines with a width over 1 pixel so this sometime "exclude" the side of the line which is out of bound at the final rendering. These all have to do with the rendering on M2000, and the bitmap export, and some times with the rendering on the paint application. InkScape always exclude info for a bounding rectangle and present the drawing as is, so we can group it and use it as one component. See the image from Inkscape. See the image from paint application which include the bounding hollow rectangle and adjust the size accordingly (see the white space at the right of the displayed bitmap).

Values for coordinates are in twips (twipsX and twipsY are the twips per pixel, and for 96 dpi these have values 15 and 15). The maths are easy here 1440 twips is a logic inch so 96 dpi means one logic inch has 96 pixles, or  1440/96 = 15 twips/pixel. Monitors inch are not real, but for printers it is real, so we can draw exactly 1 inch using 1440 twips for any dpi setting on printer. Monitors diffeents in size  may keeping same resolution as pixels on screen (say 1280 x 1024) and named "96" dpi, so 1280*15 = 19200 is the logical twips for width, but actual the size of monitor maybe a 17 inch or 19 inch has own real dpi. For phone screens we read about ppi, pixels per inch, which are the real dpi of screen, and not the dpi of the software which may varies.








We can import from clipboard to InkSpace.





We can also import to paint application (as a bitmap but with transparency until we leave the float format and make it persistent, at a fixed position).






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

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

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