diff --git a/REQUIRE b/REQUIRE index a69ea5d..2270289 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.6 +julia 0.7 StaticArrays 0.6.0 GeometryTypes 0.4.1 @@ -29,3 +29,5 @@ Images 0.9.0 # first version working on 0.6 AxisArrays ImageAxes IndirectArrays + +Statistics diff --git a/src/GLVisualize.jl b/src/GLVisualize.jl index fe7db82..5d18cee 100644 --- a/src/GLVisualize.jl +++ b/src/GLVisualize.jl @@ -16,7 +16,7 @@ using Packing using SignedDistanceFields using FreeType import IterTools -using Base.Markdown +using Markdown using FreeTypeAbstraction import ColorVectorSpace diff --git a/src/boundingbox.jl b/src/boundingbox.jl index 15c08c5..82a73e7 100644 --- a/src/boundingbox.jl +++ b/src/boundingbox.jl @@ -46,7 +46,7 @@ function (B::Type{AABB{T}})( return primitive end tsr::Tuple{Point3f0, Vec3f0, Mat4f0}, state = next(ti, state) - points = decompose(Point3f0, primitive)::Vector{Point3f0} + points = decompose(Point3f0, primitive) #::Vector{Point3f0} bb = transform(tsr[1], tsr[2], tsr[3], points) while !done(ti, state) tsr, state = next(ti, state) diff --git a/src/camera.jl b/src/camera.jl index 09a6c2b..d3abd15 100644 --- a/src/camera.jl +++ b/src/camera.jl @@ -1,3 +1,5 @@ +using Statistics + function cubeside_const_lift(_, id, mousehover) h_id, h_index = value(mousehover) if h_id == id && h_index >= 1 && h_index <= 6 @@ -28,7 +30,7 @@ function colored_cube() ydir = Vec3f0(0f0,1f0,0f0) zdir = Vec3f0(0f0,0f0,1f0) origin = Vec3f0(-0.5) - const quads = [ + quads = [ (Quad(origin + zdir, xdir, ydir), RGBA(1.0f0,0f0,0f0,1f0)), # Top (Quad(origin, ydir, xdir), RGBA(0.5f0,0f0,0f0,1f0)), # Bottom (Quad(origin + ydir, zdir, xdir), RGBA(0f0,1.0f0,0f0,1f0)), #Front @@ -39,7 +41,7 @@ function colored_cube() cube_steering = merge(map(GLNormalMesh, quads)) end -Base.middle(r::SimpleRectangle{T}) where {T} = Point{2, T}(r.x+(r.w/T(2)), r.y+(r.mousehover/T(2))) +middle(r::SimpleRectangle{T}) where {T} = Point{2, T}(r.x+(r.w/T(2)), r.y+(r.mousehover/T(2))) function get_rotation(m) diff --git a/src/documentation.jl b/src/documentation.jl index fa78da1..22500e1 100644 --- a/src/documentation.jl +++ b/src/documentation.jl @@ -13,7 +13,7 @@ end function print_type(x::TypeVar) string(x.name) end -print_type(x::TypeName) = print_type(x.name) +#print_type(x::TypeName) = print_type(x.name) print_type(x::UnionAll) = sprint(io-> show(io, x)) print_type(x) = print_type(x.name) function print_type(x::Union) diff --git a/src/gui/buttons.jl b/src/gui/buttons.jl index 2ce6d44..f9ef281 100644 --- a/src/gui/buttons.jl +++ b/src/gui/buttons.jl @@ -144,7 +144,7 @@ end function widget( r::Signal{T}, screen::Screen; args... - ) where T <: Range + ) where T <: AbstractRange slider(value(r), screen; args...) end function playbutton(screen; icon_size = 10mm) diff --git a/src/gui/numbers.jl b/src/gui/numbers.jl index ceb83c5..87cffb4 100644 --- a/src/gui/numbers.jl +++ b/src/gui/numbers.jl @@ -1,3 +1,4 @@ +using Printf drag_x(drag_id) = drag_id[1][1] @@ -39,9 +40,9 @@ function add_mouse_drags(t0, mouse_down1, mouseposition1, objectid, id_tolookfor (accum, mouse_down1, Vec2f0(0), 0, accum, 0) end -Base.clamp(x, r::Range) = clamp(x, first(r), last(r)) +Base.clamp(x, r::AbstractRange) = clamp(x, first(r), last(r)) -function slide(startvalue, slide_pos, range::Range) +function slide(startvalue, slide_pos, range::AbstractRange) val = startvalue + (slide_pos*step(range)) clamp(val, range) end diff --git a/src/parallel.jl b/src/parallel.jl index 4465dcb..f4936bf 100644 --- a/src/parallel.jl +++ b/src/parallel.jl @@ -14,6 +14,7 @@ using FileIO using Packing using SignedDistanceFields using FreeType +using Distributed # Parallel helper function to launch our glvisualize operations on the process, diff --git a/src/renderloop.jl b/src/renderloop.jl index f3ea057..493ef06 100644 --- a/src/renderloop.jl +++ b/src/renderloop.jl @@ -108,7 +108,7 @@ function fold_loop(v0, _) (val, range, index) end -function loop(range::Range, rate=60) +function loop(range::AbstractRange, rate=60) t = get_timer_signal(rate) map(first, foldp(fold_loop, (first(range), range, 1), t)) end @@ -125,7 +125,7 @@ function fold_bounce(v0, _) (val, range, index, direction) end -function bounce(range::Range{T}, rate=60) where T +function bounce(range::AbstractRange{T}, rate=60) where T t = get_timer_signal(rate) map(first, foldp(fold_bounce, (first(range), range, 1, 1), t)) end diff --git a/src/texture_atlas.jl b/src/texture_atlas.jl index 72ce5a0..3af6402 100644 --- a/src/texture_atlas.jl +++ b/src/texture_atlas.jl @@ -34,14 +34,15 @@ begin #basically a singleton for the textureatlas # random list of chars we cache # basically to make runtests fast, until we figure out a better way to cache # newly rendered chars. - const local _tobe_cached = [ + #const local _tobe_cached = [ + local _tobe_cached = [ 'π','∮','⋅','→','∞','∑','∏','∀','∈','ℝ','⌈','⌉','−','⌊','⌋','α','∧','β','∨','ℕ','⊆','₀', '⊂','ℤ','ℚ','ℂ','⊥','≠','≡','≤','≪','⊤','⇒','⇔','₂','⇌','Ω','⌀', ] - const local _atlas_cache = Dict{WeakRef, TextureAtlas}() - const local _cache_path = joinpath(dirname(@__FILE__), "..", ".cache", "texture_atlas.jls") - const local _default_font = Vector{Ptr{FreeType.FT_FaceRec}}[] - const local _alternative_fonts = Vector{Ptr{FreeType.FT_FaceRec}}[] + local _atlas_cache = Dict{WeakRef, TextureAtlas}() + local _cache_path = joinpath(dirname(@__FILE__), "..", ".cache", "texture_atlas.jls") + local _default_font = Vector{Ptr{FreeType.FT_FaceRec}}[] + local _alternative_fonts = Vector{Ptr{FreeType.FT_FaceRec}}[] function defaultfont() if isempty(_default_font) @@ -79,13 +80,13 @@ begin #basically a singleton for the textureatlas TextureAtlas(fields...) end catch e - info("You can likely ignore the following warning, if you just switched Julia versions for GLVisualize") + @info("You can likely ignore the following warning, if you just switched Julia versions for GLVisualize") warn(e) rm(_cache_path) end end atlas = TextureAtlas() - info("Caching fonts, this may take a while. Needed only on first run!") + @info("Caching fonts, this may take a while. Needed only on first run!") for c in '\u0000':'\u00ff' #make sure all ascii is mapped linearly insert_glyph!(atlas, c, defaultfont()) end diff --git a/src/types.jl b/src/types.jl index 28286de..e04ab3a 100644 --- a/src/types.jl +++ b/src/types.jl @@ -2,12 +2,12 @@ @enum RaymarchAlgorithm IsoValue Absorption MaximumIntensityProjection AbsorptionRGBA IndexedAbsorptionRGBA @enum CubeSides TOP BOTTOM FRONT BACK RIGHT LEFT -struct Grid{N, T <: Range} +struct Grid{N, T <: AbstractRange} dims::NTuple{N, T} end Base.ndims(::Grid{N,T}) where {N,T} = N -Grid(ranges::Range...) = Grid(ranges) +Grid(ranges::AbstractRange...) = Grid(ranges) function Grid(a::Array{T, N}) where {N, T} s = Vec{N, Float32}(size(a)) smax = maximum(s) @@ -74,8 +74,8 @@ import Base: getindex, length, next, start, done to_cpu_mem(x) = x to_cpu_mem(x::GPUArray) = gpu_data(x) -const ScaleTypes = Union{Vector, Vec, AbstractFloat, Void, Grid} -const PositionTypes = Union{Vector, Point, AbstractFloat, Void, Grid} +const ScaleTypes = Union{Vector, Vec, AbstractFloat, Nothing, Grid} +const PositionTypes = Union{Vector, Point, AbstractFloat, Nothing, Grid} mutable struct ScalarRepeat{T} scalar::T @@ -132,22 +132,22 @@ end -function ArrayOrStructOfArray(::Type{T}, array::Void, a, elements...) where T +function ArrayOrStructOfArray(::Type{T}, array::Nothing, a, elements...) where T StructOfArrays(T, a, elements...) end function ArrayOrStructOfArray(::Type{T}, array::StaticVector, a, elements...) where T StructOfArrays(T, a, elements...) end -function ArrayOrStructOfArray(::Type{T}, scalar::StaticVector, a::Void, elements::Void...) where T +function ArrayOrStructOfArray(::Type{T}, scalar::StaticVector, a::Nothing, elements::Nothing...) where T ScalarRepeat(transform_convert(T, scalar)) end -function ArrayOrStructOfArray(::Type{T1}, array::Array{T2}, a::Void, elements::Void...) where {T1,T2} +function ArrayOrStructOfArray(::Type{T1}, array::Array{T2}, a::Nothing, elements::Nothing...) where {T1,T2} array end -function ArrayOrStructOfArray(::Type{T1}, grid::Grid, x::Void, y::Void, z::Array) where T1<:Point +function ArrayOrStructOfArray(::Type{T1}, grid::Grid, x::Nothing, y::Nothing, z::Array) where T1<:Point GridZRepeat(grid, z) end -function ArrayOrStructOfArray(::Type{T1}, array::Grid, a::Void, elements::Void...) where T1<:Point +function ArrayOrStructOfArray(::Type{T1}, array::Grid, a::Nothing, elements::Nothing...) where T1<:Point array end function ArrayOrStructOfArray(::Type{T}, scalar::T) where T @@ -259,7 +259,7 @@ struct GLVisualizeShader <: AbstractLazyShader kw_args::Dict{Symbol, Any} function GLVisualizeShader(paths::String...; view = Dict{String, String}(), kw_args...) # TODO properly check what extensions are available - @static if !is_apple() + @static if !Sys.isapple() view["GLSL_EXTENSIONS"] = "#extension GL_ARB_conservative_depth: enable" view["SUPPORTED_EXTENSIONS"] = "#define DETPH_LAYOUT" end diff --git a/src/utils.jl b/src/utils.jl index 70de077..8d5d709 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -13,7 +13,7 @@ isa_image(x::Matrix) = isa_image(typeof(x)) isa_image(x) = false # Splits a dictionary in two dicts, via a condition -function Base.split(condition::Function, associative::Associative) +function Base.split(condition::Function, associative::AbstractDict) A = similar(associative) B = similar(associative) for (key, value) in associative @@ -170,7 +170,7 @@ function dragged_on(robj::RenderObject, button::MouseButton, window::Screen) end) end -points2f0(positions::Vector{T}, range::Range) where {T} = Point2f0[Point2f0(range[i], positions[i]) for i=1:length(range)] +points2f0(positions::Vector{T}, range::AbstractRange) where {T} = Point2f0[Point2f0(range[i], positions[i]) for i=1:length(range)] extrema2f0(x::Array{T,N}) where {T<:Intensity,N} = Vec2f0(extrema(reinterpret(Float32,x))) extrema2f0(x::Array{T,N}) where {T,N} = Vec2f0(extrema(x)) diff --git a/src/videotool.jl b/src/videotool.jl index 00e7479..a428e34 100644 --- a/src/videotool.jl +++ b/src/videotool.jl @@ -2,7 +2,7 @@ # ffmpeg version # ffmpeg -r 24 -pattern_type glob -i '*.png' -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 -immutable VideoStream +struct VideoStream io buffer window diff --git a/src/visualize/image_like.jl b/src/visualize/image_like.jl index 39ad16d..7ccb8f9 100644 --- a/src/visualize/image_like.jl +++ b/src/visualize/image_like.jl @@ -1,7 +1,6 @@ """ A matrix of colors is interpreted as an image """ - _default(::Signal{Array{RGBA{N0f8}, 2}}, ::Style{:default}, ::Dict{Symbol,Any}) diff --git a/src/visualize/lines.jl b/src/visualize/lines.jl index 6333bce..b182726 100644 --- a/src/visualize/lines.jl +++ b/src/visualize/lines.jl @@ -42,7 +42,10 @@ function ticks(points, resolution) end -function _default(position::Union{VecTypes{T}, MatTypes{T}}, s::style"lines", data::Dict) where T<:Point +_default(position::Union{VecTypes{T}, MatTypes{T}}, s::style"lines", data::Dict) where T<:Point = _default_l(position, s, data) +_default(position::Union{Array{T,1}, GPUArray{T,1}, Signal{Array{T,1}}}, s::style"lines", data::Dict) where T<:Point = _default_l(position, s, data) + +function _default_l(position::Union{VecTypes{T}, MatTypes{T}}, s::style"lines", data::Dict) where T<:Point pv = value(position) p_vec = if isa(position, GPUArray) position @@ -137,7 +140,7 @@ function _default(positions::VecTypes{T}, s::style"linesegment", data::Dict) whe data end -function _default(positions::Vector{T}, range::Range, s::style"lines", data::Dict) where T <: AbstractFloat +function _default(positions::Vector{T}, range::AbstractRange, s::style"lines", data::Dict) where T <: AbstractFloat length(positions) != length(range) && throw( DimensionMismatsch("length of $(typeof(positions)) $(length(positions)) and $(typeof(range)) $(length(range)) must match") ) diff --git a/src/visualize/particles.jl b/src/visualize/particles.jl index 17e4d64..14d3695 100644 --- a/src/visualize/particles.jl +++ b/src/visualize/particles.jl @@ -361,8 +361,7 @@ primitive_scale(c) = Vec2f0(0.1) Extracts the offset from a primitive. """ #primitive_offset(prim::GeometryPrimitive) = Vec2f0(minimum(prim)) - -primitive_offset(x, scale::Void) = Vec2f0(0) # default offset +primitive_offset(x, scale::Nothing) = Vec2f0(0) # default offset primitive_offset(x, scale) = const_lift(/, scale, -2f0) # default offset diff --git a/src/visualize/text.jl b/src/visualize/text.jl index c73ac59..eafaf8d 100644 --- a/src/visualize/text.jl +++ b/src/visualize/text.jl @@ -54,7 +54,7 @@ function Base.setindex!(t::Text, value::Char, i::Integer) t.scales[i] = gs end -function Base.setindex!(t::Text, value::Associative, i::Integer) +function Base.setindex!(t::Text, value::AbstractDict, i::Integer) for (k,v) in value getfield(t, k)[i] = v end