I’m trying to make a gradient, yet it just doesn’t seem to work my way. Could someone please let me know what is wrong with the code below? I can’t seem to fix it
for(int y = 0; y < height; y++)
for(int x = 0; x < width; x++)
float distanceFromCenter = dist(x, y, width/2, height/2)
Is this also a homework question? Your other posts are.
This looks like Python.
Look up the references for for() and dist():
I have no knowledge of Python and was able to get this to work in the Processing software in Python mode in W10 from the references:
Sorry about that, just fixed it. I tried looking for it in the link you sent, but I don’t think I understood what you meant?
Your code is half Python, half Java. This should be:
for y in range(height):
for x in range(width):
distanceFromCenter = dist(x, y, width/2, height/2)
I provided you with a link to the Python references.
The reference to for() in the Python references shows how to do a for() loop in Python:
I was helping you by directing you to resources that will help you with this problem and future ones.
I do not work with Python and was able to answer your question and write code from those references.
I generally “Favor process over syntax”:
Providing you with complete code will not help you in the long run: