Skip to content

Instantly share code, notes, and snippets.

@harmo
Last active December 28, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harmo/7536563 to your computer and use it in GitHub Desktop.
Save harmo/7536563 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
0 ________ 256
| /\ |
| /\/\ |
| /\/\/\ |
|/\/\/\/\| \ → x
|\/\/\/\/|
| \/\/\/ | / → y
| \/\/ |
|___\/___|
128
Soit une grille de 4 x 4
Chaque case fait 64 pixels de large et 32 pixels de haut
La premiere case est celle en haut au milieu, la derniere son opposee en bas
"""
total_x = 4
total_y = 4
dW = 32
dH = 16
inc_x = 0
inc_y = 0
total = 0
positions = {}
for x in range(0, total_x):
for y in range(0, total_y):
total += 1
positions[total] = (dW*(total_x+inc_x), dH*inc_y)
inc_x = inc_x+1 if y < total_y-1 else inc_x-total_x
inc_y = inc_y+1 if y < total_y-1 else inc_y-(total_y/2)
print(positions)
# {
# 1: (128, 0),
# 2: (160, 16),
# 3: (192, 32),
# 4: (224, 48),
# 5: (96, 16),
# 6: (128, 32),
# 7: (160, 48),
# 8: (192, 64),
# 9: (64, 32),
# 10: (96, 48),
# 11: (128, 64),
# 12: (160, 80),
# 13: (32, 48),
# 14: (64, 64),
# 15: (96, 80),
# 16: (128, 96)
# }
@wo0dyn
Copy link

wo0dyn commented Nov 18, 2013

👍

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