mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 10:56:10 +02:00
🎉 Add text solid strokes (#6384)
* 🎉 Add text strokes * 🔧 Minor refactor
This commit is contained in:
parent
44bf276c49
commit
61eb2f4a19
5 changed files with 166 additions and 23 deletions
|
@ -1,4 +1,4 @@
|
|||
use skia_safe::{self as skia};
|
||||
use skia_safe::{self as skia, paint::Paint};
|
||||
|
||||
use crate::render::BlendMode;
|
||||
use crate::uuid::Uuid;
|
||||
|
@ -811,6 +811,60 @@ impl Shape {
|
|||
pub fn has_fills(&self) -> bool {
|
||||
!self.fills.is_empty()
|
||||
}
|
||||
|
||||
pub fn get_text_stroke_paint(&self, stroke: &Stroke) -> Vec<Paint> {
|
||||
let mut paints = Vec::new();
|
||||
|
||||
match stroke.kind {
|
||||
StrokeKind::InnerStroke => {
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_blend_mode(skia::BlendMode::DstOver);
|
||||
paint.set_anti_alias(true);
|
||||
paints.push(paint);
|
||||
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_style(skia::PaintStyle::Stroke);
|
||||
paint.set_blend_mode(skia::BlendMode::SrcATop);
|
||||
paint.set_anti_alias(true);
|
||||
paint.set_stroke_width(stroke.width * 2.0);
|
||||
paint.set_color(match &stroke.fill {
|
||||
Fill::Solid(color) => *color,
|
||||
_ => Color::BLACK,
|
||||
});
|
||||
paints.push(paint);
|
||||
}
|
||||
StrokeKind::CenterStroke => {
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_style(skia::PaintStyle::Stroke);
|
||||
paint.set_anti_alias(true);
|
||||
paint.set_stroke_width(stroke.width);
|
||||
paint.set_color(match &stroke.fill {
|
||||
Fill::Solid(color) => *color,
|
||||
_ => Color::BLACK,
|
||||
});
|
||||
paints.push(paint);
|
||||
}
|
||||
StrokeKind::OuterStroke => {
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_style(skia::PaintStyle::Stroke);
|
||||
paint.set_blend_mode(skia::BlendMode::DstOver);
|
||||
paint.set_anti_alias(true);
|
||||
paint.set_stroke_width(stroke.width * 2.0);
|
||||
paint.set_color(match &stroke.fill {
|
||||
Fill::Solid(color) => *color,
|
||||
_ => Color::BLACK,
|
||||
});
|
||||
paints.push(paint);
|
||||
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_blend_mode(skia::BlendMode::Clear);
|
||||
paint.set_anti_alias(true);
|
||||
paints.push(paint);
|
||||
}
|
||||
}
|
||||
|
||||
paints
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue