Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/scene/Transformation.py
blob: b5ab142afac345ba7c47efe34ae5d711987a4775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import copy

class Transformation:
	def __init__(self):
		self._translation_x = 0
		self._translation_y = 0

	def set_translation(self, x, y):
		self._translation_x = x
		self._translation_y = y

	def get_position(self, x, y):
		translated_x = x + self._translation_x
		translated_y = y + self._translation_y
		return (translated_x, translated_y)

	def compose(self, transf):
		composed = copy.copy(self)
		composed._translation_x += transf._translation_x
		composed._translation_y += transf._translation_y
		return composed