Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implementation using "An efficient algorithm for subdivising linear Coons surfaces" C.Yao and J.Rokne Computer aided design 8 (1991) 291-303
Synopsis
- data CoonPatch weight = CoonPatch {
- _north :: !CubicBezier
- _east :: !CubicBezier
- _south :: !CubicBezier
- _west :: !CubicBezier
- _coonValues :: !weight
- data TensorPatch weight = TensorPatch {
- _curve0 :: !CubicBezier
- _curve1 :: !CubicBezier
- _curve2 :: !CubicBezier
- _curve3 :: !CubicBezier
- _tensorValues :: !weight
- data ParametricValues a = ParametricValues {
- _northValue :: !a
- _eastValue :: !a
- _southValue :: !a
- _westValue :: !a
- data PatchInterpolation
- type CoonColorWeight = Float
- data Subdivided a = Subdivided {
- _northWest :: !a
- _northEast :: !a
- _southWest :: !a
- _southEast :: !a
- class (Applicative (Holder a), Functor (Holder a), Foldable (Holder a), Additive (Holder a)) => InterpolablePixel a
- rasterizeTensorPatch :: (PrimMonad m, ModulablePixel px, BiSampleable src px) => TensorPatch src -> DrawContext m px ()
- rasterizeCoonPatch :: (PrimMonad m, ModulablePixel px, BiSampleable src px) => CoonPatch src -> DrawContext m px ()
- renderImageMesh :: PrimMonad m => MeshPatch (ImageMesh PixelRGBA8) -> DrawContext m PixelRGBA8 ()
- renderCoonMesh :: forall m px. (PrimMonad m, RenderablePixel px, BiSampleable (ParametricValues px) px) => MeshPatch px -> DrawContext m px ()
- renderCoonMeshBicubic :: forall m px. (PrimMonad m, RenderablePixel px, BiSampleable (CubicCoefficient px) px) => MeshPatch px -> DrawContext m px ()
- renderCoonPatch :: forall m interp px. (PrimMonad m, RenderablePixel px, BiSampleable interp px) => CoonPatch interp -> DrawContext m px ()
- renderCoonPatchAtDeepness :: forall m interp px. (PrimMonad m, RenderablePixel px, BiSampleable interp px) => Int -> CoonPatch interp -> DrawContext m px ()
- renderTensorPatch :: forall m sampled px. (PrimMonad m, RenderablePixel px, BiSampleable sampled px) => TensorPatch sampled -> DrawContext m px ()
- renderTensorPatchAtDeepness :: forall m sampled px. (PrimMonad m, RenderablePixel px, BiSampleable sampled px) => Int -> TensorPatch sampled -> DrawContext m px ()
- data DebugOption = DebugOption {}
- defaultDebug :: DebugOption
- drawCoonPatchOutline :: CoonPatch px -> Drawing pxb ()
- debugDrawCoonPatch :: DebugOption -> CoonPatch (ParametricValues PixelRGBA8) -> Drawing PixelRGBA8 ()
- debugDrawTensorPatch :: DebugOption -> TensorPatch (ParametricValues px) -> Drawing PixelRGBA8 ()
- parametricBase :: UVPatch
- subdividePatch :: CoonPatch UVPatch -> Subdivided (CoonPatch UVPatch)
- subdivideTensorPatch :: TensorPatch UVPatch -> Subdivided (TensorPatch UVPatch)
- horizontalTensorSubdivide :: TensorPatch UVPatch -> (TensorPatch UVPatch, TensorPatch UVPatch)
- transposePatch :: TensorPatch (ParametricValues a) -> TensorPatch (ParametricValues a)
Types
data CoonPatch weight Source #
Define the boundary and interpolated values of a coon patch.
-----> North _____----------------+ ^ +------------/ / . | / / | | / / | | / / east | | west | / | | | v \ \ . \ __-------------+ +----------------/ South <-----
CoonPatch | |
|
Instances
Show weight => Show (CoonPatch weight) Source # | |
PointFoldable (CoonPatch px) Source # | |
Defined in Graphics.Rasterific.PatchTypes foldPoints :: (b -> Point -> b) -> b -> CoonPatch px -> b Source # | |
Transformable (CoonPatch px) Source # | |
data TensorPatch weight Source #
Describe a tensor patch
TensorPatch | |
|
Instances
PointFoldable (TensorPatch px) Source # | |
Defined in Graphics.Rasterific.PatchTypes foldPoints :: (b -> Point -> b) -> b -> TensorPatch px -> b Source # | |
Transformable (TensorPatch px) Source # | |
Defined in Graphics.Rasterific.PatchTypes transform :: (Point -> Point) -> TensorPatch px -> TensorPatch px Source # transformM :: Monad m => (Point -> m Point) -> TensorPatch px -> m (TensorPatch px) Source # |
data ParametricValues a Source #
Values associated to the corner of a patch
North East +--------------+ |0 1| | | | | | | |3 2| +--------------+ West South
ParametricValues | |
|
Instances
data PatchInterpolation Source #
How do we want to perform color/image interpolation within the patch.
PatchBilinear | Bilinear interpolation import qualified Data.Vector as V let colorCycle = cycle [ PixelRGBA8 0 0x86 0xc1 255 , PixelRGBA8 0xff 0xf4 0xc1 255 , PixelRGBA8 0xFF 0x53 0x73 255 , PixelRGBA8 0xff 0xf4 0xc1 255 , PixelRGBA8 0 0x86 0xc1 255] colors = V.fromListN (4 * 4) colorCycle renderMeshPatch PatchBilinear $ generateLinearGrid 3 3 (V2 10 10) (V2 60 60) colors |
PatchBicubic | Bicubic interpolation import qualified Data.Vector as V let colorCycle = cycle [ PixelRGBA8 0 0x86 0xc1 255 , PixelRGBA8 0xff 0xf4 0xc1 255 , PixelRGBA8 0xFF 0x53 0x73 255 , PixelRGBA8 0xff 0xf4 0xc1 255 , PixelRGBA8 0 0x86 0xc1 255] colors = V.fromListN (4 * 4) colorCycle renderMeshPatch PatchBicubic $ generateLinearGrid 3 3 (V2 10 10) (V2 60 60) colors |
Instances
Eq PatchInterpolation Source # | |
Defined in Graphics.Rasterific.PatchTypes (==) :: PatchInterpolation -> PatchInterpolation -> Bool # (/=) :: PatchInterpolation -> PatchInterpolation -> Bool # | |
Show PatchInterpolation Source # | |
Defined in Graphics.Rasterific.PatchTypes showsPrec :: Int -> PatchInterpolation -> ShowS # show :: PatchInterpolation -> String # showList :: [PatchInterpolation] -> ShowS # |
type CoonColorWeight = Float Source #
Type of coordinate interpolation
data Subdivided a Source #
Store the new generated information after subdivision in 4 quadrants.
Subdivided | |
|
class (Applicative (Holder a), Functor (Holder a), Foldable (Holder a), Additive (Holder a)) => InterpolablePixel a Source #
Used for Coon patch rendering
toFloatPixel, fromFloatPixel, maxRepresentable
Instances
InterpolablePixel Float Source # | |
Defined in Graphics.Rasterific.Compositor toFloatPixel :: Float -> Holder Float Float fromFloatPixel :: Holder Float Float -> Float maxRepresentable :: Proxy Float -> Float | |
InterpolablePixel Word8 Source # | |
Defined in Graphics.Rasterific.Compositor toFloatPixel :: Word8 -> Holder Word8 Float fromFloatPixel :: Holder Word8 Float -> Word8 maxRepresentable :: Proxy Word8 -> Float | |
InterpolablePixel PixelRGB8 Source # | |
Defined in Graphics.Rasterific.Compositor toFloatPixel :: PixelRGB8 -> Holder PixelRGB8 Float fromFloatPixel :: Holder PixelRGB8 Float -> PixelRGB8 maxRepresentable :: Proxy PixelRGB8 -> Float | |
InterpolablePixel PixelRGBA8 Source # | |
Defined in Graphics.Rasterific.Compositor type Holder PixelRGBA8 :: * -> * toFloatPixel :: PixelRGBA8 -> Holder PixelRGBA8 Float fromFloatPixel :: Holder PixelRGBA8 Float -> PixelRGBA8 maxRepresentable :: Proxy PixelRGBA8 -> Float |
Rendering functions
Using Fast Forward Differences
rasterizeTensorPatch :: (PrimMonad m, ModulablePixel px, BiSampleable src px) => TensorPatch src -> DrawContext m px () Source #
Rasterize a tensor patch using the Fast Forward Diffrence algorithm, likely to be faster than the subdivision one.
rasterizeCoonPatch :: (PrimMonad m, ModulablePixel px, BiSampleable src px) => CoonPatch src -> DrawContext m px () Source #
Rasterize a coon patch using the Fast Forward Diffrence algorithm, likely to be faster than the subdivision one.
renderImageMesh :: PrimMonad m => MeshPatch (ImageMesh PixelRGBA8) -> DrawContext m PixelRGBA8 () Source #
Render an mesh patch by interpolating accross an image.
renderCoonMesh :: forall m px. (PrimMonad m, RenderablePixel px, BiSampleable (ParametricValues px) px) => MeshPatch px -> DrawContext m px () Source #
Render a simple coon mesh, with only color on the vertices.
renderCoonMeshBicubic :: forall m px. (PrimMonad m, RenderablePixel px, BiSampleable (CubicCoefficient px) px) => MeshPatch px -> DrawContext m px () Source #
Render a coon mesh but using cubic interpolation for the color.
Subdivision patch rendering
renderCoonPatch :: forall m interp px. (PrimMonad m, RenderablePixel px, BiSampleable interp px) => CoonPatch interp -> DrawContext m px () Source #
Render a coon patch using the subdivision algorithm (potentially slower and less precise in case of image mesh.
renderCoonPatchAtDeepness Source #
:: (PrimMonad m, RenderablePixel px, BiSampleable interp px) | |
=> Int | Maximum subdivision deepness |
-> CoonPatch interp | |
-> DrawContext m px () |
Render a coon patch using the subdivision algorithm (potentially slower and less precise in case of image mesh). You can provide a max deepness
renderTensorPatch :: forall m sampled px. (PrimMonad m, RenderablePixel px, BiSampleable sampled px) => TensorPatch sampled -> DrawContext m px () Source #
renderTensorPatchAtDeepness :: forall m sampled px. (PrimMonad m, RenderablePixel px, BiSampleable sampled px) => Int -> TensorPatch sampled -> DrawContext m px () Source #
Render a tensor patch using the subdivision algorithm (potentially slower and less precise in case of image mesh.
Debugging
data DebugOption Source #
Used to describe how to debug print a coon/tensort patch.
DebugOption | |
|
defaultDebug :: DebugOption Source #
Default options drawing nearly everything.
drawCoonPatchOutline :: CoonPatch px -> Drawing pxb () Source #
Draw the 4 bezier spline representing the boundary of a coon patch.
debugDrawCoonPatch :: DebugOption -> CoonPatch (ParametricValues PixelRGBA8) -> Drawing PixelRGBA8 () Source #
Helper function drawing many information about a coon patch.
debugDrawTensorPatch :: DebugOption -> TensorPatch (ParametricValues px) -> Drawing PixelRGBA8 () Source #
Helper function drawing many information about a tensor patch.
parametricBase :: UVPatch Source #
Define the unit square in [0, 1]^2
Manipulation
subdividePatch :: CoonPatch UVPatch -> Subdivided (CoonPatch UVPatch) Source #
Split a coon patch into four new quadrants
subdivideTensorPatch :: TensorPatch UVPatch -> Subdivided (TensorPatch UVPatch) Source #
Subdivide a tensor patch into 4 new quadrant. Perform twice the horizontal subdivision with a transposition.
horizontalTensorSubdivide :: TensorPatch UVPatch -> (TensorPatch UVPatch, TensorPatch UVPatch) Source #
Perform an operation like:
o--------o--------o--------o | | | | | | | | | | | | o--------o--------o--------o | | | | | | | | | | | | o--------o--------o--------o | | | | | | | | | | | | o--------o--------o--------o | | | | | | | | | | | | o--------o--------o--------o to (more or less) o----*---o----*----o----*---o | | | | | | | | | | | | | | | | | | | | | o----*---o----*----o----*---o | | | | | | | | | | | | | | | | | | | | | o----*---o----*----o----*---o | | | | | | | | | | | | | | | | | | | | | o----*---o----*----o----*---o | | | | | | | | | | | | | | | | | | | | | o----*---o----*----o----*---o ------------------------- Left Right
transposePatch :: TensorPatch (ParametricValues a) -> TensorPatch (ParametricValues a) Source #
Swap vertical/horizontal orientation of a tensor patch