Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 318
» Latest member: coletteleger
» Forum threads: 1,745
» Forum posts: 17,906

Full Statistics

Latest Threads
astuce pour survivre fina...
Forum: Utilities
Last Post: coletteleger
Yesterday, 04:47 AM
» Replies: 0
» Views: 9
trouver permis de conduir...
Forum: Utilities
Last Post: nicolasrene
05-05-2025, 05:24 AM
» Replies: 0
» Views: 12
LIGHTBAR Menu
Forum: Programs
Last Post: nicolasrene
05-05-2025, 05:08 AM
» Replies: 15
» Views: 945
Learning Pallet Rack Safe...
Forum: Utilities
Last Post: Sandrapew
04-03-2025, 09:36 AM
» Replies: 0
» Views: 38
Choosing New Versus or Pr...
Forum: Utilities
Last Post: Sandrapew
03-18-2025, 01:11 AM
» Replies: 0
» Views: 33
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 1,058
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 70
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 68
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 3,438
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 2,082

 
  lineFT - draw a thick line
Posted by: James D Jarvis - 08-22-2023, 12:27 AM - Forum: Utilities - No Replies

It's not fancy but it draws lines over 1 pixel in thickness.

Code: (Select All)
'draw_lineFT
' By James D. Jarvis August 21,2023
'draw a line with a defined thickness
Screen _NewImage(400, 500, 32)
Dim Shared tk&
tk& = _NewImage(3, 3, 32)
'*********************************************
'demo
'*********************************************
x1 = 100: y1 = 100
x2 = 300: y2 = 300
x3 = 100: y3 = 200
lineFT x1, y1, x2, y2, 10, _RGB32(200, 100, 0)
lineFT x2, y2, x3, y3, 10, _RGB32(200, 100, 0)
lineFT x1, y1, x3, y3, 10, _RGB32(200, 100, 0)

'*************** routines **********************
'lineFT - draw a thick line constructed from 2 mapped triangles
'DegTo - return angle (in degrees) between two points , used as an internal function in lineFT
'*********************************************
Sub lineFT (x1, y1, x2, y2, thk, klr As _Unsigned Long)
    'draw a line of thickness thk on color klr from x1,y1 to x2,y2
    'orientation of line is set in the middle of line thickness
    _Dest tk&
    Line (0, 0)-(2, 2), klr, BF 'set the color for the line
    _Dest 0
    cang = DegTo(x1, y1, x2, y2) 'get the angle from x1,y1 to x2,y2
    ta = cang + 90
    tb = ta + 180
    tax1 = x1 + (thk / 2) * Cos(0.01745329 * ta)
    tay1 = y1 + (thk / 2) * Sin(0.01745329 * ta)
    tax4 = x1 + (thk / 2) * Cos(0.01745329 * tb)
    tay4 = y1 + (thk / 2) * Sin(0.01745329 * tb)
    tax2 = x2 + (thk / 2) * Cos(0.01745329 * ta)
    tay2 = y2 + (thk / 2) * Sin(0.01745329 * ta)
    tax3 = x2 + (thk / 2) * Cos(0.01745329 * tb)
    tay3 = y2 + (thk / 2) * Sin(0.01745329 * tb)
    _MapTriangle (0, 0)-(0, 2)-(2, 0), tk& To(tax1, tay1)-(tax2, tay2)-(tax4, tay4)
    _MapTriangle (0, 0)-(0, 2)-(2, 0), tk& To(tax2, tay2)-(tax3, tay3)-(tax4, tay4)
End Sub
Function DegTo! (x1, y1, x2, y2)
    '========================
    ' returns an angle in degrees from point x1,y1 to point x2,y2
    aa! = _Atan2((y2 - y1), (x2 - x1)) / 0.01745329
    DegTo! = aa!
End Function

Print this item

  Book for sanity/insanity break: "10 PRINT CHR$(205.5+RND(1)); : GOTO 10"
Posted by: CharlieJV - 08-21-2023, 10:03 PM - Forum: General Discussion - Replies (4)

https://10print.org/10_PRINT_121114.pdf?...786I9Um03Q

Print this item

  QB64_GJ_LIB ARRay Library
Posted by: grymmjack - 08-21-2023, 12:07 AM - Forum: Programs - Replies (3)

Hi.

I've added some handy stuff to my library for dealing with arrays:
https://github.com/grymmjack/QB64_GJ_LIB/tree/main/ARR

What is in the library? Read the README.md, but:

TYPES SUPPORTED:

  • _BYTE
  • _UNSIGNED _BYTE
  • INTEGER
  • _UNSIGNED INTEGER
  • _INTEGER64
  • _UNSIGNED _INTEGER64
  • LONG
  • _UNSIGNED LONG
  • SINGLE
  • DOUBLE
  • _FLOAT
  • STRING

Every numeric type contains the following SUBs/FUNCTIONs e.g. ARR_INT.slice for the slice SUB for INTEGER type.

SUBS AND FUNCTIONS FOR NUMERIC TYPES:
Code: (Select All)
.slice        Slice an array from source to destination starting at index and count slices
.push         Push a element onto the end of the array
.pop          Pop a element off the end of the array
.shift        Pop a element off the beginning of the array
.unshift      Push a element on the beginning of the array
.copy         Copy an array
.join         Return array contents as comma delimited string
.new          Create new array using comma delimited string
.longest      Return the longest element of an array
.shortest     Return the shortest element of an array
.math         Do math on every element of an array
.min          Return minimum element of an array
.max          Return maximum element of an array
.first        Return 1st element of an array
.last         Return last element of an array
.nth          Return every nth element of an array
.in           Determine if a value exists in an array
.find         Find a value in an array and return it's index
.count        Return the number of elements in an array
.size         Return the size in bytes of all elements in an array
.reverse      Reverse the index of elements in an array
.random       Return a random element from the array
.sum          Return the sum of all elements in an array
.avg          Return the average of all elements in an array
.shuffle      Randomize the indexes of all elements in an array
.unique       Return unique elements in an array
.gt           Return elements greater than (>) value in an array
.gte          Return elements greater than or equal (>=) value in an array
.lt           Return elements less than (<>=) value in an array
.lte          Return elements less than or equal (<>=) value in an array
.replace      Replace elements in array with replacement value
.insert       Insert element in an array at index
.remove       Remove element in an array at index
.odd          Return odd numbered indexed elements in an array
.even         Return even numbered indexed elements in an array
.mod          Return evenly divisible by n numbered indexed elements in an array
.between      Return elements between a start and end index in an array
.sort         Sort elements of an array in ascending order
.rsort        Sort elements of an array in desscending order

SUBS AND FUNCTIONS FOR STRING TYPE:
Code: (Select All)
.slice        Slice an array from source to destination starting at index and count slices
.push         Push a element onto the end of the array
.pop          Pop a element off the end of the array
.shift        Pop a element off the beginning of the array
.unshift      Push a element on the beginning of the array
.copy         Copy an array
.join         Return array contents as comma delimited string
.new          Create new array using comma delimited string
.longest      Return the longest element of an array
.shortest     Return the shortest element of an array
.first        Return 1st element of an array
.last         Return last element of an array
.nth          Return every nth element of an array
.in           Determine if a value exists in an array
.find         Find a value in an array and return it's index
.count        Return the number of elements in an array
.size         Return the size in bytes of all elements in an array
.reverse      Reverse the index of elements in an array
.random       Return a random element from the array
.shuffle      Randomize the indexes of all elements in an array
.unique       Return unique elements in an array
.replace      Replace elements in array with replacement value
.insert       Insert element in an array at index
.remove       Remove element in an array at index
.odd          Return odd numbered indexed elements in an array
.even         Return even numbered indexed elements in an array
.mod          Return evenly divisible by n numbered indexed elements in an array
.between      Return elements between a start and end index in an array
.sort         Sort elements of an array in ascending order
.rsort        Sort elements of an array in desscending order

Print this item

  polyFT - draw filled polygons
Posted by: James D Jarvis - 08-20-2023, 09:55 PM - Forum: Utilities - Replies (5)

an update of an older sub to draw filled polygons using _maptriangle . This one is faster than the earlier version (polyT) and includes options for rotation, horizontal and vertical scaling, and a border.

Code: (Select All)
'draw_polyFT
' by James D.  Jarvis  , August 20,2023
'draw filled  polygons
'
'HEADER
Dim Shared xmax, ymax
xmax = 800: ymax = 500
Screen _NewImage(xmax, ymax, 32)
Dim Shared pk& 'must be included in a program that uses polyFT
pk& = _NewImage(3, 3, 32) 'must be included in a program that uses polyFT

'======================================
' demo
'======================================
' This demo draws 64000 random polygons, and then clears the screen and draws a handful of polygons  rotating

Randomize Timer

t1 = Timer
For reps = 1 To 64000
    polyFT Int(Rnd * xmax), Int(Rnd * ymax), Int(3 + Rnd * 20), Int(3 + Rnd * 12), Int(Rnd * 60), Int(1 + Rnd * 3), Int(1 + Rnd * 3), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256)), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
Next reps
t2 = Timer
Print "That took "; t2 - t1; " seconds to draw 64000 polygons"
Sleep
rtn = 0
Do
    _Limit 60
    Cls
    Print "Press <ESC> to quit>"
    polyFT 100, 100, 40, 3, rtn, 1, 1, _RGB32(100, 200, 50), 0
    polyFT 200, 100, 40, 4, 45 + rtn, 1, 1, _RGB32(100, 200, 250), 0
    polyFT 300, 100, 40, 5, rtn, 1, 1, _RGB32(200, 100, 250), 0
    polyFT 400, 100, 40, 6, rtn, 1, 1, _RGB32(100, 250, 150), 0
    polyFT 500, 100, 40, 7, rtn, 1, 1, _RGB32(150, 200, 200), 0
    polyFT 600, 100, 40, 8, 22.5 + rtn, 1, 1, _RGB32(200, 200, 0), 0
    _PrintString (100 - (_PrintWidth("Triangle")) / 2, 160), "Triangle"
    _PrintString (200 - (_PrintWidth("Square")) / 2, 160), "Square"
    _PrintString (300 - (_PrintWidth("Pentagon")) / 2, 160), "Pentagon"
    _PrintString (400 - (_PrintWidth("Hexagon")) / 2, 160), "Hexagon"
    _PrintString (500 - (_PrintWidth("Heptagon")) / 2, 160), "Heptagon"
    _PrintString (600 - (_PrintWidth("Octagon")) / 2, 160), "Octagon"
    rtn = rtn + 1: If rtn > 360 Then rtn = 0
    _Display 'for smooth display
Loop Until InKey$ = Chr$(27)

'==========================================================================
'subroutines
'
'  polyFT    draw a filled polygon
'
' setklr    is a sub to build the color image used by triangles in  polyFT
'====================================== ==================================
Sub polyFT (cx As Long, cy As Long, rad As Long, sides As Integer, rang As Long, ww, vv, klr As _Unsigned Long, lineyes As _Unsigned Long)
    'draw an equilateral polygon using filled triangle for each segment
    'centered at cx,cy to radius rad of sides # of face rotated to angle rang scaled to ww and vv of color klr and lineyes if there is an outline, a value 0 would create no outline
    setklr klr
    Dim px(sides)
    Dim py(sides)
    pang = 360 / sides
    ang = 0
    For p = 1 To sides
        px(p) = cx + (rad * Cos(0.01745329 * (ang + rang))) * ww
        py(p) = cy + (rad * Sin(0.01745329 * (ang + rang))) * vv
        ang = ang + pang

    Next p
    For p = 1 To sides - 1
        _MapTriangle (0, 0)-(0, 2)-(2, 0), pk& To(cx, cy)-(px(p), py(p))-(px(p + 1), py(p + 1))
        If lineyes > 0 Then Line (px(p), py(p))-(px(p + 1), py(p + 1)), lineyes
    Next p
    _MapTriangle (0, 0)-(0, 2)-(2, 0), pk& To(cx, cy)-(px(sides), py(sides))-(px(1), py(1))
    If lineyes > 0 Then Line (px(sides), py(sides))-(px(1), py(1)), lineyes



End Sub
Sub setklr (klr As Long)
    'internal routine to setup an image to copy a colored triangle from in the color klr
    'called by polyT
    _Dest pk&
    Line (0, 0)-(2, 2), klr, BF
    _Dest 0
End Sub

Print this item

  Compiler dead space is it all the same ?
Posted by: doppler - 08-20-2023, 09:10 AM - Forum: General Discussion - Replies (9)

And what the hell is compiler dead space, you may ask.

People who write compilers have a habit of being lazy, very lazy.  The coding part (your executable) will be the same from computer to computer.  This is true as long as the compilers are the same version.  So code from one computer coding will have the same SHA hash value as the next.  What will change is data and string areas.  The same areas which contain uninitialized memory for storage.  A dumb compiler will just assign the space.  Which shows up as a random segment of the compiling computers memory.  Looking at the EXE code in RAW mode may show some interesting information.  A smart compiler will zero out all data and string areas before sending it to the linker/exe module.

So is QB64pe using a smart or dumb compiler/linker ?  The reason I am asking is "If I send someone source code and a SHA of the resulting EXE."  I can determine if compilers are the same version on my computer and his/her computer.  Thus resolving compiler issues before they become a problem.  AKA: They said they were up to date, only to find they are 3 versions behind.

Thanks.
Nobody here may have an answer.  This a very inside question about the GCC compiler QB64pe is using.

Print this item

  fhex ... a Filled Hex
Posted by: James D Jarvis - 08-19-2023, 06:52 PM - Forum: Utilities - Replies (2)

a little routine and associated demo for drawing a filled hex.

Code: (Select All)
'Fhex
'by James D. Jarvis August 19,2023
'draw a filled hex
'demo code
Screen _NewImage(500, 500, 32)
rr = 200
For d = 1 To 10
    fcirc 250, 250, rr, _RGB32(200, 200, 0)
    fhex 250, 250, rr, _RGB32(200, 100, 100)
    rr = rr * .86
Next d
For a = 60 To 360 Step 60
    ang_line 250, 250, 200, a, _RGB32(250, 0, 0)
Next a

hx = 60: hy = 60: hl = 12
fhex hx, hy, hl, _RGB32(100, 100, 100)
For ha = 30 To 390 Step 60
    hx = 60 + (hl * 1.9) * Cos(0.01745329 * ha)
    hy = 60 + (hl * 1.9) * Sin(0.01745329 * ha)
    fhex hx, hy, hl, _RGB32(ha / 2, ha / 2, ha / 20)
Next ha

Sub fhex (cx As Long, cy As Long, r, klr As _Unsigned Long)
    'draw a hex to radius r filled with color klr centeted on cx,cy
    rcheck = ((r * .867) * (r * .867))
    For dY = -r To r
        If dY * dY < rcheck Then
            dx = r - Abs(dY / _Pi * 1.81)
            Line (cx - dx, dY + cy)-(cx + dx, dY + cy), klr, BF
        End If
    Next dY
End Sub


'ang_line and fcirc included for demo not needed for fhex itself
Sub ang_line (sx, sy, lnth, ang, klr As _Unsigned Long)
    'draw a line lnth units long from sx,sy at anlge ang measures in degrees, 0 deg is out along X axis
    nx = sx + lnth * Cos(0.01745329 * ang)
    ny = sy + lnth * Sin(0.01745329 * ang)
    Line (sx, sy)-(nx, ny), klr

End Sub
Sub fcirc (CX As Long, CY As Long, R, klr As _Unsigned Long)
    'draw a filled circle with the quickest filled circle routine in qb64, not my development
    Dim subRadius As Long, RadiusError As Long
    Dim X As Long, Y As Long
    subRadius = Abs(R)
    RadiusError = -subRadius
    X = subRadius
    Y = 0
    If subRadius = 0 Then PSet (CX, CY): Exit Sub
    Line (CX - X, CY)-(CX + X, CY), klr, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), klr, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), klr, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), klr, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), klr, BF
    Wend
End Sub

Print this item

  Microsoft BASIC PDS 7.1 User Interface Toolbox
Posted by: a740g - 08-19-2023, 04:49 AM - Forum: Programs - Replies (6)

This was supposed to go in the Museum a long time ago. However, I never got to re-implementing the assembler routines that this uses... until now.
I've included the assembly sources as comments in General.bas. Below those comments you can find the QB64 function ports.

From MS PDS 7.1 Getting Started docs:

Quote:User Interface Toolbox

With the new user interface code samples, you can design your own user interface using
BASIC procedures. The code samples in this toolbox give you complete control of character-
based window interfaces. For example, you could write a BASIC program with multiple
windows, menu bars, dialog boxes, and mouse interaction. For more information about the User
Interface toolbox, see Part 3 of the BASIC Language Reference.
Please note that this is by no means a perfect port. There are a few differences and quirks.

Happy tinkering!

[Image: Screenshot-2023-08-19-010014.png]

[Image: Screenshot-2023-08-19-081928.png]

[Image: Screenshot-2023-08-19-082014.png]

[Image: Screenshot-2023-08-19-082028.png]



Attached Files
.zip   PDSUITB64.zip (Size: 45.29 KB / Downloads: 50)
Print this item

  API Questions
Posted by: TerryRitchie - 08-18-2023, 07:35 PM - Forum: Help Me! - Replies (24)

Since I've started diving into API calls I figured a dedicated thread for API related questions would be better.

Here is my first question.

In the Wiki here: https://qb64phoenix.com/qb64wiki/index.p...ndow_Focus

It's shown how to determine the foreground window (the one in focus).

The Microsoft docs for GetForegroundWindow are located here: https://learn.microsoft.com/en-us/window...oundwindow

I noticed in the Wiki example that GetForegroundWindow is declared as an _OFFSET (%&). How was this determined? Looking at the Microsoft docs there is no indication of the type of variable returned. With other window handle (hWnd) related functions I've noticed a variable type of LONG is used. Why was _OFFSET needed here instead of LONG?

This has me confused. Any clarification would be greatly appreciated.

Print this item

  Is _WINDOWHANDLE working properly?
Posted by: TerryRitchie - 08-17-2023, 08:41 PM - Forum: Help Me! - Replies (15)

First, I'm a complete noob to API calls so this just may be my ignorance on the subject.

@SpriggsySpriggs suggested I use GetClientRect to get the client area coordinates of a Window. So I set up some code below to investigate.

However, no matter what size the screen is set to the return values of the RECT are always 0,0 - 640,400.

This makes me think that perhaps _WINDOWHANDLE is pointing to an underlying console window instead of the currently visible window?

Am I correct in my thinking, or am I using _WINDOWHANDLE incorrectly?

Code: (Select All)
TYPE RECTAPI
    left AS LONG
    top AS LONG
    right AS LONG
    bottom AS LONG
END TYPE

DIM apirect AS RECTAPI

DECLARE DYNAMIC LIBRARY "user32"
    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect
    FUNCTION GetClientRect% (BYVAL hWnd AS LONG, lpRect AS RECTAPI)
END DECLARE

SCREEN _NEWIMAGE(800, 600, 32) ' results the same no matter what size screen is used??

tmp = GetClientRect(_WINDOWHANDLE, apirect)

PRINT apirect.left
PRINT apirect.top
PRINT apirect.right
PRINT apirect.bottom

Print this item

  QBJS Particle Fountain
Posted by: bplus - 08-17-2023, 09:19 AM - Forum: QBJS, BAM, and Other BASICs - Replies (1)

I am tweaking dbox pset version with less bubble release each frame for consistent fountain pattern (same tweak as in Proggies) PLUS a wider viewing frame that spreads Bell Curve a little better:

https://qbjs.org/index.html?code=J09wdGl...A1FTdWIKCg==


   

Print this item