@@ -87,66 +87,66 @@ impl PyColor {
8787
8888 #[ staticmethod]
8989 #[ pyo3( signature = ( r, g, b, a=1.0 ) ) ]
90- pub fn from_srgb ( r : f32 , g : f32 , b : f32 , a : f32 ) -> Self {
90+ pub fn srgb ( r : f32 , g : f32 , b : f32 , a : f32 ) -> Self {
9191 Self ( Color :: Srgba ( Srgba :: new ( r, g, b, a) ) )
9292 }
9393
9494 #[ staticmethod]
9595 #[ pyo3( signature = ( r, g, b, a=1.0 ) ) ]
96- pub fn from_linear ( r : f32 , g : f32 , b : f32 , a : f32 ) -> Self {
96+ pub fn linear ( r : f32 , g : f32 , b : f32 , a : f32 ) -> Self {
9797 Self ( Color :: LinearRgba ( LinearRgba :: new ( r, g, b, a) ) )
9898 }
9999
100100 #[ staticmethod]
101101 #[ pyo3( signature = ( h, s, l, a=1.0 ) ) ]
102- pub fn from_hsla ( h : f32 , s : f32 , l : f32 , a : f32 ) -> Self {
102+ pub fn hsla ( h : f32 , s : f32 , l : f32 , a : f32 ) -> Self {
103103 Self ( Color :: Hsla ( Hsla :: new ( h, s, l, a) ) )
104104 }
105105
106106 #[ staticmethod]
107107 #[ pyo3( signature = ( h, s, v, a=1.0 ) ) ]
108- pub fn from_hsva ( h : f32 , s : f32 , v : f32 , a : f32 ) -> Self {
108+ pub fn hsva ( h : f32 , s : f32 , v : f32 , a : f32 ) -> Self {
109109 Self ( Color :: Hsva ( Hsva :: new ( h, s, v, a) ) )
110110 }
111111
112112 #[ staticmethod]
113113 #[ pyo3( signature = ( h, w, b, a=1.0 ) ) ]
114- pub fn from_hwba ( h : f32 , w : f32 , b : f32 , a : f32 ) -> Self {
114+ pub fn hwba ( h : f32 , w : f32 , b : f32 , a : f32 ) -> Self {
115115 Self ( Color :: Hwba ( Hwba :: new ( h, w, b, a) ) )
116116 }
117117
118118 #[ staticmethod]
119119 #[ pyo3( signature = ( l, a_axis, b_axis, alpha=1.0 ) ) ]
120- pub fn from_oklab ( l : f32 , a_axis : f32 , b_axis : f32 , alpha : f32 ) -> Self {
120+ pub fn oklab ( l : f32 , a_axis : f32 , b_axis : f32 , alpha : f32 ) -> Self {
121121 Self ( Color :: Oklaba ( Oklaba :: new ( l, a_axis, b_axis, alpha) ) )
122122 }
123123
124124 #[ staticmethod]
125125 #[ pyo3( signature = ( l, c, h, a=1.0 ) ) ]
126- pub fn from_oklch ( l : f32 , c : f32 , h : f32 , a : f32 ) -> Self {
126+ pub fn oklch ( l : f32 , c : f32 , h : f32 , a : f32 ) -> Self {
127127 Self ( Color :: Oklcha ( Oklcha :: new ( l, c, h, a) ) )
128128 }
129129
130130 #[ staticmethod]
131131 #[ pyo3( signature = ( l, a_axis, b_axis, alpha=1.0 ) ) ]
132- pub fn from_lab ( l : f32 , a_axis : f32 , b_axis : f32 , alpha : f32 ) -> Self {
132+ pub fn lab ( l : f32 , a_axis : f32 , b_axis : f32 , alpha : f32 ) -> Self {
133133 Self ( Color :: Laba ( Laba :: new ( l, a_axis, b_axis, alpha) ) )
134134 }
135135
136136 #[ staticmethod]
137137 #[ pyo3( signature = ( l, c, h, a=1.0 ) ) ]
138- pub fn from_lch ( l : f32 , c : f32 , h : f32 , a : f32 ) -> Self {
138+ pub fn lch ( l : f32 , c : f32 , h : f32 , a : f32 ) -> Self {
139139 Self ( Color :: Lcha ( Lcha :: new ( l, c, h, a) ) )
140140 }
141141
142142 #[ staticmethod]
143143 #[ pyo3( signature = ( x, y, z, a=1.0 ) ) ]
144- pub fn from_xyz ( x : f32 , y : f32 , z : f32 , a : f32 ) -> Self {
144+ pub fn xyz ( x : f32 , y : f32 , z : f32 , a : f32 ) -> Self {
145145 Self ( Color :: Xyza ( Xyza :: new ( x, y, z, a) ) )
146146 }
147147
148148 #[ staticmethod]
149- pub fn from_hex ( s : & str ) -> PyResult < Self > {
149+ pub fn hex ( s : & str ) -> PyResult < Self > {
150150 parse_hex ( s) . map ( Self )
151151 }
152152
@@ -242,7 +242,7 @@ impl PyColor {
242242 self . 0 . set_alpha ( val) ;
243243 }
244244
245- fn hex ( & self ) -> String {
245+ fn to_hex ( & self ) -> String {
246246 to_srgba ( & self . 0 ) . to_hex ( )
247247 }
248248
@@ -493,7 +493,7 @@ mod tests {
493493
494494 #[ test]
495495 fn test_hsla_roundtrip ( ) {
496- let c = PyColor :: from_hsla ( 0.0 , 1.0 , 0.5 , 1.0 ) ;
496+ let c = PyColor :: hsla ( 0.0 , 1.0 , 0.5 , 1.0 ) ;
497497 let s = to_srgba ( & c. 0 ) ;
498498 assert ! ( ( s. red - 1.0 ) . abs( ) < 0.01 ) ;
499499 assert ! ( s. green < 0.01 ) ;
@@ -508,7 +508,7 @@ mod tests {
508508
509509 #[ test]
510510 fn test_oklch_roundtrip ( ) {
511- let c = PyColor :: from_oklch ( 0.7 , 0.15 , 30.0 , 1.0 ) ;
511+ let c = PyColor :: oklch ( 0.7 , 0.15 , 30.0 , 1.0 ) ;
512512 let ( l, ch, h, a) = c. to_oklch ( ) ;
513513 assert ! ( ( l - 0.7 ) . abs( ) < 0.01 ) ;
514514 assert ! ( ( ch - 0.15 ) . abs( ) < 0.01 ) ;
@@ -518,7 +518,7 @@ mod tests {
518518
519519 #[ test]
520520 fn test_linear_roundtrip ( ) {
521- let c = PyColor :: from_linear ( 0.5 , 0.25 , 0.1 , 0.8 ) ;
521+ let c = PyColor :: linear ( 0.5 , 0.25 , 0.1 , 0.8 ) ;
522522 let ( r, g, b, a) = c. to_linear ( ) ;
523523 assert ! ( ( r - 0.5 ) . abs( ) < 0.01 ) ;
524524 assert ! ( ( g - 0.25 ) . abs( ) < 0.01 ) ;
0 commit comments