-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add convert to outlines #431
base: develop
Are you sure you want to change the base?
Conversation
|
||
### Returns | ||
|
||
An array of new [Layer](#layer) objects representing the outlines of this layer. |
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.
Might be nice to clarify when this has more than one layer. I'm still not sure when that would be.
Ah sorry, I didn't comment on this. It feels a bit weird to me to have this method on a But you are right that it can sometimes create multiple layers (when a shape has multiple borders IIRC). So I'm still not sure |
My opinion: The current name and location ( |
yeah, I meant more about having it as a class method (eg. more like a constructor) rather than an instance method |
Any more thoughts on naming for this? |
@mathieudutour Let me know if and how you want me to update this. Happy to do whatever you think makes the most sense. |
Yeah sorry, I need to find some time to play with a few different namings. Sorry for the delay :/ |
No worries, just remembered this had been sitting here for a while. This is an easy one to drop in to the internals for now. |
Is there a way to convert to outlines for JS Sketch plugin right now? Thank you. |
This PR needs to address this issue that was brought up in Slack 👇 . @christianklotz any insight on how this can be achieved in code? I'd be happy to implement and get this PR moving again.
|
This is going to be fixed in Sketch 60. Once out it'd be a good time to pick up this PR again. |
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.
The issue here is that this would actually fail on any layer that doesn't support conversion to outlines, e.g. symbol instances, groups, etc. There's a method canConvertToOutlines
which returns true for anything that can be converted, posing the question of how this would be translated here. Does it only return itself wrapped in an array or null
/undefined
?
/** | ||
* Return one or more layers the were converted to outlines. | ||
*/ | ||
layersByConvertingToOutlines() { |
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.
layersByConvertingToOutlines() { | |
toOutlines() { |
Maybe toOutlines
, similar to String.toUppercase
would suffice?
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.
Makes sense to me.
As for failing when |
@WCByrne it gets never called because it's only implemented for layer subclasses that support it. |
got it. I feel like returning nil then, or maybe even throw an error to make it clear why it didn't work. If you are trying to convert something to outlines, getting that layer back in an array seems like it could be confusing |
Returning nil works for me. Throwing an error is a bit harsh, especially if the method is on |
If those are the only 2 that support it, that works for me. I was just kinda going with what the internals seemed to do. FWIW, I only use it for text layers so this is a bit of a none issue for my needs. |
👍 … feel free to make the change so only the two classes have the method and I'll review. |
Addresses #408