I am in the process of converting my commercial desktop c.a.d app written in PureBasic to a webapp.
Its going smooth up til now .... FlipCoordinatesX() and FlipCoordinatesY() seem to be missing in SpiderBasic.
As a workaround I could write my own routine to recalculate all the svg vectors to get a flipped drawing.... but that would be a severe slow down
Someone with a solution or fast workarround for that ?
flipcoordinates
Re: flipcoordinates
Hi William.
It's hard to be precise without seeing exactly what you are trying to do, but a combination of TranslateCoordinates and ScaleCoordinates should do the trick.
Please be aware that this behaves a little strangely with vector text, since the coordinates appear to reference the top left of the first character.
I hope that this is useful.
Kian
It's hard to be precise without seeing exactly what you are trying to do, but a combination of TranslateCoordinates and ScaleCoordinates should do the trick.
Code: Select all
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
If StartVectorDrawing(CanvasVectorOutput(0))
;normal coordinates (blue)
VectorSourceColor(RGBA(0, 0, 255, 128))
MovePathCursor(40, 20)
For i = 1 To 4
AddPathLine(80, 0, #PB_Path_Relative)
AddPathLine(0, 40, #PB_Path_Relative)
Next i
StrokePath(10, #PB_Path_RoundCorner)
;FlipCoordinatesX(xflip)
xflip=200
MovePathCursor(0, 0)
TranslateCoordinates(xflip*2,0) ;for yflip use (0,yflip*2)
ScaleCoordinates(-1, 1) ;for yflip use (1,-1)
;flipped coordinates (red)
VectorSourceColor(RGBA(255, 0, 0, 128))
MovePathCursor(40, 20)
For i = 1 To 4
AddPathLine(80, 0, #PB_Path_Relative)
AddPathLine(0, 40, #PB_Path_Relative)
Next i
StrokePath(10, #PB_Path_RoundCorner)
;Draw mirror line
MovePathCursor(xflip,0)
AddPathLine(0,200, #PB_Path_Relative)
VectorSourceColor(RGBA(0,255, 0, 128))
DashPath(3,10, #PB_Path_RoundCorner)
StopVectorDrawing()
EndIf
EndIf
I hope that this is useful.
Kian
- William Van Hoecke
- Posts: 50
- Joined: Tue Oct 22, 2019 12:09 pm
Re: flipcoordinates
OF COURSE.....GR@#!çPM?grml.....why couldn't I think of that.
Negative scaling IS in fact mirroring. Forgot all about negative coordinates.
Very very much thanks Kian.
Converting my Purebasic desktop C.A.D. program that draws predefined symbols made up in svg
The symbols should be able to be moved, resized, rotated and .... taraaaa .... mirrored.
No details yet, but having some other vector drawing issues (behaving different from PB)
https://photos.app.goo.gl/WSbZAxWJfUZHgu3KA
Negative scaling IS in fact mirroring. Forgot all about negative coordinates.
Very very much thanks Kian.
Converting my Purebasic desktop C.A.D. program that draws predefined symbols made up in svg
The symbols should be able to be moved, resized, rotated and .... taraaaa .... mirrored.
No details yet, but having some other vector drawing issues (behaving different from PB)
https://photos.app.goo.gl/WSbZAxWJfUZHgu3KA
Last edited by William Van Hoecke on Tue Aug 03, 2021 1:01 pm, edited 1 time in total.
Re: flipcoordinates
Glad to be of help.
I don't know why I didn't do this before, but the two lines:
could just be replaced with:
since the current PathCursor position is used as the origin of the scaling.
Kian
I don't know why I didn't do this before, but the two lines:
Code: Select all
MovePathCursor(0, 0)
TranslateCoordinates(xflip*2,0)
Code: Select all
MovePathCursor(xflip, 0)
Kian