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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom gradient start point #380

Merged
merged 6 commits into from Dec 31, 2016

Conversation

Projects
None yet
4 participants
@tbaranes
Member

tbaranes commented Dec 22, 2016

Close #378

Using StartPoint.custom(0,0.5,0,0), it will render:

screen shot 2016-12-22 at 10 44 43

That may be useful! After a quick first look to update the example app, I have to say that I'm a bit lost with the ParamType 馃槰 @lastMove How am I supposed to create ParamType using custom parameters?

Missing:

  • Example app
  • Changelog
@IBAnimatableBot

This comment has been minimized.

Show comment
Hide comment
@IBAnimatableBot

IBAnimatableBot Dec 22, 2016

1 Warning
鈿狅笍 Consider adding supporting documentation to this change. Documentation can be found in the docs directory.

Generated by 馃毇 danger

IBAnimatableBot commented Dec 22, 2016

1 Warning
鈿狅笍 Consider adding supporting documentation to this change. Documentation can be found in the docs directory.

Generated by 馃毇 danger

@lastMove

This comment has been minimized.

Show comment
Hide comment
@lastMove

lastMove Dec 22, 2016

Member

Hello,
Nice feature !
How do you want to render it ?
Presently in the Playground part of the app in "predefined gradients" section;
there is a Picker with 2 components (one for the gradient, the other one for the startPoint).
So it will be difficult to had 4 more components to customise that.
Maybe we should create another section.
ParamType allows To generate and manage arrays of possible values for a pickerComponent.
And you can generate this array from enum; Sample :

let gradientValues = ParamType(fromEnum: GradientStartPoint.self)
print(gradientValues.value(at: 0))
// "top"
print(gradientValues.value(at: 4))
// "bottomRight"

It's like an array generated from enum values.

It works also to generate array of possible values from number interval :

private let numberParam = ParamType.number(min: -50, max: 50, interval: 5, ascending: true, unit: "")
// this will generate this array : [-50, -45, -40, -35, ... , 35, 40, 45, 50]

So numberParam.value(at: 0) will gives -50.

Member

lastMove commented Dec 22, 2016

Hello,
Nice feature !
How do you want to render it ?
Presently in the Playground part of the app in "predefined gradients" section;
there is a Picker with 2 components (one for the gradient, the other one for the startPoint).
So it will be difficult to had 4 more components to customise that.
Maybe we should create another section.
ParamType allows To generate and manage arrays of possible values for a pickerComponent.
And you can generate this array from enum; Sample :

let gradientValues = ParamType(fromEnum: GradientStartPoint.self)
print(gradientValues.value(at: 0))
// "top"
print(gradientValues.value(at: 4))
// "bottomRight"

It's like an array generated from enum values.

It works also to generate array of possible values from number interval :

private let numberParam = ParamType.number(min: -50, max: 50, interval: 5, ascending: true, unit: "")
// this will generate this array : [-50, -45, -40, -35, ... , 35, 40, 45, 50]

So numberParam.value(at: 0) will gives -50.

@tbaranes

This comment has been minimized.

Show comment
Hide comment
@tbaranes

tbaranes Dec 22, 2016

Member

I was thinking to add directly a predefined startPoint, but you are right, it will be for the best to add a section to render it.
Thanks for the explanation! I will give it a try.

Member

tbaranes commented Dec 22, 2016

I was thinking to add directly a predefined startPoint, but you are right, it will be for the best to add a section to render it.
Thanks for the explanation! I will give it a try.

@tbaranes

This comment has been minimized.

Show comment
Hide comment
@tbaranes

tbaranes Dec 22, 2016

Member

Working perfectly @lastMove! Thanks for the tips.

simulator screen shot 22 dec 2016 14 22 29

One more question, any suggestion how we should update the current example (it won't compile since .custom isn't compatible with the other startPoint). I see that for the animation you used PickerEntry, should I do the same or is there a better existing solution?

Member

tbaranes commented Dec 22, 2016

Working perfectly @lastMove! Thanks for the tips.

simulator screen shot 22 dec 2016 14 22 29

One more question, any suggestion how we should update the current example (it won't compile since .custom isn't compatible with the other startPoint). I see that for the animation you used PickerEntry, should I do the same or is there a better existing solution?

@JakeLin

I think it is ready to go馃憤

self = .custom(start: CGPoint(x: params[safe: 0]?.toDouble() ?? 0,
y: params[safe: 1]?.toDouble() ?? 0),
end: CGPoint(x: params[safe: 2]?.toDouble() ?? 0,
y: params[safe: 3]?.toDouble() ?? 0))

This comment has been minimized.

@JakeLin

JakeLin Dec 23, 2016

Member

Great method from @lastMove for safe extracting data from params

@JakeLin

JakeLin Dec 23, 2016

Member

Great method from @lastMove for safe extracting data from params

@tbaranes

This comment has been minimized.

Show comment
Hide comment
@tbaranes

tbaranes Dec 23, 2016

Member

Not really, the gradient example is still broken 馃槵 Open to any suggestion

Member

tbaranes commented Dec 23, 2016

Not really, the gradient example is still broken 馃槵 Open to any suggestion

@lastMove lastMove self-assigned this Dec 30, 2016

@lastMove

This comment has been minimized.

Show comment
Hide comment
@lastMove

lastMove Dec 30, 2016

Member

Should be good know.
@tbaranes the problem was that since GradientStartPoint does not anymore have a String RawValue ParamType.enumeration(values: ["top", "topLeft", "topRight", "left", "right", "bottom", "bottomRight", "bottomLeft"])

Member

lastMove commented Dec 30, 2016

Should be good know.
@tbaranes the problem was that since GradientStartPoint does not anymore have a String RawValue ParamType.enumeration(values: ["top", "topLeft", "topRight", "left", "right", "bottom", "bottomRight", "bottomLeft"])

@tbaranes

This comment has been minimized.

Show comment
Hide comment
@tbaranes

tbaranes Dec 31, 2016

Member

@lastMove thanks for that!

Member

tbaranes commented Dec 31, 2016

@lastMove thanks for that!

@tbaranes tbaranes merged commit 9e962d8 into master Dec 31, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@tbaranes tbaranes deleted the feature/custom_gradient_start branch Jan 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment