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, " → ") |
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 Base.Broadcast: broadcasted | |
| struct LazyBro{T, N, B} <: AbstractArray{T, N} | |
| size::NTuple{N, Int} | |
| broadcast::B | |
| function (LazyBro{T})(x::B, size::NTuple{N, Int}) where {T, N, B <: Base.Broadcast.Broadcasted} | |
| new{T, N, B}(size, x) | |
| end | |
| end | |
| Base.size(x::LazyBro) = x.size | |
| Base.@propagate_inbounds Base.getindex(x::LazyBro, idx...) = x.broadcast[idx...] |
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 AbstractPlotting#master" | |
| using Makie, GeometryTypes, Colors | |
| using AbstractPlotting: slider!, playbutton | |
| using Observables | |
| cd(@__DIR__) | |
| psps = [rand(50, 50, 50) for i in 1:50] | |
| mini, maxi = mapreduce(extrema, (a, b)-> (min(a[1], b[1]), max(a[2], b[2])), psps) | |
| psps_n = map(psps) do vol |
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 |


