Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env julia
using Luxor, Colors
function julia_balls()
# get centers for the three balls
points = reverse(ngon(0, 0, 100, 3, pi/6, vertices=true))
gsave()
# setcolor(0.251, 0.388, 0.847) # the darker blue not used
# setcolor(0.4, 0.51, 0.878) # the lighter blue not used
@cormullion
cormullion / more-diff-eq.jl
Last active September 4, 2016 21:40
another diff eq logo
#!/usr/bin/env julia
using Luxor, Colors
function julia_balls()
# get centers for the three balls
points = reverse(ngon(0, 0, 100, 3, pi/6, vertices=true))
gsave()
# setcolor(0.251, 0.388, 0.847) # the darker blue not used
# setcolor(0.4, 0.51, 0.878) # the lighter blue not used
@cormullion
cormullion / stackad.jl
Last active January 7, 2018 11:31
Make StackOverflow ad for Julia
#!/usr/bin/env julia
using Luxor, Colors
Drawing(600, 500, "/tmp/stackad.png")
origin()
background("white")
# background textifying, not for reading, fortunately
function background_text(str_array, fontsz, beginning::Point, ending::Point)
#!/usr/bin/env julia
using Luxor
Drawing(500, 500, "/tmp/julia-flowers.png")
background("white")
function juliaflowers(cpos::Point, radius; petals=30, outercircleratio=0.75, innercircleratio=0.65)
# clockwise, from bottom LEFT...
points3 = ngon(cpos, radius, 3, pi/6, vertices=true)
#!/usr/bin/env julia
using Luxor
function pidigits(n)
result = Int[]
k, a::BigInt, b::BigInt, a1::BigInt, b1::BigInt = 2, 4, 1, 12, 4
while n > 0
p, q, k = k * k, 2k + 1, k + 1
a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1
using Luxor
function three_circles(cpos::Point, circle_radius; outercircleratio=0.75, innercircleratio=0.65)
fontface("Georgia-Bold")
fontsize(26)
# clockwise, from bottom LEFT...
points3 = ngon(cpos, circle_radius, 3, pi/6, vertices=true)
for (n, p) in enumerate(points3)
sethue(color_sequence[n][1]...)
circle(p, outercircleratio * circle_radius, :fill)
@cormullion
cormullion / julia-data-logo.jl
Created March 21, 2017 17:51
JuliaData logo
using Luxor
function drawcell(centerpos, width, height, colornumber; hollow=false)
darker_purple = (0.584, 0.345, 0.698)
lighter_purple = (0.667, 0.475, 0.757)
darker_green = (0.22, 0.596, 0.149)
lighter_green = (0.376, 0.678, 0.318)
darker_red = (0.796, 0.235, 0.2)
lighter_red = (0.835, 0.388, 0.361)
color_sequence = [(darker_red, lighter_red),
#!/usr/bin/env julia
# inspired by http://stackoverflow.com/questions/40031913/simulate-a-bouncing-ball
# and the inspired Chris Rackauckas
using DifferentialEquations, ParameterizedFunctions, NLsolve, Luxor
f = @ode_def BallBounce begin
dy = v
dv = -g
#!/usr/bin/env julia
using Luxor, Colors
"make a color more white"
function whiten(col::Color, f=0.5)
hsl = convert(HSL, col)
h, s, l = hsl.h, hsl.s, hsl.l
return convert(RGB, HSL(h, f, f))
end
@cormullion
cormullion / animated-hypotrochoids.jl
Created May 11, 2017 09:14
Animated hypotrochoids
#!/usr/bin/env julia
using Luxor
function makerandomepitrochoid(n)
hlist = []
plist = []
for i in 1:n
R = 20
r = rand(30:3:91)