Skip to content
Snippets Groups Projects
Commit 14133385 authored by Tomáš Orviský's avatar Tomáš Orviský
Browse files

DiagramObject docstring

parent 83875913
Branches
No related merge requests found
......@@ -8,6 +8,9 @@ import pyplaml
class DiagramObject(VGroup):
"""
Base class for all diagram objects.
"""
def __init__(self, name: str, **kwargs):
super().__init__(**kwargs)
......@@ -19,6 +22,9 @@ class DiagramObject(VGroup):
@abstractmethod
def redraw(self):
"""
Resets the VGroup of an objects and creates it from scratch.
"""
self.submobjects = []
def add_note(self, note: pyplaml.DiagramNote, direction: pyplaml.Direction) -> pyplaml.DiagramNote:
......@@ -32,23 +38,29 @@ class DiagramObject(VGroup):
return note
def get_boundary_points(self):
"""
Returns a dictionary of all corners and points in between them.
"""
def lerp(t: float, a, b):
return (1 - t) * a + t * b
ul = self.get_boundary_point(direction=UL)
ur = self.get_boundary_point(direction=UR)
dl = self.get_boundary_point(direction=DL)
dr = self.get_boundary_point(direction=DR)
u = self.lerp(0.5, ul, ur)
r = self.lerp(0.5, ur, dr)
d = self.lerp(0.5, dl, dr)
l = self.lerp(0.5, ul, dl)
u = lerp(0.5, ul, ur)
r = lerp(0.5, ur, dr)
d = lerp(0.5, dl, dr)
l = lerp(0.5, ul, dl)
return {'UL': ul, 'UR': ur, 'UP': u, 'DL': dl, 'DR': dr, 'R': r, 'D': d, 'L': l, }
@staticmethod
def lerp(t: float, a, b):
return (1 - t) * a + t * b
def append_to_diagram(self, diagram: pyplaml.Diagram):
"""
Appends an object to a diagram.
"""
key = self.get_key()
if not key in diagram.objects:
diagram[key] = self
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment