YoshikuniJujo on Nostr: ...
引数については、型クラスを利用して多相的になっているので、
Swz.zxy (1, 2, 3) -- (3, 1, 2)
Swz.zxy (1, 2, 3, 4, 5) -- (3, 1, 2)
みたいにできる。さらに
data Argb = Argb Alpha Red Green Blue deriving (Show, Generic)
instance Swizzle1 Argb where type X Argb = Alpha
instance Swizzle2 Argb where type Y Argb = Red
instance Swizzle3 Argb where type Z Argb = Green
instance Swizzle4 Argb where type W Argb = Blue
みたいにすれば、
someColor = Argb a r g b
rgba :: (Red, Green, Blue, Alpha)
rgba = Swz.yzwx someColor
みたいに使える。
Swz.zxy (1, 2, 3) -- (3, 1, 2)
Swz.zxy (1, 2, 3, 4, 5) -- (3, 1, 2)
みたいにできる。さらに
data Argb = Argb Alpha Red Green Blue deriving (Show, Generic)
instance Swizzle1 Argb where type X Argb = Alpha
instance Swizzle2 Argb where type Y Argb = Red
instance Swizzle3 Argb where type Z Argb = Green
instance Swizzle4 Argb where type W Argb = Blue
みたいにすれば、
someColor = Argb a r g b
rgba :: (Red, Green, Blue, Alpha)
rgba = Swz.yzwx someColor
みたいに使える。