Use custom color wrapper type everywhere in gpui & zed

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-08-03 12:48:58 -07:00
co-authored by Nathan Sobo
parent fa01273466
commit ef0ffbe819
20 changed files with 319 additions and 233 deletions
+11 -2
View File
@@ -1,7 +1,8 @@
use super::scene::{Path, PathVertex};
use crate::{color::ColorU, json::ToJson};
use crate::{color::Color, json::ToJson};
pub use pathfinder_geometry::*;
use rect::RectF;
use serde::{Deserialize, Deserializer};
use serde_json::json;
use vector::{vec2f, Vector2F};
@@ -55,7 +56,7 @@ impl PathBuilder {
self.current = point;
}
pub fn build(mut self, color: ColorU, clip_bounds: Option<RectF>) -> Path {
pub fn build(mut self, color: Color, clip_bounds: Option<RectF>) -> Path {
if let Some(clip_bounds) = clip_bounds {
self.bounds = self
.bounds
@@ -108,6 +109,14 @@ impl PathBuilder {
}
}
pub fn deserialize_vec2f<'de, D>(deserializer: D) -> Result<Vector2F, D::Error>
where
D: Deserializer<'de>,
{
let [x, y]: [f32; 2] = Deserialize::deserialize(deserializer)?;
Ok(vec2f(x, y))
}
impl ToJson for Vector2F {
fn to_json(&self) -> serde_json::Value {
json!([self.x(), self.y()])