mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Change number inputs to be f32 instead of f64 for most nodes (#1543)
This commit is contained in:
@@ -15,7 +15,7 @@ pub struct TextGeneratorNode<Text, FontName, Size> {
|
||||
}
|
||||
|
||||
#[node_fn(TextGeneratorNode)]
|
||||
fn generate_text<'a: 'input, T>(editor: EditorApi<'a, T>, text: String, font_name: Font, font_size: f64) -> crate::vector::VectorData {
|
||||
fn generate_text<'a: 'input, T>(editor: EditorApi<'a, T>, text: String, font_name: Font, font_size: f32) -> crate::vector::VectorData {
|
||||
let buzz_face = editor.font_cache.get(&font_name).map(|data| load_face(data));
|
||||
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size, None))
|
||||
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size as f64, None))
|
||||
}
|
||||
|
||||
@@ -212,7 +212,11 @@ pub struct ResamplePoints<Spacing, StartOffset, StopOffset, AdaptiveSpacing> {
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(ResamplePoints)]
|
||||
fn resample_points(mut vector_data: VectorData, spacing: f64, start_offset: f64, stop_offset: f64, adaptive_spacing: bool) -> VectorData {
|
||||
fn resample_points(mut vector_data: VectorData, spacing: f32, start_offset: f32, stop_offset: f32, adaptive_spacing: bool) -> VectorData {
|
||||
let spacing = spacing as f64;
|
||||
let start_offset = start_offset as f64;
|
||||
let stop_offset = stop_offset as f64;
|
||||
|
||||
for subpath in &mut vector_data.subpaths {
|
||||
if subpath.is_empty() || spacing.is_zero() || !spacing.is_finite() {
|
||||
continue;
|
||||
|
||||
@@ -20,6 +20,7 @@ pub enum TaggedValue {
|
||||
None,
|
||||
String(String),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
F32(f32),
|
||||
F64(f64),
|
||||
Bool(bool),
|
||||
@@ -82,6 +83,7 @@ impl Hash for TaggedValue {
|
||||
Self::None => {}
|
||||
Self::String(x) => x.hash(state),
|
||||
Self::U32(x) => x.hash(state),
|
||||
Self::U64(x) => x.hash(state),
|
||||
Self::F32(x) => x.to_bits().hash(state),
|
||||
Self::F64(x) => x.to_bits().hash(state),
|
||||
Self::Bool(x) => x.hash(state),
|
||||
@@ -159,6 +161,7 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::None => Box::new(()),
|
||||
TaggedValue::String(x) => Box::new(x),
|
||||
TaggedValue::U32(x) => Box::new(x),
|
||||
TaggedValue::U64(x) => Box::new(x),
|
||||
TaggedValue::F32(x) => Box::new(x),
|
||||
TaggedValue::F64(x) => Box::new(x),
|
||||
TaggedValue::Bool(x) => Box::new(x),
|
||||
@@ -219,6 +222,7 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::None => "()".to_string(),
|
||||
TaggedValue::String(x) => format!("\"{x}\""),
|
||||
TaggedValue::U32(x) => x.to_string() + "_u32",
|
||||
TaggedValue::U64(x) => x.to_string() + "_u64",
|
||||
TaggedValue::F32(x) => x.to_string() + "_f32",
|
||||
TaggedValue::F64(x) => x.to_string() + "_f64",
|
||||
TaggedValue::Bool(x) => x.to_string(),
|
||||
@@ -233,6 +237,7 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::None => concrete!(()),
|
||||
TaggedValue::String(_) => concrete!(String),
|
||||
TaggedValue::U32(_) => concrete!(u32),
|
||||
TaggedValue::U64(_) => concrete!(u64),
|
||||
TaggedValue::F32(_) => concrete!(f32),
|
||||
TaggedValue::F64(_) => concrete!(f64),
|
||||
TaggedValue::Bool(_) => concrete!(bool),
|
||||
@@ -296,6 +301,7 @@ impl<'a> TaggedValue {
|
||||
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
|
||||
x if x == TypeId::of::<String>() => Ok(TaggedValue::String(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<u32>() => Ok(TaggedValue::U32(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<u64>() => Ok(TaggedValue::U64(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<f32>() => Ok(TaggedValue::F32(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<f64>() => Ok(TaggedValue::F64(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<bool>() => Ok(TaggedValue::Bool(*downcast(input).unwrap())),
|
||||
|
||||
@@ -623,7 +623,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
vec![
|
||||
fn_type!(WasmEditorApi),
|
||||
fn_type!(ImaginateController),
|
||||
fn_type!(f64),
|
||||
fn_type!(u64),
|
||||
fn_type!(Option<DVec2>),
|
||||
fn_type!(u32),
|
||||
fn_type!(ImaginateSamplingMethod),
|
||||
@@ -734,7 +734,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
register_node!(graphene_std::raster::MandelbrotNode, input: Footprint, params: []),
|
||||
async_node!(graphene_core::vector::CopyToPoints<_, _>, input: Footprint, output: VectorData, fn_params: [Footprint => VectorData, Footprint => VectorData]),
|
||||
async_node!(graphene_core::vector::CopyToPoints<_, _>, input: Footprint, output: GraphicGroup, fn_params: [Footprint => VectorData, Footprint => GraphicGroup]),
|
||||
register_node!(graphene_core::vector::ResamplePoints<_, _, _, _>, input: VectorData, params: [f64, f64, f64, bool]),
|
||||
register_node!(graphene_core::vector::ResamplePoints<_, _, _, _>, input: VectorData, params: [f32, f32, f32, bool]),
|
||||
register_node!(graphene_core::vector::SplinesFromPointsNode, input: VectorData, params: []),
|
||||
register_node!(graphene_core::vector::generator_nodes::CircleGenerator<_>, input: (), params: [f32]),
|
||||
register_node!(graphene_core::vector::generator_nodes::EllipseGenerator<_, _>, input: (), params: [f32, f32]),
|
||||
@@ -748,7 +748,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
input: Vec<graphene_core::vector::bezier_rs::Subpath<graphene_core::uuid::ManipulatorGroupId>>,
|
||||
params: [Vec<graphene_core::uuid::ManipulatorGroupId>]
|
||||
),
|
||||
register_node!(graphene_core::text::TextGeneratorNode<_, _, _>, input: WasmEditorApi, params: [String, graphene_core::text::Font, f64]),
|
||||
register_node!(graphene_core::text::TextGeneratorNode<_, _, _>, input: WasmEditorApi, params: [String, graphene_core::text::Font, f32]),
|
||||
register_node!(graphene_std::brush::VectorPointsNode, input: VectorData, params: []),
|
||||
register_node!(graphene_core::ExtractImageFrame, input: WasmEditorApi, params: []),
|
||||
async_node!(graphene_core::ConstructLayerNode<_, _>, input: Footprint, output: GraphicGroup, fn_params: [Footprint => graphene_core::GraphicElement, Footprint => GraphicGroup]),
|
||||
|
||||
Reference in New Issue
Block a user