|
1 | 1 | module TikzGraph |
2 | 2 | export rgbcolor!, Node, Line, BoundingBox, Mesh, Canvas, >>, command, canvas, generate_standalone, StringElement, PlainText, uselib! |
3 | | -export Cycle, Controls, annotate, Annotate, autoid!, vizgraph! |
| 3 | +export Cycle, Controls, annotate, Annotate, autoid!, vizgraph!, writepdf |
4 | 4 |
|
5 | 5 | const instance_counter = Ref(0) |
6 | 6 | abstract type AbstractTikzElement end |
@@ -99,7 +99,7 @@ function Mesh(xmin, xmax, ymin, ymax; step="1.0cm", draw="gray", line_width=0.03 |
99 | 99 | Mesh(xmin, xmax, ymin, ymax, build_props(; step=step, draw=draw, line_width=line_width, kwargs...)) |
100 | 100 | end |
101 | 101 | function command(grid::Mesh) |
102 | | - return "\\draw[$(parse_args(String[], grid.props))] ($(grid.xmin),$(grid.ymin)) grid ($(grid.xmax),$(grid.ymax));" |
| 102 | + return "\\draw[$(parse_args(String[], grid.props))] ($(grid.xmin-1e-3),$(grid.ymin-1e-3)) grid ($(grid.xmax),$(grid.ymax));" |
103 | 103 | end |
104 | 104 |
|
105 | 105 | struct Cycle end |
@@ -184,6 +184,11 @@ function Base.write(io::IO, canvas::Canvas) |
184 | 184 | write(io, generate_standalone(canvas)) |
185 | 185 | end |
186 | 186 |
|
| 187 | +function writepdf(filename::AbstractString, canvas::Canvas) |
| 188 | + write(filename, canvas) |
| 189 | + run(`latexmk -pdf $filename -output-directory=$(dirname(filename))`) |
| 190 | +end |
| 191 | + |
187 | 192 | function vizgraph!(c::Canvas, locations::AbstractVector, edges; fills=fill("black", length(locations)), |
188 | 193 | texts=fill("", length(locations)), ids=[autoid!() for i=1:length(locations)], minimum_size="0.4cm", |
189 | 194 | draw="", line_width="1pt", edgecolors=fill("black", length(edges))) |
|
0 commit comments