mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Add a basic API and rudimentary frontend for node graph layers (#846)
* Node graph API stub * Rename and fix SetInputValue * Get list of links from network * Test populating node graph UI * Node properties * Fix viewport bounds * Slightly change promise usage * A tiny bit of cleanup I did while reading code * Cleanup and work towards hooking up node links in Vue template * Add the brighten colour node * Run cargo fmt * Add to and from hsla * GrayscaleImage node with small perf improvement * Fix gutter panel resizing * Display node links from backend * Add support for connecting node links * Use existing message * Fix formatting error * Add a (currently crashing) brighten node * Replace brighten node with proto node implementation * Add support for connecting node links * Update watch dirs * Add hue shift node * Add create_node function to editor api * Basic insert node UI * Fix broken names * Add log * Fix positioning * Set connector index to 0 * Add properties for Heu shift / brighten * Allow deselecting nodes * Redesign Properties panel collapsible sections Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
committed by
Keavon Chambers
parent
e8256dd350
commit
504136b61b
@@ -22,6 +22,58 @@ impl<'n> Node<Color> for &'n GrayscaleNode {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct BrightenColorNode<N: Node<(), Output = f32>>(N);
|
||||
|
||||
impl<N: Node<(), Output = f32>> Node<Color> for BrightenColorNode<N> {
|
||||
type Output = Color;
|
||||
fn eval(self, color: Color) -> Color {
|
||||
let brightness = self.0.eval(());
|
||||
let per_channel = |col: f32| (col + brightness / 255.).clamp(0., 1.);
|
||||
Color::from_rgbaf32_unchecked(per_channel(color.r()), per_channel(color.g()), per_channel(color.b()), color.a())
|
||||
}
|
||||
}
|
||||
impl<N: Node<(), Output = f32> + Copy> Node<Color> for &BrightenColorNode<N> {
|
||||
type Output = Color;
|
||||
fn eval(self, color: Color) -> Color {
|
||||
let brightness = self.0.eval(());
|
||||
let per_channel = |col: f32| (col + brightness / 255.).clamp(0., 1.);
|
||||
Color::from_rgbaf32_unchecked(per_channel(color.r()), per_channel(color.g()), per_channel(color.b()), color.a())
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Node<(), Output = f32> + Copy> BrightenColorNode<N> {
|
||||
pub fn new(node: N) -> Self {
|
||||
Self(node)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct HueShiftNode<N: Node<(), Output = f32>>(N);
|
||||
|
||||
impl<N: Node<(), Output = f32>> Node<Color> for HueShiftNode<N> {
|
||||
type Output = Color;
|
||||
fn eval(self, color: Color) -> Color {
|
||||
let hue_shift = self.0.eval(());
|
||||
let [hue, saturation, luminance, alpha] = color.to_hsla();
|
||||
Color::from_hsla(hue + hue_shift / 360., saturation, luminance, alpha)
|
||||
}
|
||||
}
|
||||
impl<N: Node<(), Output = f32> + Copy> Node<Color> for &HueShiftNode<N> {
|
||||
type Output = Color;
|
||||
fn eval(self, color: Color) -> Color {
|
||||
let hue_shift = self.0.eval(());
|
||||
let [hue, saturation, luminance, alpha] = color.to_hsla();
|
||||
Color::from_hsla(hue + hue_shift / 360., saturation, luminance, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Node<(), Output = f32> + Copy> HueShiftNode<N> {
|
||||
pub fn new(node: N) -> Self {
|
||||
Self(node)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ForEachNode<MN>(pub MN);
|
||||
|
||||
impl<'n, I: Iterator<Item = S>, MN: 'n, S> Node<I> for &'n ForEachNode<MN>
|
||||
|
||||
Reference in New Issue
Block a user