This notebook generates the JModels logo and favicon. Credits go to Makie.jl for making it easy to create a nice PNG with a transparent background.

begin
    using Pkg
    Pkg.activate(; temp=true)
    packages = [
        PackageSpec(; name="CairoMakie", version="0.7")
        PackageSpec(; name="ColorTypes", version="0.11")
    ]
    Pkg.add(packages)
    Pkg.develop(; path=dirname(dirname(dirname(@__DIR__))))
end
using CairoMakie, ColorTypes, JModels
julia_color = Dict(
    "blue" => RGB(77/255, 101/255, 175/255),
    "red" => RGB(201/255, 60/255, 50/255),
    "green" => RGB(59/255, 150/255, 71/255),
    "purple" => RGB(145/255, 89/255, 162/255)
)
Dict{String, RGB{Float64}} with 4 entries:
  "purple" => RGB{Float64}(0.568627,0.34902,0.635294)
  "blue"   => RGB{Float64}(0.301961,0.396078,0.686275)
  "green"  => RGB{Float64}(0.231373,0.588235,0.278431)
  "red"    => RGB{Float64}(0.788235,0.235294,0.196078)
size = 480;
logo = let
    fig = Figure(; resolution=(size, size), backgroundcolor=:transparent)
    ax = Axis(fig[1, 1]; backgroundcolor=:transparent)

    cluster(x::Int, y::Int) = Point2f.([x - 1, x, x + 1], [y, y + 2, y]) 

    markersize = 50
    
    scatter!(ax, cluster(2, 2); color=julia_color["red"], markersize)
    scatter!(ax, cluster(5, 4); color=julia_color["green"], markersize)
    scatter!(ax, cluster(8, 6); color=julia_color["purple"], markersize)

    limits!(ax, 0, 10, 1, 9)

    lines!(ax, [0.2, 9.8], [1.2, 8.8]; color=julia_color["blue"], linewidth=8)

    hidespines!(ax)
    hidedecorations!(ax)
    
    fig
end
favicon_path = joinpath(pkgdir(JModels), "docs", "src", "assets", "favicon.png");
# Favicons are usually around 48x48.
let
    mkpath(dirname(favicon_path))
    save(favicon_path, logo, px_per_unit=48/size)
    cd(dirname(favicon_path)) do
        # Documenter.jl wants an ico file.
        cp("favicon.png", "favicon.ico"; force=true)
    end
end;
logo_path = let
    path = joinpath(pkgdir(JModels), "docs", "src", "assets", "logo.png")
    mkpath(dirname(path))
    path
end
"/home/runner/work/JModels.jl/JModels.jl/docs/src/assets/logo.png"
save(logo_path, logo; px_per_unit=240/size);