Skip to content

Instantly share code, notes, and snippets.

@somacdivad
Created February 14, 2022 16:14
Show Gist options
  • Save somacdivad/0946862de3644b797662db2f4802df3a to your computer and use it in GitHub Desktop.
Save somacdivad/0946862de3644b797662db2f4802df3a to your computer and use it in GitHub Desktop.
Julia code that reproduces Jeremy Hinton's "Lilac Chaser" illusion. See https://michaelbach.de/ot/col-lilacChaser/ for more information on how the illusion works.
using Javis
video = Video(500, 500)
N = 12
frames = 4(N+1)
Background(1:frames, (args...) -> background("grey70"))
# Draw crosshairs
Object(@JShape begin
sethue("black")
setline(2)
line(Point(0, 25), Point(0, -25), action=:stroke)
line(Point(25, 0), Point(-25, 0), action=:stroke)
end)
# Draw the magenta circles and flash them on and off
for i in 1:N
θᵢ = (2π/N)*i
pᵢ = 200*Point(cos(θᵢ), sin(θᵢ))
magenta_to_grey = blend(pᵢ, 1, pᵢ, 50, "magenta", "grey70")
Cᵢ = Object(@JShape begin
setblend(blend)
circle(pᵢ, 50, :fill)
end blend=magenta_to_grey)
allgrey = blend(pᵢ, 50, pᵢ, 50, "grey70", "grey70")
act!(Cᵢ, Action(4i:4i, change(:blend, allgrey)))
act!(Cᵢ, Action(4i+4:4i+4, change(:blend, magentablend)))
end
render(video, pathname="lilac_chaser.gif", framerate=50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment