diff --git a/MetaballsKit/PreferencesViewController.swift b/MetaballsKit/PreferencesViewController.swift index b5532d0..d248bf1 100644 --- a/MetaballsKit/PreferencesViewController.swift +++ b/MetaballsKit/PreferencesViewController.swift @@ -26,6 +26,10 @@ public class PreferencesViewController: NSViewController { tag: Int(ColorStyle.gradient2Horizontal.rawValue), colorNames: [NSLocalizedString("Right", comment: "two color horizontal gradient, color 1"), 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() { stackView.translatesAutoresizingMaskIntoConstraints = false stackView.orientation = .horizontal - stackView.spacing = 8 + stackView.spacing = 12 stackView.alignment = .centerY stackView.distribution = .fill diff --git a/MetaballsKit/Shaders.metal b/MetaballsKit/Shaders.metal index 3a09eb9..af9dc91 100644 --- a/MetaballsKit/Shaders.metal +++ b/MetaballsKit/Shaders.metal @@ -83,16 +83,22 @@ sampleToColorShader(RasterizerData in [[stage_in]], const float target = parameters.target; const float feather = parameters.feather; const float sample = sampleAtPoint(in.position.xy, balls, parameters.numberOfBalls); - const float blend = in.position.x / parameters.size.x; float4 out; switch (parameters.colorStyle) { case SingleColor: out = singleColor(sample, target, feather, parameters.colors[0]); 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]); 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;