[Module] DrawVectorEx - Module

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

[Module] DrawVectorEx - Module

Post by Thorsten1867 »

DrawVectorEx - Module (all OS / 64Bit / DPI)

Simplified use of the VectorDrawing library

Image

Code: Select all

; Draw::AlphaColor_()   - similar to RGBA()
; Draw::Box_()          - similar to Box()
; Draw::Circle_()       - similar to Circle()
; Draw::CircleArc_()    - draws a arc of a circle
; Draw::CircleSector_() - draws a circle sector
; Draw::Ellipse_()      - similar to Ellipse()
; Draw::EllipseArc_()   - draws a arc of a ellipse
; Draw::Font_()         - similar to DrawingFont()
; Draw::Line_()         - similar to Line()
; Draw::HLine_()        - draws a horizontal line
; Draw::VLine_()        - draws a vertical line
; Draw::LineXY_()       - similar to LineXY()
; Draw::MixColor_()     - mixes 2 colours in a mixing ratio of 1% - 99%
; Draw::SetStroke_()    - changes the stroke width
; Draw::StartVector_()  - similar to StartVectorDrawing()
; Draw::StopVector_()   - similar to StopVectorDrawing()
; Draw::Text_()         - similar to DrawText()
; Draw::TextHeight_()   - similar to TextHeight()
; Draw::TextWidth_()    - similar to TextWidth()
Download: DrawVectorExModule.pbi
Last edited by Thorsten1867 on Thu Mar 12, 2020 8:47 am, edited 4 times in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: [Module] DrawVectorEx - Module

Post by RSBasic »

Very nice Image
Image
Image
User avatar
skywalk
Addict
Addict
Posts: 3960
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Module] DrawVectorEx - Module

Post by skywalk »

This is very helpful!
Wish I had it before so many code stumbles. :oops:
Some of the module elements are called often and should be Macro's.

Code: Select all

  ;- ===========================================================================
  ;-   DeclareModule
  ;- ===========================================================================
  ;Declare.q AlphaColor_(Color.i, Alpha.i)
  ;Declare.q MixColor_(Color1.i, Color2.i, Factor.i=50)
  Macro dpiX(Num_i)
    DesktopScaledX(Num_i)
  EndMacro
  Macro dpiY(Num_i)
    DesktopScaledY(Num_i)
  EndMacro

  Macro AlphaColor_(Color_i, Alpha_i)
    RGBA(Red(Color_i), Green(Color_i), Blue(Color_i), Alpha_i)
  EndMacro
  Macro MixColor_(Color1_i, Color2_i, Factor_i=50)
    BlendColor_(Color1_i, Color2_i, Factor_i)
  EndMacro
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
IdeasVacuum
Always Here
Always Here
Posts: 6424
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Module] DrawVectorEx - Module

Post by IdeasVacuum »

OMG - I have had so much trouble getting the Vector Lib to work in the real world, it just isn't intuitive. This Module is going to save my hair (whats left of it). :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: [Module] DrawVectorEx - Module

Post by Everything »

Thorsten1867 wrote:Download: DrawVectorExModule.pbi
Isn't this link to Date64Module.pbi ?
IdeasVacuum
Always Here
Always Here
Posts: 6424
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Module] DrawVectorEx - Module

Post by IdeasVacuum »

Everything wrote:Isn't this link to Date64Module.pbi ?
It does, but via "Download of PureBasic - Modules" you will find all of Thorsten's Modules, including DrawVectorEx.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: [Module] DrawVectorEx - Module

Post by Everything »

IdeasVacuum wrote:but via "Download of PureBasic - Modules" you will find all of Thorsten's Modules, including DrawVectorEx
Yes I know, just wanted to point out an error in the module link (just in case)
User avatar
Blue
Addict
Addict
Posts: 863
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: [Module] DrawVectorEx - Module

Post by Blue »

a direct link : Thorsten Hoeppner's PB modules (in Github)

Thank you very much, Thorsten, for clarifying the whole Vector Drawing library.
Studying your code has gotten me to finally understand what I was doing so wrong in regards to vector drawing and DPi awareness.
Most appreciated.

And you should give serious consideration to Skywalk's suggestion of replacing some of the simpler one-line one-value Procedures with Macros. It makes a lot of sense.
Last edited by Blue on Thu Mar 12, 2020 3:32 am, edited 2 times in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
IdeasVacuum
Always Here
Always Here
Posts: 6424
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Module] DrawVectorEx - Module

Post by IdeasVacuum »

Hi Thorsten

An enhancement request - tangent arcs:

Image
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] DrawVectorEx - Module

Post by Thorsten1867 »

Have you the code for tangent arcs?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
IdeasVacuum
Always Here
Always Here
Posts: 6424
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Module] DrawVectorEx - Module

Post by IdeasVacuum »

Hi Thorsten

I thought they were supported by GDI+, but I'm wrong, I can't find a mention in Danilo's gDrawing Lib.

I think I should be able to get a handle on it myself. A couple of diagrams showing the geometry rules:

Image

There is an interesting discussion, with code, here:

http://csharphelper.com/blog/2019/10/co ... -arc-in-c/

However in most circumstances the User would have two lines meeting in a sharp corner and the tangent arc would be applied to that corner. In the CAD world it's called a "fillet".
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: [Module] DrawVectorEx - Module

Post by freak »

quidquid Latine dictum sit altum videtur
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] DrawVectorEx - Module

Post by Thorsten1867 »

IdeasVacuum wrote:Image
Do you have some coordinates for the lines to test?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
IdeasVacuum
Always Here
Always Here
Posts: 6424
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Module] DrawVectorEx - Module

Post by IdeasVacuum »

A couple of examples:

Image
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] DrawVectorEx - Module

Post by Thorsten1867 »

Please test!
I hope it does what it should. It's been decades since I did any math. :?

Image
Last edited by Thorsten1867 on Sat Mar 14, 2020 8:21 pm, edited 1 time in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Post Reply