Skip to content

Commit

Permalink
Make shape args optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
matham committed Oct 8, 2020
1 parent 5cd1c02 commit bc97b1c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions kivy_garden/painter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ def update(*largs):
self.fbind('center', update)

@classmethod
def create_shape(cls, center, radius, **inst_kwargs):
def create_shape(cls, center=(0, 0), radius=dp(10), **inst_kwargs):
"""Creates a new circle instance from the given arguments.
E.g.:
Expand Down Expand Up @@ -1644,7 +1644,9 @@ def update(*largs):
self.fbind('center', update)

@classmethod
def create_shape(cls, center, radius_x, radius_y, angle, **inst_kwargs):
def create_shape(
cls, center=(0, 0), radius_x=dp(10), radius_y=dp(15), angle=0,
**inst_kwargs):
"""Creates a new ellipse instance from the given arguments.
E.g.:
Expand Down Expand Up @@ -1955,7 +1957,7 @@ def update(*largs):
update()

@classmethod
def create_shape(cls, points, selection_point, **inst_kwargs):
def create_shape(cls, points=(), selection_point=(), **inst_kwargs):
"""Creates a new polygon instance from the given arguments.
E.g.:
Expand All @@ -1971,6 +1973,9 @@ def create_shape(cls, points, selection_point, **inst_kwargs):
will be passed as options to the class when it is instantiated.
:return: The newly created polygon instance.
"""
if not selection_point:
selection_point = points[:2]

shape = cls(
points=points, selection_point=selection_point, **inst_kwargs)
shape.set_valid()
Expand Down Expand Up @@ -2294,7 +2299,7 @@ def update(*largs):
self.fbind('position', update)

@classmethod
def create_shape(cls, position, **inst_kwargs):
def create_shape(cls, position=(0, 0), **inst_kwargs):
"""Creates a new point instance from the given arguments.
E.g.:
Expand Down Expand Up @@ -2634,7 +2639,8 @@ def add_colored_shapes_area(self):
spacing: '20dp'
Spinner:
id: mode
values: ['circle', 'ellipse', 'polygon', 'freeform', 'point', 'none']
values: ['circle', 'ellipse', 'polygon', 'freeform', 'point', \
'none']
text: 'freeform'
ToggleButton:
id: lock
Expand Down

0 comments on commit bc97b1c

Please sign in to comment.