x,y and i,j

I made a python reader and writer for the image representation CSUnplugged activity. You can even download it for Windows.
What I learned (the hard way) is that i corresponds to y (vertical), and j corresponds to x (horizontal), e.g.

for i in range(len(rect)):
  for j in range(len(rect[i])):
    x = j*LD
    y = i*LD
    if rect[i][j] == 0:
      canvas.create_rectangle(x,y,x+LD,y+LD,fill="#ffffff")
    else:
      canvas.create_rectangle(x,y,x+LD,y+LD,fill="#000000")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s