Allow a slider to set the colorRotation in radians

This commit is contained in:
Eryn Wells 2018-10-09 16:51:35 -07:00
parent e2886f9aad
commit 1b8fc1feb7
5 changed files with 74 additions and 6 deletions

View file

@ -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()
}