Allow a slider to set the colorRotation in radians
This commit is contained in:
parent
e2886f9aad
commit
1b8fc1feb7
5 changed files with 74 additions and 6 deletions
|
|
@ -49,7 +49,7 @@ public struct Parameters {
|
|||
public var color2 = Float4()
|
||||
public var color3 = Float4()
|
||||
|
||||
public var colorRotation = Matrix2x2(1.0)
|
||||
public var colorTransform = Matrix3x3(1.0)
|
||||
|
||||
public var colorStyle: ColorStyle {
|
||||
get {
|
||||
|
|
@ -303,6 +303,19 @@ public class Field {
|
|||
didChange = true
|
||||
}
|
||||
|
||||
if let rotation = userInfo["colorRotation"] as? Float {
|
||||
// Create a transform matrix to handle it
|
||||
let dx = Float(size.x) / 2.0
|
||||
let dy = Float(size.y) / 2.0
|
||||
let translate = Matrix3x3.translation(dx: dx, dy: dy)
|
||||
let rotate = Matrix3x3.rotation(angle: rotation)
|
||||
let invTranslate = Matrix3x3.translation(dx: -dx, dy: -dy)
|
||||
parameters.colorTransform = invTranslate * rotate * translate
|
||||
// Save the value to defaults
|
||||
defaults.colorRotation = rotation
|
||||
didChange = true
|
||||
}
|
||||
|
||||
if didChange {
|
||||
populateParametersBuffer()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue