mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 04:58:11 +08:00
Apply lints and cleanup to Rust code
This commit is contained in:
@@ -72,7 +72,7 @@ impl FolderLayer {
|
||||
let mut insert_index = insert_index as i128;
|
||||
|
||||
if insert_index < 0 {
|
||||
insert_index = self.layers.len() as i128 + insert_index as i128 + 1;
|
||||
insert_index = self.layers.len() as i128 + insert_index + 1;
|
||||
}
|
||||
|
||||
if insert_index <= self.layers.len() as i128 && insert_index >= 0 {
|
||||
|
||||
@@ -21,9 +21,10 @@ fn format_opacity(name: &str, opacity: f32) -> String {
|
||||
}
|
||||
|
||||
/// Represents different ways of rendering an object
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, specta::Type)]
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, specta::Type)]
|
||||
pub enum ViewMode {
|
||||
/// Render with normal coloration at the current viewport resolution
|
||||
#[default]
|
||||
Normal,
|
||||
/// Render only the outlines of shapes at the current viewport resolution
|
||||
Outline,
|
||||
@@ -31,12 +32,6 @@ pub enum ViewMode {
|
||||
Pixels,
|
||||
}
|
||||
|
||||
impl Default for ViewMode {
|
||||
fn default() -> Self {
|
||||
ViewMode::Normal
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains metadata for rendering the document as an svg
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct RenderData<'a> {
|
||||
@@ -55,18 +50,13 @@ impl<'a> RenderData<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash, Serialize, Deserialize, specta::Type)]
|
||||
#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Hash, Serialize, Deserialize, specta::Type)]
|
||||
pub enum GradientType {
|
||||
#[default]
|
||||
Linear,
|
||||
Radial,
|
||||
}
|
||||
|
||||
impl Default for GradientType {
|
||||
fn default() -> Self {
|
||||
GradientType::Linear
|
||||
}
|
||||
}
|
||||
|
||||
/// A gradient fill.
|
||||
///
|
||||
/// Contains the start and end points, along with the colors at varying points along the length.
|
||||
@@ -183,19 +173,14 @@ impl Gradient {
|
||||
///
|
||||
/// Can be None, a solid [Color], a linear [Gradient], a radial [Gradient] or potentially some sort of image or pattern in the future
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, specta::Type)]
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, specta::Type)]
|
||||
pub enum Fill {
|
||||
#[default]
|
||||
None,
|
||||
Solid(Color),
|
||||
Gradient(Gradient),
|
||||
}
|
||||
|
||||
impl Default for Fill {
|
||||
fn default() -> Self {
|
||||
Self::None
|
||||
}
|
||||
}
|
||||
|
||||
impl Fill {
|
||||
/// Construct a new solid [Fill] from a [Color].
|
||||
pub fn solid(color: Color) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user