Need help trying to figure out code
-
n=0 c=10 loop a=n*137.5 r=c*sqrt(n) x=r*cos(a)+gwidth()/2 y=r*sin(a)+gheight()/2 // ------------------------------------------------------------------------------ // In this line circle x,y is the locaion, 10 stands for the radius // What does {1, (a%256)/255, (n%255)/255, 1,} mean ? circle(x, y, 6, 10, {1, (a%256)/255, (n%255)/255, 1,} false) // ------------------------------------------------------------------------- n+=1 if n=400 then break endif update() repeat print("Press [A] to exit...") while controls(0).a==false loop update() repeat
-
Hi @kendog400, the parameter in question is the color of the circle. It's a vector in the format
{red, green, blue, alpha}
, although it looks like your alpha parameter is missing. Use an alpha value of 1 for an opaque circle. Check out the circle command help page for more details.The green parameter
(a%256)/255
will give you a value in the range 0 to 1, no matter whata
is. It will increase as your loop runs. To visualize this, check out these graphs. You'll notice that no matter what the range ofa
is for input, the Y value of any point on the line is limited to (and including) 0 and 1. (Note: I think you have a typo here, as using 256 will give you a value slightly outside this range. Try 255.)The blue parameter
(n%255)/255
is pretty much the same. Asn
increases, your blue value increases. Asn
nears 255, blue nears 1. Whenn
passes 255, blue loops back to 0.I hope that's able to answer your question!
-
@kendog400 I can see you've sent a post with the content: "Thanks!" but the forum software won't allow that to be approved because it's not long enough. If you literally just want to say thanks, do so by clicking the little up arrow next to the word Quote which "upvotes" the message. Otherwise you'll need to make the post longer for it to be approved. Again, this isn't us being funny, there is just a minimum length for post content (which I've now forgotten because I closed the error message).
-
OK, I'm new to site so I havenet figure out the ins-&-outs...