Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, sys, pprint
- def main():
- patches = [['A1', 'A2', 'A3', 'A4'],
- ['B1', 'B2', 'B3', 'B4'],
- ['C1', 'C2', 'C3', 'C4'],
- ['D1', 'D2', 'D3', 'D4']]
- for y in range(0, len(patches)):
- for x in range(0, len(patches[0])):
- regions = makePatch([7,2], [x,y], 1024, 8, 4)
- print '%s: {' % patches[y][x]
- print ' regions: ['
- for z in range(0, 9):
- print ' { height: %d, width: %d, x: %d, y: %d }%s' % (regions[z]['height'], regions[z]['width'], regions[z]['x'], regions[z]['y'], '' if z == 8 else ',')
- print ' ],'
- print ' color: red'
- print '}%s' % ('' if x == len(patches[0]) - 1 and y == len(patches) - 1 else ',')
- def makePatch(big, small, size, cBig, cSmall):
- smallSize = size / cBig / cSmall
- startX = big[0] * cSmall * smallSize + (small[0] * smallSize)
- startY = big[1] * cSmall * smallSize + (small[1] * smallSize)
- regionSize = smallSize / 3
- regions = []
- sizes = [[8, 8], [16, 8], [8, 8],
- [8,16], [16,16], [8,16],
- [8, 8], [16, 8], [8, 8]]
- offY = 0
- for y in range(0, 3):
- offX = 0
- for x in range(0, 3):
- size = sizes[y * 3 + x]
- regions.append({'height' : size[1] if size[1] != 16 else 1, 'width' : size[0] if size[0] != 16 else 1, 'x' : startX + offX, 'y' : startY + offY})
- offX += size[0]
- offY += sizes[y * 3][1]
- return regions
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement