This commit is contained in:
Chad Brokaw 2022-11-16 12:02:11 -05:00
parent 20f7b68514
commit 9adeaf3e82
3 changed files with 25 additions and 5 deletions

View file

@ -305,7 +305,12 @@ impl Recording {
buf_proxy
}
pub fn upload_image(&mut self, width: u32, height: u32, data: impl Into<Vec<u8>>) -> ImageProxy {
pub fn upload_image(
&mut self,
width: u32,
height: u32,
data: impl Into<Vec<u8>>,
) -> ImageProxy {
let data = data.into();
let image_proxy = ImageProxy::new(width, height);
self.push(Command::UploadImage(image_proxy, data));

View file

@ -143,7 +143,12 @@ pub fn render_full(scene: &Scene, shaders: &FullShaders) -> (Recording, BufProxy
let width = ramps.width();
let height = ramps.height();
let data: &[u8] = bytemuck::cast_slice(data);
println!("gradient image: {}x{} ({} bytes)", width, height, data.len());
println!(
"gradient image: {}x{} ({} bytes)",
width,
height,
data.len()
);
ResourceProxy::Image(recording.upload_image(width, height, data))
};
let n_pathtag = data.tag_stream.len();

View file

@ -15,7 +15,10 @@
// Also licensed under MIT license, at your choice.
use kurbo::BezPath;
use piet_scene::{Affine, Brush, Color, Fill, LinearGradient, PathElement, Point, Scene, SceneBuilder, Stroke, GradientStop};
use piet_scene::{
Affine, Brush, Color, Fill, GradientStop, LinearGradient, PathElement, Point, Scene,
SceneBuilder, Stroke,
};
use crate::pico_svg::PicoSvg;
@ -68,9 +71,16 @@ pub fn gen_test_scene() -> Scene {
offset: 1.0,
color: Color::rgb8(0, 0, 255),
},
].into()
]
.into(),
});
builder.fill(Fill::NonZero, Affine::scale(3.0, 3.0), &gradient, None, &path);
builder.fill(
Fill::NonZero,
Affine::scale(3.0, 3.0),
&gradient,
None,
&path,
);
}
_ => {
let xml_str =