You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When @svgeesus and I defined the Color API instead of the exotic properties we use in Color.js we went with .get() and .set() methods that are more consistent with the rest of the Web Platform, since there's guidance to avoid exotic properties as they conflate object properties with data.
These methods have several advantages over the current syntax:
Object properties clearly separate from data
Ability to look up coordinates by ColorSpace object which allows for anonymous color spaces
Ability to set multiple coordinates at once, or even in a relative way
Properties hide the fact that these are actually performing conversion behind the scenes. It's easy for someone to use color.lch.lightness and then later on color.lch.chroma without ever thinking of caching color.lch. OTOH, we could cache it behind the scenes.
Currently color.to() to convert to another Color object is a method, but color.<colorspace> to get coordinates in another colorspace is a property. This is pretty weird, and I've often done things like color.lch expecting a color and not an array.
These methods should also be implemented in Color.js, so that it can be used as a polyfill of the Color API.
The text was updated successfully, but these errors were encountered:
When @svgeesus and I defined the Color API instead of the exotic properties we use in Color.js we went with
.get()
and.set()
methods that are more consistent with the rest of the Web Platform, since there's guidance to avoid exotic properties as they conflate object properties with data.These methods have several advantages over the current syntax:
color.lch.lightness
and then later oncolor.lch.chroma
without ever thinking of cachingcolor.lch
. OTOH, we could cache it behind the scenes.color.to()
to convert to anotherColor
object is a method, butcolor.<colorspace>
to get coordinates in another colorspace is a property. This is pretty weird, and I've often done things likecolor.lch
expecting a color and not an array.These methods should also be implemented in Color.js, so that it can be used as a polyfill of the Color API.
The text was updated successfully, but these errors were encountered: