# PureBasic Forum

 It is currently Sat Jan 16, 2021 9:50 am

 All times are UTC + 1 hour

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Vectordrawing Flip Coordinates for Math/Cad OutputPosted: Sat Nov 09, 2019 11:59 am

Joined: Fri May 12, 2006 6:51 pm
Posts: 2801
Location: Germany
For graphical output of mathematical or CAD coordinates, you often need the correct alignment of the Y-axis and the direction of rotation.

This is possible with FlipCoordinatesY, but unfortunately it is not possible to suppress the rotation of the texts.
Maybe an additional parameter that does not mirror the text.
Or a parameter that always remains flipped, even after ResetCoordinates.

Current solution.
Code:
;-TOP
; Flip Y-Coordinates by mk-soft, v0.6

EnableExplicit

Global _IsFlipped_, _OldY_.d

Macro _PB_(Function)
Function
EndMacro

Macro BeginFlipCoordinates()
FlipCoordinatesY(VectorOutputHeight() * 0.5) : _IsFlipped_ = #True
EndMacro

Macro EndFlipCoordinates()
_PB_(ResetCoordinates)() : _IsFlipped_ = #False
EndMacro

Macro ResetCoordinates(_Value_=#PB_Coordinate_User)
_PB_(ResetCoordinates)(_Value_) : If _IsFlipped_ : FlipCoordinatesY(VectorOutputHeight() * 0.5, _Value_) : EndIf
EndMacro

Macro DrawVectorText(_Text_)
If _IsFlipped_
_OldY_ = PathCursorY()
FlipCoordinatesY(_OldY_) : _PB_(DrawVectorText)(_Text_) : FlipCoordinatesY(_OldY_)
Else
_PB_(DrawVectorText)(_Text_)
EndIf
EndMacro

Define i

If OpenWindow(0, 0, 0, 450, 300, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

If StartVectorDrawing(CanvasVectorOutput(0))
VectorFont(FontID(0))

MovePathCursor(10, 10)
DrawVectorText("Flip Coordinates Example")

BeginFlipCoordinates()

; Part 1
ResetCoordinates()

AddPathSegments("M 40 20 L 120 20 L 120 60 L 200 60 L 200 100 L 280 100 L 280 140 L 360 140 L 360 180")
VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(5, #PB_Path_RoundCorner)

MovePathCursor(10, 30)
RotateCoordinates(10, 30, 45)
DrawVectorText("Red Line")

;Part 2
ResetCoordinates()

TranslateCoordinates(50, 50)

AddPathSegments("M 40 20 L 120 20 L 120 60 L 200 60 L 200 100 L 280 100 L 280 140 L 360 140 L 360 180")
VectorSourceColor(RGBA(0, 0, 255, 255))
StrokePath(5, #PB_Path_RoundCorner)

MovePathCursor(10, 30)
RotateCoordinates(10, 30, 45)
DrawVectorText("Blue Line")

; Part 3
ResetCoordinates()

VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(5, #PB_Path_RoundCorner)

VectorSourceColor(RGBA(0, 0, 255, 255))
StrokePath(5, #PB_Path_RoundCorner)

; Part 4
ResetCoordinates()

VectorSourceColor(RGBA(64, 64, 64, 255))
For i = 0 To 260 Step 20
MovePathCursor(420, i + 20)
DrawVectorText(Str(i))
Next

EndFlipCoordinates()

StopVectorDrawing()
EndIf

Repeat
Define Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 24 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite