|
Post by alexfish on Oct 1, 2023 21:12:15 GMT 1
The gcode conversion Text as mentioned only 2 pictures one is the imported Q.svg from librecad txt to svg , and is off the table the second is the corrected svg2code done in hug/bacon version the one the is missing here are known svg2gcode the will be view in gcode view 'upside down" see previous post the correct version the last line to is missing , here testing proof of BR Alex as view in a GCODE APP likes of say bCNC second piky = corrected svg2code Height Q = 100mm have checked the height in gcode view height = 128mm third pic added gcode view & svg image viewer , as can see need last line + Z axis correction
|
|
|
Post by alexfish on Oct 2, 2023 21:54:10 GMT 1
code base for text.svg Text2hug canvas completed worked as pix per mm so little jaggy , since value int for the canvas IE 49.89 will be 49 picky Attachments:
|
|
|
Post by alexfish on Oct 3, 2023 14:56:11 GMT 1
The svg2gcode.bac will see crossover in gcode viewer IE bCNC so will have to intervene . easy if click on the line in view for normal text may not need to , but always check BR Alex the code + svg file see archive 'CHANGE PATH ============================== Q$= LOAD$("/home/pi/Q.svg") <<-------------- '=========================================== INCLUDE "hug.bac" start_t = TIMER HUGOPTIONS("NOSCALING")
LOCAL xx1,xx2,yy1,yy2 TYPE float
win= WINDOW("svg2gcode",810,610) can = CANVAS(800,600) ATTACH (win,can,5,5) 'CHANGE PATH ============================== Q$= LOAD$("/home/pi/Q.svg") '=========================================== Q$ = REPLACE$(Q$,CHR$(34),"") Q$ = REPLACE$(Q$,"<line","G01") Q$ = REPLACE$(Q$,"x1=","X ") Q$ = REPLACE$(Q$,"y1=","Y ") Q$ = REPLACE$(Q$,"/>",NL$)
SPLIT Q$ BY NL$ TO arr$ SIZE dim float val = 0.0 float ck = 0.0 float sy = 129.0 'get height of text FOR t = 0 TO dim -1 res$ = CHOP$(arr$[t])
IF INSTR(res$,"X") AND INSTR(res$,"Y") AND INSTR(res$,"x2") AND INSTR(res$,"y2") THEN IF LEN(res$) >3 THEN yy1=VAL(INBETWEEN$(res$,"Y","x2")) IF ck < yy1 THEN ck = yy1 END IF END IF END IF
NEXT
Q$ = "" LOCAL begin LOCAL begin$ FOR t = 0 TO dim -1 res$ = CHOP$(arr$[t]) IF INSTR(res$,"X") AND INSTR(res$,"Y") AND INSTR(res$,"x2") AND INSTR(res$,"y2") THEN xx1= VAL(INBETWEEN$(res$,"X","Y")) yy1=VAL(INBETWEEN$(res$,"Y","x2")) xx2=VAL(INBETWEEN$(res$,"x2=","y2")) yy2 = VAL(MID$(res$,INSTR(res$,"y2")+3))
IF LEN(res$) >3 THEN LINE("#FF0000",xx1 +5, yy1 +5, xx2 +5, yy2 +5) M$ = MID$(res$,1,INSTR(res$,"x2")-2) Q$ = Q$ & MID$(res$,1,INSTR(res$,"Y")) & " " & STR$(ck-yy1)& " X " & STR$(xx2) & " Y " & STR$(ck-yy2) & NL$ IF begin THEN
ELSE begin$ = "G0 X 0 Y 0 Z 0" & NL$ begin$ = begin$ & "G0 X " & STR$(xx1) & " Y " & STR$(ck-yy1) & NL$ begin$ = begin$ & "G01 Z -5" & NL$ begin=1 END IF END IF END IF NEXT begin$= begin$ & Q$ SAVE begin$ TO "text999.nc" PRINT "time : ", TIMER - start_t DISPLAY TODO NEXT text with path in IE <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="55.55555556mm" height="100mm" viewBox="0 0 55.55555556 100"> <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1"> <line x1="0" y1="100" x2="0" y2="0"/> <line x1="0" y1="0" x2="27.77777778" y2="0"/> <path d="M27.77777778,0 A27.77777778,27.77777778 0 1,1 27.77777778,55.55555556 "/> <line x1="27.77777778" y1="55.55555556" x2="0" y2="55.55555556"/> </g> </svg> that falls into the full 'svg master parser' where A is missing, need to know (p's and q's) Attachments:Q.svg.bz2 (934 B)
|
|
|
Post by alexfish on Oct 3, 2023 20:01:33 GMT 1
Summary of
letter P the path |D is it p or q rx ry rot large-A-f sweep x y A 27.0,27.0 0.0 1.0, 1.0, 27.0, 55.0
rx 27 x27 ry 27 y55 NOTE there are no degrees so need so sweep IE easy speak degrees
.p1 y1 27
.p2 y 55
assumed degrees = 180 and cord is vertical center 55-27 = : D= 28 r = 14
arc = for t = 0 to 180 sin(rad) cos(rad) pixel(x,y) next
sumarrary P path example
x0 y0 lineto x0 y100, lineto x27 y100 direction --> do the arc downto 55 lineto x0 y55
= double hard as we need to flip the flipping thing in the Vertical for the GCODE
|
|
|
Post by alexfish on Oct 3, 2023 20:37:39 GMT 1
what do you mean , I can't spell summary
stick
sumarrary in the browser
and for code
if char = q then
if char = p then
BR Alex
|
|
|
Post by alexfish on Oct 3, 2023 20:57:22 GMT 1
Fonts Alphabets & Languages and all
native to where I live , old speak
A Riddle how Apt
Have Fun
BR Alex
|
|
|
Post by alexfish on Oct 4, 2023 9:17:08 GMT 1
Drawing / carving / milling fonts etc
Down to the last bit in the chain
in first demo of drawing on the canvas , each move gives the last move to
instance X1 0 Y1 0 X2 100 Y2 100 in case of arc = last point x/y
taken that next draw in the file not = last point
ie last point x100 y100 next line x30 y50 to x600 y50
here assume
retract G01 Z0 f*** move G0 X30 Y50 pen down G1 Z-5
now here can relate to TURTLE PENUP PENDOWN
now adding similar to the method else with have a unwanted method in the gcode ,IE wanted = the above pen up Z0 .... pen down Z-5 ' Added 'Z0' = top of workpiece - clearance and the Z-5 = 5 units into the work piece
need 5 clearance ... add it to the ...
Yes Z is a weirdo machine speak home z may be -200 the bed of machine = 0 if item is 20mm thick the top = Z-20:: touch item with tool = touch it & press button , Now = 0 BR Alex ------ Now draw
|
|
|
Post by alexfish on Oct 4, 2023 10:59:54 GMT 1
In this world Text Wise
Hi-lighting a modern day text buffer ' a problem with chars'
OPTION PARSE FALSE
INCLUDE "hug.bac" char bit[256] FOR t = 33 TO 126 bit[t] = t NEXT
FOR t = 33 TO 126 PRINT CHR$(bit[t]) ," " ; NEXT
PRINT PRINT "--------------------------------"
win = WINDOW("Asci",600,400) ed = EDIT(600,400) FONT(ed, "monospace,20px") ATTACH(win,ed,0,0) FOR t = 33 TO 126 TEXT(ed,CHR$(t)) NEXT TEXT(ed,NL$ & NL$) FOR t = 33 TO 126 TEXT(ed,CHR$(t) & " ") NEXT
PRINT
DISPLAY
Try to reach each char esp : in top line right
|
|
|
Post by alexfish on Oct 4, 2023 11:41:45 GMT 1
Then Run This
OPTION PARSE FALSE
INCLUDE "hug.bac" char bit[256] FOR t = 33 TO 126 bit[t] = t NEXT
FOR t = 33 TO 126 PRINT CHR$(bit[t]) ," " ; NEXT
PRINT PRINT "--------------------------------"
win = WINDOW("Asci",600,400) ed = EDIT(600,400) FONT(ed, "monospace,20px") ATTACH(win,ed,0,0) LOCAL ptr
FOR t = 33 TO 126 TEXT(ed,CHR$(t)) INCR ptr NEXT TEXT(ed,NL$ & "LEN" & NL$) C$ = GRAB$(ed) PRINT LEN(C$)
TEXT (ed,"Char Count :" & STR$(ptr) & NL$) TEXT (ed,"Char Count edit :" & STR$(LEN(C$)) & NL$) PRINT C$
DISPLAY
Sitting Here
LEN Char Count :94 Char Count edit :99
|
|
|
Post by alexfish on Oct 4, 2023 11:48:54 GMT 1
Just had to double check if copy and paste hug edit text and paste in bacon editor all is good also of Note ;RPIos . sourceview2 and vte0.9 :: libs and devs are back in repos BR Alex
|
|
|
Post by alexfish on Oct 4, 2023 14:26:40 GMT 1
That is a wrap since last few posts (font wise) and have touched on the pixbuf hence takes us back to the original canvas edit editor updated the editor to produce TEXT = P <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="55.55555556mm" height="100mm" viewBox="0 0 55.55555556 100"> <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1"> <line x1="0" y1="100" x2="0" y2="0"/> <line x1="0" y1="0" x2="27.77777778" y2="0"/> <path d="M27.77777778,0 A27.77777778,27.77777778 0 1,1 27.77777778,55.55555556 "/> <line x1="27.77777778" y1="55.55555556" x2="0" y2="55.55555556"/> </g> </svg> <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="55.55555556mm" height="100mm" viewBox="0 0 55.55555556 100"> <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1"> <line x1="0" y1="100" x2="0" y2="0"/> <line x1="0" y1="0" x2="27.77777778" y2="0"/> <path d="M27.77777778,0 A27.77777778,27.77777778 0 0,0 27.77777778,55.55555556 "/> <line x1="27.77777778" y1="55.55555556" x2="0" y2="55.55555556"/> </g> </svg> P's & Qs 0 1,1 -----> 0 0,0 <------
have fun + BR Alex spot the diff picky Attachments:
|
|
|
Post by alexfish on Oct 4, 2023 14:37:07 GMT 1
Final fling want a circle
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="55.55555556mm" height="100mm" viewBox="0 0 55.55555556 100"> <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1">
<path d="M27.77777778,0 A27.77777778,27.77777778 0 1,1 27.77777778,55.55555556 "/> <path d="M27.77777778,0 A27.77777778,27.77777778 0 0,0 27.77777778,55.55555556 "/>
</g> </svg>
|
|
|
Post by alexfish on Oct 4, 2023 15:02:57 GMT 1
Ideas awaiting
Font.types
realspeak represents glyphs .
here are two svg glyphs with the bits filled in
<path d="M27.77777778,0 A27.77777778,27.77777778 0 1,1 27.77777778,55.55555556 "/> <path d="M27.77777778,0 A27.77777778,27.77777778 0 0,0 27.77777778,55.55555556 "/>
think CHAR letter
look at the word C H A R say each bit is a part of a char
for each char requires n/char's at position in the file(glyph pos)
'O' = line 1 in the file and line2 in the file so reads
'O',1,2
a bit of 'P' glyph is at 1 in the file
and so on call the file say
mymonofont.svg
So we have a term for getting the fonts ready 'BAKE' them into a buffer Sitting here , they will get baked into a 'pixbuf' these baked bits need to be composited into a bigger pixbuf(machine side)
methods are in the hug imager thread, well that is one method to see them + can bake them into a svg file as shown , + load the results into the canvas
Just a thought
BR Alex
ADDED Some bits to start playing with
<path d="M 5 ,35 A27 ,27 0 1,1 57 ,35 "/> <path d="M 5 ,35 A27 ,27 0 1,1 57 ,150 "/> <path d="M 5 ,35 A27 ,27 0 1,1 57 ,250 "/> <path d="M 5 ,35 A27 ,27 0 1,1 5 ,250 "/>
then swap out the 0,1,1 to 0,0,0
adjust the Y's to suit
Lost
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="800" height="800" > <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1">
<path d="M 5 ,35 A0 ,0 0 1,1 5 ,250 "/> <path d="M 5 ,35 A20 ,20 0 1,1 5 ,250 "/> <path d="M 5 ,35 A30 ,20 0 1,1 5 ,250 "/> </g> </svg>
|
|
|
Post by alexfish on Oct 4, 2023 19:07:30 GMT 1
Found Your Feet <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:lc="http://www.librecad.org" xmlns:xlink="http://www.w3.org/1999/xlink" width="800" height="800" > <g lc:layername="0" lc:is_locked="false" lc:is_construction="false" fill="none" stroke="black" stroke-width="1">
<path d="M 5 ,35 A0 ,0 0 1,1 5 ,250 "/> <path d="M 5 ,35 A10 ,20 0 1,1 5 ,250 "/> <path d="M 5 ,35 A20 ,20 0 1,1 5 ,250 "/> <path d="M 250 ,35 A30 ,20 0 1,1 250 ,250 "/> <path d="M 250 ,35 A30 ,20 0 0,0 250 ,250 "/> <path d="M 250 ,250 A25 ,20 0 0,0 250 ,500 "/> <path d="M 250 ,250 A25 ,20 0 1,1 250 ,500 "/> <path d="M 250 ,250 A10 ,20 0 0,0 250 ,500 "/> <path d="M 5 ,500 A10 ,20 0 1,1 250 ,500 "/> </g> </svg> Attachments:
|
|
|
Post by alexfish on Oct 4, 2023 19:34:57 GMT 1
This is where imager5.2 comes to use
of note the pixbuf functions come to hand
of note to put the point
SUB PUT_PIXEL_RGBA(long pixbuf,int x,int y,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels ' check x y fits width & heigh before getting to here width = gdk_pixbuf_get_width (pixbuf) height = gdk_pixbuf_get_height (pixbuf) IF (x >= 0 AND x <= width) AND (y >= 0 AND y <= height) THEN rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + y * rowstride + x * n_channels p[0] = red p[1] = green p[2] = blue p[3] = alpha ELSE END IF END SUB
can use same method to find a pixel etc
and role on the gcode if required + the bits for the machine
here is load svg into a pixbuf
so can put the image to the canvas + scan the file using the above for where the pixels are x,y
know: from the svg file can code to gcode file , no math involved: here we can translate the scanned bits then send them to stepper controller AKA the stepper lib that drives the x axis y axis z axis
the svg bit
'======================================================================== FUNCTION SVG2PIXBUF(STRING svg$) TYPE long LOCAL pix, ebox, context LOCAL pixloader, pixbuf TYPE long LOCAL size TYPE NUMBER LOCAL res TYPE int LOCAL raw_array TYPE unsigned char* REM Get the associated canvas pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix)) context = hug_widget_context(STR$(pix)) size = LEN(svg$) raw_array = (unsigned char*)svg$ pixloader = gdk_pixbuf_loader_new() res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader, 0) pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) RETURN pixbuf END FUNCTION 'author vovchik '======================================================================
math wise example of arc function
'====================================================================== SUB DP_ARC(long hug_pix,double deg1,double deg2, double hug_xsize, double hug_ysize,int hug_fill) TYPE long LOCAL x,y,t,i,angle TYPE double newpix = gdk_pixbuf_new(0,TRUE,8,hug_xsize*2,hug_ysize*2) IF hug_fill THEN FOR i = deg1 TO deg2 STEP .05 angle = 2 * PI * i / 360 x = (hug_xsize/2)*SIN(angle) y = (hug_ysize/2)*COS(angle) FOR t = (hug_xsize/2)-x TO (hug_xsize/2)+x PUT_PIXEL_RGBA(hug_pix,t, (hug_ysize/2)+y,DEC(MID$(RGBA.RGB$,2,2)),DEC(MID$(RGBA.RGB$,4,2)),DEC(MID$(RGBA.RGB$,6,2)),DEC(RGBA.ALPHA$) )
NEXT NEXT ELSE FOR i = deg1 TO deg2 STEP .05 angle = 2 * PI * i / 360 x = (hug_xsize/2)*SIN(angle) y = (hug_ysize/2)*COS(angle) t = (hug_xsize/2)-x PUT_PIXEL_RGBA(hug_pix,t, (hug_ysize/2)+y,DEC(MID$(RGBA.RGB$,2,2)),DEC(MID$(RGBA.RGB$,4,2)),DEC(MID$(RGBA.RGB$,6,2)),DEC(RGBA.ALPHA$) ) t=(hug_xsize/2)+x NEXT
END IF
END SUB '======================================================================
|
|