Add vertical gradient
This commit is contained in:
parent
094a15f145
commit
edce32e021
2 changed files with 13 additions and 3 deletions
|
@ -26,6 +26,10 @@ public class PreferencesViewController: NSViewController {
|
||||||
tag: Int(ColorStyle.gradient2Horizontal.rawValue),
|
tag: Int(ColorStyle.gradient2Horizontal.rawValue),
|
||||||
colorNames: [NSLocalizedString("Right", comment: "two color horizontal gradient, color 1"),
|
colorNames: [NSLocalizedString("Right", comment: "two color horizontal gradient, color 1"),
|
||||||
NSLocalizedString("Left", comment: "two color horizontal gradient, color 2")]),
|
NSLocalizedString("Left", comment: "two color horizontal gradient, color 2")]),
|
||||||
|
StyleItem(name: NSLocalizedString("Two Color Gradient — Vertical", comment: "two color vertical gradient menu item"),
|
||||||
|
tag: Int(ColorStyle.gradient2Vertical.rawValue),
|
||||||
|
colorNames: [NSLocalizedString("Top", comment: "two color vertical gradient, color 1"),
|
||||||
|
NSLocalizedString("Bottom", comment: "two color vertical gradient, color 2")]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +256,7 @@ class ParameterView: NSView {
|
||||||
private func commonInit() {
|
private func commonInit() {
|
||||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
stackView.orientation = .horizontal
|
stackView.orientation = .horizontal
|
||||||
stackView.spacing = 8
|
stackView.spacing = 12
|
||||||
stackView.alignment = .centerY
|
stackView.alignment = .centerY
|
||||||
stackView.distribution = .fill
|
stackView.distribution = .fill
|
||||||
|
|
||||||
|
|
|
@ -83,17 +83,23 @@ sampleToColorShader(RasterizerData in [[stage_in]],
|
||||||
const float target = parameters.target;
|
const float target = parameters.target;
|
||||||
const float feather = parameters.feather;
|
const float feather = parameters.feather;
|
||||||
const float sample = sampleAtPoint(in.position.xy, balls, parameters.numberOfBalls);
|
const float sample = sampleAtPoint(in.position.xy, balls, parameters.numberOfBalls);
|
||||||
const float blend = in.position.x / parameters.size.x;
|
|
||||||
|
|
||||||
float4 out;
|
float4 out;
|
||||||
switch (parameters.colorStyle) {
|
switch (parameters.colorStyle) {
|
||||||
case SingleColor:
|
case SingleColor:
|
||||||
out = singleColor(sample, target, feather, parameters.colors[0]);
|
out = singleColor(sample, target, feather, parameters.colors[0]);
|
||||||
break;
|
break;
|
||||||
case Gradient2Horizontal:
|
case Gradient2Horizontal: {
|
||||||
|
const float blend = in.position.x / parameters.size.x;
|
||||||
out = gradient2(sample, target, feather, blend, parameters.colors[0], parameters.colors[1]);
|
out = gradient2(sample, target, feather, blend, parameters.colors[0], parameters.colors[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Gradient2Vertical: {
|
||||||
|
const float blend = in.position.y / parameters.size.y;
|
||||||
|
out = gradient2(sample, target, feather, blend, parameters.colors[0], parameters.colors[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue