Personal tools

Diagrams

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (Related non-Haskell projects: Pyx)
(link to new 0.6 -> 0.7 migration page)
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The '''diagrams''' library provides an embedded domain-specific language (EDSL) for creating simple pictures and diagrams in Haskell
+
[[Category:Graphics]]
  +
[[Category:Libraries]]
  +
[[Category:Packages]]
   
* [http://code.haskell.org/diagrams/ Homepage]
+
[[Image:Diagrams-logo.png]]
* [http://byorgey.wordpress.com/ Blog]
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/diagrams HackageDB]
 
   
  +
The [http://projects.haskell.org/diagrams diagrams framework] provides an embedded domain-specific language (EDSL) for declarative drawing.
   
== Rewrite ==
+
This is the diagrams wiki, for collecting tips and tricks, examples, information about related projects, and any other related information. If you are looking for more structured documentation (tutorial, user manual, API reference), see the [http://projects.haskell.org/diagrams diagrams web page]. There is also a [http://code.google.com/p/diagrams/issues/list bug tracker].
   
=== Core DSL ===
+
* [[/FAQ|Frequently asked questions]]
  +
* [[/Install|Installation instructions]]
  +
* [[/Contributing|How to contribute]]
  +
* [[/Projects|Projects]]: who is working on what.
  +
* [[/GSoC|Google Summer of Code projects]]
   
==== Style ====
+
* [[/GHC7.6|Current status of diagrams and GHC 7.6]]
Do we either want
 
   
<code>
+
* [[/Dev/Migrate0.7|0.6 to 0.7 migration]]: Description of API changes that may affect diagrams 0.6 code, with explanations of how to migrate to 0.7
yellowCircle x y radius = yellowFill $ circleShape x y radius
 
</code>
 
   
or
+
* [[/Dev|Developer wiki]]: notes on wanted features, style guidelines, best practices, etc.
   
<code>
+
* [[/Dev/BuildStatus|Build status]] of all diagrams packages at a glance.
drawYellowCircle x y radius = do $
+
* [http://projects.haskell.org/diagrams/backend-tests/all-index.html Current test case results for backends side-by-side.]
setFill yellow
 
drawCircle x y radius
 
</code>
 
?
 
 
The first version allows better reuse and functional composition.
 
 
==== Elements ====
 
* graphical primitives
 
** path
 
*** boundingBox
 
*** moveTo, lineTo, cubic bezier, quadratic bezier, arcTo
 
** text
 
*** boundingBox
 
*** convertToPath
 
** circle
 
*** boundingBox
 
*** convertToPath
 
** ellipse
 
*** boundingBox
 
*** convertToPath
 
** rectangle
 
*** boundingBox
 
*** convertToPath
 
** polygon
 
*** boundingBox
 
*** convertToPath
 
** polyline
 
*** boundingBox
 
*** convertToPath
 
* graphical attributes
 
** fill
 
*** paint
 
**** solid color, gradient, pattern
 
*** fill rule
 
**** evenOdd, nonZero
 
** stroke
 
*** paint
 
**** solid color, gradient, pattern
 
*** width
 
*** line cap
 
*** line join
 
*** miter limit
 
*** dash
 
**** offset
 
**** array
 
** marker symbols
 
** effects
 
*** shadow, blur, turbulence
 
* constraint solving
 
* animations/pages/frames
 
 
=== Data structures ===
 
<haskell>
 
data Figure = Figure {
 
fill :: Fill
 
, shape :: Shape
 
, stroke :: Stroke
 
}
 
 
data Fill = Fill {
 
fillPaint :: Paint,
 
}
 
 
data Stroke = Stroke {
 
strokePaint :: Paint,
 
, lineWidth :: Double,
 
, dashPattern :: DashPattern
 
, lineCap :: LineCap
 
, lineJoin :: LineJoin
 
, miterLimit :: Double
 
} deriving(Eq, Show)
 
 
data Paint =
 
SolidColor
 
| Pattern
 
| Gradient
 
deriving(Eq, Show)
 
 
data LineCap =
 
LineCapButt
 
| LineCapRound
 
| LineCapSquare
 
deriving(Eq, Show)
 
 
data LineJoin =
 
LineJoinMiter
 
| LineJoinRound
 
| LineJoinBevel
 
deriving(Eq, Show)
 
 
data Shape =
 
Path
 
| Primitive
 
| Text
 
deriving(Eq, Show)
 
 
data Path = Path {
 
segments :: [Segment]
 
}
 
deriving(Eq, Show)
 
 
data Segment =
 
Move Point
 
| Line {
 
a :: Point
 
, b :: Point
 
}
 
| HorizontalLine {
 
a :: Point
 
, w :: Double
 
}
 
| VerticalLine {
 
a :: Point
 
, h :: Double
 
}
 
| QuadraticBezier Point Point Point
 
| CubicBezier Point Point Point Point
 
deriving(Eq, Show)
 
 
data Point =
 
Node2d Double Double
 
| Node3d Double Double Double
 
deriving(Eq, Show)
 
 
data Primitive =
 
Circle
 
| Ellipse
 
| Rectangle
 
| RegularPolygon
 
| Square
 
| Star
 
deriving(Eq, Show)
 
 
class PathLike a =
 
convertToPath :: a -> Path
 
</haskell>
 
 
 
=== Modules/Extensions ===
 
 
==== Paths ====
 
* inset, outset
 
* boolean operations
 
* morphing
 
* approximation (autotrace)
 
 
See
 
* http://lib2geom.sourceforge.net/
 
* http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/live_effects/
 
 
==== Shapes and symbols ====
 
* stars, [http://local.wasp.uwa.edu.au/~pbourke/geometry/supershape/ supershape], [http://www.jroller.com/aalmiray/entry/jsilhouette_0_3_released symbols]
 
* diagrams
 
** histograms, density plots
 
 
=== Input/Output ===
 
 
Many Haskell graphic libraries are tied to a specific rendering backend (Cairo, OpenGL, libGD etc) which makes collaboration and reuse of code and data structures very hard or impossible.
 
 
Also some dependencies are hard to fulfill. Cairo is very difficult to install on Mac OS 10.6. If you just need to generate PDF diagrams, you could choose the pure HPDF library where e.g. Hieroglyph can not be installed because of its Cairo dependence.
 
 
==== Output ====
 
* interactive drawing via Cairo
 
* PDF export via pure [http://hackage.haskell.org/package/HPDF HPDF]
 
* EPS export
 
* SWF export
 
* LaTeX export
 
* exotic backends
 
** generate Java2d or [http://www.processing.org/ Processing] source code
 
 
==== Input ====
 
* pure Haskell PNG import via [http://hackage.haskell.org/package/pngload pngload]
 
* pure Haskell SVG import
 
 
== Inspiration ==
 
 
* [[Applications_and_libraries/Graphics]]
 
 
=== Related non-Haskell projects ===
 
 
* [http://asymptote.sourceforge.net/ Asymptote]
 
* [http://had.co.nz/ggplot2/ ggplot2]
 
* [http://www.tug.org/metapost.html MetaPost]
 
* [http://pyx.sourceforge.net/ Pyx]
 
* [http://www.texample.net/tikz/examples/ TikZ]
 
 
=== Food for thought ===
 
 
* [http://www.adobe.com/devnet/pdf/pdf_reference.html PDF reference]
 
* [http://www.w3.org/TR/SVG11/ SVG reference]
 
* [http://www.adobe.com/devnet/swf/pdf/swf_file_format_spec_v10.pdf SWF reference]
 

Revision as of 19:31, 1 August 2013

Diagrams-logo.png

The diagrams framework provides an embedded domain-specific language (EDSL) for declarative drawing.

This is the diagrams wiki, for collecting tips and tricks, examples, information about related projects, and any other related information. If you are looking for more structured documentation (tutorial, user manual, API reference), see the diagrams web page. There is also a bug tracker.

  • 0.6 to 0.7 migration: Description of API changes that may affect diagrams 0.6 code, with explanations of how to migrate to 0.7
  • Developer wiki: notes on wanted features, style guidelines, best practices, etc.