simplifying drawing for performance purposes.
Does not yet work
This commit is contained in:
parent
4e20d26c97
commit
af5526c650
1 changed files with 27 additions and 19 deletions
|
@ -19,26 +19,19 @@ drawRect
|
||||||
-> G.Color -- ^ Color to draw in
|
-> G.Color -- ^ Color to draw in
|
||||||
-> DrawType -- ^ Draw type
|
-> DrawType -- ^ Draw type
|
||||||
-> GeglRectangle -- ^ Dimensions of Rectangle
|
-> GeglRectangle -- ^ Dimensions of Rectangle
|
||||||
-> Affection a ()
|
-> IO ()
|
||||||
drawRect buf color dt rect@G.GeglRectangle{..} =
|
drawRect buf color (Fill) rect@G.GeglRectangle{..} =
|
||||||
liftIO $ G.iterateOver buf rect (B.PixelFormat B.RGBA B.CFdouble) G.GeglAccessReadWrite G.GeglAbyssNone $
|
G.pixelPoke buf rect (B.PixelFormat B.RGBA B.CFdouble) G.GeglAccessReadWrite G.GeglAbyssNone $
|
||||||
(\(G.Pixel px py pc) ->
|
(\(x, y) ->
|
||||||
case dt of
|
let col = unsafeColorize color
|
||||||
Fill ->
|
in
|
||||||
let col = colorize pc color
|
G.Pixel x y col
|
||||||
in
|
|
||||||
G.Pixel px py col
|
|
||||||
Line width ->
|
|
||||||
if (px >= rectangleX && px <= (rectangleX + width) ||
|
|
||||||
px <= (rectangleX + rectangleWidth) && px >= (rectangleX + rectangleWidth - width)) &&
|
|
||||||
(py >= rectangleY && py <= (rectangleY + width) ||
|
|
||||||
py <= (rectangleY + rectangleHeight) && py >= (rectangleY + rectangleHeight - width))
|
|
||||||
then
|
|
||||||
let col = colorize pc color
|
|
||||||
in G.Pixel px py col
|
|
||||||
else
|
|
||||||
G.Pixel px py pc
|
|
||||||
)
|
)
|
||||||
|
drawRect buf color (Line size) rect@G.GeglRectangle{..} = do
|
||||||
|
drawRect buf color Fill (G.GeglRectangle rectangleX rectangleY rectangleWidth size)
|
||||||
|
drawRect buf color Fill (G.GeglRectangle rectangleX rectangleY size rectangleHeight)
|
||||||
|
drawRect buf color Fill (G.GeglRectangle (rectangleWidth - size) rectangleY size rectangleHeight)
|
||||||
|
drawRect buf color Fill (G.GeglRectangle rectangleX (rectangleHeight - size) rectangleWidth size)
|
||||||
|
|
||||||
-- | compute color for a single pixel
|
-- | compute color for a single pixel
|
||||||
colorize
|
colorize
|
||||||
|
@ -69,3 +62,18 @@ colorize (rr, rg, rb, ra) col =
|
||||||
, G.CVdouble $ CDouble $ blu / da
|
, G.CVdouble $ CDouble $ blu / da
|
||||||
, G.CVdouble $ CDouble $ ca
|
, G.CVdouble $ CDouble $ ca
|
||||||
)
|
)
|
||||||
|
|
||||||
|
unsafeColorize col =
|
||||||
|
let
|
||||||
|
(r, g, b) = case col of
|
||||||
|
G.RGBA cr cg cb _ -> (cr, cg, cb)
|
||||||
|
G.RGB cr cg cb -> (cr, cg, cb)
|
||||||
|
a = case col of
|
||||||
|
G.RGBA _ _ _ ca -> ca
|
||||||
|
G.RGB _ _ _ -> 1
|
||||||
|
in
|
||||||
|
( G.CVdouble $ CDouble $ r
|
||||||
|
, G.CVdouble $ CDouble $ g
|
||||||
|
, G.CVdouble $ CDouble $ b
|
||||||
|
, G.CVdouble $ CDouble $ a
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue