Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
d5c97ea3
Commit
d5c97ea3
authored
Mar 05, 2015
by
Sumit Sahrawat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #350 -- Show diagrams Animations as animated .gif images
parent
b0bca8ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
Diagrams.hs
...ll-display/ihaskell-diagrams/IHaskell/Display/Diagrams.hs
+2
-1
Animation.hs
.../ihaskell-diagrams/IHaskell/Display/Diagrams/Animation.hs
+58
-0
ihaskell-diagrams.cabal
ihaskell-display/ihaskell-diagrams/ihaskell-diagrams.cabal
+6
-3
No files found.
ihaskell-display/ihaskell-diagrams/IHaskell/Display/Diagrams.hs
View file @
d5c97ea3
{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, FlexibleInstances #-}
module
IHaskell.Display.Diagrams
(
diagram
)
where
module
IHaskell.Display.Diagrams
(
diagram
,
animation
)
where
import
ClassyPrelude
import
ClassyPrelude
...
@@ -11,6 +11,7 @@ import Diagrams.Prelude
...
@@ -11,6 +11,7 @@ import Diagrams.Prelude
import
Diagrams.Backend.Cairo
import
Diagrams.Backend.Cairo
import
IHaskell.Display
import
IHaskell.Display
import
IHaskell.Display.Diagrams.Animation
instance
IHaskellDisplay
(
QDiagram
Cairo
R2
Any
)
where
instance
IHaskellDisplay
(
QDiagram
Cairo
R2
Any
)
where
display
renderable
=
do
display
renderable
=
do
...
...
ihaskell-display/ihaskell-diagrams/IHaskell/Display/Diagrams/Animation.hs
0 → 100644
View file @
d5c97ea3
{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, FlexibleInstances #-}
module
IHaskell.Display.Diagrams.Animation
(
animation
)
where
import
ClassyPrelude
hiding
(
filename
)
import
Diagrams.Prelude
import
Diagrams.Backend.Cairo
import
Diagrams.Backend.Cairo.CmdLine
(
GifOpts
(
..
))
import
Diagrams.Backend.CmdLine
(
DiagramOpts
(
..
),
mainRender
)
import
IHaskell.Display
instance
IHaskellDisplay
(
QAnimation
Cairo
R2
Any
)
where
display
renderable
=
do
gif
<-
animationData
renderable
return
$
Display
[
html
$
"<img src=
\"
data:image/gif;base64,"
++
gif
++
"
\"
/>"
]
animationData
::
Animation
Cairo
R2
->
IO
String
animationData
renderable
=
do
switchToTmpDir
-- Generate the frames
let
fps
=
30
animAdjusted
=
animEnvelope'
fps
renderable
frames
=
simulate
fps
animAdjusted
timediff
=
100
`
div
`
ceiling
fps
::
Int
frameSet
=
map
(
\
x
->
(
x
#
bg
white
,
timediff
))
frames
-- Compute width and height.
let
shape
=
activeStart
animAdjusted
w
=
width
shape
h
=
height
shape
aspect
=
w
/
h
imgHeight
=
300
imgWidth
=
aspect
*
imgHeight
-- Write the image.
let
filename
=
".ihaskell-diagram.gif"
diagOpts
=
DiagramOpts
{
_width
=
Just
.
ceiling
$
imgWidth
,
_height
=
Just
.
ceiling
$
imgHeight
,
_output
=
filename
}
gifOpts
=
GifOpts
{
_dither
=
True
,
_noLooping
=
False
,
_loopRepeat
=
Nothing
}
mainRender
(
diagOpts
,
gifOpts
)
frameSet
-- Convert to ascii represented base64 encoding
imgData
<-
readFile
$
fpFromString
filename
return
.
unpack
.
base64
$
imgData
-- Rendering hint.
animation
::
Animation
Cairo
R2
->
Animation
Cairo
R2
animation
=
id
ihaskell-display/ihaskell-diagrams/ihaskell-diagrams.cabal
View file @
d5c97ea3
...
@@ -51,7 +51,7 @@ library
...
@@ -51,7 +51,7 @@ library
exposed-modules: IHaskell.Display.Diagrams
exposed-modules: IHaskell.Display.Diagrams
-- Modules included in this library but not exported.
-- Modules included in this library but not exported.
-- other-modules:
other-modules: IHaskell.Display.Diagrams.Animation
-- Language extensions.
-- Language extensions.
default-extensions: DoAndIfThenElse
default-extensions: DoAndIfThenElse
...
@@ -66,7 +66,10 @@ library
...
@@ -66,7 +66,10 @@ library
diagrams==1.2.*,
diagrams==1.2.*,
diagrams-lib,
diagrams-lib,
diagrams-cairo,
diagrams-cairo,
ihaskell >= 0.5
ihaskell >= 0.5,
-- The active package, used to represent animations
active >= 0.1.0 && <0.1.1
-- Directories containing source files.
-- Directories containing source files.
-- hs-source-dirs:
-- hs-source-dirs:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment