Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 735
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 25
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 25
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 1,854
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,146
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 304
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 113
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,306
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 224
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 134
|
|
|
Word (text) processor |
Posted by: krovit - 08-25-2023, 08:07 AM - Forum: Programs
- Replies (18)
|
|
Good morning!
I am very pleased to see that the development of QB64 has not stopped. Thank you all for your commitment and perseverance!
I also hope that you are all well because these are very difficult times.
A question: I had found, here on the forums, a procedure for a simple but very efficient and streamlined word processor but now I just can not find it.
Can someone tell me where it is?
Thank you!
|
|
|
Having trouble Windows command line SORT via SHELL |
Posted by: GTC - 08-24-2023, 02:42 PM - Forum: Help Me!
- Replies (19)
|
|
My program generates 12 output files that then need to be sorted, and I'd rather do those sorts from within the app (via SHELL) than have to use SORT standalone from the command line afterwards.
Here's an example of how I'm calling it:
Sort_Command$ = "SORT " + "x.x" + " >> " + "y.y"
SHELL Sort_Command$
If I type that sort command on the command line I get y.y as a sorted version of x.x ... which is desired.
However when executed via SHELL a message flashes up in the output window (too fast to read before a blank window replaces it), and no sort occurs.
I have used SHELL previously with other commands and experienced no problems.
Is there a way of directing the contents of the output window to a file, so that I can read whatever is being shown on that?
|
|
|
Why do FOR/NEXT variables end up +1 more? |
Posted by: Dav - 08-24-2023, 12:36 PM - Forum: Help Me!
- Replies (14)
|
|
I vaguely remember something about this at the old .com forum, but I forget the reason, so I thought I'd just ask about it here.
Why are variable used with FOR/NEXT +1 more at the end? I was doing a count using a FOR/NEXT variable and couldn't figure out why afterwards the variable end up +1 number higher when over.
In this example, the FOR/NEXT prints all 10 t's, but when printing the last t value over, it's at 11, and the FOR/NEXT never went to 11. Why is that?
- Dav
Code: (Select All)
'print 10 t's
For t = 1 To 10 'stop t at 10
Print t
Next
'so t is 10...but...
Print
Print
Print t 'this show 11 now?
|
|
|
Would this "RbgaPset" be a way around not having _RGBA ? |
Posted by: CharlieJV - 08-22-2023, 06:16 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (4)
|
|
Implementing _RGBA in BAM would be, I think, I real nightmare.
Instead, I'm thinking better to set an include library with this "RgbaPset" function. Question is: am I right in thinking this yields the same as what _RGBA would do color-wise ?
Code: (Select All) SUB RgbaPset(x,y,r,g,b,a)
c = POINT(x,y)
c$ = RIGHT$("000000" + HEX$(c), 6)
cr = VAL("0x" + LEFT$(c$,2)) * 256 ^ 2
cg = VAL("0x" + MID$(c$,3,2)) * 256 ^ 1
cb = VAL("0x" + RIGHT$(c$,2))
PSET(x,y), { [cr * (255-a)/255 + r * a / 255] _
+ [cg * (255-a)/255 + g * a / 255] _
+ [cb * (255-a)/255 + b * a / 255] }
END SUB
screen 27
line (0,0) - (400,400), &h0000ff ,BF
FOR this_x = 50 to 150
FOR this_y = 50 to 150
RgbaPset(this_x,this_y,0,0,0,100)
next this_y
next this_x
|
|
|
Ball Sub - draws several kind of filled, textured balls (circles) |
Posted by: Dav - 08-22-2023, 05:21 PM - Forum: Programs
- Replies (15)
|
|
Started updating my little Ball SUB (filled circle), thought I'd build it up over time by adding different kinds of textures to the balls, instead of just plain solid colors. Although this is nowhere near the speed of the gold standard fcirc routine, it can be handy, and it's easy to drop the SUB in your programs.
So far it can draw 6 kinds of filled balls. Solid, Gradient, and some textures like grainy, striped, plasma, mixed.
I will come up with some more textures. If you'd like to add one, please do.
- Dav
Code: (Select All)
'===========
'BALLSUB.BAS v1.0
'===========
'Simple Ball SUB that draws balls of different textures.
'Solid, Gradient, planet, plasma, noisey, striped, mixed.
'Coded by Dav, AUGUST/2023
Randomize Timer
Screen _NewImage(1000, 600, 32)
Do
'make random ball to show all kinds
ball Int(Rnd * 7), Rnd * _Width, Rnd * _Height, Rnd * 300 + 25, Rnd * 255, Rnd * 255, Rnd * 255, 100 + Rnd * 155
_Limit 10
Loop Until InKey$ <> ""
Sub ball (kind, x, y, size, r, g, b, a)
'SUB by Dav that draws many types of filled balls (circles).
'Not super fast, but small and easy to add to your programs.
'kind=0 (Gradient)
'kind=1 (noisey)
'kind=2 (planets)
'kind=3 (plasma)
'kind=4 (striped)
'kind=5 (plasma mix with gradient noise)
'kind=6 (solid)
'get current display status to restore later
displayStatus%% = _AutoDisplay
'turn off screen updates while we draw
_Display
t = Timer
For y2 = y - size To y + size
For x2 = x - size To x + size
If Sqr((x2 - x) ^ 2 + (y2 - y) ^ 2) <= size Then
clr = (size - (Sqr((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
Select Case kind
Case 1: 'noisey (grainy)
noise = Rnd * 255
Case 2: 'planet
noise = 20 * Sin((x2 + y2) / 30) + 10 * Sin((x2 + y2) / 10)
Case 3: 'plasma
r = (Sin(x2 / (size / 4)) + Sin(y2 / size / 2)) * 128 + 128
g = (Sin(x2 / (size / 6)) + Cos(y2 / (size / 4))) * 128 + 128
b = (Cos(x2 / (size / 4)) + Sin(y2 / (size / 6))) * 128 + 128
Case 4: 'striped
dx = x2 - size: dy = y2 - size
dis = Sqr(dx * dx + dy * dy)
r = Sin(dis / 5) * 255
g = Cos(dis / 25) * 255
b = 255 - Sin(dis / 50) * 255
Case 5: 'plasma mix with gradient & noise
noise = Int(Rnd * 50)
r = Sin(6.005 * t) * size - y2 + size + 255
g = Sin(3.001 * t) * size - x2 + size + 255
b = Sin(2.001 * x2 / size + t + y2 / size) * r + 255
t = t + .00195
Case Else: 'solid & gradient (no noise)
noise = 0
End Select
If kind = 6 Then
'if solid color
PSet (x2, y2), _RGBA(r, g, b, a)
Else
'all others, noise & gradient color aware
PSet (x2, y2), _RGBA(clr * r - noise, clr * g - noise, clr * b - noise, a)
End If
End If
Next
Next
'show the ball on the screen
_Display
'If autodislay was previously on, turn it back on
If displayStatus%% = 1 Then _AutoDisplay
End Sub
|
|
|
Space Orbs. Small screen saver. |
Posted by: Dav - 08-22-2023, 01:54 PM - Forum: Programs
- Replies (16)
|
|
Here's a little screen saver showing pulsating orbs over a starry background with plasma clouds. I was playing around some old code, turned it into something new. Tested and runs OK under Windows and Linux.
- Dav
Code: (Select All)
'=============
'SpaceOrbs.bas
'=============
'Screensaver of Orbs pulsating in space
'Coded by Dav for QB64-PE, AUGUST/2023
RANDOMIZE TIMER
SCREEN _NEWIMAGE(1000, 640, 32)
'=== orb settings
orbs = 60 'number of orbs on screen
OrbSizeMin = 5 'smallest size an orb can get
OrbSizeMax = 60 'largest size an orb can get
DIM OrbX(orbs), OrbY(orbs), OrbSize(orbs), OrbGrowth(orbs)
'=== generate some random orb values
FOR i = 1 TO orbs
OrbX(i) = RND * _WIDTH 'x pos
OrbY(i) = RND * _HEIGHT 'y pos
OrbSize(i) = OrbSizeMin + (RND * (OrbSizeMax - OrbSizeMin)) 'orb size
OrbGrowth(i) = INT(RND * 2) 'way orb is changing, 0=shrinking, 1=growing
NEXT
'=== make a space background image
FOR i = 1 TO 100000
PSET (RND * _WIDTH, RND * _HEIGHT), _RGBA(0, 0, RND * 255, RND * 225)
NEXT
FOR i = 1 TO 1000
x = RND * _WIDTH: y = RND * _HEIGHT
LINE (x, y)-(x + RND * 3, y + RND * 3), _RGBA(192, 192, 255, RND * 100), BF
NEXT
'=== grab screen image for repeated use
back& = _COPYIMAGE(_DISPLAY)
DO
'=== place starry background first
_PUTIMAGE (0, 0), back&
'=== draw moving plasma curtain next
t = TIMER
FOR x = 0 TO _WIDTH STEP 3
FOR y = 0 TO _HEIGHT STEP 3
b = SIN(x / (_WIDTH / 2) + t + y / (_HEIGHT / 2))
b = b * (SIN(1.1 * t) * (_HEIGHT / 2) - y + (_HEIGHT / 2))
LINE (x, y)-STEP(2, 2), _RGBA(b / 3, 0, b, RND * 25), BF
NEXT: t = t + .085
NEXT
'=== now process all the orbs
FOR i = 1 TO orbs
'=== draw orb on screen
FOR y2 = OrbY(i) - OrbSize(i) TO OrbY(i) + OrbSize(i) STEP 3
FOR x2 = OrbX(i) - OrbSize(i) TO OrbX(i) + OrbSize(i) STEP 3
'make gradient plasma color
IF SQR((x2 - OrbX(i)) ^ 2 + (y2 - OrbY(i)) ^ 2) <= OrbSize(i) THEN
clr = (OrbSize(i) - (SQR((x2 - OrbX(i)) * (x2 - OrbX(i)) + (y2 - OrbY(i)) * (y2 - OrbY(i))))) / OrbSize(i)
r = SIN(6.005 * t) * OrbSize(i) - y2 + OrbSize(i) + 255
g = SIN(3.001 * t) * OrbSize(i) - x2 + OrbSize(i) + 255
b = SIN(2.001 * x2 / OrbSize(i) + t + y2 / OrbSize(i)) * r + 255
LINE (x2, y2)-STEP(2, 2), _RGBA(clr * r, clr * g, clr * b, 5 + RND * 15), BF
END IF
NEXT
NEXT
'=== change orb values
'if orb is shrinking, subtract from size, else add to it
IF OrbGrowth(i) = 0 THEN OrbSize(i) = OrbSize(i) - 1 ELSE OrbSize(i) = OrbSize(i) + 1
'if orb reaches maximum size, switch growth value to 0 to start shrinking now
IF OrbSize(i) >= OrbSizeMax THEN OrbGrowth(i) = 0
'if orb reaches minimum size, switch growth value to 1 to start growing now
IF OrbSize(i) <= OrbSizeMin THEN OrbGrowth(i) = 1
'creates the shakiness. randomly adjust x/y positions by +/-3 each
IF INT(RND * 2) = 0 THEN OrbX(i) = OrbX(i) + 3 ELSE OrbX(i) = OrbX(i) - 3
IF INT(RND * 2) = 0 THEN OrbY(i) = OrbY(i) + 3 ELSE OrbY(i) = OrbY(i) - 3
NEXT
_DISPLAY
_LIMIT 15
LOOP UNTIL INKEY$ <> ""
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
|