From 1edc7c1259590091cbc22e3908c5d0a8c5e4a0b6 Mon Sep 17 00:00:00 2001 From: vishnuxx Date: Wed, 13 Oct 2021 19:40:35 +0530 Subject: [PATCH 1/2] added Skew Functionality --- joy.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/joy.py b/joy.py index 27f86d4..86a3b3a 100644 --- a/joy.py +++ b/joy.py @@ -625,6 +625,24 @@ def __init__(self, sx, sy=None): def as_str(self): return f"scale({self.sx} {self.sy})" + +class Skew(Transformation): + def __init__(self , sx=0 , sy=0) -> None: + if sy is None: + sy = sx + self.sx = sx + self.sy = sy + + def as_str(self): + str = "" + if self.sy is None: + str = f"skewX({self.sx})" + else: + str = f"skewX({self.sx}) skewY{self.sy})" + + + + class Repeat(Transformation): """Repeat is a higher-order transformation that repeats a transformation multiple times. @@ -1010,3 +1028,5 @@ def random(a=None, b=None): else: delta = b - a return a + delta * random_module.random() + + From 3f50266e150a973d2f5c166099ab29c927b0d79d Mon Sep 17 00:00:00 2001 From: vishnuxx Date: Wed, 13 Oct 2021 20:26:31 +0530 Subject: [PATCH 2/2] added Skew transformation class and fixed some bugs --- joy.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/joy.py b/joy.py index 86a3b3a..a6dca0a 100644 --- a/joy.py +++ b/joy.py @@ -627,18 +627,28 @@ def as_str(self): class Skew(Transformation): - def __init__(self , sx=0 , sy=0) -> None: - if sy is None: - sy = sx - self.sx = sx - self.sy = sy + """Creates a new scale transformation. + + Parameters: + x: + The Skew factor in the x direction. + + y: + The Skew factor in the y direction. Defaults to + the value of x if not provided. + """ + def __init__(self , x=0 , y=0): + if y is None: + y = x + self.x = x + self.y = y def as_str(self): str = "" - if self.sy is None: - str = f"skewX({self.sx})" + if self.y is None: + str = f"skewX({self.x})" else: - str = f"skewX({self.sx}) skewY{self.sy})" + str = f"skewX({self.x}) skewY({self.y})"