mirror of
https://github.com/penpot/penpot.git
synced 2025-07-22 21:17:13 +02:00
✨ Serialize solid fills as bytes (wasm)
This commit is contained in:
parent
81f18ad7f4
commit
093fa18839
7 changed files with 73 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
use skia_safe::{self as skia, Rect};
|
||||
|
||||
use super::Color;
|
||||
pub use super::Color;
|
||||
use crate::uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
@ -112,9 +112,12 @@ impl ImageFill {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
pub struct SolidColor(pub Color);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Fill {
|
||||
Solid(Color),
|
||||
Solid(SolidColor),
|
||||
LinearGradient(Gradient),
|
||||
RadialGradient(Gradient),
|
||||
Image(ImageFill),
|
||||
|
@ -132,7 +135,7 @@ impl Fill {
|
|||
|
||||
pub fn to_paint(&self, rect: &Rect, anti_alias: bool) -> skia::Paint {
|
||||
match self {
|
||||
Self::Solid(color) => {
|
||||
Self::Solid(SolidColor(color)) => {
|
||||
let mut p = skia::Paint::default();
|
||||
p.set_color(*color);
|
||||
p.set_style(skia::PaintStyle::Fill);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::shapes::fills::Fill;
|
||||
use crate::shapes::fills::{Fill, SolidColor};
|
||||
use skia_safe::{self as skia, Rect};
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -78,10 +78,9 @@ impl Stroke {
|
|||
}
|
||||
|
||||
pub fn new_center_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) -> Self {
|
||||
let transparent = skia::Color::from_argb(0, 0, 0, 0);
|
||||
Stroke {
|
||||
fill: Fill::Solid(transparent),
|
||||
width: width,
|
||||
fill: Fill::Solid(SolidColor(skia::Color::TRANSPARENT)),
|
||||
width,
|
||||
style: StrokeStyle::from(style),
|
||||
cap_end: StrokeCap::from(cap_end),
|
||||
cap_start: StrokeCap::from(cap_start),
|
||||
|
@ -90,10 +89,9 @@ impl Stroke {
|
|||
}
|
||||
|
||||
pub fn new_inner_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) -> Self {
|
||||
let transparent = skia::Color::from_argb(0, 0, 0, 0);
|
||||
Stroke {
|
||||
fill: Fill::Solid(transparent),
|
||||
width: width,
|
||||
fill: Fill::Solid(SolidColor(skia::Color::TRANSPARENT)),
|
||||
width,
|
||||
style: StrokeStyle::from(style),
|
||||
cap_end: StrokeCap::from(cap_end),
|
||||
cap_start: StrokeCap::from(cap_start),
|
||||
|
@ -102,10 +100,9 @@ impl Stroke {
|
|||
}
|
||||
|
||||
pub fn new_outer_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) -> Self {
|
||||
let transparent = skia::Color::from_argb(0, 0, 0, 0);
|
||||
Stroke {
|
||||
fill: Fill::Solid(transparent),
|
||||
width: width,
|
||||
fill: Fill::Solid(SolidColor(skia::Color::TRANSPARENT)),
|
||||
width,
|
||||
style: StrokeStyle::from(style),
|
||||
cap_end: StrokeCap::from(cap_end),
|
||||
cap_start: StrokeCap::from(cap_start),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue