|
Post by bplus on Jan 23, 2023 16:31:18 GMT
A guy going over old QB 9 liners showed us a version of this graphic, I used _NewImage
_Title "Impossible Oval" 'b+ 2023-01-23
Screen _NewImage(800, 600, 32) Dim As Long block block = _NewImage(80, 40, 32) _Dest block For y = 0 To 40 Line (0, y)-(100, y), midInk~&(80, 0, 0, 255, 100, 100, 1 - y / 40), BF Next _Dest 0 r = 230: a = 0 Do x = 410 + r * 1.5 * Cos(a): y = 300 + r * Sin(a) _PutImage (x - 50, y - 20), block, 0 a = a + .002 _Limit 1000 Loop Until a >= _Pi(2.47)
Function midInk~& (r1%, g1%, b1%, r2%, g2%, b2%, fr##) midInk~& = _RGB32(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##) End Function
|
|
|
Post by SixVivid on Apr 20, 2023 8:13:04 GMT
Thats actually pretty cool I dont understand what its doing lol
|
|
|
Post by bplus on Apr 20, 2023 14:37:42 GMT
Thats actually pretty cool I dont understand what its doing lol It is quite a jump from old QB stuff to QB64, to help explain QB64 over QB old I will explain in detail (note: all _Keywords are new to QB64 over old QB): _Title "Impossible Oval" 'b+ 2023-01-23 ' FYI start a file with a Title ' and when you go to save it the QB64 IDE will try that name first for yoy
Screen _NewImage(800, 600, 32) ' this sets up a screen width = 800 here, height = 600 here ' 32 gives us _RGB32 colors millions! including alpha = transparent blends
Dim As Long block ' I am setting up a handle for calling an image like a side worksheet for drawing
block = _NewImage(80, 40, 32) ' now I am setting up memory block for image and assigning the handle
_Dest block ' now I am telling QB64 to do all drawing or printing in my side image
For y = 0 To 40 ' here I am drawing a block that is color gradient Line (0, y)-(100, y), midInk~&(80, 0, 0, 255, 100, 100, 1 - y / 40), BF ' midInk takes 2 RGB colors measures the difference in Red, Green, Blue and takes the fraction spec'd in frac## ' to make a color between the first color and the 2nd Next ' now we have a side image of color graient block from first color to 2nd color
_Dest 0 ' set all drawing and printing back to main screen AKA 0
Print "Here's the Color block we just drew off on the side, ...zzz press any to continue" _PutImage (400 - 50, 300 - 20), block, 0 ' this draws the block centered in middle of our screen Sleep ' ...zzz wait for keypress
r = 230: a = 0 ' a couple of variables r for Radius, a for Angle in rdian units here
Do ' find the next location on the circle to draw our side image of a colored block x = 410 + r * 1.5 * Cos(a) y = 300 + r * Sin(a)
_PutImage (x - 50, y - 20), block, 0 ' this draws the block there
a = a + .002 ' this increments the angle going around a circle _Limit 1000 ' this slows down the drawing a tiny bit Loop Until a >= _Pi(2.47) ' need a to go around slightly more than 2*pi = 1 circle
' midInk takes 2 RGB colors measures the difference in Red, Green, Blue and takes the fraction spec'd in frac## ' to make a color between the first color and the 2nd Function midInk~& (r1%, g1%, b1%, r2%, g2%, b2%, fr##) midInk~& = _RGB32(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##) End Function
|
|