Safe Haskell | None |
---|---|
Language | Haskell2010 |
Graphics.Rasterific.Immediate
Description
This module implements drawing primitives to draw directly into the output texture, without generating an intermediate scene representation.
If you need to draw complex scenes or plot an important set of data, this is the module you should use. The downside is that you must specify everything you need at each draw call, there is no API to help you propagate constants.
The "stroking" must be done using the functions of the
Outline
module.
- type DrawContext m px = StateT (MutableImage (PrimState m) px) m
- data DrawOrder px = DrawOrder {
- _orderPrimitives :: ![[Primitive]]
- _orderTexture :: !(Texture px)
- _orderFillMethod :: !FillMethod
- _orderMask :: !(Maybe (Texture (PixelBaseComponent px)))
- _orderDirect :: !(forall s. DrawContext (ST s) px ())
- orderToDrawing :: DrawOrder px -> Drawing px ()
- runDrawContext :: forall m px. (PrimMonad m, RenderablePixel px) => Int -> Int -> px -> DrawContext m px () -> m (Image px)
- fillWithTextureAndMask :: (PrimMonad m, RenderablePixel px) => FillMethod -> Texture px -> Texture (PixelBaseComponent px) -> [Primitive] -> DrawContext m px ()
- fillWithTexture :: (PrimMonad m, RenderablePixel px) => FillMethod -> Texture px -> [Primitive] -> DrawContext m px ()
- fillWithTextureNoAA :: (PrimMonad m, RenderablePixel px) => FillMethod -> Texture px -> [Primitive] -> DrawContext m px ()
- fillOrder :: (PrimMonad m, RenderablePixel px) => DrawOrder px -> DrawContext m px ()
- textToDrawOrders :: Dpi -> Texture px -> Point -> [TextRange px] -> [DrawOrder px]
- transformOrder :: (Point -> Point) -> DrawOrder px -> DrawOrder px
- meshToImage :: forall px. RenderablePixel px => Maybe Transformation -> Int -> Int -> PatchInterpolation -> MeshPatch px -> Image px
Documentation
type DrawContext m px = StateT (MutableImage (PrimState m) px) m #
Monad used to describe the drawing context.
Reify a filling function call, to be able to manipulate them in a simpler fashion.
Constructors
DrawOrder | |
Fields
|
Instances
Transformable (DrawOrder px) # | |
PlaneBoundable (DrawOrder px) # | |
orderToDrawing :: DrawOrder px -> Drawing px () #
Transform back a low level drawing order to a more high level Drawing
Arguments
:: (PrimMonad m, RenderablePixel px) | |
=> Int | Rendering width |
-> Int | Rendering height |
-> px | Background color |
-> DrawContext m px () | Actual drawing computation |
-> m (Image px) |
Start an image rendering. See fillWithTexture
for
an usage example. This function can work with either
IO
or ST
.
Arguments
:: (PrimMonad m, RenderablePixel px) | |
=> FillMethod | |
-> Texture px | Color/Texture used for the filling of the geometry |
-> Texture (PixelBaseComponent px) | Texture used for the mask. |
-> [Primitive] | Primitives to fill |
-> DrawContext m px () |
Fill some geometry using a composition mask for visibility.
immediateDrawMaskExample :: Image PixelRGBA8 immediateDrawMaskExample = runST $ runDrawContext 200 200 (PixelRGBA8 0 0 0 255) $ forM_ [1 .. 10] $ \ix -> fillWithTextureAndMask FillWinding texture mask $ rectangle (V2 10 (ix * 18 - 5)) 180 13 where texture = uniformTexture $ PixelRGBA8 0 0x86 0xc1 255 mask = sampledImageTexture $ runST $ runDrawContext 200 200 0 $ fillWithTexture FillWinding (uniformTexture 255) maskGeometry maskGeometry = strokize 15 JoinRound (CapRound, CapRound) $ circle (V2 100 100) 80
Arguments
:: (PrimMonad m, RenderablePixel px) | |
=> FillMethod | |
-> Texture px | Color/Texture used for the filling |
-> [Primitive] | Primitives to fill |
-> DrawContext m px () |
Fill some geometry.
immediateDrawExample :: Image PixelRGBA8 immediateDrawExample = runST $ runDrawContext 200 200 (PixelRGBA8 0 0 0 0) $ fillWithTexture FillWinding texture geometry where circlePrimitives = circle (V2 100 100) 50 geometry = strokize 4 JoinRound (CapRound, CapRound) circlePrimitives texture = uniformTexture (PixelRGBA8 255 255 255 255)
Arguments
:: (PrimMonad m, RenderablePixel px) | |
=> FillMethod | |
-> Texture px | Color/Texture used for the filling |
-> [Primitive] | Primitives to fill |
-> DrawContext m px () |
Function identical to fillWithTexture
but with anti-aliasing
(and transparency) disabled.
fillOrder :: (PrimMonad m, RenderablePixel px) => DrawOrder px -> DrawContext m px () #
Render the drawing orders on the canvas.
Arguments
:: Dpi | Current output device resolution |
-> Texture px | Texture to use if no texture is defined in the range |
-> Point | Baseline position |
-> [TextRange px] | Text description. |
-> [DrawOrder px] |
Helper function transforming text range to draw order.
meshToImage :: forall px. RenderablePixel px => Maybe Transformation -> Int -> Int -> PatchInterpolation -> MeshPatch px -> Image px #