Skip to content

Instantly share code, notes, and snippets.

@cormullion
cormullion / maps.jl
Created March 20, 2024 17:23
a map icon
using Thebes
using Luxor
using Rotations
using Colors
julia_colors = [Luxor.julia_red,
Luxor.julia_purple,
Luxor.julia_blue,
Luxor.julia_green
]
@cormullion
cormullion / rectangular-moon-card.jl
Created January 9, 2024 09:08
rectangular moon calendar
using Colors, Luxor, Dates, JSON, DataFrames, Downloads
theyear = 2024
data_url = "https://svs.gsfc.nasa.gov/vis/a000000/a005100/a005187/mooninfo_2024.json"
if !isfile(string(@__DIR__, "/nasa-moon-$(theyear)-data.json"))
Downloads.download(data_url, "nasa-moon-2024-data.json")
end
function getdata()
@cormullion
cormullion / tape.jl
Last active December 13, 2023 12:14
rotating tape spools
using Luxor, Colors
function drawtape(spoolradius, separation, e)
@layer begin
# draw the 'tape' threading between the spools
# (e is normalized 0 to 1 for animation)
sr = spoolradius + 10 # outside spool, not realistic
spoolcenters = ngon(O, separation, 3, vertices = true)
top_point = Point(spoolcenters[2].x, spoolcenters[2].y - spoolradius - 10)
# top left spool
@cormullion
cormullion / tidiertext-logo.jl
Last active November 28, 2023 10:11
a logo idea
using Luxor, Colors
# julia colors as extracted from the SVG
tidier_lighter_colors = [
RGB(202 / 256, 60 / 256, 50 / 256), # lighter red
RGB(57 / 256, 151 / 256, 70 / 256), # lighter green
RGB(146 / 256, 89 / 256, 163 / 256), # lighter purple
RGB(76 / 256, 100 / 256, 176 / 256), # lighter blue
]
using Luxor, Colors
function draw_logo(color=colorant"black")
box(O, 580, 500, 40, :clip)
mountain = [
Point(-300, 250),
Point(-300, 200),
Point(-64, -70),
Point(40, 40),
Point(105, -5),
@cormullion
cormullion / propeller-check.jl
Created July 16, 2023 16:14
a propeller icon
using Luxor, Colors
function blade(θ, n)
@layer begin
rotate(θ)
move(Point(46, 3.693))
curve(Point(147.98, -101.378), Point(366.389, 35.292), Point(240, 145))
curve(Point(43, 316), Point(107, 16), Point(46, 3.693))
sethue(Colors.JULIA_LOGO_COLORS[mod1(n - 1, end)])
fillpath()
@cormullion
cormullion / juliaperformance.jl
Last active June 14, 2023 11:09
julia performance
using Luxor
function main()
Drawing(500, 500, "/tmp/juliaperformance.svg")
origin()
squircle(O, 245, 245, :clip, rt=0.3)
sethue("ivory")
paint()
@layer begin
translate(0, 200)
@cormullion
cormullion / animation-sketch.jl
Created June 6, 2023 14:37
an animated something
using Luxor, Thebes, MathTeXEngine
function frame(scene, framenumber)
background("white")
sethue("black")
fontsize(15)
eased_n = scene.easingfunction(framenumber, 0, 1, scene.framerange.stop)
helloworld()
eyepoint(200, 200, 100)
setline(0.5)
### A Pluto.jl notebook ###
# v0.12.15
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
@cormullion
cormullion / pendulums.jl
Last active October 24, 2022 11:39
George's double pendulums
using Luxor, DynamicalSystems, Colors
function frame(scene, framenumber, datas)
background("black")
# datas contains two datasets
# each dataset is an array of sarrays of 4 floats
d1, d2 = datas
offset = π / 2
L = 200
disksize = 15