This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base = dirname(Base.find_source_file("sysimg.jl")) | |
file = "/home/sd/Desktop/precompile.jl" # snippet from slack | |
cd(homedir() * "/Desktop") | |
filebase = homedir() * "/Desktop/sysimg" | |
mkdir(filebase) | |
cd(base) | |
run(`julia1 --output-ji $filebase/corecompiler.ji --startup-file=no -g0 -O0 compiler/compiler.jl`) | |
run(`julia1 -g1 -O0 -C "native" --output-ji $filebase/sys.ji --startup-file=no --warn-overwrite=yes --sysimage $filebase/corecompiler.ji sysimg.jl`) | |
run(`julia1 -O3 -C "native" --output-o $filebase/sys.a --startup-file=no --warn-overwrite=yes --sysimage $filebase/sys.ji $file`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg"add FixedPointNumbers" | |
using WebSockets, WebIO, Colors, ImageMagick | |
using CSSUtil | |
using ImageFiltering, JSExpr | |
using Base64, FixedPointNumbers | |
using ImageTransformations | |
# using the string macro since for loops + ifs seem to make problems | |
const redraw = js""" | |
function redraw(context, brushsize, rect, drawtext){ | |
context.clearRect(0, 0, rect.height, rect.width); // Clears the canvas |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Makie | |
N = 100 | |
scene = mesh( | |
FRect3D(Vec3f0(-0.5), Vec3f0(1)), color = :skyblue2, | |
) | |
rect = scene[end] # last plot is the rect | |
# there are a couple of ratate! functions, that accept e.g. a vector etc | |
rotate!(rect, Quaternionf0(0, 0.4, 0, 1)) | |
scene |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function project_position(scene, point, model) | |
res = scene.camera.resolution[] | |
p4d = to_ndim(Vec4f0, to_ndim(Vec3f0, point, 0f0), 1f0) | |
clip = scene.camera.projectionview[] * model * p4d | |
p = (clip / clip[4])[Vec(1, 2)] | |
(p .+ 1) ./ 2 | |
end | |
""" | |
`scatter(x, y, z)` / `scatter(x, y)` / `scatter(positions)` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
`scatter(x, y, z)` / `scatter(x, y)` / `scatter(positions)` | |
Plots a marker for each element in `(x, y, z)`, `(x, y)`, or `positions`. | |
""" | |
function draw(scene::Scene, plot::Scatter) | |
# Extracts attributes from plot and makes them available in the current scope | |
# This also applies all conversions + extracts the current value from them. | |
# e.g. plot[:color] might be e.g. Node(:red), while @get_attribute(plot, (color,)) will be |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code taken from article: http://www.tylermw.com/throwing-shade/ | |
# Author: Tyler Morgan-Wall | |
function shadows( | |
A, volcanoshadow = fill(1.0, size(A)); | |
sunangle = 45 / 180*pi, | |
angle = -90 / 180 * pi, | |
diffangle = 90 / 180 * pi, | |
numberangles = 25, | |
anglebreaks = range(angle, stop = diffangle, length = numberangles), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
growth(🐇, 🥕) = 🐇 * 🥕 * (1.0 - 🐇) | |
function orbitdiagram(growth, r1, r2, n = 500, a = zeros(1000, n); T = 1000) | |
rs = range(r1, stop = r2, length = 1000) | |
for (j, r) in enumerate(rs) | |
x = 0.5 | |
for _ in 1:T; x = growth(x, r); end | |
for i in 1:n | |
x = growth(x, r) | |
@inbounds a[j, i] = x | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple 1 to 1 conversion - can only be used to transform arguments + pass additional attributes | |
# and change the default plot type - but can't be used for complex plots! | |
# Name is up for debate! | |
function convert_arguments(args...) | |
# Return a named tuple with the optional fields: | |
return ( | |
arguments = convert.(args), | |
plot = Scatter, # Optionally define the default plot type | |
attributes = ( | |
labels = create_labels(args...), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Makie, Interact, WebIO, Colors | |
widgets = ( | |
slider = widget(range(0.0, stop = 2pi, length = 200), label = "size"), # Slider | |
ranges = rangepicker( | |
range(0.1, stop = 3.0, length = 50) | |
), | |
toggle = widget(false), # Checkbox | |
text = widget("text"), # Textbox | |
# spinbox = widget(1.1), # Spinbox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using WebIO, TreeViews, CSSUtil, JSExpr, Interact | |
x = Lal(1f0, rand(10)) | |
using TreeViews: treenode, numberofnodes | |
function represent_node(s, x, i) | |
unfold = true | |
n = treenode(x, i) | |
str = sprint() do io | |
treelabel(io, x, i) | |
print(io, " → ") |