Rasterific-0.7.4.2: A pure haskell drawing engine.

Safe HaskellNone
LanguageHaskell2010

Graphics.Rasterific.MeshPatch

Contents

Description

Module defining the type of mesh patch grid.

Synopsis

Types

data InterBezier #

Store the two bezier control points of a bezier.

Constructors

InterBezier 

Fields

Instances
Eq InterBezier # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Show InterBezier # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

PointFoldable InterBezier # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

foldPoints :: (b -> Point -> b) -> b -> InterBezier -> b #

Transformable InterBezier # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

data Derivatives #

Store the inner points of a tensor patch.

Instances
Eq Derivatives # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Show Derivatives # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

PointFoldable Derivatives # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

foldPoints :: (b -> Point -> b) -> b -> Derivatives -> b #

Transformable Derivatives # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

data MeshPatch px #

Define a mesh patch grid, the grid is conceptually a regular grid of _meshPatchWidth * _meshPatchHeight patches but with shared edges

Constructors

MeshPatch 

Fields

Instances
Functor MeshPatch # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

fmap :: (a -> b) -> MeshPatch a -> MeshPatch b #

(<$) :: a -> MeshPatch b -> MeshPatch a #

Eq px => Eq (MeshPatch px) # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

(==) :: MeshPatch px -> MeshPatch px -> Bool #

(/=) :: MeshPatch px -> MeshPatch px -> Bool #

Show px => Show (MeshPatch px) # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

showsPrec :: Int -> MeshPatch px -> ShowS #

show :: MeshPatch px -> String #

showList :: [MeshPatch px] -> ShowS #

PointFoldable (MeshPatch px) # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

foldPoints :: (b -> Point -> b) -> b -> MeshPatch px -> b #

Transformable (MeshPatch px) # 
Instance details

Defined in Graphics.Rasterific.PatchTypes

Methods

transform :: (Point -> Point) -> MeshPatch px -> MeshPatch px #

transformM :: Monad m => (Point -> m Point) -> MeshPatch px -> m (MeshPatch px) #

newtype CubicCoefficient px #

Store information for cubic interpolation in a patch.

Constructors

CubicCoefficient 
Instances
(InterpolablePixel px, Num (Holder px Float)) => BiSampleable (CubicCoefficient px) px #

Bicubic interpolator

Instance details

Defined in Graphics.Rasterific.BiSampleable

Methods

interpolate :: CubicCoefficient px -> Float -> Float -> px #

Functions

calculateMeshColorDerivative :: forall px. InterpolablePixel px => MeshPatch px -> MeshPatch (Derivative px) #

Prepare a gradient mesh to use cubic color interpolation, see renderCubicMesh documentation to see the global use of this function.

verticeAt #

Arguments

:: MeshPatch px 
-> Int

Between 0 and _meshPatchWidth + 1 (excluded)

-> Int

Between 0 and _meshPatchHeight + 1 (excluded)

-> Point 

Retrieve a mesh primary vertice purely

generateLinearGrid #

Arguments

:: Int

Width in patch

-> Int

Height in patch

-> Point

Position of the upper left corner

-> V2 Float

Size of each patch in x adn y

-> Vector px

Vector of values, size must be (width + 1) * (height + 1)

-> MeshPatch px 

Generate a valid gradient with the shape of a simple grid using some simple information. You can use thawMesh and freezeMesh to mutate it.

generateImageMesh #

Arguments

:: Int

Horizontal cell count

-> Int

Vertical cell count

-> Point

Position of the corner upper left

-> Image px

Image to transform through a mesh

-> MeshPatch (ImageMesh px) 

Generate a meshpatch at the size given by the image and a number of cell in a mesh

Extraction functions

Simple

coonPatchAt #

Arguments

:: MeshPatch px 
-> Int

x

-> Int

y

-> CoonPatch (ParametricValues px) 

Extract a coon patch at a given position.

tensorPatchAt #

Arguments

:: MeshPatch px 
-> Int

x

-> Int

y

-> TensorPatch (ParametricValues px) 

Extract a tensor patch at a given position

coonImagePatchAt #

Arguments

:: MeshPatch (ImageMesh px) 
-> Int

x

-> Int

y

-> CoonPatch (ImageMesh px) 

Extract an image patch out of a mesh at a given position.

tensorImagePatchAt #

Arguments

:: MeshPatch (ImageMesh px) 
-> Int

x

-> Int

y

-> TensorPatch (ImageMesh px) 

Extract a tensor image patch out of a mesh at a given position.

coonPatchAtWithDerivative #

Arguments

:: InterpolablePixel px 
=> MeshPatch (Derivative px) 
-> Int

x

-> Int

y

-> CoonPatch (CubicCoefficient px) 

Extract a coon patch for cubic interpolation at a given position see calculateMeshColorDerivative

tensorPatchAtWithDerivative #

Arguments

:: InterpolablePixel px 
=> MeshPatch (Derivative px) 
-> Int

x

-> Int

y

-> TensorPatch (CubicCoefficient px) 

Extract a tensor patch for cubic interpolation at a given position see calculateMeshColorDerivative

Multiple

coonPatchesOf :: MeshPatch px -> [CoonPatch (ParametricValues px)] #

Extract a list of all the coon patches of the mesh.

tensorPatchesOf :: MeshPatch px -> [TensorPatch (ParametricValues px)] #

Extract a list of all the tensor patches of the mesh.

imagePatchesOf :: MeshPatch (ImageMesh px) -> [CoonPatch (ImageMesh px)] #

Extract all the coon patch of a mesh using an image interpolation.

tensorImagePatchesOf :: MeshPatch (ImageMesh px) -> [TensorPatch (ImageMesh px)] #

Extract all the tensor patch of a mesh using an image interpolation.

cubicCoonPatchesOf :: InterpolablePixel px => MeshPatch (Derivative px) -> [CoonPatch (CubicCoefficient px)] #

Extract all the coon patch of a mesh using cubic interpolation.

cubicTensorPatchesOf :: InterpolablePixel px => MeshPatch (Derivative px) -> [TensorPatch (CubicCoefficient px)] #

Extract all the tensor patch of a mesh using cubic interpolation.

Mutable mesh

data MutableMesh s px #

Mutable version of a MeshPatch

thawMesh :: PrimMonad m => MeshPatch px -> m (MutableMesh (PrimState m) px) #

Normal mesh to mutable mesh

freezeMesh :: PrimMonad m => MutableMesh (PrimState m) px -> m (MeshPatch px) #

Mutable mesh to freezed mesh.

Monadic mesh creation

withMesh :: MeshPatch px -> (forall m. (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) => m a) -> (a, MeshPatch px) #

Given an original MeshPatch, provide context to mutate it through modification functions.

setVertice #

Arguments

:: (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) 
=> Int

x coordinate in [0, w]

-> Int

y coordinate in [0, h]

-> Point

new point value

-> m () 

Set the vertice of a mesh at a given coordinate

getVertice :: (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) => Int -> Int -> m Point #

Get the position of vertice

setHorizPoints :: (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) => Int -> Int -> InterBezier -> m () #

Set the two control bezier points horizontally

setVertPoints :: (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) => Int -> Int -> InterBezier -> m () #

Set the two control bezier points vertically

setColor :: (MonadReader (MutableMesh (PrimState m) px) m, PrimMonad m) => Int -> Int -> px -> m () #

Set the value associated to a vertex