mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 20:12:30 +01:00
9900e9a2b8
* A number of new image splits * Address comments. * git subrepo pull --force --branch=imgflip tools/splat subrepo: subdir: "tools/splat" merged: "9caaa45df9" upstream: origin: "https://github.com/ethteck/splat.git" branch: "imgflip" commit: "9caaa45df9" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * use flip_y over flip * git subrepo pull --force --branch=imgflip tools/splat subrepo: subdir: "tools/splat" merged: "ef663ec0d5" upstream: origin: "https://github.com/ethteck/splat.git" branch: "imgflip" commit: "ef663ec0d5" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * use flip_y * git subrepo pull --force --branch=imgflip tools/splat subrepo: subdir: "tools/splat" merged: "3144dc17f6" upstream: origin: "https://github.com/ethteck/splat.git" branch: "imgflip" commit: "3144dc17f6" git-subrepo: version: "0.4.3" origin: "???" commit: "???" Co-authored-by: JoshDuMan <Joshua.Shoup.1996@gmail.com>
18 lines
662 B
Python
18 lines
662 B
Python
from itertools import zip_longest
|
|
from math import ceil
|
|
|
|
def iter_in_groups(iterable, n, fillvalue=None):
|
|
args = [iter(iterable)] * n
|
|
return zip_longest(*args, fillvalue=fillvalue)
|
|
|
|
def iter_image_indexes(width, height, bytes_per_x=1, bytes_per_y=1, flip_h=False, flip_v=False):
|
|
w = int(width * bytes_per_x)
|
|
h = int(height * bytes_per_y)
|
|
|
|
xrange = range(w - ceil(bytes_per_x), -1, -ceil(bytes_per_x)) if flip_h else range(0, w, ceil(bytes_per_x))
|
|
yrange = range(h - ceil(bytes_per_y), -1, -ceil(bytes_per_y)) if flip_v else range(0, h, ceil(bytes_per_y))
|
|
|
|
for y in yrange:
|
|
for x in xrange:
|
|
yield x, y, (y * w) + x
|