0

I am trying to make a grid over a picture and I have managed that much using the function:

def grid(pic):
  width = getWidth(pic)
  height = getHeight(pic)
  size = 10
  for x in range(0, width, size):
    addLine(pic, x+size, 0, x+size, height)
  for y in range(0, height, size):
    addLine(pic, 0, y+size, width, y+size)

Now I need to make a function called grid2(pic,size). This function is supposed to take the code from the previous function (grid(pic)) and make it so the grid lines are now 20 pixels apart. Im not great with parameters so I don't fully understand how to do this. I was wondering if someone could help me thanks a ton.

Lenny
  • 193
  • 1
  • 11

1 Answers1

0

Hey we are in the same class; mine is working, and all I did was take the variable in the first function out and put it in the parameters. The rest of the code should be good to remain the same.

def grid2(pic, size):
  width = getWidth(pic)
  height = getHeight(pic)

  # Add lines along the X axis.
  for x in range(0, width, size):
    addLine(pic, x+size, 0, x+size, height)

  # Add lines down the Y axis
  for y in range(0, height, size):
    addLine(pic, 0, y+size, width, y+size)

In command prompt you will get:

p=makePicture(pickAFile())
grid2(p,20)

Test it with larger numbers to see if it is actually working.

super_mario3d
  • 95
  • 1
  • 5
Ryan
  • 1