Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Draw Library (for QB64PE v4.4 up)
#1
DRAW LIBRARY
============
A high‑performance 2D drawing library for QB64‑PE, providing fast routines for shapes, lines, images, text rendering, and geometric transformations.

FEATURES
  • Fast filled shapes using scanline algorithms
  • Thick lines, triangles, quads, and rounded rectangles
  • Rotated and scaled image rendering
  • Rotated and filled ellipses
  • Arc and ring‑arc support
  • Text‑to‑image rendering
  • Clean naming conventions
  • No dependencies beyond QB64‑PE

INSTALLATION

  1. Place the library file in your project folder.
  2. Add this line at the top of your program:
    '$INCLUDE:'Draw Library.QLB'
  3. Compile and run.

COMMAND INDEX

CIRCLES & ELLIPSES
  • Draw.Circle.Fill
  • Draw.Circle.Thick
  • Draw.Ellipse.Filled
  • Draw.Ellipse.Arc.Fill
  • Draw.Ellipse.Ring.Arc.Fill
  • Draw.Ellipse.Tilt
  • Draw.Ellipse.Tilt.Fill
  • Draw.Ring.Arc.Fill
  • Draw.Arc.Fill
LINES
  • Draw.Line.Angle
  • Draw.Line.Thick
TRIANGLES
  • Draw.Triangle
  • Draw.Triangle.Fill
  • Draw.Triangle.Thick
QUADRILATERALS
  • Draw.Quad
  • Draw.Quad.Fill
  • Draw.Quad.Thick
RECTANGLES
  • Draw.Rect.Rounded
  • Draw.Rect.Rounded.Fill
IMAGES & TEXT
  • Draw.Image
  • Draw.Text.To.Image&


Philosophy
The Draw Library is built around a few core principles:
  • 1. Consistency
    • Every command follows the same naming pattern:
      Code: (Select All)
      Draw.<Shape>.<Variant>
  • 2. Performance
    • Wherever possible, routines use:
      _MAPTRIANGLE for fast GPU‑accelerated fills
      _MEM for direct pixel writes
      Integer math for speed and stability
  • 3. Compatibility
    • All routines work in:
      Any 32‑bit screen mode
      Any resolution
      Any aspect ratio
  • 4. Simplicity
    • The API is designed to be intuitive:
      No global state
      No hidden dependencies
      No required initialization

EXAMPLE
Code: (Select All)

'$INCLUDE:'Draw Library.QLB'

SCREEN _NEWIMAGE(800, 600, 32)

Draw.Circle.Fill 400, 300, 100, _RGB32(255, 140, 0)

img& = _LOADIMAGE("ship.png", 32)
Draw.Image img&, 400, 300, 1, 1, 45, 0

LICENSE

This library is free to use, modify, and distribute in any QB64PE project.
Attribution is appreciated but not required.

AUTHOR

Created by Steve, with a focus on clarity, performance, and developer‑friendly design.


Attached Files
.7z   Draw Library.7z (Size: 13.8 KB / Downloads: 32)
Reply
#2
Updated this to a library for QB64PE v4.4.   

Overhauled a lot of routines to either fix them (such as the rounded rectangle which had an issue with alpha blending), or optimize them (the thick circle routine is now about 10 times faster than before).

Added the new ellipse arc and ring routines.

There's now 22 (I think?) different drawing type commands in this library, and they should all work on all OSes equally.  There's no Windows specific code in this library like there are in some of my others.

This was a popular library before, with 359 downloads (if I remember correct) before, and it's only gotten BETTER.  If you were using the old version, swap to this version again.  There may be a few name changes and such so everything fits the same syntax as described above, but it's all been cleaned up, enhanced, and expanded upon nicely.

And.... 

Even as much as it annoys the crap out of me...

EVERY command has a QB64PE style documentation associated with it.  If you don't know what a *.md file is, it's a MARKDOWN TEXT format and is used for github and other such things.  For Windows I've found MarkText to be easy enough to use and nice to display things properly.  If you don't have a good markdown editor, reader, you might consider to give it a try:

https://github.com/marktext/marktext/releases

They're supposed to also have linux/max builds there as well, but as someone who's not a linux/mac user, all I can say is see for yourself.  I don't know crapola about how easy it is to setup, or use, or how functional is it on those systems.  Tongue
Reply
#3
This is awesome, but am I the only one getting major virus flags on this? 
Usually it's not this bad, Windows even wouldn't let me save this Web page, 
and didn't restore the deleted files after selecting "allow"... 

[Image: threat-detected.png]
Reply
#4
I just redownloaded the package and double checked to make certain I didn't do something goofy like embedding an EXE in there which might cause some antivirus to explode on it.

It's all just.... text files.

It's one BAS file as a demo.
One QLB library file, which is just a text file with a different extension.
And a bazillion MD files which are markdown text files -- just fancy text files.  Think RTF (rich text files) but in modern format.

If there's a virus in there somewhere, I'll eat my hat.  LOL!!

Sounds like you might need to disable windows defender or whatever anti-virus you have, then download it and move it to a whitelisted folder and extract the contents, before reenabling your AV.

Or, if you have an option to "Download To...", then download it directly to a whitelisted folder (like QB64PE usually should be).  You should probably be able to avoid the issue at that point as well, I'd think.
Reply
#5
Chrome / Edge / Firefox:
Settings → Downloads → Change download location.
You can also enable “Ask where to save each file” if you want a “Download To…” prompt every time.

^ Change your browser like the above to get a SAVE AS prompt and then you can choose where stuff gets downloaded to.  In this case, if you download directly to your QB64PE folder (which you should have whitelisted so your own stuff doesn't compile and trigger false warning flags for viruses), then it should be fine I would think and not cause you any problems.
Reply
#6
Thanks for checking Steve. I do have Save As but will look at the Defender settings. I mostly stopped asking about the virus warnings, only piped up this time because when I did "allow file" it didn't restore it, which is new. I guess Microsoft is getting extra heavy-handed with Defender (as they are with Windows) and it's damn annoying.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Input Devices Library SMcNeill 2 164 02-01-2026, 10:36 PM
Last Post: SMcNeill
  KeyBoard Library (for QB64PE v 4.4.0 up) SMcNeill 3 610 02-01-2026, 09:40 PM
Last Post: SMcNeill
  Date Library (v 4.4.0 up) SMcNeill 4 251 02-01-2026, 09:37 PM
Last Post: SMcNeill
  Screen Library SMcNeill 0 574 05-09-2025, 02:41 PM
Last Post: SMcNeill
  Text to Speech Library (Windows only) SMcNeill 11 4,027 07-01-2023, 07:58 PM
Last Post: mnrvovrfc

Forum Jump:


Users browsing this thread: