mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-08 00:05:00 +00:00
New node: Sample Gradient
This commit is contained in:
parent
c156c0a4ce
commit
a8a5a1f3fd
3 changed files with 34 additions and 11 deletions
|
@ -127,7 +127,7 @@ pub(crate) fn property_from_type(
|
|||
Some("Angle") => number_widget(document_node, node_id, index, name, number_input.mode_range().min(min(-180.)).max(max(180.)).unit("°"), true).into(),
|
||||
Some("PixelLength") => number_widget(document_node, node_id, index, name, number_input.min(min(0.)).unit(" px"), true).into(),
|
||||
Some("Length") => number_widget(document_node, node_id, index, name, number_input.min(min(0.)), true).into(),
|
||||
Some("Fraction") => number_widget(document_node, node_id, index, name, number_input.min(min(0.)).max(max(1.)), true).into(),
|
||||
Some("Fraction") => number_widget(document_node, node_id, index, name, number_input.mode_range().min(min(0.)).max(max(1.)), true).into(),
|
||||
Some("IntegerCount") => number_widget(document_node, node_id, index, name, number_input.int().min(min(1.)), true).into(),
|
||||
Some("SeedValue") => number_widget(document_node, node_id, index, name, number_input.int().min(min(0.)), true).into(),
|
||||
Some("Resolution") => vec2_widget(document_node, node_id, index, name, "W", "H", " px", Some(64.), add_blank_assist),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::Ctx;
|
||||
use crate::raster::BlendMode;
|
||||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::registry::types::Percentage;
|
||||
use crate::registry::types::{Fraction, Percentage};
|
||||
use crate::vector::style::GradientStops;
|
||||
use crate::{Color, Node};
|
||||
use core::marker::PhantomData;
|
||||
|
@ -412,6 +412,37 @@ fn color_value(_: impl Ctx, _primary: (), #[default(Color::BLACK)] color: Option
|
|||
color
|
||||
}
|
||||
|
||||
// // Aims for interoperable compatibility with:
|
||||
// // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27grdm%27%20%3D%20Gradient%20Map
|
||||
// // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=Gradient%20settings%20(Photoshop%206.0)
|
||||
// #[node_macro::node(category("Raster: Adjustment"))]
|
||||
// async fn gradient_map<T: Adjust<Color>>(
|
||||
// _: impl Ctx,
|
||||
// #[implementations(
|
||||
// Color,
|
||||
// ImageFrameTable<Color>,
|
||||
// GradientStops,
|
||||
// )]
|
||||
// mut image: T,
|
||||
// gradient: GradientStops,
|
||||
// reverse: bool,
|
||||
// ) -> T {
|
||||
// image.adjust(|color| {
|
||||
// let intensity = color.luminance_srgb();
|
||||
// let intensity = if reverse { 1. - intensity } else { intensity };
|
||||
// gradient.evaluate(intensity as f64)
|
||||
// });
|
||||
|
||||
// image
|
||||
// }
|
||||
|
||||
/// Gets the color at the specified position along the gradient, given a position from 0 (left) to 1 (right).
|
||||
#[node_macro::node(category("General"))]
|
||||
fn sample_gradient(_: impl Ctx, _primary: (), gradient: GradientStops, position: Fraction) -> Color {
|
||||
let position = position.clamp(0., 1.);
|
||||
gradient.evaluate(position)
|
||||
}
|
||||
|
||||
/// Constructs a gradient value which may be set to any sequence of color stops to represent the transition between colors.
|
||||
#[node_macro::node(category("Value"))]
|
||||
fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
|
||||
|
|
|
@ -1388,15 +1388,7 @@ async fn jitter_points(_: impl Ctx, vector_data: VectorDataTable, #[default(5.)]
|
|||
}
|
||||
|
||||
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
|
||||
async fn morph(
|
||||
_: impl Ctx,
|
||||
source: VectorDataTable,
|
||||
#[expose] target: VectorDataTable,
|
||||
#[range((0., 1.))]
|
||||
#[default(0.5)]
|
||||
time: Fraction,
|
||||
#[min(0.)] start_index: IntegerCount,
|
||||
) -> VectorDataTable {
|
||||
async fn morph(_: impl Ctx, source: VectorDataTable, #[expose] target: VectorDataTable, #[default(0.5)] time: Fraction, #[min(0.)] start_index: IntegerCount) -> VectorDataTable {
|
||||
let time = time.clamp(0., 1.);
|
||||
|
||||
let source_alpha_blending = source.one_instance().alpha_blending;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue