Skip to content
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

Allow Line.points definition to be a mix of lists/tuples #3866

Merged
merged 6 commits into from Feb 1, 2016

Conversation

udiboy1209
Copy link
Contributor

Fix for issue #3481

Line.points can be defined as list of lists, tuples and coordinates (float values).
Setter method modified to check each element of the argument list and append it to self._points accordingly.
Line example file /examples/canvas/line.py updated with the new possible way of defining points.

Note: appending a tuple to points causes problems

Fix for issue kivy#3481
Line.points can be defined as list of lists, tuples and
coordinates (float values)
setter method modified to check each element of the argument
list and append it to self._points accordingly
Line example file /examples/canvas/line.py updated with the new
possible way of defining points
Forgot to remove it after experimenting, sorry 👅
def __set__(self, points):
self._points = list(points)
tmp = []
for p in points:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested, but it looks like a slow implementation. I think mixing lists/tuples with plain values is not a priority. points could be either a plain list/tuple, a list/tuple of lists, a list/tuple of tuples, or a list/tuple of lists and tuples (possibly mixed). This way, a faster algo could be used, something like what @kived proposed in the issue.

Ignores the case when self._points is a mix of list/tuple/float
Only works in cases where self._points is a list of iterables
@dessant dessant added the Status: On-hold PR is on hold and should not be merged until issues inside are resolved label Jan 5, 2016
@udiboy1209
Copy link
Contributor Author

@dessant I made the changes you requested. I agree the previous algorithm was slower. Given the conditions you mentioned we can use kived's algorithm

def __set__(self, points):
self._points = list(points)
import itertools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for doing the import in the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised that will slow things down :P

Moved import to top of module
Added case when points is a plain list
@dessant
Copy link
Contributor

dessant commented Feb 1, 2016

👍

@dessant dessant removed the Status: On-hold PR is on hold and should not be merged until issues inside are resolved label Feb 1, 2016
dessant added a commit that referenced this pull request Feb 1, 2016
Allow Line.points definition to be a mix of lists/tuples
@dessant dessant merged commit 02d63ce into kivy:master Feb 1, 2016
@matham matham removed this from the 2.0.0 milestone Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: graphics kivy/graphics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants