Skip to content

Merging turing-logo-graphics repository #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions turing-logo-graphics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
Manifest.toml
5 changes: 5 additions & 0 deletions turing-logo-graphics/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
5 changes: 5 additions & 0 deletions turing-logo-graphics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Turing logo graphics

![Turing logo text](images/logo-text-small.png) ![Turing logo text dark](images/logo-text-dark-small.png)

![Turing logo](images/logo-medium.png)
Binary file added turing-logo-graphics/font/TamilMN-Bold.ttf
Binary file not shown.
Binary file added turing-logo-graphics/images/logo-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
273 changes: 273 additions & 0 deletions turing-logo-graphics/images/logo-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added turing-logo-graphics/images/logo-medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
273 changes: 273 additions & 0 deletions turing-logo-graphics/images/logo-medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added turing-logo-graphics/images/logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
273 changes: 273 additions & 0 deletions turing-logo-graphics/images/logo-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-dark-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-dark-medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-dark-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added turing-logo-graphics/images/logo-text-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added turing-logo-graphics/images/logo-text-medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added turing-logo-graphics/images/logo-text-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions turing-logo-graphics/images/logo-text-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions turing-logo-graphics/src/logo-text.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using Luxor
using Luxor: julia_blue

function getloc(tpath, idx)
xpoint = 0
ypoint = Inf
xpoint = polycentroid(tpath[idx]).x
for t in tpath
cpos = polycentroid(t)
(cpos.y < ypoint) && (ypoint = cpos.y)
end
return xpoint, ypoint
end

function find_i_index(txt)
i = 0
for c in txt
if c in (
'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h',
'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y',
'z',
'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y',
'Z',
)
i += 1
elseif c == 'j'
i += 2
elseif c == 'i'
return i + 1
else
@error "Unsupoorted character \"$c\""
end
end
@error "No \"i\" in the given text \"$txt\""
end

"""
Create a Julia style logo for the
given text which contains an "i".
Example:
```julia
textlogo("Turing")
```
![](https://github.com/TuringLang/turing-logo-graphics/raw/main/images/logo-text-small.png)
Acknowledgement for https://github.com/JuliaGraphics/Luxor.jl/issues/78#issuecomment-570317514
"""
function textlogo(
txt::String;
ff::String="TamilMN-Bold", # TamilMN-Bold is the font Julia's logo
fs::Int=50, # font size
xshift=( fs / 6), # shifts for x
yshift=(-fs / 6), # and y axes to move Julia circles
is_dark::Bool=false, # dark mode or not
is_firstblue::Bool=false, # to draw a transparent blue on the first letter or not
is_overlapred=true, # to overlap red or purple?
filename="$(lowercase(txt))-logo.svg"
)
@assert !('c' in txt) "No \"i\" in the given text \"$txt\""
ratio, wratio = fs / 50, length(txt) / 6
radius = fs / 5
for suffix in ("png", "svg")
drawing = Drawing(180 * ratio * wratio, 80 * ratio, "$filename.$suffix")

translate(5 * ratio * wratio, 65 * ratio)
fontface(ff)
fontsize(fs)
if is_dark
background("black")
sethue("white")
else
background("white")
sethue("black")
end

text(txt)
textoutlines(txt, O, :path)
tpath = pathtopoly()

# Red, green and purple circles
xpoint, ypoint = getloc(tpath, find_i_index(txt))
if is_overlapred
xtrans, ytrans = xpoint + xshift, ypoint + yshift
else
xtrans, ytrans = xpoint + xshift, ypoint + yshift
end
translate( xtrans, ytrans)
juliacircles(radius)
translate(-xtrans, -ytrans)

# Blue circle
if is_firstblue
xpoint, ypoint = getloc(tpath, 1)
translate(xpoint - xshift, ypoint)
p = ngon(O, radius, 1, pi/6, vertices=true)[1]
setcolor((julia_blue..., 0.5))
circle(p, 2 * radius, :fill)
end

finish()
end
preview()
end

turinglogo(; kwargs...) = textlogo("Turing"; kwargs...)

turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-small"), fs=50)
turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-medium"), fs=100)
turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-large"), fs=200)

turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-dark-small"), fs=50, is_dark=true)
turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-dark-medium"), fs=100, is_dark=true)
turinglogo(; filename=joinpath(@__DIR__, "../images/logo-text-dark-large"), fs=200, is_dark=true)
47 changes: 47 additions & 0 deletions turing-logo-graphics/src/logo.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Distributions, Plots, Colors

# Gaussian with known variance
# mu ~ Normal(mu0, sig0)
# xi ~ Normal(mu, sig_like)
# Ref: https://en.wikipedia.org/wiki/Conjugate_prior#Continuous_distributions
function get_posterior_parameters(xs, mu0, sig0, siglike)
n = length(xs)
var = inv(1 / sig0^2 + n / siglike^2)
mu = var * (mu0 / sig0^2 + sum(xs) / siglike^2)
return mu, sqrt(var)
end

function turinglogo(filename::String; figsize=(450, 300))
default(size=figsize, leg=false)

mu0, sig0, siglike = 0.0, 1.0, 1.0
prior = Normal(mu0, sig0)
# Inference with one datum
obs = [5.0]
post1 = Normal(get_posterior_parameters(obs, mu0, sig0, siglike)...)
# Inference with more data
push!(obs, 1.0)
post2 = Normal(get_posterior_parameters(obs, mu0, sig0, siglike)...)

julia_purple = parse(Colorant, RGBA(0.702, 0.322, 0.8))
julia_brown = parse(Colorant, RGBA(0.8, 0.2, 0.2))
julia_green = parse(Colorant, RGBA(0.133, 0.541, 0.133))

xs = -3:0.01:5
lw = 15.0
fig = plot(xs, pdf.(Ref(prior), xs), color=julia_purple, linewidth=lw, grid=false)
plot!(xs, pdf.(Ref(post1), xs), color=julia_brown, linewidth=lw)
plot!(xs, pdf.(Ref(post2), xs), color=julia_green, linewidth=lw)
xaxis!(false)
yaxis!(false)

display(fig)

for suffix in ("png", "svg")
savefig(joinpath(@__DIR__, "$filename.$suffix"))
end
end

turinglogo("../images/logo-small"; figsize=(450, 300))
turinglogo("../images/logo-medium"; figsize=(600, 400))
turinglogo("../images/logo-large"; figsize=(750, 500))