Skip to content

Instantly share code, notes, and snippets.

@sgodycki
Created October 1, 2021 15:36
Show Gist options
  • Save sgodycki/0375c24198dbba9aaa5ba487dc2d8936 to your computer and use it in GitHub Desktop.
Save sgodycki/0375c24198dbba9aaa5ba487dc2d8936 to your computer and use it in GitHub Desktop.
Struggling with Sol Lewitt
mode=Python
mode.id=jycessing.mode.PythonMode
size(600,600)
background(255)
fill(220, 50, 100,50)
x = 100
while x <= 300:
stroke(255)
line(200,x, 200,100)
rect(300,x*2,200,100)
y= 150
while y<=300:
rect(x,y,200,100)
arc(100,250,400,200,0,HALF_PI)
y=y+150
x = x + 100
@sgodycki
Copy link
Author

sgodycki commented Oct 1, 2021

Struggling with the Sol Lewwit project i just can't seem to get my shapes to interact as much as I would like them too. Could you point me in the right direction? @rors

@rors
Copy link

rors commented Oct 4, 2021

(I originally accidentally commented from an account I use as a sample student demo account – if you got another alert, you can ignore it.)

Interesting. Well this is a great effort so far. I'd suggest you might try analyzing the code you have so far and getting a sense of what each bit drawing code is doing. You could comment out lines 8, 11, and 12, then run the code and see what the line() command is doing. Then comment out lines 7, 11, and 12, and see what the first rect() is doing. And repeat that for the last two draw command as well. So comment out lines 7, 8, and 12, to see what 11 is doing; and lastly, comment out 7, 8, and 11 to see what line 12 is doing. Working in isolation, you can work on each command to expand what it is doing, and then uncomment all the lines to put the composition back together.

I just did that and I can see that line() is not doing too much. That's because the second point of the line is hard-coded as 200,100 and that never changes. Maybe you could try putting a variable in the third or fourth arguments and see what happens.

From that analysis and from stepping through the code mentally, it looks like your outer while loop only repeats three times (for x values of 100, 200, and 300), and your inner while loop is only repeating two times (for y values of 150 and 300). Can you think of how you might adjusting some of the values there to increase that? Try changing the initial values, stopping values, or increment values of either loop to increase the number of iterations.

I think one of the most interesting things you're bringing in here is arc(). But you're not using any of your looping variables in the parameters to that command. Try integrating x or y as the parameters there. As the docs explain, the first and second arguments correspond to the horizontal and vertical location of the arc in the window. So to start, you could simply use x and y for those arguments. Also, the fifth and sixth arguments to arc() indicate the start and stopping point of the curved line, as specified in radians, which go from 0 to 2*PI. You have HALF_PI in there now, which is good. That's about 25% of a circle, like a quarter of a pie. You could try multiplying that by your looping variable somehow. Think about the values of x: 100, 200, 300. Those numbers themselves are too large to multiply with. But if you divide x by 300 you get: 1/3, 2/3, and 1. Putting that together, you'd have:

        arc(x,y, 400,200, 0,HALF_PI * x/300)

Try all that and let me know what you get!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment