geomancy-0.4.0.0: src/Geomancy/Swizzle/Vec/Extend.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Geomancy.Swizzle.Vec.Extend () where
import GHC.Records (HasField(..))
import Geomancy.Vec2 (Vec2, withVec2)
import Geomancy.Vec3 (Vec3, vec3, withVec3)
import Geomancy.Vec4 (Vec4, vec4)
instance HasField "xy0" Vec2 Vec3 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec3 x y 0
instance HasField "xy1" Vec2 Vec3 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec3 x y 1
instance HasField "xy00" Vec2 Vec4 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec4 x y 0 0
instance HasField "xy01" Vec2 Vec4 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec4 x y 0 1
instance HasField "xy10" Vec2 Vec4 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec4 x y 1 0
instance HasField "xy11" Vec2 Vec4 where
{-# INLINE getField #-}
getField v = withVec2 v \x y -> vec4 x y 1 1
instance HasField "xyz0" Vec3 Vec4 where
{-# INLINE getField #-}
getField v = withVec3 v \x y z -> vec4 x y z 0
instance HasField "xyz1" Vec3 Vec4 where
{-# INLINE getField #-}
getField v = withVec3 v \x y z -> vec4 x y z 1