mirror of
https://github.com/penpot/penpot.git
synced 2026-04-04 02:12:58 +02:00
WIP
This commit is contained in:
@@ -1271,13 +1271,37 @@ impl RenderState {
|
||||
_timestamp: i32,
|
||||
_sync_render: bool,
|
||||
) -> Result<(), String> {
|
||||
let mut p = skia::Paint::default();
|
||||
p.set_color(skia::Color::from_argb(255, 47, 44, 53));
|
||||
p.set_style(skia::PaintStyle::Fill);
|
||||
let fill_color = skia::Color::from_argb(255, 47, 44, 53);
|
||||
let rect = skia::Rect::from_xywh(600.0, 600.0, 200.0, 200.0);
|
||||
|
||||
let b = skia::image_filters::blur((32., 32.), None, None, None);
|
||||
p.set_image_filter(b);
|
||||
self.surfaces.get_mut(SurfaceId::Target).canvas().draw_rect(skia::Rect::from_xywh(600.0, 600.0, 200.0, 200.0), &p);
|
||||
// Blur margin: sigma 4 needs ~12px extra each side for Gaussian falloff
|
||||
let sigma = 32.0;
|
||||
let mut blur_rect = rect;
|
||||
blur_rect.outset((1., 1.));
|
||||
|
||||
let mut blur_paint = skia::Paint::default();
|
||||
blur_paint.set_image_filter(skia::image_filters::blur((sigma, sigma), Some(skia::TileMode::Clamp), None, None));
|
||||
|
||||
let canvas = self.surfaces.get_mut(SurfaceId::Target).canvas();
|
||||
// canvas.clear(self.background_color);
|
||||
let layer_rec = skia::canvas::SaveLayerRec::default()
|
||||
.bounds(&blur_rect)
|
||||
.paint(&blur_paint);
|
||||
canvas.save_layer(&layer_rec);
|
||||
|
||||
// Draw background first so the blur samples it at the edges (no halo when bg = fill)
|
||||
// let mut bg_paint = skia::Paint::default();
|
||||
// bg_paint.set_color(self.background_color);
|
||||
// bg_paint.set_style(skia::PaintStyle::Fill);
|
||||
// canvas.draw_rect(blur_rect, &bg_paint);
|
||||
|
||||
// Draw shape on top
|
||||
let mut shape_paint = skia::Paint::default();
|
||||
shape_paint.set_color(fill_color);
|
||||
shape_paint.set_style(skia::PaintStyle::Fill);
|
||||
canvas.draw_rect(rect, &shape_paint);
|
||||
|
||||
canvas.restore();
|
||||
self.flush_and_submit();
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user