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
| export play | |
| """ | |
| play(img, timedim, t) | |
| Slice a 3D array along axis `timedim` at time `t`. | |
| This can be used to treat a 3D array like a video and create an image stream from it. | |
| """ | |
| function play(array::Array{T, 3}, timedim::Integer, t::Integer) where T | |
| index = ntuple(dim-> dim == timedim ? t : Colon(), Val(3)) |
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, GeometryTypes | |
| points = decompose(Point2f0, Circle(Point2f0(0), 1f0)) | |
| points[1] ≈ points[end] # first and last are the same, so they will get removed | |
| # lets remove it ourselves, so that we can more easily map over it! | |
| pop!(points) | |
| mesh = GLNormalMesh(points) | |
| # Visualize poly | |
| scene = Makie.mesh(mesh, shading = false) | |
| mplot = scene[end] | |
| # Points get converted to 3d + get one end point |
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 Rhea, Makie | |
| # Vbox: left and right-most spines match, heights are distributed | |
| # Hbox: top and bottom-most spines match, widths are distributed | |
| # grid: rows and columns aligned | |
| mutable struct Axis | |
| l::variable{Float64} | |
| t::variable{Float64} | |
| r::variable{Float64} |
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 Sockets | |
| import AssetRegistry | |
| using WebSockets | |
| using WebSockets: is_upgrade, upgrade, writeguarded | |
| using WebSockets: HTTP | |
| using Hyperscript | |
| @tags div script | |
| @tags_noescape style |
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 Interact, WebIO, Random | |
| struct Item{NT} | |
| data::NT | |
| end | |
| Item(; kw...) = Item(values(kw)) | |
| Base.getproperty(x::Item, key::Symbol) = getfield(getfield(x, :data), key) | |
| items = map(1:170) do i | |
| Item( |
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 searchmodule(mod, name, visited = Set()) | |
| mod in visited && return nothing | |
| push!(visited, mod) | |
| string(mod) == string(name) && return mod | |
| if mod isa Module | |
| name == nameof(mod) && return mod | |
| for sym in names(mod) | |
| res = searchmodule(getfield(mod, sym), name, visited) | |
| res !== nothing && return res | |
| 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
| # load test image | |
| using Makie | |
| using AbstractPlotting: limits | |
| # The data | |
| """ | |
| Very simple resampling of an index range | |
| """ | |
| function resample(range) |
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 WebSockets, WebIO, Colors, ImageMagick | |
| using CSSUtil | |
| using ImageFiltering, JSExpr | |
| using Base64, FixedPointNumbers | |
| using ImageTransformations, CSSUtil | |
| # 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 | |
| context.beginPath(); |
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 Colors, FixedPointNumbers | |
| const DWORD = Culong | |
| const LONG = Clong | |
| const WORD = Cushort | |
| const CIEXYZTRIPLE = NTuple{3, XYZ{Float32}} | |
| struct BITMAPV5HEADER | |
| bV5Size::DWORD | |
| bV5Width::LONG | |
| bV5Height::LONG |
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
| AbstractPlotting.set_theme!() # reset theme | |
| function lorenz(t0, a, b, c, h) | |
| Point3f0( | |
| t0[1] + h * a * (t0[2] - t0[1]), | |
| t0[2] + h * (t0[1] * (b - t0[3]) - t0[2]), | |
| t0[3] + h * (t0[1] * t0[2] - c * t0[3]), | |
| ) | |
| end | |
| # step through the `time` | |
| function lorenz(array::Vector, a = 5.0 ,b = 2.0, c = 6.0, d = 0.01) |