-
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
Feature/gradient layer accessors #3
base: master
Are you sure you want to change the base?
Conversation
let randomChange = arc4random_uniform(4) | ||
switch randomChange { | ||
case 0: | ||
self.gradientLayer.uiColors = [UIColor.random, UIColor.random] |
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.
self not needed
var degrees = CGFloat(atan2(product, determinant)) * 180 / CGFloat.pi | ||
if degrees < 0 { degrees = 360 + degrees } | ||
|
||
return degrees.truncatingRemainder(dividingBy: 360) |
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.
maybe add radToDegrees
and degreesToRad
helpers?
switch ang { | ||
case 0...45, 315...360: | ||
return isStartPoint ? | ||
CGPoint(x: 0, y: n * tanx(ang) + n) : | ||
CGPoint(x: 1, y: n * tanx(-ang) + n) | ||
case 45...135: | ||
return isStartPoint ? | ||
CGPoint(x: n * tanx(ang - 90) + n, y: 1) : | ||
CGPoint(x: n * tanx(-ang - 90) + n, y: 0) | ||
case 135...225: | ||
return isStartPoint ? | ||
CGPoint(x: 1, y: n * tanx(-ang) + n) : | ||
CGPoint(x: 0, y: n * tanx(ang) + n) | ||
case 225...315: | ||
return isStartPoint ? | ||
CGPoint(x: n * tanx(-ang - 90) + n, y: 0) : | ||
CGPoint(x: n * tanx(ang - 90) + n, y: 1) | ||
default: | ||
return isStartPoint ? | ||
CGPoint(x: 0, y: n) : | ||
CGPoint(x: 1, y: n) | ||
} |
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.
I'm going to decide to believe you 😂
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.
I will post the source fro you :)
Gradient attributes accessors