chore: renamed the structs Vec2, Vec3, Vec4, Mat2, Mat3, Mat4, Point2, Point3 to v2, v3, v4, m2, m3, m4, p2, p3

This commit is contained in:
lisk77 2025-04-17 00:54:09 +02:00
parent 982323f671
commit fd8cf1f278
22 changed files with 430 additions and 430 deletions

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -106,11 +106,11 @@ impl Color for Hsla {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.hue, self.saturation, self.lightness, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.hue, self.saturation, self.lightness, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -104,11 +104,11 @@ impl Color for Hsva {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.hue, self.saturation, self.value, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.hue, self.saturation, self.value, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -167,11 +167,11 @@ impl Color for Hwba {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.hue, self.whiteness, self.blackness, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.hue, self.whiteness, self.blackness, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -148,11 +148,11 @@ impl Color for Laba {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.lightness, self.a, self.b, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.lightness, self.a, self.b, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Laba, LinearRgba, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -98,11 +98,11 @@ impl Color for Lcha {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.lightness, self.chroma, self.hue, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.lightness, self.chroma, self.hue, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,5 +1,5 @@
pub use comet_math as math;
use comet_math::Vec4;
use comet_math::v4;
pub use linear_rgba::*;
pub use rgba::*;
pub use hwba::*;
@ -24,6 +24,6 @@ mod oklcha;
pub trait Color: Copy {
fn to_wgpu(&self) -> wgpu::Color;
fn to_vec(&self) -> Vec4;
fn from_vec(color: Vec4) -> Self;
fn to_vec(&self) -> v4;
fn from_vec(color: v4) -> Self;
}

View file

@ -1,5 +1,5 @@
use wgpu;
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Laba, Lcha, Oklaba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -136,11 +136,11 @@ impl Color for LinearRgba {
}
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.red, self.green, self.blue, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.red, self.green, self.blue, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklcha, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -118,11 +118,11 @@ impl Color for Oklaba {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.lightness, self.a, self.b, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.lightness, self.a, self.b, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Xyza};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -97,11 +97,11 @@ impl Color for Oklcha {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.lightness, self.chroma, self.hue, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.lightness, self.chroma, self.hue, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}

View file

@ -1,4 +1,4 @@
use crate::{math::Vec4, Color, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
use crate::{math::v4, Color, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Xyza};
/// sRGB representation of color
/// There are two variants: `sRgba<u8>` and `sRgba<f32>`
@ -139,8 +139,8 @@ impl sRgba<u8> {
self.to_linear().to_oklaba()
}
pub fn to_vec(&self) -> Vec4 {
Vec4::new(
pub fn to_vec(&self) -> v4 {
v4::new(
self.red as f32,
self.green as f32,
self.blue as f32,
@ -334,8 +334,8 @@ impl sRgba<f32> {
self.to_hsva().to_hsla()
}
pub fn to_vec(&self) -> Vec4 {
Vec4::new(
pub fn to_vec(&self) -> v4 {
v4::new(
self.red,
self.green,
self.blue,
@ -349,11 +349,11 @@ impl Color for sRgba<f32> {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.red, self.green, self.blue, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.red, self.green, self.blue, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}
@ -363,8 +363,8 @@ impl Color for sRgba<u8> {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(
fn to_vec(&self) -> v4 {
v4::new(
self.red as f32,
self.green as f32,
self.blue as f32,
@ -372,7 +372,7 @@ impl Color for sRgba<u8> {
)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x() as u8, color.y() as u8, color.z() as u8, color.w() as u8)
}
}

View file

@ -1,4 +1,4 @@
use comet_math::Vec4;
use comet_math::v4;
use crate::{sRgba, Color, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha};
#[derive(Debug, Clone, PartialEq, Copy)]
@ -114,11 +114,11 @@ impl Color for Xyza {
self.to_linear().to_wgpu()
}
fn to_vec(&self) -> Vec4 {
Vec4::new(self.x, self.y, self.z, self.alpha)
fn to_vec(&self) -> v4 {
v4::new(self.x, self.y, self.z, self.alpha)
}
fn from_vec(color: Vec4) -> Self {
fn from_vec(color: v4) -> Self {
Self::new(color.x(), color.y(), color.z(), color.w())
}
}