|
Post by bplus on Jan 23, 2023 12:54:26 GMT -5
Had to give Charlie's Impossible Oval a shot, QB64 style: _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 bplus on Apr 20, 2023 11:56:10 GMT -5
Fully commented to help explain what's going on specially to users of old QB stuff:
_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
|
|
|
Post by bplus on May 12, 2023 10:44:39 GMT -5
Thanks to dbox project QBJS, I can share with some slightly modified QB64 code Runs: For Impossible Oval we have:
https://qbjs.org/index.html?code=X1RpdGxlICJJbXBvc3NpYmxlIE92YWwiICdiKyAyMDIzLTAxLTIzICAgJyBGWUkgc3RhcnQgYSBmaWxlIHdpdGggYSDFQwonICBhbmQgd2hlbiB5b3UgZ28gdG8gc2F2ZSBpdCB0aGUgUUI2NCBJREUgd2lsbCB0cnkgdGhhdCBuYW1lIGZpcnN0IGZvciB5b3kKClNjcmVlbiBfTmV3SW1hZ2UoODAwLCA2xAUzMikgJyB0aGlzIHNldHMgdXAgYSBzxjB3aWR0aCA9IDgwMCBoZXJlLCAgaGVpZ2h0ID3EPcUUCicgMzIgZ2l2ZXMgdXMgX1JHQjMyIGNvbG9ycyBtaWxsaW9ucyEgaW5jbHVkaW5nIGFscGhhID0gdHJhbnNwYXJlbnQgYmxlbmRzCgoKRGltIEFzIExvbmcgYmxvY2ssIHIsIHgsIHkgJyBJIGFt5ACldMRH5QCoaGFuZGxl5QDoY2FsbMVfbiBp5ADjIGxpa2XkAMtpZGUgd29ya3NoZWXmARNkcmF3aW5nyG1TaW5nbGUgYQrFcSA97QEnLCA06QElbm938QCEbWVtb3J55gCsxV3GfeQBu2Fzc2lnbsQo5AGu5gCrCgoKX0Rlc+QA8sQxy1R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BqDHcnNs5AYjbHkgbW9yZeQEb24gMipwaSA9IDHoAIwKCv8EHv8EHv8EHvMEHv8EGvcEGkZ1bsZQ6AUEIChyMSUsIGfEBWLEBXIyxA/EBWLEBWZyIyPmAg/JMj3nBxTEOiArIChyMiUgLSByMSUpICrFMMVPxBpnxRpnzBpixhpixRpiyhopCkVuZCDoAJ8=
Click the tiny < top mid screen to see full screen Run of code.
Crap this forum editor destroys letters coding so copy/paste "code" to your browser to lookup.
|
|