Path Bool library code cleanup (#2000)

* Remove log statements

* Add feature gates to functions in path.rs

* Fix infinite parsing loop and add new test

* License tweaks

* Remove trailing zero in whole number floats

* Flatten visual-tests directory

* Code review

* Clean up printlines

* Add error handling to path parsing

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2024-09-23 12:16:31 +02:00
committed by GitHub
parent 3ddc052538
commit 8a1089938e
175 changed files with 442 additions and 346 deletions

View File

@@ -239,7 +239,7 @@ fn brush(_footprint: Footprint, image: ImageFrame<Color>, bounds: ImageFrame<Col
// For numerical stability we want to place the first blit point at a stable, integer offset
// in layer space.
let snap_offset = positions[0].floor() - positions[0];
let stroke_origin_in_layer = bbox.start - snap_offset - DVec2::splat(stroke.style.diameter / 2.0);
let stroke_origin_in_layer = bbox.start - snap_offset - DVec2::splat(stroke.style.diameter / 2.);
let stroke_to_layer = DAffine2::from_translation(stroke_origin_in_layer) * DAffine2::from_scale(stroke_size);
let normal_blend = BlendColorPairNode::new(CopiedNode::new(BlendMode::Normal), CopiedNode::new(100.));
@@ -297,7 +297,7 @@ fn brush(_footprint: Footprint, image: ImageFrame<Color>, bounds: ImageFrame<Col
}
}
let blend_params = BlendColorPairNode::new(CopiedNode::new(BlendMode::MultiplyAlpha), CopiedNode::new(100.0));
let blend_params = BlendColorPairNode::new(CopiedNode::new(BlendMode::MultiplyAlpha), CopiedNode::new(100.));
let blend_executor = BlendImageTupleNode::new(ValueNode::new(blend_params));
actual_image = blend_executor.eval((actual_image, erase_restore_mask));
}

View File

@@ -295,7 +295,7 @@ async fn blend_gpu_image(_: (), foreground: ImageFrame<Color>, background: Image
let fg_point = (*i4) * bg_point + (*i5);
if !((fg_point.cmpge(Vec2::ZERO) & bg_point.cmpge(Vec2::ZERO)) == BVec2::new(true, true)) {{
Color::from_rgbaf32_unchecked(0.0, 0.0, 0.0, 0.0)
Color::from_rgbaf32_unchecked(0., 0., 0., 0.)
}} else {{
i2[((fg_point.y as u32) * i3 + (fg_point.x as u32)) as usize]
}}

View File

@@ -22,8 +22,8 @@ async fn image_color_palette<F: 'n + Send>(
let bins = GRID * GRID * GRID;
let mut histogram: Vec<usize> = vec![0; (bins + 1.0) as usize];
let mut colors: Vec<Vec<Color>> = vec![vec![]; (bins + 1.0) as usize];
let mut histogram: Vec<usize> = vec![0; (bins + 1.) as usize];
let mut colors: Vec<Vec<Color>> = vec![vec![]; (bins + 1.) as usize];
let image = image.eval(footprint).await;
for pixel in image.image.data.iter() {
@@ -44,10 +44,10 @@ async fn image_color_palette<F: 'n + Send>(
for i in shorted.iter().take(max_size as usize) {
let list = colors[*i].clone();
let mut r = 0.0;
let mut g = 0.0;
let mut b = 0.0;
let mut a = 0.0;
let mut r = 0.;
let mut g = 0.;
let mut b = 0.;
let mut a = 0.;
for color in list.iter() {
r += color.r();
@@ -86,7 +86,7 @@ mod test {
image: Image {
width: 100,
height: 100,
data: vec![Color::from_rgbaf32(0.0, 0.0, 0.0, 1.0).unwrap(); 10000],
data: vec![Color::from_rgbaf32(0., 0., 0., 1.).unwrap(); 10000],
base64_string: None,
},
..Default::default()
@@ -94,6 +94,6 @@ mod test {
})
}),
};
assert_eq!(futures::executor::block_on(node.eval(())), [Color::from_rgbaf32(0.0, 0.0, 0.0, 1.0).unwrap()]);
assert_eq!(futures::executor::block_on(node.eval(())), [Color::from_rgbaf32(0., 0., 0., 1.).unwrap()]);
}
}

View File

@@ -517,10 +517,10 @@ pub fn pick_safe_imaginate_resolution((width, height): (f64, f64)) -> (u64, u64)
let scale = (MAX_RESOLUTION as f64 / resolution as f64).sqrt();
let size = size.as_dvec2() * scale;
if size.x < 64.0 {
if size.x < 64. {
// The image is extremely wide
(64, MAX_DIMENSION)
} else if size.y < 64.0 {
} else if size.y < 64. {
// The image is extremely high
(MAX_DIMENSION, 64)
} else {

View File

@@ -309,7 +309,7 @@ fn extend_image_to_bounds(image: ImageFrame<Color>, bounds: DAffine2) -> ImageFr
// Compute new transform.
// let layer_to_new_texture_space = (DAffine2::from_scale(1. / new_scale) * DAffine2::from_translation(new_start) * layer_to_image_space).inverse();
let new_texture_to_layer_space = image.transform * DAffine2::from_scale(1.0 / orig_image_scale) * DAffine2::from_translation(new_start) * DAffine2::from_scale(new_scale);
let new_texture_to_layer_space = image.transform * DAffine2::from_scale(1. / orig_image_scale) * DAffine2::from_translation(new_start) * DAffine2::from_scale(new_scale);
ImageFrame {
image: new_img,
transform: new_texture_to_layer_space,
@@ -641,10 +641,10 @@ fn mandelbrot(footprint: Footprint) -> ImageFrame<Color> {
#[inline(always)]
fn mandelbrot_impl(c: Vec2, max_iter: usize) -> usize {
let mut z = Vec2::new(0.0, 0.0);
let mut z = Vec2::new(0., 0.);
for i in 0..max_iter {
z = Vec2::new(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
if z.length_squared() > 4.0 {
z = Vec2::new(z.x * z.x - z.y * z.y, 2. * z.x * z.y) + c;
if z.length_squared() > 4. {
return i;
}
}

View File

@@ -45,7 +45,7 @@ async fn draw_image_frame(_: (), image: ImageFrame<graphene_core::raster::SRGBA8
// TODO: replace "2d" with "bitmaprenderer" once we switch to ImageBitmap (lives on gpu) from ImageData (lives on cpu)
let context = canvas.get_context("2d").unwrap().unwrap().dyn_into::<CanvasRenderingContext2d>().unwrap();
let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width, image.image.height).expect("Failed to construct ImageData");
context.put_image_data(&image_data, 0.0, 0.0).unwrap();
context.put_image_data(&image_data, 0., 0.).unwrap();
}
graphene_core::application_io::SurfaceHandleFrame {
surface_handle,