Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cormullion committed Jan 12, 2023
1 parent 2e5a59a commit cb9fbce
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 42 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Changelog

## [v0.5.0] - 2022-12-??
## [v0.5.0] - 2023-01-12

### Added

## Changed

- update docs, etc.
- arrow widths
- default linewidth calculation fixed (don't use Luxor internals ...)

### Removed

Expand Down
Binary file modified docs/src/assets/figures/karnak-social-media-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ end
g, pkgnames = build_depgraph("DataFrames")
d = @svg begin
d = @drawsvg begin
background("grey5")
sethue("gold")
fontsize(10)
Expand All @@ -283,7 +283,7 @@ d = @svg begin
end
end,
)
end
end 800 700
nothing # hide
```

Expand Down
108 changes: 72 additions & 36 deletions examples/karnaksocmedprev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,89 @@ function hiero()
translate(pos)
setline(0.5)
bb = BoundingBox(box(O, tiles.tilewidth, tiles.tileheight))
rule(O + (tiles.tilewidth)/2, π/2)
rule(O + (tiles.tilewidth) / 2, π / 2)
R = rand(1:10)
if R == 1
if R == 1
g = binary_tree(rand(2:4))
dirg = SimpleDiGraph(collect(edges(g)))
drawgraph(dirg, vertexshapesizes = 1, layout = buchheim, edgegaps=0, edgecurvature=1, boundingbox=bb, margin=5)
elseif R == 2
drawgraph(
dirg,
vertexshapesizes = 1,
layout = buchheim,
edgegaps = 0,
edgecurvature = 1,
boundingbox = bb,
margin = 5,
)
elseif R == 2
g = star_graph(rand(3:10))
drawgraph(g, boundingbox=bb, margin=10, layout=stress, vertexstrokeweights=0.25)
elseif R == 3
drawgraph(g, boundingbox = bb, margin = 10, layout = stress, vertexstrokeweights = 0.25)
elseif R == 3
g = smallgraph(:truncatedcube)
drawgraph(g, boundingbox=bb, margin=10, vertexshapes = :none, layout=stress, vertexstrokeweights=0.3)
elseif R == 4
drawgraph(
g,
boundingbox = bb,
margin = 10,
vertexshapes = :none,
layout = stress,
vertexstrokeweights = 0.3,
)
elseif R == 4
g = smallgraph(:tutte)
drawgraph(g, boundingbox=bb, margin=10, vertexshapes = :none, layout=stress, vertexstrokeweights=0.3)
elseif R == 5
drawgraph(
g,
boundingbox = bb,
margin = 10,
vertexshapes = :none,
layout = stress,
vertexstrokeweights = 0.3,
)
elseif R == 5
g = smallgraph(:truncatedtetrahedron)
drawgraph(g, boundingbox=bb, margin=10, vertexshapesizes = 2, layout=stress, vertexstrokeweights=0.3)
elseif R == 6
drawgraph(
g,
boundingbox = bb,
margin = 10,
vertexshapesizes = 2,
layout = stress,
vertexstrokeweights = 0.3,
)
elseif R == 6
g = smallgraph(:cubical)
drawgraph(g, boundingbox=bb, margin=10, layout = Spring(Ptype=Float64))
elseif R == 7
drawgraph(g, boundingbox = bb, margin = 10, layout = Spring(Ptype = Float64))
elseif R == 7
g = smallgraph(:octahedral)
drawgraph(g, boundingbox=bb, margin=10, layout = Spring(Ptype=Float64))
drawgraph(g, boundingbox = bb, margin = 10, layout = Spring(Ptype = Float64))
else
g = complete_graph(rand(4:12))
drawgraph(g, boundingbox=bb, margin=10, vertexshapesizes = 1, vertexstrokeweights=0.15, layout = Spring(Ptype=Float64))
drawgraph(
g,
boundingbox = bb,
margin = 10,
vertexshapesizes = 1,
vertexstrokeweights = 0.15,
layout = Spring(Ptype = Float64),
)
end
end
end
end

@png begin

pl = box(BoundingBox())
mesh1 = mesh(pl, [
Colors.RGBA(0.0, 0.0, 0.1, 0.99),
Colors.RGBA(0.7, 0.5, 0.0, 0.99),
Colors.RGBA(0.2, 0.1, 0.2, 0.99),
Colors.RGBA(0.0, 0.1, 0.2, 0.99),
])
mesh1 = mesh(
pl,
[
Colors.RGBA(0.0, 0.0, 0.1, 0.99),
Colors.RGBA(0.7, 0.5, 0.0, 0.99),
Colors.RGBA(0.2, 0.1, 0.2, 0.99),
Colors.RGBA(0.0, 0.1, 0.2, 0.99),
],
)
setmesh(mesh1)
paint()

panes = Tiler(1280, 640, 1, 2, margin=0)
panes = Tiler(1280, 640, 1, 2, margin = 0)

# left
@layer begin
Expand All @@ -69,10 +107,11 @@ end

# right
@layer begin
setopacity(0.2)
sethue("midnightblue")
setopacity(0.15)
box(first(panes[2]), 640, 640, :fill)
box(first(panes[2]), 640, 640, :clip)

sethue("gold2")
hiero()
clipreset()
Expand All @@ -89,15 +128,15 @@ end
@layer begin
translate(first(panes[1]))
scale(0.9)
placeimage(logo, O, centered=true)
placeimage(logo, O, centered = true)
end

@layer begin
translate(first(panes[2]))
fontsize(80)
fontface("Goblin")
bx = box(O, panes.tilewidth/1.5, panes.tileheight/1.5)
textoutlines("KARNAK", O + (0, -150), halign=:center, :path)
bx = box(O, panes.tilewidth / 1.5, panes.tileheight / 1.5)
textoutlines("KARNAK", O + (0, -150), halign = :center, :path)
@layer begin
sethue("gold")
fillpreserve()
Expand All @@ -106,21 +145,18 @@ end
strokepath()
end

bx = box(O + (0, 100), panes.tilewidth/1.5, panes.tileheight/1.8)
bx = box(O + (0, 100), panes.tilewidth / 1.5, panes.tileheight / 1.8)
@layer begin
sethue("black")
setopacity(0.2)
poly(bx, :fill)
end
fontsize(25)
fontsize(28)
fontface("WorkSans-Bold")
sethue("gold")
textwrap("Karnak.jl is a small utility package for Luxor.jl
that helps with drawing some graph-style drawings, more for
decorative purposes than anything else. Uses Graphs.jl and
NetworkLayout.jl.", 800, boxtopleft(BoundingBox(bx)) + (20, 0),
leading=get_fontsize() + 20)

for drawing graphs and networks. It uses Graphs.jl and
NetworkLayout.jl.", 400, boxtopleft(BoundingBox(bx)) + (20, 0),
leading = get_fontsize() + 30)
end

end 1280 640 "docs/src/assets/figures/karnak-social-media-preview.png"
6 changes: 3 additions & 3 deletions src/drawgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ function _drawedgelines(from, to, edgesrc, edgedest;
end

# set the stroke weight
currentdrawing().surfacetype == :png ? linewidth = 2 : linewidth = 1

Luxor.current_surface_type() == :png ? linewidth = 2 : linewidth = 1
if isnothing(edgestrokeweights)
if isnothing(edgestrokeweights)
# by default, do nothing
elseif edgestrokeweights isa Array
if !isempty(edgestrokeweights)
Expand Down Expand Up @@ -501,7 +501,7 @@ function _drawvertexshapes(vertex, coordinates::Array{Point,1};
end

# set the stroke weight
Luxor.current_surface_type() == :png ? linewidth = 2 : linewidth = 1
currentdrawing().surfacetype == :png ? linewidth = 2 : linewidth = 1

if isnothing(vertexstrokeweights)
# by default, do nothing
Expand Down

0 comments on commit cb9fbce

Please sign in to comment.