Compose.FormBatch — Type
A form batch is a vectorized form with n primitives transformed into a simpler representation: one primitive repositioned n times.
On certain backends this leads to more efficient drawing. For example, SVG can be shortened by using <def> and <use> tags, and raster graphics can render the form primitive to a back buffer and blit it into place for faster drawing.
Batching is an optimization transform that happens at draw time. There's currently no mechanism to manually batch. E.g. contexts cannot have FormBatch children.
Compose.Mirror — Method
Mirror(θ, x, y)Mirror line passing through point (x,y) at angle θ (in radians).
Compose.Mirror — Method
Mirror(θ)Mirror(θ)=Mirror(θ, 0.5w, 0.5h)
Compose.PGF — Type
PGF([output::Union{IO,AbstractString}], width=√200cm, height=10cm, only_tikz=false; texfonts=false) -> BackendCreate a Portable Graphics Format backend. The output is normally passed to draw. Specify a filename using a string as the first argument. If only_tikz is true then the output is a "tikzpicture", otherwise the output is a complete latex document with headers and footers. If texfonts is false, include "\usepackage{fontspec}" in the headers.
Examples
c = compose(context(), rectangle())
draw(PGF("myplot.tex", 10cm, 5cm, true, texfonts=true), c)Compose.Rotation — Method
Rotation(θ, x, y)Rotate all forms in context around point (x,y) by angle θ in radians.
Compose.Rotation — Method
Rotation(θ)Rotation(θ)=Rotation(θ, 0.5w, 0.5h)
Compose.SVG — Type
SVG([output::Union{IO,AbstractString}], width=√200cm, height=10cm, jsmode=:none) -> BackendCreate a Scalable Vector Graphic backend. The output is normally passed to draw. Specify a filename using a string as the first argument. jsmode can be one of :none, :embed, :linkabs, or :linkrel. See also SVGJS.
Examples
c = compose(context(), line())
draw(SVG("myplot.svg"), c)Compose.Shear — Method
Shear(s, θ, x, y)Shear line passing through point (x,y) at angle θ (in radians), with shear s.
Compose.Shear — Method
Shear(s, θ)Shear(s, θ)=Shear(s, θ, 0.5w, 0.5h)
Compose.UnitBox — Method
UnitBox(x0, y0, width, height; leftpad=0mm, rightpad=0mm, toppad=0mm, bottompad=0mm)Specifies the coordinate system for a context, with origin x0, y0, plus width, height.
Compose.UnitBox — Method
UnitBox(width, height; leftpad=0mm, rightpad=0mm, toppad=0mm, bottompad=0mm)Specifies the coordinate system for a context, with origin 0, 0 plus width, height.
Compose.UnitBox — Method
UnitBox() = UnitBox(0.0, 0.0, 1.0, 1.0)Compose.PDF — Function
PDF([output::Union{AbstractString, IO}], width=√200cm, height=10cm; dpi=72) -> BackendCreate a Portable Document Format backend. The output is normally passed to draw. Specify a filename using a string as the first argument. Depends on Cairo.jl.
Examples
using Cairo
c = compose(context(), circle())
draw(PDF("myplot.pdf", 10cm, 5cm, dpi=250), c)Compose.PDF — Method
The Cairo and Fontconfig packages are necessary for saving as PDF. Add them with the package manager if necessary, then run import Cairo, Fontconfig before invoking PDF.
Compose.PNG — Function
PNG([output::Union{AbstractString, IO}], width=√200cm, height=10cm; dpi=96) -> BackendCreate a Portable Network Graphics backend. The output is normally passed to draw. Specify a filename using a string as the first argument. Depends on Cairo.jl.
Examples
using Cairo
c = compose(context(), circle())
draw(PNG("myplot.png", 10cm, 5cm, dpi=250), c)Compose.PNG — Method
The Cairo and Fontconfig packages are necessary for saving as PNG. Add them with the package manager if necessary, then run import Cairo, Fontconfig before invoking PNG.
Compose.PS — Function
PS([output::Union{AbstractString, IO}], width=√200cm, height=10cm; dpi=72) -> BackendCreate a Postscript backend. The output is normally passed to draw. Specify a filename using a string as the first argument. Depends on Cairo.jl.
Examples
using Cairo
c = compose(context(), circle())
draw(PS("myplot.ps", 10cm, 5cm, dpi=250), c)Compose.PS — Method
The Cairo and Fontconfig packages are necessary for saving as PS. Add them with the package manager if necessary, then run import Cairo, Fontconfig before invoking PS.
Compose.SVGJS — Function
SVGJS([output::Union{IO,AbstractString}], width=√200cm, height=10cm, jsmode=:embed) -> BackendCreate a Scalable Vector Graphic backend that enables Gadfly's interactivity (pan, zoom, etc.). The default jsmode splices the requisite javascript directly into the output. One can alternatively link to identical external javascript with :linkabs and :linkrel. The output is normally passed to draw. Specify a filename using a string as the first argument. See also SVG.
Compose.arc — Function
arc(xs::AbstractVector, ys::AbstractVector, rs::AbstractVector, θ1s::AbstractVector, θ2s::AbstractVector, sectors::AbstractVector)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.arc — Function
arc(x, y, r, θ1, θ2, sector)Define an arc with its center at (x,y), radius of r, between θ1 and θ2. sector (optional) is true or false, true for a pie sector, false for an arc. Arcs are drawn clockwise from θ1 to θ2.
Compose.arrow — Method
arrow(values::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.arrow — Method
arrow(value::Bool)
`arrow()` is a property of arcs, lines and curves. The color of the arrowhead is the same as `stroke()`, but for svg the results will be browser-dependent.Compose.arrow — Method
arrow()
`arrow() = arrow(true)`Compose.batch — Method
Attempt to batch a form. Return a Nothing singleton if the Form could not be batched, and FormBatch object if the original form can be replaced.
Compose.bezigon — Method
bezigon(anchor0::Tuple, sides::Vector{<:Vector{<:Tuple}})Define a bezier polygon. anchor0 is the starting point as an (x,y) tuple. sides contains Vectors of side points (tuples): each vector has the control point(s) and end point for each side (the end point forms the next starting point). The sides can be linear (1 point), quadratic (2 points) or cubic (3 points).
Compose.bezigon — Method
bezigon(anchors::Vector{Tuple}, polysides=Vector{<:Vector{<:Vector{<:Tuple}}})Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.bitmap — Function
bitmap(mimes::AbstractArray, datas::AbstractArray, x0s::AbstractArray, y0s::AbstractArray, widths::AbstractArray, heights::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.bitmap — Function
bitmap(mime, data, x0, y0, width, height)Define a bitmap of size widthxheight with its top left corner at the point (x, y).
Compose.canbatch — Method
Some backends can more efficiently draw forms by batching. If so, they shuld define a similar method that returns true.
Compose.circle — Function
circle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.circle — Function
circle(x, y, r)Define a circle with its center at (x,y) and a radius of r.
Compose.circle — Method
circle()Define a circle in the center of the current context with a diameter equal to the width of the context.
Compose.clip — Method
clip(point_arrays::AbstractArray...)Arguments can be passed in arrays in order to perform multiple clipping operations at once.
Compose.clip — Method
clip(points::AbstractArray)clip() is a property. Only forms inside the clip shape will be visible.
Compose.compose! — Method
compose!(a::Context, b, c, ds...) -> aAdd b, c, and ds to the graphic as children of a.
Compose.compose — Method
compose(a::Context, b, c, ds...) -> ContextAdd b, c, and ds to the graphic as children of a copy of a.
Compose.context — Function
context(x0=0.0w, y0=0.0h, width=1.0w, height=1.0h;
units=nothing,
rotation=nothing, mirror=nothing, shear=nothing,
withjs=false, withoutjs=false,
minwidth=nothing, minheight=nothing,
order=0, clip=false, raster=false) -> ContextCreate a node in the tree structure that defines a graphic. Use compose to connect child nodes to a parent node. See also Rotation, Mirror, and Shear.
Arguments
units: the coordinate system for the context, defined by aUnitBox.order: the Z-order of this context relative to its siblings.clip: clip children of the canvas by its bounding box if true.withjs: ignore this context and everything under it if we are not drawing to the SVGJS backend.withoutjs: ignore this context if we are drawing on the SVGJS backend.raster: if possible, render this subtree as a bitmap. This requires the Cairo. If Cairo isn't available, the default rendering is used.minwidthandminheight: the minimum size needed to be drawn correctly, in millimeters.
Compose.count_unique_primitives — Method
Count the number of unique primitives in a property, stopping when max_count is exceeded.
Compose.curve — Function
curve(anchor0, ctrl0, ctrl1, anchor1)Define a bezier curve between anchor0 and anchor1 with control points ctrl0 and ctrl1.
Compose.curve — Function
curve(anchor0s::AbstractArray, ctrl0s::AbstractArray, ctrl1s::AbstractArray, anchor1s::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.draw — Method
draw(b::Backend, c::Context)Output the tree-structured graphic in c to the given backend.
Examples
draw(SVGJS("foo.svg"), compose(context(), text(0,0,"foo")))Compose.ellipse — Function
ellipse(x, y, x_radius, y_radius)Define an ellipse with its center at (x,y) with radii x_radius and y_radius.
Compose.ellipse — Function
ellipse(xs::AbstractArray, ys::AbstractArray, x_radiuses::AbstractArray, y_radiuses::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.ellipse — Method
ellipse()Define an ellipse in the center of the current context with x_radius=0.5w and y_radius=0.5h.
Compose.excise_vector_children! — Method
Remove and return vector forms and vector properties from the Context.
Compose.fillopacity — Method
fillopacity(values::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.fillopacity — Method
fillopacity(value)Define a fill opacity, where 0≤value≤1. For svg, nested contexts will inherit from parent contexts e.g. (context(), fillopacity(a), (context(), fill(c::String), circle())).
Compose.filter_redundant_offsets! — Method
Produce a new array of offsets in which near duplicate values have been removed.
Compose.line — Function
line(point_arrays::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.line — Method
line(points)Define a line. points is an array of (x,y) tuples.
Compose.ngon — Function
ngon(x, y, r, n::Int)Define a n-sided polygon with its center at (x,y), and radius of r. For an upside-down ngon, use -r.
Compose.ngon — Function
ngon(xs::AbstractVector, ys::AbstractVector, rs::AbstractVector, ns::AbstractVector{Int})Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.optimize_batching — Method
Attempt to transform a tree into an equivalent tree that can more easily be batched.
What this does is look for patterns in which a long vector form is accompanied by a large vector property that has a relatively small number of unique values. If there are n unique values, we can split it into n contexts, each with a shorter vector form and only scalar properties.
Compose.points — Method
points(x::Compose.Form)Extract points from a Compose.Form
Compose.polygon — Function
polygon(point_arrays::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.polygon — Method
polygon(points)Define a polygon. points is an array of (x,y) tuples that specify the corners of the polygon.
Compose.rectangle — Function
rectangle(x0, y0, width, height)Define a rectangle of size widthxheight with its top left corner at the point (x, y).
Compose.rectangle — Function
rectangle(x0s::AbstractArray, y0s::AbstractArray, widths::AbstractArray, heights::AbstractArray)Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.rectangle — Method
rectangle()Define a rectangle that fills the current context completely.
Compose.sector — Method
sector(xs::AbstractVector, ys::AbstractVector, rs::AbstractVector, θ1s::AbstractVector, θ2s::AbstractVector)Arguments can be passed in arrays in order to perform multiple drawing operations.
Compose.sector — Method
sector(x, y, r, θ1, θ2)Define a pie sector with its center at (x,y), radius of r, between θ1 and θ2.
Compose.star — Function
star(x, y, r, n::Int, ratio)Define a n-pointed star with its center at (x,y), outer radius of r, and inner radius equal to r*ratio. For an upside-down star, use -r.
Compose.star — Function
star(xs::AbstractVector, ys::AbstractVector, rs::AbstractVector, ns::AbstractVector{Int}, ratios::AbstractVector{Float64})Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.text — Function
text(xs::AbstractArray, ys::AbstractArray, values::AbstractArray [,haligns::HAlignment [,valigns::VAlignment [,rots::Rotation]]])Arguments can be passed in arrays in order to perform multiple drawing operations at once.
Compose.text — Function
text(x, y, value [,halign::HAlignment [,valign::VAlignment [,rot::Rotation]]])Draw the text value at the position (x,y) relative to the current context.
The default alignment of the text is hleft vbottom. The vertical and horizontal alignment is specified by passing hleft, hcenter or hright and vtop, vcenter or vbottom as values for halign and valign respectively.
Compose.xgon — Function
xgon(x, y, r, n::Int, ratio)Define a cross with n arms with its center at (x,y), outer radius of r, and inner radius equal to r*ratio. For an upside-down xgon, use -r.
Compose.xgon — Function
xgon(xs::AbstractVector, ys::AbstractVector, rs::AbstractVector, ns::AbstractVector{Int}, ratios::AbstractVector{Float64})Arguments can be passed in arrays in order to perform multiple drawing operations at once.