mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 09:58:11 +08:00
Add camelcase rule, import Error type from JS and rename get_inner_color to inner. (#44)
* Add camelcase rule to .eslintrc.js * Import Error type from JS, rename crate::wrappers::Color::get_inner_color to crate::wrappers::Color::inner
This commit is contained in:
committed by
Keavon Chambers
parent
0156813dec
commit
fe111a6684
@@ -1,3 +1,4 @@
|
||||
use crate::shims::Error;
|
||||
use graphite_editor_core::tools::{SelectAppendMode, ToolType};
|
||||
use graphite_editor_core::Color as InnerColor;
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -8,13 +9,16 @@ pub struct Color(InnerColor);
|
||||
#[wasm_bindgen]
|
||||
impl Color {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self {
|
||||
Self(InnerColor::from_rgbaf32(red, green, blue, alpha).unwrap_throw())
|
||||
pub fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Result<Color, JsValue> {
|
||||
match InnerColor::from_rgbaf32(red, green, blue, alpha) {
|
||||
Ok(v) => Ok(Self(v)),
|
||||
Err(e) => Err(Error::new(&e.to_string()).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Color {
|
||||
pub fn get_inner_color(&self) -> InnerColor {
|
||||
pub fn inner(&self) -> InnerColor {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user