mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-19 05:46:37 +00:00
76e57bd081
assets/text/TODO: updated. libtools/ToolLine.py: reflect brush width in pre-line dragging cursor.
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# OperatorTile.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
from Operator import Operator
|
|
import copy
|
|
|
|
class OperatorTile(Operator):
|
|
name = "Tile"
|
|
|
|
def apply2(self, mapPoint, mousePoint, regionOld, region):
|
|
if self.lastPoint == None:
|
|
self.lastPoint = list(mapPoint)
|
|
if self.tileObject == None:
|
|
self.tileObject = copy.deepcopy(region)
|
|
delta = [b - a for a, b in zip(self.lastPoint, mapPoint)]
|
|
if delta[1] > 0:
|
|
for numNewRow in range(delta[1]):
|
|
newRow = copy.deepcopy(self.tileObject[len(region) % len(self.tileObject)])
|
|
if len(newRow) < len(region[0]):
|
|
for numNewCol in range(len(newRow), len(region[0])):
|
|
newRow += [list(self.tileObject[len(region) % len(self.tileObject)][numNewCol % len(self.tileObject[len(region) % len(self.tileObject)])])]
|
|
region += [newRow]
|
|
if delta[0] > 0:
|
|
for numRow in range(len(region)):
|
|
for numNewCol in range(len(region[numRow]), len(region[numRow]) + delta[0]):
|
|
region[numRow] += [list(self.tileObject[numRow % len(self.tileObject)][numNewCol % len(self.tileObject[numRow % len(self.tileObject)])])]
|
|
self.lastPoint = list(mapPoint)
|
|
return region
|
|
|
|
def __init__(self, *args):
|
|
self.lastPoint, self.tileObject = None, None
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|