mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Fix fills and strokes opacity shouldn't affect shadows
This commit is contained in:
@@ -22,7 +22,9 @@ use options::RenderOptions;
|
|||||||
pub use surfaces::{SurfaceId, Surfaces};
|
pub use surfaces::{SurfaceId, Surfaces};
|
||||||
|
|
||||||
use crate::performance;
|
use crate::performance;
|
||||||
use crate::shapes::{Blur, BlurType, Corners, Fill, Shadow, Shape, StructureEntry, Type};
|
use crate::shapes::{
|
||||||
|
Blur, BlurType, Corners, Fill, Shadow, Shape, SolidColor, Stroke, StructureEntry, Type,
|
||||||
|
};
|
||||||
use crate::state::ShapesPool;
|
use crate::state::ShapesPool;
|
||||||
use crate::textlayout::{
|
use crate::textlayout::{
|
||||||
paragraph_builder_group_from_text, stroke_paragraph_builder_group_from_text,
|
paragraph_builder_group_from_text, stroke_paragraph_builder_group_from_text,
|
||||||
@@ -1062,9 +1064,32 @@ impl RenderState {
|
|||||||
) {
|
) {
|
||||||
let mut transformed_shadow: Cow<Shadow> = Cow::Borrowed(shadow);
|
let mut transformed_shadow: Cow<Shadow> = Cow::Borrowed(shadow);
|
||||||
transformed_shadow.to_mut().offset = (0., 0.);
|
transformed_shadow.to_mut().offset = (0., 0.);
|
||||||
transformed_shadow.to_mut().color = skia::Color::from_argb(255, 0, 0, 0);
|
transformed_shadow.to_mut().color = skia::Color::BLACK;
|
||||||
transformed_shadow.to_mut().blur = transformed_shadow.blur * scale;
|
transformed_shadow.to_mut().blur = transformed_shadow.blur * scale;
|
||||||
|
|
||||||
|
let mut plain_shape = Cow::Borrowed(shape);
|
||||||
|
|
||||||
|
// The opacity of fills and strokes shouldn't affect the shadow,
|
||||||
|
// so we paint everything black with the same opacity
|
||||||
|
plain_shape.to_mut().clear_fills();
|
||||||
|
if shape.has_fills() {
|
||||||
|
plain_shape
|
||||||
|
.to_mut()
|
||||||
|
.add_fill(Fill::Solid(SolidColor(skia::Color::BLACK)));
|
||||||
|
}
|
||||||
|
|
||||||
|
plain_shape.to_mut().clear_strokes();
|
||||||
|
for stroke in shape.strokes.iter() {
|
||||||
|
plain_shape.to_mut().add_stroke(Stroke {
|
||||||
|
fill: Fill::Solid(SolidColor(skia::Color::BLACK)),
|
||||||
|
width: stroke.width,
|
||||||
|
style: stroke.style.clone(),
|
||||||
|
cap_end: stroke.cap_end,
|
||||||
|
cap_start: stroke.cap_start,
|
||||||
|
kind: stroke.kind,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let mut shadow_paint = skia::Paint::default();
|
let mut shadow_paint = skia::Paint::default();
|
||||||
shadow_paint.set_image_filter(transformed_shadow.get_drop_shadow_filter());
|
shadow_paint.set_image_filter(transformed_shadow.get_drop_shadow_filter());
|
||||||
shadow_paint.set_blend_mode(skia::BlendMode::SrcOver);
|
shadow_paint.set_blend_mode(skia::BlendMode::SrcOver);
|
||||||
@@ -1085,7 +1110,7 @@ impl RenderState {
|
|||||||
shapes,
|
shapes,
|
||||||
modifiers,
|
modifiers,
|
||||||
structure,
|
structure,
|
||||||
shape,
|
&plain_shape,
|
||||||
scale_content,
|
scale_content,
|
||||||
clip_bounds,
|
clip_bounds,
|
||||||
SurfaceId::DropShadows,
|
SurfaceId::DropShadows,
|
||||||
|
|||||||
Reference in New Issue
Block a user