-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clip! Clip! Clip! #8
Changes from all commits
4aff6b5
320c76e
a140d77
9b76ffc
d6d4959
25464a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Clip(object): | ||
def __init__(self, clipped_in : bool=True): | ||
self.clipped_in = clipped_in | ||
|
||
def is_inner(self): | ||
return self.clipped_in | ||
|
||
def is_outer(self): | ||
return not self.clipped_in | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from ..Stroke import Stroke | ||
from ..Fill import Fill | ||
from ..Item import Item | ||
from ..Clip import Clip | ||
from .Shape import Shape | ||
from ..util.Vector2 import Vector2 | ||
|
||
|
@@ -14,7 +15,7 @@ class Polygon(Shape): | |
# create circle as an ellipse with same x and y radius | ||
|
||
def __init__(self, | ||
clipped: bool, | ||
clip: Clip, | ||
points: Iterable[Vector2], | ||
stroke: Optional[Stroke] = None, fill: Optional[Fill] = None, | ||
children: Iterable[Item] = [], rotation: Union[int, float] = 0 | ||
|
@@ -27,7 +28,7 @@ def __init__(self, | |
center.x /= len(points) | ||
center.y /= len(points) | ||
# set position to center | ||
super().__init__(clipped, center, | ||
super().__init__(clip, center, | ||
stroke=stroke, fill=fill, | ||
children=children, rotation=rotation) | ||
self.points = points | ||
|
@@ -50,6 +51,8 @@ def render(self) -> str: | |
s += ' ' + self.stroke.render() | ||
if self.fill != None: | ||
s += ' ' + self.fill.render() | ||
else: | ||
s += ' ' + 'fill="#000000" fill-opacity="0.0"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe for such defaults we should have a defaults.py file with a bunch of enums and default values. So, if we decide to change something later, it will be much easier to hunt down all the cases where it was used. For example if we want to change the default color. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be a separate PR though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sounds like a good idea for other default values. I only put black in there because it needed a fill color. All this does is make the fill invisible when PhoTeX is supplied "no fill" for a shape! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but what if in the future we want the default color to be customization or we want it to be white? We would need to go through all the files and manually update them. My idea was to have a unified location for such defaults. Again though, let's keep this separate from this PR. Also, I think transparent black is a good choice. |
||
s += ' />' | ||
# Render Children | ||
if len(self.children) > 0: | ||
|
@@ -66,6 +69,7 @@ def defs(self) -> str: | |
if index != len(self.points) - 1: | ||
s += ' ' | ||
s += '" ' | ||
|
||
# Apply translation for map since it is relative to parent: | ||
s += f' transform="translate(-{self.position.x}, -{self.position.y})"' | ||
# Apply rotation if needed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a new line to the end of the file