diff --git a/README.md b/README.md index 0e32a1b..752a1cb 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Karnak.jl is a small extension for the Luxor.jl package to help with constructing graph-style drawings. -Karnak relies on [Graphs.jl](https://juliagraphs.org/Graphs.jl/) for graph construction, and +Karnak relies on [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) for graph construction, and on [NetworkLayout.jl](https://juliagraphs.org/NetworkLayout.jl/) for graph layout. The focus in Karnak, unlike other graph visualization diff --git a/docs/src/index.md b/docs/src/index.md index 7948106..1e46e4d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -6,7 +6,7 @@ Karnak.jl is a small extension for the Luxor.jl package to help with constructing graph-style drawings. Karnak relies on -[Graphs.jl](https://juliagraphs.org/Graphs.jl/) for graph +[Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) for graph construction, and on [NetworkLayout.jl](https://juliagraphs.org/NetworkLayout.jl/) for graph layout. diff --git a/examples/julia-graphs-logo.jl b/examples/julia-graphs-logo.jl new file mode 100644 index 0000000..68c22e1 --- /dev/null +++ b/examples/julia-graphs-logo.jl @@ -0,0 +1,57 @@ +using Graphs +using Karnak +using Colors + +function lighten(col::Colorant, f) + c = convert(RGB, col) + return RGB(f * c.r, f * c.g, f * c.b) +end + +function julia_sphere(pt::Point, w, col::Colorant; + action = :none) + setmesh(mesh( + makebezierpath(box(pt, w * 1.5, w * 1.5)), + [lighten(col, .5), + lighten(col, 1.75), + lighten(col, 1.25), + lighten(col, .6)])) + circle(pt, w, action) +end + +function draw_edge(pt1, pt2) + for k in 0:0.1:1 + setline(rescale(k, 0, 1, 25, 1)) + sethue(lighten(colorant"grey50", rescale(k, 0, 1, 0.5, 1.5))) + setopacity(rescale(k, 0, 1, 0.5, 0.75)) + line(pt1, pt2, :stroke) + end +end + +outerpts = ngonside(O, 450, 4, π/4, vertices=true) +innerpts = ngonside(O, 150, 4, π/2, vertices=true) +pts = vcat(outerpts, innerpts) +colors = map(c -> RGB(c...), [Luxor.julia_blue, Luxor.julia_red, Luxor.julia_green, Luxor.julia_purple]) + +Drawing(600, 600, "/tmp/julia-graphs.svg") + origin() + squircle(O, 294, 294, :clip, rt=0.2) + sethue("black") + paint() + g = SimpleGraph([ + Edge(1,2), Edge(2,3), Edge(3,4), Edge(1,4), + Edge(5,6), Edge(6,7), Edge(7,8), Edge(5,8), + Edge(1,5), Edge(2,6), Edge(3,7), Edge(4,8), + ]) + + drawgraph(Graph(g), + layout=pts, + vertexfunction = (v, c) -> begin + d = distance(O, c[v]) + d > 200 ? k = 0 : k = 1 + julia_sphere(c[v], rescale(d, 0, 200, 52, 50), colors[mod1(v + k, 4)], action=:fill) + end, + edgefunction = (k, s, d, f, t) -> draw_edge(f, t) + ) +finish() +preview() +# run(`svgo -i /private/tmp/julia-graphs.svg -o /private/tmp/julia-graphs-opt.svg`)