Migrate demo artwork and fix all failing CI tests (#1459)

* Initial work on fixing tests

* Fix formatting

* Remove dead code to satisfy rustc warnings

* Insert into an artboard

* Load updated artwork in editor

* Remove popup when importing image

* Fix up demo art

* Change transform app[lication method

* Reduce number of enums called BlendMode

* Finalize the demo artwork upgrade

* Code review pass

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-11-19 01:06:19 +00:00
committed by Keavon Chambers
parent 719c96ecd8
commit 8a1cf3ad5d
40 changed files with 1238 additions and 477 deletions

View File

@@ -1,123 +0,0 @@
use serde::{Deserialize, Serialize};
use std::fmt;
/// Describes how overlapping SVG elements should be blended together.
/// See the [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/blend-mode#examples) for examples.
#[derive(PartialEq, Eq, Copy, Clone, Debug, Serialize, Deserialize, specta::Type)]
pub enum BlendMode {
// Normal group
Normal,
// Not supported by SVG, but we should someday support: Dissolve
// Darken group
Darken,
Multiply,
ColorBurn,
// Not supported by SVG, but we should someday support: Linear Burn, Darker Color
// Lighten group
Lighten,
Screen,
ColorDodge,
// Not supported by SVG, but we should someday support: Linear Dodge (Add), Lighter Color
// Contrast group
Overlay,
SoftLight,
HardLight,
// Not supported by SVG, but we should someday support: Vivid Light, Linear Light, Pin Light, Hard Mix
// Inversion group
Difference,
Exclusion,
// Not supported by SVG, but we should someday support: Subtract, Divide
// Component group
Hue,
Saturation,
Color,
Luminosity,
}
impl fmt::Display for BlendMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
// Normal group
BlendMode::Normal => write!(f, "Normal"),
// Darken group
BlendMode::Darken => write!(f, "Darken"),
BlendMode::Multiply => write!(f, "Multiply"),
BlendMode::ColorBurn => write!(f, "Color Burn"),
// Lighten group
BlendMode::Lighten => write!(f, "Lighten"),
BlendMode::Screen => write!(f, "Screen"),
BlendMode::ColorDodge => write!(f, "Color Dodge"),
// Contrast group
BlendMode::Overlay => write!(f, "Overlay"),
BlendMode::SoftLight => write!(f, "Soft Light"),
BlendMode::HardLight => write!(f, "Hard Light"),
// Inversion group
BlendMode::Difference => write!(f, "Difference"),
BlendMode::Exclusion => write!(f, "Exclusion"),
// Component group
BlendMode::Hue => write!(f, "Hue"),
BlendMode::Saturation => write!(f, "Saturation"),
BlendMode::Color => write!(f, "Color"),
BlendMode::Luminosity => write!(f, "Luminosity"),
}
}
}
impl BlendMode {
/// Convert the enum to the CSS string for the blend mode.
/// [Read more](https://developer.mozilla.org/en-US/docs/Web/CSS/blend-mode#values)
pub fn to_svg_style_name(&self) -> &str {
match self {
// Normal group
BlendMode::Normal => "normal",
// Darken group
BlendMode::Darken => "darken",
BlendMode::Multiply => "multiply",
BlendMode::ColorBurn => "color-burn",
// Lighten group
BlendMode::Lighten => "lighten",
BlendMode::Screen => "screen",
BlendMode::ColorDodge => "color-dodge",
// Contrast group
BlendMode::Overlay => "overlay",
BlendMode::SoftLight => "soft-light",
BlendMode::HardLight => "hard-light",
// Inversion group
BlendMode::Difference => "difference",
BlendMode::Exclusion => "exclusion",
// Component group
BlendMode::Hue => "hue",
BlendMode::Saturation => "saturation",
BlendMode::Color => "color",
BlendMode::Luminosity => "luminosity",
}
}
/// List of all the blend modes in their conventional ordering and grouping.
pub fn list_modes_in_groups() -> [&'static [BlendMode]; 6] {
[
// Normal group
&[BlendMode::Normal],
// Darken group
&[BlendMode::Darken, BlendMode::Multiply, BlendMode::ColorBurn],
// Lighten group
&[BlendMode::Lighten, BlendMode::Screen, BlendMode::ColorDodge],
// Contrast group
&[BlendMode::Overlay, BlendMode::SoftLight, BlendMode::HardLight],
// Inversion group
&[BlendMode::Difference, BlendMode::Exclusion],
// Component group
&[BlendMode::Hue, BlendMode::Saturation, BlendMode::Color, BlendMode::Luminosity],
]
}
}

View File

@@ -1,4 +1,3 @@
use super::blend_mode::BlendMode;
use super::folder_layer::FolderLayer;
use super::layer_layer::LayerLayer;
use super::shape_layer::ShapeLayer;
@@ -7,6 +6,7 @@ use crate::intersection::Quad;
use crate::DocumentError;
use crate::LayerId;
use graphene_core::raster::BlendMode;
use graphene_core::vector::VectorData;
use graphene_std::vector::subpath::Subpath;

View File

@@ -14,8 +14,6 @@
//! using the CSS [`mix-blend-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) property and the layer opacity.
pub mod base64_serde;
/// Different ways of combining overlapping SVG elements.
pub mod blend_mode;
/// Contains the [FolderLayer](folder_layer::FolderLayer) type that encapsulates other layers, including more folders.
pub mod folder_layer;
/// Contains the base [Layer](layer_info::Layer) type, an abstraction over the different types of layers.