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
#Get a console handle | |
GetConsoleWindow() = ccall((:GetConsoleWindow, :kernel32), Ptr{Void}, ()) | |
GetDC(win) = ccall((:GetDC, :user32), Ptr{Void}, (Ptr{Void},), win) | |
ReleaseDC(win, dc) = ccall((:ReleaseDC, :user32), Cint, (Ptr{Void}, Ptr{Void}), win, dc) | |
function GetCursorPos() # mouse position | |
pos = Ref{Tuple{Int32, Int32}}() | |
ccall((:GetCursorPos, :user32), UInt8, (Ptr{Tuple{Int32, Int32}},), pos) | |
Int64.(pos[]) | |
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
using Makie, Colors | |
using AbstractPlotting: modelmatrix | |
scene = Scene(resolution = (1000, 1000)) | |
AbstractPlotting.set_theme!() | |
ui_width = 260 | |
ui = Scene(scene, lift(x-> IRect(0, 0, ui_width, widths(x)[2]), pixelarea(scene))) | |
plot_scene = Scene(scene, lift(x-> IRect(ui_width, 0, widths(x) .- Vec(ui_width, 0)), pixelarea(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
using Makie | |
points = node(:poly, Point2f0[(0, 0), (0.5, 0.5), (1.0, 0.0)]) | |
scene = poly(points, strokewidth = 2, strokecolor = :black, color = :skyblue2, show_axis = false, scale_plot = false) | |
scatter!(points, color = :white, strokewidth = 10, markersize = 0.05, strokecolor = :black, raw = true) | |
pplot = scene[end] | |
push!(points[], Point2f0(0.6, -0.3)) | |
points[] = points[] |
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 HTTP | |
function url_exists(url) | |
try | |
r = HTTP.request("GET", url) | |
return r.status == 200 | |
catch e | |
return false | |
end | |
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
cd(@__DIR__) | |
using Makie | |
using FileIO, GeometryTypes, Colors, GDAL | |
GDAL.allregister() | |
istiff(x) = endswith(x, ".tif") | |
function loadf0(x) | |
img = GDAL.open(x, GDAL.GA_ReadOnly) | |
band = GDAL.getrasterband(img, 1) | |
xsize = GDAL.getrasterbandxsize(band) | |
ysize = GDAL.getrasterbandysize(band) |
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 | |
import DiffEqPhysics: SimulationResult | |
import AbstractPlotting: Plot, default_theme, plot!, to_value | |
# Probably worth having a macro for this! | |
function default_theme(scene::SceneLike, ::Type{<: Plot(SimulationResult)}) | |
Theme( | |
simulation_index = 1 |
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
unroll(f, ::Val{1}) = f() | |
function unroll(f, ::Val{N}) where N | |
f(); unroll(f, Val(N-1)) | |
end | |
function test() | |
box = Ref(1.0) # explicitely box to make escape analysis easier | |
unroll(()-> box[] += sin(box[]), Val(3)) | |
box[] | |
end |
creation | isbits type | immutable type | mutable type | array | gpu array | (device) local memory |
---|---|---|---|---|---|---|
pass to device | yes, copy | no ptrs, copy | copy | no | by reference | no |
on device | yes | may contain device ptr | no | no | no | yes |
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 GLVisualize, GeometryTypes, Colors | |
using GLAbstraction | |
using Reactive | |
window = glscreen() | |
timesignal = bounce(linspace(0f0,1f0,360)) | |
description = """ | |
Animated 2D particles in 3D space with glow. | |
""" |