Add color rotation matrix to Parameters
This commit is contained in:
parent
0844fbc010
commit
d3190dd7e7
3 changed files with 13 additions and 3 deletions
|
@ -13,6 +13,7 @@ import simd
|
||||||
public typealias Float2 = packed_float2
|
public typealias Float2 = packed_float2
|
||||||
public typealias Float3 = float3
|
public typealias Float3 = float3
|
||||||
public typealias Float4 = float4
|
public typealias Float4 = float4
|
||||||
|
public typealias Matrix2x2 = float2x2
|
||||||
public typealias Matrix3x3 = float3x3
|
public typealias Matrix3x3 = float3x3
|
||||||
public typealias Matrix4x4 = float4x4
|
public typealias Matrix4x4 = float4x4
|
||||||
|
|
||||||
|
@ -42,6 +43,15 @@ extension Float4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Matrix2x2 {
|
||||||
|
static func rotation(theta: Float) -> Matrix2x2 {
|
||||||
|
return self.init(rows: [
|
||||||
|
Float2(cos(theta), -sin(theta)),
|
||||||
|
Float2(sin(theta), cos(theta)),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension Matrix4x4 {
|
extension Matrix4x4 {
|
||||||
/// Create a 4x4 orthographic projection matrix with the provided 6-tuple.
|
/// Create a 4x4 orthographic projection matrix with the provided 6-tuple.
|
||||||
/// @see https://en.wikipedia.org/wiki/Orthographic_projection
|
/// @see https://en.wikipedia.org/wiki/Orthographic_projection
|
||||||
|
|
|
@ -49,6 +49,8 @@ public struct Parameters {
|
||||||
public var color2 = Float4()
|
public var color2 = Float4()
|
||||||
public var color3 = Float4()
|
public var color3 = Float4()
|
||||||
|
|
||||||
|
public var colorRotation = Matrix2x2(1.0)
|
||||||
|
|
||||||
public var colorStyle: ColorStyle {
|
public var colorStyle: ColorStyle {
|
||||||
get {
|
get {
|
||||||
return ColorStyle(rawValue: _colorStyle)!
|
return ColorStyle(rawValue: _colorStyle)!
|
||||||
|
@ -234,9 +236,6 @@ public class Field {
|
||||||
var r = ball.radius
|
var r = ball.radius
|
||||||
ptr = write(value: &r, to: ptr)
|
ptr = write(value: &r, to: ptr)
|
||||||
ptr = ptr.advanced(by: 4) // Skip 4 bytes to maintain alignment.
|
ptr = ptr.advanced(by: 4) // Skip 4 bytes to maintain alignment.
|
||||||
// if idx == 0 {
|
|
||||||
// print("Populated ball \(idx): x:\(ball.position.x), y:\(ball.position.y), r:\(r)")
|
|
||||||
// }
|
|
||||||
idx += 1
|
idx += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct {
|
||||||
float target;
|
float target;
|
||||||
float feather;
|
float feather;
|
||||||
float4 colors[4];
|
float4 colors[4];
|
||||||
|
float2x2 colorRotation;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|
||||||
typedef float3 Ball;
|
typedef float3 Ball;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue