|
Post by plus on Mar 7, 2022 18:26:24 GMT
' Eye Candy #9.txt for JB from SmallBASIC trans of Sprezzo #2 Problem 2022-03-06.bas (QB64)
global H$, XMAX, YMAX, PI, P2, CN, PR, PG, PB, XC, YC, Diagonal H$ = "gr" XMAX = 500 YMAX = 500 PI = acs(-1) P2 = PI * 2 XC = XMAX / 2 YC = YMAX / 2 Diagonal = int(YC * sqr(2)) 'gots to be an Integer!!!!!!!!!!!!!!!!!!!!!!! maxC = Diagonal + 200
nomainwin WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (1200 - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (700 - YMAX) / 2 'or delete if YMAX is 700 or above
open "Eye Candy #9, these take awhile to develop " for graphics_nsb_nf as #gr #gr "trapclose quit" #gr "down" #gr "size 4" dim colr$(maxC) ' <<<< WTH wont maxC work???? because it's a Float and can't Dim with floats! while 1 scan call resetPlasma For i = 0 To Diagonal + 200 scan colr$(i) = Plasma$() Next s = 0 For a = 0 To P2 Step P2 / (2 * 360) i = 50 * Sin(s) ' 2 * s or just s For r = 0 To Diagonal scan #gr "color ";colr$(r + i + 100) #gr "set ";XC + r * Cos(a);" ";YC + r * Sin(a) Next s = s + P2 / 22.5 Next #gr "flush" call Pause 3000 wend wait
function Plasma$() ' just to put something in as parameter CN = CN + .2 Plasma$ = str$(127 + 127 * Sin(PR * CN)) + " " + str$(127 + 127 * Sin(PG * CN)) + " " + str$(127 + 127 * Sin(PB * CN)) End Function
Sub resetPlasma PR = Rnd(0) ^ 2: PG = Rnd(0) ^ 2: PB = Rnd(0) ^ 2 End Sub
sub Pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
sub quit H$ close #gr '<=== this needs Global H$ = "gr" end 'Thanks Facundo, close graphic wo error end sub
|
|
|
Post by marshawn on Mar 8, 2022 3:48:12 GMT
nice bplus! Was there an Eye Candy #1 to 8?
|
|
|
Post by tsh73 on Mar 8, 2022 7:50:24 GMT
interesting. I've got strange effect (sure JB thing) If I let it draw full circle, minimize window and then restore window, it redraws about 1/5 and starts redrawing again. Probably never finishes. Win10 32 bit, JB2. (should check on other computer)
interesting things to do: * could it be computed via (x,y) instead of polar coords? If so it likely would speed things up a bit * will 256 color version looks still nice? (now maxC shows 553) * if so, there is a way to animate by changing paletter in 256 color bitmap. Should be good. * could that thing be changed so it looks like spiked spiral? * if so, will it looks rotating then animated with palette?
(that sure needs some free time :)) )
|
|
|
Post by plus on Mar 8, 2022 16:25:47 GMT
nice bplus! Was there an Eye Candy #1 to 8? Ha! got so much Eye Candy stuff I lost count! Say would you like to see my selection of Persian Carpets? I think that was at the other forum worth a return appearance.
|
|
|
Post by plus on Mar 8, 2022 16:40:28 GMT
interesting. I've got strange effect (sure JB thing) If I let it draw full circle, minimize window and then restore window, it redraws about 1/5 and starts redrawing again. Probably never finishes. Win10 32 bit, JB2. (should check on other computer) interesting things to do: * could it be computed via (x,y) instead of polar coords? If so it likely would speed things up a bit * will 256 color version looks still nice? (now maxC shows 553) * if so, there is a way to animate by changing paletter in 256 color bitmap. Should be good. * could that thing be changed so it looks like spiked spiral? * if so, will it looks rotating then animated with palette? (that sure needs some free time ) I don't know why some people max / min their screens while something is being drawn, seems kinda rude (just kidding!) Yeah a JB thing, it takes so long to draw here but worth the wait I hope. Uhmm... not using Polar coordinates, to describe what I did was this: I took a stick and added plasma sequence of colors to it. Then I rotated the stick around a circle one end anchored to center. As I moved stick around I also moved the anchor point up and down the stick, ignoring the colors less than anchor point. Using sin() smoothed out the moves from jagged slightly crooked teeth of saw blade look. So the size of the palette needed depends upon the length of the stick and how much you want to move it in and out. Dang that sounds naughty. Update: Well yes, I guess it is like Polar coordinates, you've got an angle and a radius and you locate with Sin() and Cos() yes, but I am going out on the radius 0 to length of diagonal plus some +/-r*sin(a) so it's more like a line to me.
|
|
|
Post by plus on Mar 8, 2022 17:28:26 GMT
I have to say, I was trying to find code to draw this background: So if anyone has a clue, let me know.
|
|
|
Post by Rod on Mar 8, 2022 18:57:53 GMT
I am not sure why the drawing is so slow. I need more time to see what is going on. However the redraw on min/max is because you are writing thousands of segments with FLUSH. On restore JB will start redrawing all of those segments again.
|
|
|
Post by plus on Mar 8, 2022 19:02:30 GMT
The flush is after one drawing is made, at least 30 secs of time elapse between flushes.
|
|
|
Post by Rod on Mar 8, 2022 19:20:29 GMT
Sorry your correct, need to get of my iPhone and onto a PC
|
|
|
Post by plus on Mar 9, 2022 16:55:35 GMT
I did manage to animate a growing out from center image but used tools JB doesn't have.
Do you think it is possible to get a bitmap of a triangle?
Then we can take a triangle snap shot of a small section of circle (like a pizza slice) the first 2PI/64 angle from 0 and repeat it around the circle.
|
|
|
Post by Rod on Mar 9, 2022 19:13:43 GMT
Well you could draw four quadrants at the same time, calculate one and draw the opposite/mirror/flip. Kinda fractal.
|
|
|
Post by plus on Mar 9, 2022 19:23:56 GMT
Well you could draw four quadrants at the same time, calculate one and draw the opposite/mirror/flip. Kinda fractal. hmm... we could rotate a point as many times as we like around a circle, will that be faster? Doubt it, because we are still drawing a pixel at a time, but I will look into it and see.
|
|
|
Post by Rod on Mar 10, 2022 13:32:49 GMT
This is what I meant, you would need to stop once it has done the first quadrant instead of full 360.
' Eye Candy #9.txt for JB from SmallBASIC trans of Sprezzo #2 Problem 2022-03-06.bas (QB64)
global H$, XMAX, YMAX, PI, P2, CN, PR, PG, PB, XC, YC, Diagonal H$ = "gr" XMAX = 500 YMAX = 500 PI = acs(-1) P2 = PI * 2 XC = XMAX / 2 YC = YMAX / 2 Diagonal = int(YC * sqr(2)) 'gots to be an Integer!!!!!!!!!!!!!!!!!!!!!!! maxC = Diagonal + 200
nomainwin WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (1200 - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (700 - YMAX) / 2 'or delete if YMAX is 700 or above
open "Eye Candy #9, these take awhile to develop " for graphics_nsb_nf as #gr #gr "trapclose quit" #gr "down" #gr "size 4" dim colr$(maxC) ' <<<< WTH wont maxC work???? because it's a Float and can't Dim with floats! while 1 scan call resetPlasma For i = 0 To Diagonal + 200 scan colr$(i) = Plasma$() Next s = 0 For a = 0 To P2 Step P2 / (2 * 360) i = 50 * Sin(s) ' 2 * s or just s For r = 0 To Diagonal scan xx=XC + r * Cos(a) yy=YC + r * Sin(a) #gr "color ";colr$(r + i + 100) #gr "set ";xx;" ";yy #gr "set ";250-(xx-250);" ";250-(yy-250) #gr "set ";xx;" ";250-(yy-250) #gr "set ";250-(xx-250);" ";yy
Next s = s + P2 / 22.5 Next #gr "flush" call Pause 3000 wend wait
function Plasma$() ' just to put something in as parameter CN = CN + .2 Plasma$ = str$(127 + 127 * Sin(PR * CN)) + " " + str$(127 + 127 * Sin(PG * CN)) + " " + str$(127 + 127 * Sin(PB * CN)) End Function
Sub resetPlasma PR = Rnd(0) ^ 2: PG = Rnd(0) ^ 2: PB = Rnd(0) ^ 2 End Sub
sub Pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
sub quit H$ close #gr '<=== this needs Global H$ = "gr" end 'Thanks Facundo, close graphic wo error end sub
|
|
|
Post by tenochtitlanuk on Mar 10, 2022 17:37:53 GMT
A caution about r/theta polar plotting. You tend to get gaps where plotting to an integral Cartesian coordinate misses a point. And unless you adjust theta step size to be smaller at larger radii similar. For fun I did polar HSV-coloured spirals. Very slow. And may crash from consuming memory unless you screensave, cls and re-draw at intervals. For the record here are 'Triskelion' and by drawing similar two-armed spirals at different phases and creating an animated gif I get things like ( sorry left some angles out..)
|
|
|
Post by plus on Mar 11, 2022 15:38:49 GMT
|
|