09-19-2024, 12:00 PM
Could some of you mac users please run this code and see if SQR causes the same error there? I've been wondering about all my graphics programs that use SQR now.
Thanks!
- Dav
Thanks!
- Dav
Code: (Select All)
'Imageball.bas
'Draws a ball with image& on it
'By Dav for QB64
Screen _NewImage(800, 600, 32)
'Make sample texture& image to use
texture& = _NewImage(250, 250, 32)
'point to the image
_Dest texture&
'draw something there
Cls , _RGB(33, 66, 99)
For x = 0 To _Width Step 25
For y = 0 To _Height Step 25
Line (x, y)-Step(50, 50), _RGBA(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
Circle (Rnd * _Width, Rnd * _Height), 5 + Rnd * 20, _RGB(Rnd * 255, Rnd * 255, 255)
Line (x, y)-Step(50, 50), _RGB(0, 0, 0, 0), B
Next
Next
'go back to main screen
_Dest 0
Do
ImageBall Rnd * _Width, Rnd * _Height, 75 + Rnd * 75, texture&
_Limit 60
Loop Until _KeyHit
End
Sub ImageBall (x, y, size, image&)
'puts image& on a ball.
'To make it look better, make a temp image to match the size of the ball
temp& = _NewImage(size * 2, size * 2, 32)
'put the image& into temp&, stretch to fill
_PutImage (0, 0)-(_Width(temp&), _Height(temp&)), image&, temp&
orig& = _Source 'save current _source
_Source temp& 'switch to temp&
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
c& = Point(x2 - x + size, y2 - y + size): r = _Red32(c&): g = _Green32(c&): b = _Blue32(c&)
PSet (x2, y2), _RGB(clr * r, clr * g, clr * b)
End If
Next
Next
_FreeImage temp&
_Source orig&
End Sub