Hi Guys
I love the PB forum Thanks for the many replies and smart ideas. I have had a ton of great ideas for other parts of the App but had a brain freeze when first trying-out the Vector Lib.
The image I posted is representative of the number of lines that make the shape, +- 3 or 4, so very light data. My App adds some geometry too. With the Compiler set to dpi aware, the resulting diagram, in pixels, is actually way more accurate than required, so I'm chuffed about that.
I think the AddPathBox() function might be Fred's own addition? It would be incredibly useful if we had a function to define the ordinate system - for "serious" drawing, that would negate a lot of Flip Coordinate calls and other bits of incoming data management.
It's a pity that the function naming is rather inconsistent too. Could have prefixed every Lib function with "Vector"........
Vector Drawing Change coordinates system
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Vector Drawing Change coordinates system
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Vector Drawing Change coordinates system
This is all that's needed:
Working demo:
Code: Select all
Macro ReverseVector_Y_Coordinates()
FlipCoordinatesY(VectorOutputHeight() / 2)
EndMacro
Code: Select all
; PB 5.71
EnableExplicit
Macro ReverseVector_Y_Coordinates()
FlipCoordinatesY(VectorOutputHeight() / 2)
EndMacro
Macro Vector_LineXY (_x1_, _y1_, _x2_, _y2_)
MovePathCursor(_x1_, _y1_)
AddPathLine(_x2_, _y2_)
EndMacro
#Window = 0
#Canvas = 0
Define event.i, width.i=450, height.i=300
If OpenWindow(#Window, 0, 0, width, height, "Standard math coordinate system", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) = 0
MessageRequester("Fatal error", "Can't open main window.")
End
EndIf
CanvasGadget(#Canvas, 0, 0, width, height)
If StartVectorDrawing(CanvasVectorOutput(#Canvas))
; Draw a blue "L" near the lower left corner,
; using the standard math coordinate system:
ReverseVector_Y_Coordinates()
Vector_LineXY(20, 80, 20, 20)
Vector_LineXY(20, 20, 50, 20)
VectorSourceColor(RGBA(0, 0, 255, 255))
StrokePath(5)
ResetCoordinates() ; Restore the default coordinate system.
StopVectorDrawing()
EndIf
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
Re: Vector Drawing Change coordinates system
Like my example with macros. "Begin - EndFlipCoordinates".
You can also do this between DrawVectorText and ResetCoordinates.
viewtopic.php?f=13&t=73976&start=0#p544297
You can also do this between DrawVectorText and ResetCoordinates.
viewtopic.php?f=13&t=73976&start=0#p544297
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Vector Drawing Change coordinates system
Sorry, in my opinion your code is unnecessarily complicated (as well as other codes in this thread).mk-soft wrote:Like my example with macros. "Begin - EndFlipCoordinates".
You can also do this between DrawVectorText and ResetCoordinates.
viewtopic.php?f=13&t=73976&start=0#p544297
So I felt the need to show that there is a simple and straightforward solution to the problem.