From 187a5df4a4c35bddbf34d343498e89ce17c5fa74 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 23 Aug 2021 17:20:49 +0200 Subject: [PATCH 1/4] Switch to GeometryBasics 0.4.1 --- CairoMakie/Project.toml | 2 +- CairoMakie/src/overrides.jl | 8 +- CairoMakie/src/primitives.jl | 62 +++---- CairoMakie/src/utils.jl | 32 ++-- GLMakie/Project.toml | 2 +- GLMakie/experiments/cuda_interop.jl | 2 +- GLMakie/experiments/shaderabstr.jl | 20 +- .../src/GLAbstraction/GLExtendedFunctions.jl | 4 +- GLMakie/src/GLAbstraction/GLRenderObject.jl | 6 +- GLMakie/src/GLAbstraction/GLTypes.jl | 2 +- GLMakie/src/GLAbstraction/GLUniforms.jl | 2 +- GLMakie/src/GLAbstraction/GLUtils.jl | 6 +- GLMakie/src/GLVisualize/GLVisualize.jl | 2 +- GLMakie/src/GLVisualize/precompile.jl | 4 +- .../src/GLVisualize/visualize/image_like.jl | 18 +- GLMakie/src/GLVisualize/visualize/mesh.jl | 6 +- .../src/GLVisualize/visualize/particles.jl | 56 +++--- GLMakie/src/GLVisualize/visualize/surface.jl | 18 +- .../src/GLVisualize/visualize_interface.jl | 4 +- GLMakie/src/drawing_primitives.jl | 28 +-- GLMakie/src/events.jl | 4 +- GLMakie/src/postprocessing.jl | 14 +- GLMakie/src/precompile.jl | 2 +- GLMakie/src/screen.jl | 12 +- GLMakie/test/glmakie_tests.jl | 22 +-- GLMakie/test/unit_tests.jl | 8 +- MakieRecipes/src/bezier.jl | 8 +- MakieRecipes/src/pipeline_integration.jl | 6 +- Project.toml | 4 +- ReferenceTests/src/runtests.jl | 2 +- ReferenceTests/src/tests/attributes.jl | 2 +- ReferenceTests/src/tests/examples2d.jl | 36 ++-- ReferenceTests/src/tests/examples3d.jl | 100 +++++----- ReferenceTests/src/tests/recipes.jl | 10 +- ReferenceTests/src/tests/short_tests.jl | 28 +-- ReferenceTests/src/tests/text.jl | 36 ++-- WGLMakie/Project.toml | 2 +- WGLMakie/README.md | 8 +- WGLMakie/src/imagelike.jl | 36 ++-- WGLMakie/src/lines.jl | 4 +- WGLMakie/src/meshes.jl | 16 +- WGLMakie/src/particles.jl | 14 +- WGLMakie/src/serialization.jl | 12 +- docs/documentation/animation.md | 10 +- docs/documentation/events.md | 2 +- docs/documentation/inspector.md | 12 +- docs/documentation/layoutables.md | 2 +- docs/documentation/lighting.md | 22 +-- docs/documentation/nodes.md | 2 +- docs/documentation/recipes.md | 8 +- docs/examples/layoutables/axis.md | 8 +- docs/examples/layoutables/intervalslider.md | 2 +- docs/examples/layoutables/legend.md | 8 +- docs/examples/layoutables/slider.md | 2 +- docs/examples/plotting_functions/arrows.md | 18 +- docs/examples/plotting_functions/band.md | 4 +- docs/examples/plotting_functions/poly.md | 12 +- docs/examples/plotting_functions/series.md | 2 +- docs/examples/plotting_functions/stem.md | 2 +- .../examples/plotting_functions/streamplot.md | 2 +- docs/examples/plotting_functions/text.md | 4 +- docs/tutorials/layout-tutorial.md | 2 +- src/Makie.jl | 16 +- src/basic_recipes/arc.jl | 6 +- src/basic_recipes/arrows.jl | 46 ++--- src/basic_recipes/axis.jl | 14 +- src/basic_recipes/band.jl | 2 +- src/basic_recipes/barplot.jl | 20 +- src/basic_recipes/buffers.jl | 8 +- src/basic_recipes/contourf.jl | 20 +- src/basic_recipes/contours.jl | 14 +- src/basic_recipes/convenience_functions.jl | 4 +- src/basic_recipes/error_and_rangebars.jl | 34 ++-- src/basic_recipes/pie.jl | 6 +- src/basic_recipes/poly.jl | 10 +- src/basic_recipes/series.jl | 6 +- src/basic_recipes/spy.jl | 6 +- src/basic_recipes/stairs.jl | 14 +- src/basic_recipes/streamplot.jl | 8 +- src/basic_recipes/text.jl | 34 ++-- src/basic_recipes/timeseries.jl | 4 +- src/basic_recipes/volumeslices.jl | 2 +- src/basic_recipes/wireframe.jl | 6 +- src/camera/camera.jl | 10 +- src/camera/camera2d.jl | 44 ++--- src/camera/camera3d.jl | 68 +++---- src/camera/old_camera3d.jl | 70 +++---- src/camera/projection_math.jl | 34 ++-- src/colorsampler.jl | 14 +- src/conversions.jl | 104 +++++------ src/deprecated.jl | 3 + src/display.jl | 10 +- src/interaction/inspector.jl | 172 +++++++++--------- src/interaction/interactive_api.jl | 38 ++-- src/interfaces.jl | 8 +- src/jl_rasterizer/main.jl | 62 +++---- src/layouting/boundingbox.jl | 42 ++--- src/layouting/data_limits.jl | 24 +-- src/layouting/layouting.jl | 50 ++--- src/layouting/transformation.jl | 30 +-- src/makielayout/MakieLayout.jl | 8 +- src/makielayout/defaultattributes.jl | 66 +++---- src/makielayout/geometrybasics_extension.jl | 32 ++-- src/makielayout/helpers.jl | 10 +- src/makielayout/interactions.jl | 26 +-- src/makielayout/layoutables/axis.jl | 42 ++--- src/makielayout/layoutables/axis3d.jl | 36 ++-- src/makielayout/layoutables/box.jl | 2 +- src/makielayout/layoutables/button.jl | 6 +- src/makielayout/layoutables/colorbar.jl | 8 +- src/makielayout/layoutables/intervalslider.jl | 10 +- src/makielayout/layoutables/label.jl | 6 +- src/makielayout/layoutables/legend.jl | 6 +- src/makielayout/layoutables/menu.jl | 10 +- src/makielayout/layoutables/slider.jl | 10 +- src/makielayout/layoutables/textbox.jl | 10 +- src/makielayout/layoutables/toggle.jl | 4 +- src/makielayout/lineaxis.jl | 50 ++--- src/makielayout/mousestatemachine.jl | 12 +- src/makielayout/roundedrect.jl | 4 +- src/makielayout/types.jl | 18 +- src/patterns.jl | 16 +- src/precompile.jl | 50 ++--- src/scenes.jl | 52 +++--- src/shorthands.jl | 4 +- src/stats/boxplot.jl | 6 +- src/stats/crossbar.jl | 2 +- src/stats/density.jl | 20 +- src/stats/hist.jl | 2 +- src/stats/violin.jl | 10 +- src/themes/theme_black.jl | 10 +- src/theming.jl | 6 +- src/types.jl | 38 ++-- src/units.jl | 14 +- src/utilities/quaternions.jl | 2 +- src/utilities/texture_atlas.jl | 12 +- src/utilities/utilities.jl | 6 +- test/conversions.jl | 8 +- test/events.jl | 106 +++++------ test/makielayout.jl | 10 +- test/quaternions.jl | 12 +- test/statistical_tests.jl | 28 +-- test/transformations.jl | 34 ++-- 143 files changed, 1343 insertions(+), 1338 deletions(-) create mode 100644 src/deprecated.jl diff --git a/CairoMakie/Project.toml b/CairoMakie/Project.toml index 9eaf85b7fdd..cb3ac0b3068 100644 --- a/CairoMakie/Project.toml +++ b/CairoMakie/Project.toml @@ -22,7 +22,7 @@ Colors = "0.10, 0.11, 0.12" FFTW = "1" FileIO = "1.1" FreeType = "3, 4.0" -GeometryBasics = "0.2, 0.3" +GeometryBasics = "0.4.1" Makie = "=0.15.1" StaticArrays = "0.12, 1.0" julia = "1.3" diff --git a/CairoMakie/src/overrides.jl b/CairoMakie/src/overrides.jl index 8e7f6100fa4..bf40596e4a2 100644 --- a/CairoMakie/src/overrides.jl +++ b/CairoMakie/src/overrides.jl @@ -58,9 +58,9 @@ function draw_poly(scene::Scene, screen::CairoScreen, poly, points_list::Vector{ end -draw_poly(scene::Scene, screen::CairoScreen, poly, rect::Rect2D) = draw_poly(scene, screen, poly, [rect]) +draw_poly(scene::Scene, screen::CairoScreen, poly, rect::Rect2) = draw_poly(scene, screen, poly, [rect]) -function draw_poly(scene::Scene, screen::CairoScreen, poly, rects::Vector{<:Rect2D}) +function draw_poly(scene::Scene, screen::CairoScreen, poly, rects::Vector{<:Rect2}) model = poly.model[] projected_rects = project_rect.(Ref(scene), rects, Ref(model)) @@ -90,14 +90,14 @@ function draw_poly(scene::Scene, screen::CairoScreen, poly, rects::Vector{<:Rect end function polypath(ctx, polygon) - ext = decompose(Point2f0, polygon.exterior) + ext = decompose(Point2f, polygon.exterior) Cairo.move_to(ctx, ext[1]...) for point in ext[2:end] Cairo.line_to(ctx, point...) end Cairo.close_path(ctx) - interiors = decompose.(Point2f0, polygon.interiors) + interiors = decompose.(Point2f, polygon.interiors) for interior in interiors Cairo.move_to(ctx, interior[1]...) for point in interior[2:end] diff --git a/CairoMakie/src/primitives.jl b/CairoMakie/src/primitives.jl index 45e1ac0f381..918f2508c3d 100644 --- a/CairoMakie/src/primitives.jl +++ b/CairoMakie/src/primitives.jl @@ -18,7 +18,7 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Union{Lines, # TODO this shouldn't be necessary anymore! if positions isa SubArray{<:Point3, 1, P, <:Tuple{Array{<:AbstractFace}}} where P positions = let - pos = Point3f0[] + pos = Point3f[] for tup in positions push!(pos, tup[1]) push!(pos, tup[2]) @@ -174,7 +174,7 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Scatter) model = primitive[:model][] positions = primitive[1][] isempty(positions) && return - size_model = transform_marker ? model : Mat4f0(I) + size_model = transform_marker ? model : Mat4f(I) font = to_font(to_value(get(primitive, :font, Makie.defaultfont()))) @@ -235,12 +235,12 @@ function draw_marker(ctx, marker::Char, font, pos, scale, strokecolor, strokewid inkbb = Makie.FreeTypeAbstraction.inkboundingbox(charextent) # scale normalized bbox by font size - inkbb_scaled = FRect2D(origin(inkbb) .* scale, widths(inkbb) .* scale) + inkbb_scaled = Rect2f(origin(inkbb) .* scale, widths(inkbb) .* scale) # flip y for the centering shift of the character because in Cairo y goes down centering_offset = [1, -1] .* (-origin(inkbb_scaled) .- 0.5 .* widths(inkbb_scaled)) # this is the origin where we actually have to place the glyph so it can be centered - charorigin = pos .+ Vec2f0(marker_offset[1], -marker_offset[2]) + charorigin = pos .+ Vec2f(marker_offset[1], -marker_offset[2]) old_matrix = get_font_matrix(ctx) set_font_matrix(ctx, scale_matrix(scale...)) @@ -272,7 +272,7 @@ end function draw_marker(ctx, marker::Circle, pos, scale, strokecolor, strokewidth, marker_offset, rotation) marker_offset = marker_offset + scale ./ 2 - pos += Point2f0(marker_offset[1], -marker_offset[2]) + pos += Point2f(marker_offset[1], -marker_offset[2]) Cairo.arc(ctx, pos[1], pos[2], scale[1]/2, 0, 2*pi) Cairo.fill_preserve(ctx) @@ -285,7 +285,7 @@ end function draw_marker(ctx, marker::Rect, pos, scale, strokecolor, strokewidth, marker_offset, rotation) s2 = Point2((widths(marker) .* scale .* (1, -1))...) - pos = pos .+ Point2f0(marker_offset[1], -marker_offset[2]) + pos = pos .+ Point2f(marker_offset[1], -marker_offset[2]) Cairo.rotate(ctx, to_2d_rotation(rotation)) Cairo.rectangle(ctx, pos[1], pos[2], s2...) Cairo.fill_preserve(ctx) @@ -350,7 +350,7 @@ function draw_glyph_collection(scene, ctx, position, glyph_collection, rotation, cairoface = set_ft_font(ctx, font) old_matrix = get_font_matrix(ctx) - p3_offset = to_ndim(Point3f0, offset, 0) + p3_offset = to_ndim(Point3f, offset, 0) glyph in ('\r', '\n') && return @@ -362,9 +362,9 @@ function draw_glyph_collection(scene, ctx, position, glyph_collection, rotation, # and then projected # glyph position in data coordinates (offset has rotation applied already) - gpos_data = to_ndim(Point3f0, position, 0) .+ glyphoffset .+ p3_offset + gpos_data = to_ndim(Point3f, position, 0) .+ glyphoffset .+ p3_offset - scale3 = scale isa Number ? Point3f0(scale, scale, 0) : to_ndim(Point3f0, scale, 0) + scale3 = scale isa Number ? Point3f(scale, scale, 0) : to_ndim(Point3f, scale, 0) # this could be done better but it works at least @@ -373,12 +373,12 @@ function draw_glyph_collection(scene, ctx, position, glyph_collection, rotation, # origin. The resulting vectors give the directions in which the character # needs to be stretched in order to match the 3D projection - xvec = rotation * (scale3[1] * Point3f0(1, 0, 0)) - yvec = rotation * (scale3[2] * Point3f0(0, -1, 0)) + xvec = rotation * (scale3[1] * Point3f(1, 0, 0)) + yvec = rotation * (scale3[2] * Point3f(0, -1, 0)) - glyphpos = project_position(scene, gpos_data, Mat4f0(I)) - xproj = project_position(scene, gpos_data + xvec, Mat4f0(I)) - yproj = project_position(scene, gpos_data + yvec, Mat4f0(I)) + glyphpos = project_position(scene, gpos_data, Mat4f(I)) + xproj = project_position(scene, gpos_data + xvec, Mat4f(I)) + yproj = project_position(scene, gpos_data + yvec, Mat4f(I)) xdiff = xproj - glyphpos ydiff = yproj - glyphpos @@ -395,7 +395,7 @@ function draw_glyph_collection(scene, ctx, position, glyph_collection, rotation, glyphpos = project_position( scene, position, - Mat4f0(I)) .+ (p3_to_p2(glyphoffset .+ p3_offset)) .* (1, -1) # flip for Cairo + Mat4f(I)) .+ (p3_to_p2(glyphoffset .+ p3_offset)) .* (1, -1) # flip for Cairo # and the scale is just taken as is scale = length(scale) == 2 ? scale : SVector(scale, scale) @@ -413,7 +413,7 @@ function draw_glyph_collection(scene, ctx, position, glyph_collection, rotation, Cairo.show_text(ctx, string(glyph)) Cairo.restore(ctx) - if strokewidth > 0 && strokecolor != RGBAf0(0, 0, 0, 0) + if strokewidth > 0 && strokecolor != RGBAf(0, 0, 0, 0) Cairo.save(ctx) Cairo.move_to(ctx, glyphpos...) set_font_matrix(ctx, mat) @@ -525,8 +525,8 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Union{Heatmap # find projected image corners # this already takes care of flipping the image to correct cairo orientation - xy = project_position(scene, Point2f0(first.(imsize)), model) - xymax = project_position(scene, Point2f0(last.(imsize)), model) + xy = project_position(scene, Point2f(first.(imsize)), model) + xymax = project_position(scene, Point2f(last.(imsize)), model) w, h = xymax .- xy s = to_cairo_image(image, primitive) @@ -557,7 +557,7 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Union{Heatmap end # find projected image corners # this already takes care of flipping the image to correct cairo orientation - xys = [project_position(scene, Point2f0(x, y), model) for x in xs, y in ys] + xys = [project_position(scene, Point2f(x, y), model) for x in xs, y in ys] colors = to_rgba_image(image, primitive) # Note: xs and ys should have size ni+1, nj+1 @@ -663,7 +663,7 @@ nan2zero(x) = !isnan(x) * x function draw_mesh3D( scene, screen, primitive; - mesh = primitive[1][], pos = Vec4f0(0), scale = 1f0 + mesh = primitive[1][], pos = Vec4f(0), scale = 1f0 ) @get_attribute(primitive, (color, shading, lightposition, ambient, diffuse, specular, shininess, faceculling)) @@ -694,8 +694,8 @@ function draw_mesh3D( vs = broadcast(decompose(Point, mesh), (func,)) do v, f # Should v get a nan2zero? v = Makie.apply_transform(f, v) - p4d = to_ndim(Vec4f0, scale .* to_ndim(Vec3f0, v, 0f0), 1f0) - view * (model * p4d .+ to_ndim(Vec4f0, pos, 0f0)) + p4d = to_ndim(Vec4f, scale .* to_ndim(Vec3f, v, 0f0), 1f0) + view * (model * p4d .+ to_ndim(Vec4f, pos, 0f0)) end fs = decompose(GLTriangleFace, mesh) uv = hasproperty(mesh, :uv) ? mesh.uv : nothing @@ -711,18 +711,18 @@ function draw_mesh3D( if lightposition == :eyeposition lightposition = scene.camera.eyeposition[] end - lightpos = (view * to_ndim(Vec4f0, lightposition, 1.0))[Vec(1, 2, 3)] + lightpos = (view * to_ndim(Vec4f, lightposition, 1.0))[Vec(1, 2, 3)] # Camera to screen space ts = map(vs) do v clip = projection * v @inbounds begin p = (clip ./ clip[4])[Vec(1, 2)] - p_yflip = Vec2f0(p[1], -p[2]) + p_yflip = Vec2f(p[1], -p[2]) p_0_to_1 = (p_yflip .+ 1f0) / 2f0 end p = p_0_to_1 .* scene.camera.resolution[] - Vec3f0(p[1], p[2], clip[3]) + Vec3f(p[1], p[2], clip[3]) end # Approximate zorder @@ -744,7 +744,7 @@ function draw_mesh3D( H = normalize(L + normalize(-v[SOneTo(3)])) spec_coeff = max(dot(H, N), 0.0)^shininess c = RGBA(c) - new_c = (ambient .+ diff_coeff .* diffuse) .* Vec3f0(c.r, c.g, c.b) .+ + new_c = (ambient .+ diff_coeff .* diffuse) .* Vec3f(c.r, c.g, c.b) .+ specular * spec_coeff RGBA(new_c..., c.alpha) end @@ -752,7 +752,7 @@ function draw_mesh3D( cols[k] end # debug normal coloring - # n1, n2, n3 = Vec3f0(0.5) .+ 0.5ns[f] + # n1, n2, n3 = Vec3f(0.5) .+ 0.5ns[f] # c1 = RGB(n1...) # c2 = RGB(n2...) # c3 = RGB(n3...) @@ -812,7 +812,7 @@ function surface2mesh(xs::Makie.ClosedInterval, ys::Makie.ClosedInterval, zs::Ab end function surface2mesh(xs::AbstractVector, ys::AbstractVector, zs::AbstractMatrix) - ps = [nan2zero.(Point3f0(xs[i], ys[j], zs[i, j])) for j in eachindex(ys) for i in eachindex(xs)] + ps = [nan2zero.(Point3f(xs[i], ys[j], zs[i, j])) for j in eachindex(ys) for i in eachindex(xs)] idxs = LinearIndices(size(zs)) faces = [ QuadFace(idxs[i, j], idxs[i+1, j], idxs[i+1, j+1], idxs[i, j+1]) @@ -822,7 +822,7 @@ function surface2mesh(xs::AbstractVector, ys::AbstractVector, zs::AbstractMatrix end function surface2mesh(xs::AbstractMatrix, ys::AbstractMatrix, zs::AbstractMatrix) - ps = [nan2zero.(Point3f0(xs[i, j], ys[i, j], zs[i, j])) for j in 1:size(zs, 2) for i in 1:size(zs, 1)] + ps = [nan2zero.(Point3f(xs[i, j], ys[i, j], zs[i, j])) for j in 1:size(zs, 2) for i in 1:size(zs, 1)] idxs = LinearIndices(size(zs)) faces = [ QuadFace(idxs[i, j], idxs[i+1, j], idxs[i+1, j+1], idxs[i, j+1]) @@ -850,7 +850,7 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Makie.MeshSca view = scene.camera.view[] zorder = sortperm(pos, by = p -> begin - p4d = to_ndim(Vec4f0, to_ndim(Vec3f0, p, 0f0), 1f0) + p4d = to_ndim(Vec4f, to_ndim(Vec3f, p, 0f0), 1f0) cam_pos = view * model * p4d cam_pos[3] / cam_pos[4] end, rev=false) @@ -883,7 +883,7 @@ function draw_atomic(scene::Scene, screen::CairoScreen, primitive::Makie.MeshSca draw_mesh3D( scene, screen, submesh, mesh = m, pos = p, - scale = scale isa Real ? Vec3f0(scale) : to_ndim(Vec3f0, scale, 1f0) + scale = scale isa Real ? Vec3f(scale) : to_ndim(Vec3f, scale, 1f0) ) end diff --git a/CairoMakie/src/utils.jl b/CairoMakie/src/utils.jl index c6669d5209a..dab45c88daf 100644 --- a/CairoMakie/src/utils.jl +++ b/CairoMakie/src/utils.jl @@ -8,13 +8,13 @@ function project_position(scene, point, model) point = Makie.apply_transform(scene.transformation.transform_func[], point) res = scene.camera.resolution[] - p4d = to_ndim(Vec4f0, to_ndim(Vec3f0, point, 0f0), 1f0) + p4d = to_ndim(Vec4f, to_ndim(Vec3f, point, 0f0), 1f0) clip = scene.camera.projectionview[] * model * p4d @inbounds begin # between -1 and 1 p = (clip ./ clip[4])[Vec(1, 2)] # flip y to match cairo - p_yflip = Vec2f0(p[1], -p[2]) + p_yflip = Vec2f(p[1], -p[2]) # normalize to between 0 and 1 p_0_to_1 = (p_yflip .+ 1f0) / 2f0 end @@ -22,10 +22,10 @@ function project_position(scene, point, model) return p_0_to_1 .* res end -project_scale(scene::Scene, s::Number, model = Mat4f0(I)) = project_scale(scene, Vec2f0(s), model) +project_scale(scene::Scene, s::Number, model = Mat4f(I)) = project_scale(scene, Vec2f(s), model) -function project_scale(scene::Scene, s, model = Mat4f0(I)) - p4d = to_ndim(Vec4f0, s, 0f0) +function project_scale(scene::Scene, s, model = Mat4f(I)) + p4d = to_ndim(Vec4f, s, 0f0) p = @inbounds (scene.camera.projectionview[] * model * p4d)[Vec(1, 2)] ./ 2f0 return p .* scene.camera.resolution[] end @@ -37,11 +37,11 @@ function project_rect(scene, rect::Rect, model) end function project_polygon(scene, poly::P, model) where P <: Polygon - ext = decompose(Point2f0, poly.exterior) - interiors = decompose.(Point2f0, poly.interiors) + ext = decompose(Point2f, poly.exterior) + interiors = decompose.(Point2f, poly.interiors) Polygon( - Point2f0.(project_position.(Ref(scene), ext, Ref(model))), - [Point2f0.(project_position.(Ref(scene), interior, Ref(model))) for interior in interiors], + Point2f.(project_position.(Ref(scene), ext, Ref(model))), + [Point2f.(project_position.(Ref(scene), interior, Ref(model))) for interior in interiors], ) end @@ -73,7 +73,7 @@ to_2d_rotation(quat::Makie.Quaternion) = -Makie.quaternion_to_2d_angle(quat) # Since I don't know how to fix this in GLMakie, # I've reversed the order of arguments to atan, # such that our behaviour is consistent with GLMakie's. -to_2d_rotation(vec::Vec2f0) = atan(vec[1], vec[2]) +to_2d_rotation(vec::Vec2f) = atan(vec[1], vec[2]) to_2d_rotation(n::Real) = n @@ -130,19 +130,19 @@ function to_rgba_image(img::AbstractMatrix{<: AbstractFloat}, attributes) [get_rgba_pixel(pixel, colormap, colorrange, nan_color, lowclip, highclip) for pixel in img] end -to_rgba_image(img::AbstractMatrix{<: Colorant}, attributes) = RGBAf0.(img) +to_rgba_image(img::AbstractMatrix{<: Colorant}, attributes) = RGBAf.(img) function get_rgba_pixel(pixel, colormap, colorrange, nan_color, lowclip, highclip) vmin, vmax = colorrange if isnan(pixel) - RGBAf0(nan_color) + RGBAf(nan_color) elseif pixel < vmin && !isnothing(lowclip) - RGBAf0(lowclip) + RGBAf(lowclip) elseif pixel > vmax && !isnothing(highclip) - RGBAf0(highclip) + RGBAf(highclip) else - RGBAf0(Makie.interpolated_getindex(colormap, pixel, colorrange)) + RGBAf(Makie.interpolated_getindex(colormap, pixel, colorrange)) end end @@ -199,7 +199,7 @@ function per_face_colors( wsize = reverse(size(matcap)) wh = wsize .- 1 cvec = map(normals) do n - muv = 0.5n[Vec(1,2)] .+ Vec2f0(0.5) + muv = 0.5n[Vec(1,2)] .+ Vec2f(0.5) x, y = clamp.(round.(Int, Tuple(muv) .* wh) .+ 1, 1, wh) return matcap[end - (y - 1), x] end diff --git a/GLMakie/Project.toml b/GLMakie/Project.toml index 7640bcc62d9..d007be1aca7 100644 --- a/GLMakie/Project.toml +++ b/GLMakie/Project.toml @@ -28,7 +28,7 @@ FileIO = "1.1" FixedPointNumbers = "0.7, 0.8" FreeTypeAbstraction = "0.8, 0.9" GLFW = "3" -GeometryBasics = "0.3" +GeometryBasics = "0.4.1" Makie = "=0.15.1" MeshIO = "0.4" ModernGL = "1" diff --git a/GLMakie/experiments/cuda_interop.jl b/GLMakie/experiments/cuda_interop.jl index bcaf7df397a..ca8d8443c1c 100644 --- a/GLMakie/experiments/cuda_interop.jl +++ b/GLMakie/experiments/cuda_interop.jl @@ -1,7 +1,7 @@ using CUDA, GLMakie -scene = scatter(rand(Point2f0, 10_000), show_axis=false) +scene = scatter(rand(Point2f, 10_000), show_axis=false) screen = display(scene) buffer = screen.renderlist[1][3][:position] diff --git a/GLMakie/experiments/shaderabstr.jl b/GLMakie/experiments/shaderabstr.jl index af913e2c4da..5dfe724fe48 100644 --- a/GLMakie/experiments/shaderabstr.jl +++ b/GLMakie/experiments/shaderabstr.jl @@ -1,15 +1,15 @@ using ShaderAbstractions: Buffer, Sampler, VertexArray # Mesh -mesh(Sphere(Point3f0(0), 1f0)) |> display -mesh(Sphere(Point3f0(0), 1f0), color=:red, ambient=Vec3f0(0.9)) +mesh(Sphere(Point3f(0), 1f0)) |> display +mesh(Sphere(Point3f(0), 1f0), color=:red, ambient=Vec3f(0.9)) -tocolor(x) = RGBf0(x...) -positions = Observable(decompose(Point3f0, Sphere(Point3f0(0), 1f0))) -triangles = Observable(decompose(GLTriangleFace, Sphere(Point3f0(0), 1f0))) -uv = Observable(GeometryBasics.decompose_uv(Sphere(Point3f0(0), 1f0))) +tocolor(x) = RGBf(x...) +positions = Observable(decompose(Point3f, Sphere(Point3f(0), 1f0))) +triangles = Observable(decompose(GLTriangleFace, Sphere(Point3f(0), 1f0))) +uv = Observable(GeometryBasics.decompose_uv(Sphere(Point3f(0), 1f0))) xyz_vertex_color = Observable(tocolor.(positions[])) -texture = Observable(rand(RGBAf0, 10, 10)) +texture = Observable(rand(RGBAf, 10, 10)) pos_buff = Buffer(positions) triangles_buff = Buffer(triangles) @@ -32,7 +32,7 @@ struct OGLContext <: ShaderAbstractions.AbstractContext end instance = ShaderAbstractions.VertexArray(posmeta, triangles_buff) -ShaderAbstractions.type_string(OGLContext(), Vec2f0) +ShaderAbstractions.type_string(OGLContext(), Vec2f) p = ShaderAbstractions.Program( OGLContext(), @@ -44,7 +44,7 @@ p = ShaderAbstractions.Program( println(p.vertex_source) uniforms = Dict{Symbol, Any}( - :texturecoordinates => Vec2f0(0), + :texturecoordinates => Vec2f(0), :image => nothing ) rshader = GLMakie.GLAbstraction.gl_convert(shader, uniforms) @@ -112,7 +112,7 @@ function getter_function(io::IO, ::Vertex, ::AbstractVector{T}, name) where T """) end -texsampler = Makie.sampler(rand(RGBf0, 4, 4), uv) +texsampler = Makie.sampler(rand(RGBf, 4, 4), uv) coords = meta(positions, color=texsampler, normals=mesh_normals) texture_mesh = GeometryBasics.Mesh(coords, triangles) diff --git a/GLMakie/src/GLAbstraction/GLExtendedFunctions.jl b/GLMakie/src/GLAbstraction/GLExtendedFunctions.jl index 80b13b64804..95235c2a67f 100644 --- a/GLMakie/src/GLAbstraction/GLExtendedFunctions.jl +++ b/GLMakie/src/GLAbstraction/GLExtendedFunctions.jl @@ -165,8 +165,8 @@ function glGetTexLevelParameteriv(target::GLenum, level, name::GLenum) result[1] end -glViewport(x::Rect2D) = glViewport(minimum(x)..., widths(x)...) -glScissor(x::Rect2D) = glScissor(minimum(x)..., widths(x)...) +glViewport(x::Rect2) = glViewport(minimum(x)..., widths(x)...) +glScissor(x::Rect2) = glScissor(minimum(x)..., widths(x)...) function glGenRenderbuffers(format::GLenum, attachment::GLenum, dimensions) renderbuffer = GLuint[0] diff --git a/GLMakie/src/GLAbstraction/GLRenderObject.jl b/GLMakie/src/GLAbstraction/GLRenderObject.jl index 962dea14c37..bfcf5a5ac05 100644 --- a/GLMakie/src/GLAbstraction/GLRenderObject.jl +++ b/GLMakie/src/GLAbstraction/GLRenderObject.jl @@ -1,6 +1,6 @@ function RenderObject( data::Dict{Symbol}, program, pre, - bbs=Node(FRect3D(Vec3f0(0), Vec3f0(1))), + bbs=Node(Rect3f(Vec3f(0), Vec3f(1))), main=nothing ) RenderObject(convert(Dict{Symbol,Any}, data), program, pre, bbs, main) @@ -73,14 +73,14 @@ end export EmptyPrerender export prerendertype -function instanced_renderobject(data, program, bb=Node(FRect3D(Vec3f0(0), Vec3f0(1))), primitive::GLenum=GL_TRIANGLES, main=nothing) +function instanced_renderobject(data, program, bb=Node(Rect3f(Vec3f(0), Vec3f(1))), primitive::GLenum=GL_TRIANGLES, main=nothing) pre = StandardPrerender() robj = RenderObject(convert(Dict{Symbol,Any}, data), program, pre, nothing, bb, main) robj.postrenderfunction = StandardPostrenderInstanced(main, robj.vertexarray, primitive) robj end -function std_renderobject(data, program, bb=Node(FRect3D(Vec3f0(0), Vec3f0(1))), primitive=GL_TRIANGLES, main=nothing) +function std_renderobject(data, program, bb=Node(Rect3f(Vec3f(0), Vec3f(1))), primitive=GL_TRIANGLES, main=nothing) pre = StandardPrerender() robj = RenderObject(convert(Dict{Symbol,Any}, data), program, pre, nothing, bb, main) robj.postrenderfunction = StandardPostrender(robj.vertexarray, primitive) diff --git a/GLMakie/src/GLAbstraction/GLTypes.jl b/GLMakie/src/GLAbstraction/GLTypes.jl index 1ca49d54117..7a4359341c7 100644 --- a/GLMakie/src/GLAbstraction/GLTypes.jl +++ b/GLMakie/src/GLAbstraction/GLTypes.jl @@ -303,7 +303,7 @@ end function RenderObject( data::Dict{Symbol,Any}, program, pre::Pre, post, - bbs=Node(FRect3D(Vec3f0(0), Vec3f0(1))), + bbs=Node(Rect3f(Vec3f(0), Vec3f(1))), main=nothing ) where Pre targets = get(data, :gl_convert_targets, Dict()) diff --git a/GLMakie/src/GLAbstraction/GLUniforms.jl b/GLMakie/src/GLAbstraction/GLUniforms.jl index efb4ef96ef0..05cc509e1bf 100644 --- a/GLMakie/src/GLAbstraction/GLUniforms.jl +++ b/GLMakie/src/GLAbstraction/GLUniforms.jl @@ -188,7 +188,7 @@ gl_promote(x::Type{T}) where {T <: StaticVector} = similar_type(T, gl_promote(el gl_promote(x::Type{T}) where {T <: GeometryBasics.Mesh} = NativeMesh{T} -gl_convert(x::AbstractVector{Vec3f0}) = x +gl_convert(x::AbstractVector{Vec3f}) = x gl_convert(x::T) where {T <: Number} = gl_promote(T)(x) gl_convert(x::T) where {T <: Colorant} = gl_promote(T)(x) diff --git a/GLMakie/src/GLAbstraction/GLUtils.jl b/GLMakie/src/GLAbstraction/GLUtils.jl index de3f8bba6c9..dbbc64a7a04 100644 --- a/GLMakie/src/GLAbstraction/GLUtils.jl +++ b/GLMakie/src/GLAbstraction/GLUtils.jl @@ -168,7 +168,7 @@ export NativeMesh NativeMesh(m::T) where {T <: GeometryBasics.Mesh} = NativeMesh{T}(m) NativeMesh(m::Observable{T}) where {T <: GeometryBasics.Mesh} = NativeMesh{T}(m) -convert_texcoordinates(uv::AbstractVector{Vec2f0}) = uv +convert_texcoordinates(uv::AbstractVector{Vec2f}) = uv convert_texcoordinates(x::AbstractVector{<:Number}) = convert(Vector{Float32}, x) function NativeMesh{T}(mesh::T) where T <: GeometryBasics.Mesh @@ -185,7 +185,7 @@ function NativeMesh{T}(mesh::T) where T <: GeometryBasics.Mesh result[:image] = Texture(val.colors) result[:texturecoordinates] = GLBuffer(convert_texcoordinates(val.values)) if val.scaling.range !== nothing - result[:color_norm] = Observable(Vec2f0(val.scaling.range)) + result[:color_norm] = Observable(Vec2f(val.scaling.range)) end elseif field in (:position, :uv, :uvw, :normals, :attribute_id, :color) if field == :color @@ -225,7 +225,7 @@ function NativeMesh{T}(m::Node{T}) where T <: GeometryBasics.Mesh update!(result.data[:image], val.colors) update!(result.data[:texturecoordinates], convert_texcoordinates(val.values)) if val.scaling.range !== nothing - result.data[:color_norm][] = Vec2f0(val.scaling.range) + result.data[:color_norm][] = Vec2f(val.scaling.range) end else field == :color && (field = :vertex_color) diff --git a/GLMakie/src/GLVisualize/GLVisualize.jl b/GLMakie/src/GLVisualize/GLVisualize.jl index 7124c821e5c..e64971e1f1d 100644 --- a/GLMakie/src/GLVisualize/GLVisualize.jl +++ b/GLMakie/src/GLVisualize/GLVisualize.jl @@ -21,7 +21,7 @@ using LinearAlgebra import Makie: to_font, glyph_uv_width! import ..GLMakie: get_texture!, loadshader -const GLBoundingBox = FRect3D +const GLBoundingBox = Rect3f include("visualize_interface.jl") export visualize # Visualize an object diff --git a/GLMakie/src/GLVisualize/precompile.jl b/GLMakie/src/GLVisualize/precompile.jl index 3c40a882059..aff46bf72c0 100644 --- a/GLMakie/src/GLVisualize/precompile.jl +++ b/GLMakie/src/GLVisualize/precompile.jl @@ -4,11 +4,11 @@ function _precompile_() Base.precompile(Tuple{typeof(assemble_robj),Dict{Symbol, Any},GLVisualizeShader,GeometryBasics.HyperRectangle{3, Float32},UInt32,Nothing,Nothing}) # time: 0.112225175 Base.precompile(Tuple{typeof(to_index_buffer),Observable{Vector{Int64}}}) # time: 0.09670886 Base.precompile(Tuple{typeof(ticks),Vector{T} where T,Int64}) # time: 0.07404702 - Base.precompile(Tuple{typeof(vec2quaternion),Observable{Vector{Quaternionf0}}}) # time: 0.043232486 + Base.precompile(Tuple{typeof(vec2quaternion),Observable{Vector{Quaternionf}}}) # time: 0.043232486 isdefined(GLVisualize, Symbol("#GLVisualizeShader#8#10")) && Base.precompile(Tuple{getfield(GLVisualize, Symbol("#GLVisualizeShader#8#10")),Dict{String, String},Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}},Type{GLVisualizeShader},String,Vararg{String, N} where N}) # time: 0.035577767 Base.precompile(Tuple{typeof(_position_calc),Observable{Vector{Point{3, Float32}}},Type{GLBuffer}}) # time: 0.016643895 Base.precompile(Tuple{typeof(_position_calc),Observable{Vector{Point{2, Float32}}},Type{GLBuffer}}) # time: 0.013070196 - Base.precompile(Tuple{typeof(vec2quaternion),Observable{Quaternionf0}}) # time: 0.012976533 + Base.precompile(Tuple{typeof(vec2quaternion),Observable{Quaternionf}}) # time: 0.012976533 Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:view,), Tuple{Dict{String, String}}},Type{GLVisualizeShader},String,String,String,String,String}) # time: 0.009165488 Base.precompile(Tuple{typeof(visualize),Any,Any,Any}) # time: 0.00876585 Base.precompile(Tuple{typeof(ticks),Vector{Float64},Int64}) # time: 0.008059256 diff --git a/GLMakie/src/GLVisualize/visualize/image_like.jl b/GLMakie/src/GLVisualize/visualize/image_like.jl index 5103f1a38b4..368c0d7bf1e 100644 --- a/GLMakie/src/GLVisualize/visualize/image_like.jl +++ b/GLMakie/src/GLVisualize/visualize/image_like.jl @@ -24,7 +24,7 @@ function _default(main::MatTypes{T}, ::Style, data::Dict) where T <: Colorant primitive = const_lift(ranges) do r x, y = minimum(r[1]), minimum(r[2]) xmax, ymax = maximum(r[1]), maximum(r[2]) - return FRect2D(x, y, xmax - x, ymax - y) + return Rect2f(x, y, xmax - x, ymax - y) end => to_uvmesh preferred_camera = :orthographic_pixel fxaa = false @@ -47,10 +47,10 @@ A matrix of Intensities will result in a contourf kind of plot function gl_heatmap(main::MatTypes{T}, data::Dict) where T <: AbstractFloat @gen_defaults! data begin intensity = main => Texture - primitive = Rect2D(0f0,0f0,1f0,1f0) => native_triangle_mesh - nan_color = RGBAf0(1, 0, 0, 1) - highclip = RGBAf0(0, 0, 0, 0) - lowclip = RGBAf0(0, 0, 0, 0) + primitive = Rect2(0f0,0f0,1f0,1f0) => native_triangle_mesh + nan_color = RGBAf(1, 0, 0, 1) + highclip = RGBAf(0, 0, 0, 0) + lowclip = RGBAf(0, 0, 0, 0) color_map = nothing => Texture color_norm = nothing stroke_width::Float32 = 0.0f0 @@ -83,8 +83,8 @@ end function _default(main::VolumeTypes{T}, s::Style, data::Dict) where T <: VolumeElTypes @gen_defaults! data begin volumedata = main => Texture - hull = FRect3D(Vec3f0(0), Vec3f0(1)) => to_plainmesh - model = Mat4f0(I) + hull = Rect3f(Vec3f(0), Vec3f(1)) => to_plainmesh + model = Mat4f(I) modelinv = const_lift(inv, model) color_map = default(Vector{RGBA}, s) => Texture color_norm = color_map == nothing ? nothing : const_lift(extrema2f0, main) @@ -104,8 +104,8 @@ end function _default(main::VolumeTypes{T}, s::Style, data::Dict) where T <: RGBA @gen_defaults! data begin volumedata = main => Texture - hull = FRect3D(Vec3f0(0), Vec3f0(1)) => to_plainmesh - model = Mat4f0(I) + hull = Rect3f(Vec3f(0), Vec3f(1)) => to_plainmesh + model = Mat4f(I) modelinv = const_lift(inv, model) # These don't do anything but are needed for type specification in the frag shader color_map = nothing => Texture diff --git a/GLMakie/src/GLVisualize/visualize/mesh.jl b/GLMakie/src/GLVisualize/visualize/mesh.jl index 6e39a48094b..9e41fbad83b 100644 --- a/GLMakie/src/GLVisualize/visualize/mesh.jl +++ b/GLMakie/src/GLVisualize/visualize/mesh.jl @@ -4,14 +4,14 @@ function _default(mesh::TOrSignal{M}, s::Style, data::Dict) where M <: GeometryB shading = true backlight = 0f0 main = mesh - vertex_color = Vec4f0(0) - texturecoordinates = Vec2f0(0) + vertex_color = Vec4f(0) + texturecoordinates = Vec2f(0) image = nothing => Texture matcap = nothing => Texture color_map = nothing => Texture color_norm = nothing fetch_pixel = false - uv_scale = Vec2f0(1) + uv_scale = Vec2f(1) shader = GLVisualizeShader( "fragment_output.frag", "util.vert", "standard.vert", "standard.frag", view = Dict("light_calc" => light_calc(shading)) diff --git a/GLMakie/src/GLVisualize/visualize/particles.jl b/GLMakie/src/GLVisualize/visualize/particles.jl index e3e8f5c8aff..d8b54a14918 100644 --- a/GLMakie/src/GLVisualize/visualize/particles.jl +++ b/GLMakie/src/GLVisualize/visualize/particles.jl @@ -49,25 +49,25 @@ using Makie: get_texture_atlas vec2quaternion(rotation::StaticVector{4}) = rotation function vec2quaternion(r::StaticVector{2}) - vec2quaternion(Vec3f0(r[1], r[2], 0)) + vec2quaternion(Vec3f(r[1], r[2], 0)) end function vec2quaternion(rotation::StaticVector{3}) - Makie.rotation_between(Vec3f0(0, 0, 1), Vec3f0(rotation)) + Makie.rotation_between(Vec3f(0, 0, 1), Vec3f(rotation)) end -vec2quaternion(rotation::Vec4f0) = rotation +vec2quaternion(rotation::Vec4f) = rotation vec2quaternion(rotation::VectorTypes) = const_lift(x-> vec2quaternion.(x), rotation) vec2quaternion(rotation::Node) = lift(vec2quaternion, rotation) -vec2quaternion(rotation::Makie.Quaternion)= Vec4f0(rotation.data) +vec2quaternion(rotation::Makie.Quaternion)= Vec4f(rotation.data) vec2quaternion(rotation)= vec2quaternion(to_rotation(rotation)) -GLAbstraction.gl_convert(rotation::Makie.Quaternion)= Vec4f0(rotation.data) +GLAbstraction.gl_convert(rotation::Makie.Quaternion)= Vec4f(rotation.data) """ This is the main function to assemble particles with a GLNormalMesh as a primitive """ function meshparticle(p, s, data) - rot = get!(data, :rotation, Vec4f0(0, 0, 0, 1)) + rot = get!(data, :rotation, Vec4f(0, 0, 0, 1)) rot = vec2quaternion(rot) delete!(data, :rotation) @gen_defaults! data begin @@ -77,7 +77,7 @@ function meshparticle(p, s, data) position_y = nothing => TextureBuffer position_z = nothing => TextureBuffer - scale = Vec3f0(1) => TextureBuffer + scale = Vec3f(1) => TextureBuffer scale_x = nothing => TextureBuffer scale_y = nothing => TextureBuffer scale_z = nothing => TextureBuffer @@ -97,10 +97,10 @@ function meshparticle(p, s, data) else nothing end => to_meshcolor - vertex_color = Vec4f0(1) + vertex_color = Vec4f(1) matcap = nothing => Texture fetch_pixel = false - uv_scale = Vec2f0(1) + uv_scale = Vec2f(1) instances = const_lift(length, position) shading = true @@ -156,20 +156,20 @@ returns the Shape for the distancefield algorithm primitive_shape(::Char) = DISTANCEFIELD primitive_shape(x::X) where {X} = primitive_shape(X) primitive_shape(::Type{T}) where {T <: Circle} = CIRCLE -primitive_shape(::Type{T}) where {T <: Rect2D} = RECTANGLE +primitive_shape(::Type{T}) where {T <: Rect2} = RECTANGLE primitive_shape(x::Shape) = x """ Extracts the scale from a primitive. """ -primitive_scale(prim::GeometryPrimitive) = Vec2f0(widths(prim)) -primitive_scale(::Union{Shape, Char}) = Vec2f0(40) -primitive_scale(c) = Vec2f0(0.1) +primitive_scale(prim::GeometryPrimitive) = Vec2f(widths(prim)) +primitive_scale(::Union{Shape, Char}) = Vec2f(40) +primitive_scale(c) = Vec2f(0.1) """ Extracts the offset from a primitive. """ -primitive_offset(x, scale::Nothing) = Vec2f0(0) # default offset +primitive_offset(x, scale::Nothing) = Vec2f(0) # default offset primitive_offset(x, scale) = const_lift(/, scale, -2f0) # default offset @@ -177,7 +177,7 @@ primitive_offset(x, scale) = const_lift(/, scale, -2f0) # default offset Extracts the uv offset and width from a primitive. """ primitive_uv_offset_width(c::Char) = glyph_uv_width!(c) -primitive_uv_offset_width(x) = Vec4f0(0,0,1,1) +primitive_uv_offset_width(x) = Vec4f(0,0,1,1) """ Gets the texture atlas if primitive is a char. @@ -191,9 +191,9 @@ function _default( ) where {C <: Colorant, P <: Point} data[:image] = p[1] # we don't want this to be overwritten by user @gen_defaults! data begin - scale = lift(x-> Vec2f0(size(x)), p[1]) + scale = lift(x-> Vec2f(size(x)), p[1]) shape = RECTANGLE - offset = Vec2f0(0) + offset = Vec2f(0) end sprites(p, s, data) end @@ -203,9 +203,9 @@ function _default( ) where {C <: AbstractFloat, P <: Point} data[:distancefield] = p[1] # we don't want this to be overwritten by user @gen_defaults! data begin - scale = lift(x-> Vec2f0(size(x)), p[1]) + scale = lift(x-> Vec2f(size(x)), p[1]) shape = RECTANGLE - offset = Vec2f0(0) + offset = Vec2f(0) end sprites(p, s, data) end @@ -219,8 +219,8 @@ function _default( if !all(x-> x == sizes[1], sizes) # if differently sized # create texture atlas maxdims = sum(map(Vec{2, Int}, sizes)) - rectangles = map(x->Rect2D(0, 0, x...), sizes) - rpack = RectanglePacker(Rect2D(0, 0, maxdims...)) + rectangles = map(x->Rect2(0, 0, x...), sizes) + rpack = RectanglePacker(Rect2(0, 0, maxdims...)) uv_coordinates = [push!(rpack, rect).area for rect in rectangles] max_xy = maximum(maximum.(uv_coordinates)) texture_atlas = Texture(C, (max_xy...,)) @@ -231,14 +231,14 @@ function _default( m = max_xy .- 1 mini = reverse((minimum(uv)) ./ m) maxi = reverse((maximum(uv) .- 1) ./ m) - return Vec4f0(mini..., maxi...) + return Vec4f(mini..., maxi...) end images = texture_atlas end data[:image] = images # we don't want this to be overwritten by user @gen_defaults! data begin shape = RECTANGLE - offset = Vec2f0(0) + offset = Vec2f(0) end sprites(p, s, data) end @@ -267,7 +267,7 @@ Main assemble functions for sprite particles. Sprites are anything like distance fields, images and simple geometries """ function sprites(p, s, data) - rot = get!(data, :rotation, Vec4f0(0, 0, 0, 1)) + rot = get!(data, :rotation, Vec4f(0, 0, 0, 1)) rot = vec2quaternion(rot) delete!(data, :rotation) @@ -307,7 +307,7 @@ function sprites(p, s, data) distancefield = primitive_distancefield(p[1]) => Texture indices = const_lift(length, p[2]) => to_index_buffer # rotation and billboard don't go along - billboard = rotation == Vec4f0(0,0,0,1) => "if `billboard` == true, particles will always face camera" + billboard = rotation == Vec4f(0,0,0,1) => "if `billboard` == true, particles will always face camera" fxaa = false shader = GLVisualizeShader( "fragment_output.frag", "util.vert", "sprites.geom", @@ -342,7 +342,7 @@ end function _default(main::TOrSignal{S}, s::Style, data::Dict) where S <: AbstractString @gen_defaults! data begin relative_scale = 4 # - start_position = Point2f0(0) + start_position = Point2f(0) atlas = get_texture_atlas() distancefield = get_texture!(atlas) stroke_width = 0f0 @@ -358,10 +358,10 @@ function _default(main::TOrSignal{S}, s::Style, data::Dict) where S <: AbstractS enabletransparency() end uv_offset_width = const_lift(main) do str - Vec4f0[glyph_uv_width!(atlas, c, font) for c = str] + Vec4f[glyph_uv_width!(atlas, c, font) for c = str] end scale = const_lift(main, relative_scale) do str, s - Vec2f0[glyph_scale!(atlas, c, font, s) for c = str] + Vec2f[glyph_scale!(atlas, c, font, s) for c = str] end end delete!(data, :font) diff --git a/GLMakie/src/GLVisualize/visualize/surface.jl b/GLMakie/src/GLVisualize/visualize/surface.jl index a99f67cfaac..b91a77c1a1d 100644 --- a/GLMakie/src/GLVisualize/visualize/surface.jl +++ b/GLMakie/src/GLVisualize/visualize/surface.jl @@ -5,7 +5,7 @@ function _default(main::Tuple{MatTypes{T}, MatTypes{T}, MatTypes{T}}, s::Style{: position_x = main[1] => (Texture, "x position, must be a `Matrix{Float}`") position_y = main[2] => (Texture, "y position, must be a `Matrix{Float}`") position_z = main[3] => (Texture, "z position, must be a `Matrix{Float}`") - scale = Vec3f0(0) => "scale must be 0, for a surfacemesh" + scale = Vec3f(0) => "scale must be 0, for a surfacemesh" end surface(position_z, s, data) end @@ -16,7 +16,7 @@ function _default(main::Tuple{VectorTypes{T}, VectorTypes{T}, MatTypes{T}}, s::S position_x = main[1] => (Texture, "x position, must be a `Vector{Float}`") position_y = main[2] => (Texture, "y position, must be a `Vector{Float}`") position_z = main[3] => (Texture, "z position, must be a `Matrix{Float}`") - scale = Vec3f0(0) => "scale must be 0, for a surfacemesh" + scale = Vec3f(0) => "scale must be 0, for a surfacemesh" end surface(position_z, s, data) end @@ -39,12 +39,12 @@ function _default(main::Tuple{G, MatTypes{T}}, s::Style{:surface}, data::Dict) w position = main[1] =>" Position given as a `Grid{2}`. Can be constructed e.g. `Grid(LinRange(0,2,N1), LinRange(0,3, N2))`" position_z = main[2] => (Texture, "height offset for the surface, must be `Matrix{Float}`") - scale = Vec3f0(xscale, yscale, 1) => "scale of the grid planes forming the surface. Can be made smaller, to let the grid show" + scale = Vec3f(xscale, yscale, 1) => "scale of the grid planes forming the surface. Can be made smaller, to let the grid show" end surface(position_z, s, data) end -_extrema(x::FRect3D) = Vec2f0(minimum(x)[3], maximum(x)[3]) +_extrema(x::Rect3f) = Vec2f(minimum(x)[3], maximum(x)[3]) nothing_or_vec(x) = x nothing_or_vec(x::Array) = vec(x) @@ -79,7 +79,7 @@ end function surface(main, s::Style{:surface}, data::Dict) @gen_defaults! data begin - primitive = Rect2D(0f0,0f0,1f0,1f0) => native_triangle_mesh + primitive = Rect2(0f0,0f0,1f0,1f0) => native_triangle_mesh scale = nothing position = nothing position_x = nothing => Texture @@ -98,11 +98,11 @@ function surface(main, s::Style{:surface}, data::Dict) fetch_pixel = false matcap = nothing => Texture - nan_color = RGBAf0(1, 0, 0, 1) - highclip = RGBAf0(0, 0, 0, 0) - lowclip = RGBAf0(0, 0, 0, 0) + nan_color = RGBAf(1, 0, 0, 1) + highclip = RGBAf(0, 0, 0, 0) + lowclip = RGBAf(0, 0, 0, 0) - uv_scale = Vec2f0(1) + uv_scale = Vec2f(1) instances = const_lift(x->(size(x,1)-1) * (size(x,2)-1), main) => "number of planes used to render the surface" shader = GLVisualizeShader( "fragment_output.frag", "util.vert", "surface.vert", diff --git a/GLMakie/src/GLVisualize/visualize_interface.jl b/GLMakie/src/GLVisualize/visualize_interface.jl index 71245c3a21e..8e8fe20c550 100644 --- a/GLMakie/src/GLVisualize/visualize_interface.jl +++ b/GLMakie/src/GLVisualize/visualize_interface.jl @@ -117,7 +117,7 @@ function assemble_shader(data) delete!(data, :shader) glp = get(data, :gl_primitive, GL_TRIANGLES) return assemble_robj( - data, shader, FRect3D(), glp, + data, shader, Rect3f(), glp, get(data, :prerender, nothing), get(data, :postrender, nothing) ) @@ -163,7 +163,7 @@ visualize(@nospecialize(main), s::Symbol=:default; kw_args...) = visualize(main, function visualize(@nospecialize(main), @nospecialize(s), @nospecialize(data)) data = _default(main, s, copy(data)) @gen_defaults! data begin # make sure every object has these! - model = Mat4f0(I) + model = Mat4f(I) end return assemble_shader(data) end diff --git a/GLMakie/src/drawing_primitives.jl b/GLMakie/src/drawing_primitives.jl index eace7897f32..58488fb3c91 100644 --- a/GLMakie/src/drawing_primitives.jl +++ b/GLMakie/src/drawing_primitives.jl @@ -2,7 +2,7 @@ using Makie: get_texture_atlas, glyph_uv_width!, transform_func_obs, apply_trans using Makie: attribute_per_char, FastPixel, el32convert, Pixel using Makie: convert_arguments, preprojected_glyph_arrays -convert_attribute(s::ShaderAbstractions.Sampler{RGBAf0}, k::key"color") = s +convert_attribute(s::ShaderAbstractions.Sampler{RGBAf}, k::key"color") = s function convert_attribute(s::ShaderAbstractions.Sampler{T, N}, k::key"color") where {T, N} ShaderAbstractions.Sampler( el32convert(s.data), minfilter = s.minfilter, magfilter = s.magfilter, @@ -129,8 +129,8 @@ function lift_convert_inner(value, key, plot_key, plot) end end -to_vec4(val::RGB) = RGBAf0(val, 1.0) -to_vec4(val::RGBA) = RGBAf0(val) +to_vec4(val::RGB) = RGBAf(val, 1.0) +to_vec4(val::RGBA) = RGBAf(val) function lift_convert_inner(value, ::key"highclip", plot_key, plot) return lift(value, plot.colormap) do value, cmap @@ -146,12 +146,12 @@ function lift_convert_inner(value, ::key"lowclip", plot_key, plot) end end -pixel2world(scene, msize::Number) = pixel2world(scene, Point2f0(msize))[1] +pixel2world(scene, msize::Number) = pixel2world(scene, Point2f(msize))[1] function pixel2world(scene, msize::StaticVector{2}) # TODO figure out why Vec(x, y) doesn't work correctly - p0 = Makie.to_world(scene, Point2f0(0.0)) - p1 = Makie.to_world(scene, Point2f0(msize)) + p0 = Makie.to_world(scene, Point2f(0.0)) + p1 = Makie.to_world(scene, Point2f(msize)) diff = p1 - p0 return diff end @@ -191,7 +191,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, @nospecialize(x::Union{Scat if isa(x, Scatter) gl_attributes[:billboard] = map(rot-> isa(rot, Billboard), x.rotations) gl_attributes[:distancefield][] == nothing && delete!(gl_attributes, :distancefield) - gl_attributes[:uv_offset_width][] == Vec4f0(0) && delete!(gl_attributes, :uv_offset_width) + gl_attributes[:uv_offset_width][] == Vec4f(0) && delete!(gl_attributes, :uv_offset_width) end positions = handle_view(x[1], gl_attributes) @@ -266,7 +266,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, glyphcollection = x[1] - res = map(x->Vec2f0(widths(x)), pixelarea(scene)) + res = map(x->Vec2f(widths(x)), pixelarea(scene)) projview = scene.camera.projectionview transfunc = Makie.transform_func_obs(scene) pos = gl_attributes[:position] @@ -310,7 +310,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, gl_attributes[:color] = lift(glyphcollection) do gc if gc isa AbstractArray reduce(vcat, (Makie.collect_vector(g.colors, length(g.glyphs)) for g in gc), - init = RGBAf0[]) + init = RGBAf[]) else Makie.collect_vector(gc.colors, length(gc.glyphs)) end @@ -318,7 +318,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, gl_attributes[:stroke_color] = lift(glyphcollection) do gc if gc isa AbstractArray reduce(vcat, (Makie.collect_vector(g.strokecolors, length(g.glyphs)) for g in gc), - init = RGBAf0[]) + init = RGBAf[]) else Makie.collect_vector(gc.strokecolors, length(gc.glyphs)) end @@ -327,7 +327,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, gl_attributes[:rotation] = lift(glyphcollection) do gc if gc isa AbstractArray reduce(vcat, (Makie.collect_vector(g.rotations, length(g.glyphs)) for g in gc), - init = Quaternionf0[]) + init = Quaternionf[]) else Makie.collect_vector(gc.rotations, length(gc.glyphs)) end @@ -341,7 +341,7 @@ function draw_atomic(screen::GLScreen, scene::Scene, robj = visualize((DISTANCEFIELD, positions), Style(:default), gl_attributes) # Draw text in screenspace if x.space[] == :screen - robj[:view] = Observable(Mat4f0(I)) + robj[:view] = Observable(Mat4f(I)) robj[:projection] = scene.camera.pixel_space robj[:projectionview] = scene.camera.pixel_space end @@ -553,13 +553,13 @@ function draw_atomic(screen::GLScreen, scene::Scene, vol::Volume) mi = minimum.(xyz) maxi = maximum.(xyz) w = maxi .- mi - m2 = Mat4f0( + m2 = Mat4f( w[1], 0, 0, 0, 0, w[2], 0, 0, 0, 0, w[3], 0, mi[1], mi[2], mi[3], 1 ) - return convert(Mat4f0, m) * m2 + return convert(Mat4f, m) * m2 end return visualize(vol[4], Style(:default), gl_attributes) end diff --git a/GLMakie/src/events.jl b/GLMakie/src/events.jl index d9f2d428895..4c317db4b03 100644 --- a/GLMakie/src/events.jl +++ b/GLMakie/src/events.jl @@ -55,7 +55,7 @@ function window_area(scene::Scene, screen::Screen) # TODO put back window position, but right now it makes more trouble than it helps# # x, y = GLFW.GetWindowPos(window) # if minimum(rect) != Vec(x, y) - # event[] = IRect(x, y, framebuffer_size(window)) + # event[] = Recti(x, y, framebuffer_size(window)) # end w, h = GLFW.GetFramebufferSize(window) if Vec(w, h) != widths(rect) @@ -64,7 +64,7 @@ function window_area(scene::Scene, screen::Screen) # dpi of a monitor should be the same in x y direction. # if not, minimum seems to be a fair default dpievent[] = minimum(props.dpi) - event[] = IRect(minimum(rect), w, h) + event[] = Recti(minimum(rect), w, h) end end return diff --git a/GLMakie/src/postprocessing.jl b/GLMakie/src/postprocessing.jl index fd829ce5ffa..abde78e241c 100644 --- a/GLMakie/src/postprocessing.jl +++ b/GLMakie/src/postprocessing.jl @@ -18,7 +18,7 @@ end const PostProcessROBJ = RenderObject{PostprocessPrerender} -rcpframe(x) = 1f0 ./ Vec2f0(x[1], x[2]) +rcpframe(x) = 1f0 ./ Vec2f(x[1], x[2]) struct PostProcessor{F} robjs::Vector{PostProcessROBJ} @@ -36,7 +36,7 @@ function ssao_postprocessor(framebuffer) if !haskey(framebuffer.buffers, :position) glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.id[1]) position_buffer = Texture( - Vec4f0, size(framebuffer), minfilter = :nearest, x_repeat = :clamp_to_edge + Vec4f, size(framebuffer), minfilter = :nearest, x_repeat = :clamp_to_edge ) attach_framebuffer(position_buffer, GL_COLOR_ATTACHMENT2) push!(framebuffer.buffers, :position => position_buffer) @@ -44,7 +44,7 @@ function ssao_postprocessor(framebuffer) if !haskey(framebuffer.buffers, :normal) glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.id[1]) normal_occlusion_buffer = Texture( - Vec4f0, size(framebuffer), minfilter = :nearest, x_repeat = :clamp_to_edge + Vec4f, size(framebuffer), minfilter = :nearest, x_repeat = :clamp_to_edge ) attach_framebuffer(normal_occlusion_buffer, GL_COLOR_ATTACHMENT3) push!(framebuffer.buffers, :normal_occlusion => normal_occlusion_buffer) @@ -65,7 +65,7 @@ function ssao_postprocessor(framebuffer) kernel = map(1:N_samples) do i n = normalize([2.0rand() .- 1.0, 2.0rand() .- 1.0, rand()]) scale = lerp_min + (lerp_max - lerp_min) * (i / N_samples)^2 - v = Vec3f0(scale * rand() * n) + v = Vec3f(scale * rand() * n) end @@ -83,11 +83,11 @@ function ssao_postprocessor(framebuffer) :normal_occlusion_buffer => framebuffer.buffers[:normal_occlusion], :kernel => kernel, :noise => Texture( - [normalize(Vec2f0(2.0rand(2) .- 1.0)) for _ in 1:4, __ in 1:4], + [normalize(Vec2f(2.0rand(2) .- 1.0)) for _ in 1:4, __ in 1:4], minfilter = :nearest, x_repeat = :repeat ), - :noise_scale => map(s -> Vec2f0(s ./ 4.0), framebuffer.resolution), - :projection => Node(Mat4f0(I)), + :noise_scale => map(s -> Vec2f(s ./ 4.0), framebuffer.resolution), + :projection => Node(Mat4f(I)), :bias => Node(0.025f0), :radius => Node(0.5f0) ) diff --git a/GLMakie/src/precompile.jl b/GLMakie/src/precompile.jl index 4f69014e4ce..04e504ffcd3 100644 --- a/GLMakie/src/precompile.jl +++ b/GLMakie/src/precompile.jl @@ -10,7 +10,7 @@ function _precompile_() isdefined(GLMakie, Symbol("#81#82")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#81#82")),Symbol}) # time: 0.07212781 Base.precompile(Tuple{typeof(draw_atomic),Screen,Scene,Union{Scatter{ArgType} where ArgType, MeshScatter{ArgType} where ArgType}}) # time: 0.06695828 isdefined(GLMakie, Symbol("#89#90")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#89#90")),LineSegments{Tuple{Vector{Point{2, Float32}}}}}) # time: 0.050924074 - isdefined(GLMakie, Symbol("#104#109")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#104#109")),String,Vector{Point{3, Float32}},Vector{Float32},Vector{FTFont},Vec{2, Float32},Vector{Quaternionf0},SMatrix{4, 4, Float32, 16},Float64,Float64}) # time: 0.038516257 + isdefined(GLMakie, Symbol("#104#109")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#104#109")),String,Vector{Point{3, Float32}},Vector{Float32},Vector{FTFont},Vec{2, Float32},Vector{Quaternionf},SMatrix{4, 4, Float32, 16},Float64,Float64}) # time: 0.038516257 isdefined(GLMakie, Symbol("#81#82")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#81#82")),Bool}) # time: 0.030008739 isdefined(GLMakie, Symbol("#101#102")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#101#102")),Int64,Point{3, Float32},Float32,FTFont,Vec{2, Float32}}) # time: 0.029477166 isdefined(GLMakie, Symbol("#81#82")) && Base.precompile(Tuple{getfield(GLMakie, Symbol("#81#82")),Symbol}) # time: 0.019217245 diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index b857489012e..205cc1deea1 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -418,7 +418,7 @@ end -function pick_native(screen::Screen, rect::IRect2D) +function pick_native(screen::Screen, rect::Rect2i) isopen(screen) || return Matrix{SelectionID{Int}}(undef, 0, 0) window_size = widths(screen) fb = screen.framebuffer @@ -469,7 +469,7 @@ function Makie.pick(scene::SceneLike, screen::Screen, xy::Vec{2, Float64}) end end -function Makie.pick(scene::SceneLike, screen::Screen, rect::IRect2D) +function Makie.pick(scene::SceneLike, screen::Screen, rect::Rect2i) map(pick_native(screen, rect)) do sid if haskey(screen.cache2plot, sid.id) (screen.cache2plot[sid.id], sid.index) @@ -489,11 +489,11 @@ function Makie.pick_closest(scene::SceneLike, screen::Screen, xy, range) x0, y0 = max.(1, floor.(Int, xy .- range)) x1, y1 = min.((w, h), floor.(Int, xy .+ range)) dx = x1 - x0; dy = y1 - y0 - sid = pick_native(screen, IRect2D(x0, y0, dx, dy)) + sid = pick_native(screen, Rect2i(x0, y0, dx, dy)) min_dist = range^2 id = SelectionID{Int}(0, 0) - x, y = xy .+ 1 .- Vec2f0(x0, y0) + x, y = xy .+ 1 .- Vec2f(x0, y0) for i in 1:dx, j in 1:dy d = (x-i)^2 + (y-j)^2 if (d < min_dist) && (sid[i, j][1] > 0x00000000) && @@ -521,11 +521,11 @@ function Makie.pick_sorted(scene::SceneLike, screen::Screen, xy, range) x1, y1 = min.([w, h], floor.(Int, xy .+ range)) dx = x1 - x0; dy = y1 - y0 - picks = pick_native(screen, IRect2D(x0, y0, dx, dy)) + picks = pick_native(screen, Rect2i(x0, y0, dx, dy)) selected = filter(x -> x[1] > 0 && haskey(screen.cache2plot, x[1]), unique(vec(picks))) distances = [range^2 for _ in selected] - x, y = xy .+ 1 .- Vec2f0(x0, y0) + x, y = xy .+ 1 .- Vec2f(x0, y0) for i in 1:dx, j in 1:dy if picks[i, j][1] > 0 d = (x-i)^2 + (y-j)^2 diff --git a/GLMakie/test/glmakie_tests.jl b/GLMakie/test/glmakie_tests.jl index d3e273e2103..16db7614f4a 100644 --- a/GLMakie/test/glmakie_tests.jl +++ b/GLMakie/test/glmakie_tests.jl @@ -22,7 +22,7 @@ using ReferenceTests.RNG y = r*[-sin(angle/2),0,sin(angle/2)] linewidth = 40 * 2.0^j - lines!(scene, x .+ sep*i, y .+ sep*j, color=RGBAf0(0,0,0,0.5), linewidth=linewidth) + lines!(scene, x .+ sep*i, y .+ sep*j, color=RGBAf(0,0,0,0.5), linewidth=linewidth) lines!(scene, x .+ sep*i, y .+ sep*j, color=:red) end end @@ -46,16 +46,16 @@ end # Test for resizing of TextureBuffer @cell "Dynamically adjusting number of particles in a meshscatter" begin - pos = Node(RNG.rand(Point3f0, 2)) - rot = Node(RNG.rand(Vec3f0, 2)) - color = Node(RNG.rand(RGBf0, 2)) + pos = Node(RNG.rand(Point3f, 2)) + rot = Node(RNG.rand(Vec3f, 2)) + color = Node(RNG.rand(RGBf, 2)) size = Node(0.1*RNG.rand(2)) makenew = Node(1) on(makenew) do i - pos[] = RNG.rand(Point3f0, i) - rot[] = RNG.rand(Vec3f0, i) - color[] = RNG.rand(RGBf0, i) + pos[] = RNG.rand(Point3f, i) + rot[] = RNG.rand(Vec3f, i) + color[] = RNG.rand(RGBf, i) size[] = 0.1*RNG.rand(i) end @@ -63,7 +63,7 @@ end rotations=rot, color=color, markersize=size, - limits=FRect3D(Point3(0), Point3(1)) + limits=Rect3f(Point3(0), Point3(1)) ) Record(scene, [10, 5, 100, 60, 177]) do i @@ -76,16 +76,16 @@ end function update_loop(m, buff, screen) for i = 1:20 GLFW.PollEvents() - buff .= RNG.rand.(Point3f0) .* 20f0 + buff .= RNG.rand.(Point3f) .* 20f0 m[1] = buff GLMakie.render_frame(screen) GLFW.SwapBuffers(GLMakie.to_native(screen)) glFinish() end end - fig, ax, meshplot = meshscatter(RNG.rand(Point3f0, 10^4) .* 20f0) + fig, ax, meshplot = meshscatter(RNG.rand(Point3f, 10^4) .* 20f0) screen = Makie.backend_display(GLMakie.GLBackend(), fig.scene) - buff = RNG.rand(Point3f0, 10^4) .* 20f0; + buff = RNG.rand(Point3f, 10^4) .* 20f0; update_loop(meshplot, buff, screen) set_window_config!(renderloop=GLMakie.renderloop) fig diff --git a/GLMakie/test/unit_tests.jl b/GLMakie/test/unit_tests.jl index 86258ecdfa9..45b3bcc8860 100644 --- a/GLMakie/test/unit_tests.jl +++ b/GLMakie/test/unit_tests.jl @@ -2,7 +2,7 @@ using GLMakie.Makie: backend_display, getscreen function project_sp(scene, point) point_px = Makie.project(scene, point) - offset = Point2f0(minimum(pixelarea(scene)[])) + offset = Point2f(minimum(pixelarea(scene)[])) return point_px .+ offset end @@ -33,15 +33,15 @@ end # force a full render to happen GLMakie.Makie.colorbuffer(screen) # test for pick a single data point (with idx > 65535) - point_px = project_sp(ax.scene, Point2f0(N-1,N-1)) + point_px = project_sp(ax.scene, Point2f(N-1,N-1)) plot,idx = pick(ax.scene, point_px) @test idx == N-1 # test for pick a rectangle of data points (also with some indices > 65535) - rect = FRect2D(99990.5,99990.5,8,8) + rect = Rect2f(99990.5,99990.5,8,8) origin_px = project_sp(ax.scene, Point(origin(rect))) tip_px = project_sp(ax.scene, Point(origin(rect) .+ widths(rect))) - rect_px = IRect2D(round.(origin_px), round.(tip_px .- origin_px)) + rect_px = Rect2i(round.(origin_px), round.(tip_px .- origin_px)) picks = unique(pick(ax.scene, rect_px)) # objects returned in plot_idx should be either grid lines (i.e. LineSegments) or Scatter points diff --git a/MakieRecipes/src/bezier.jl b/MakieRecipes/src/bezier.jl index 748dd881504..bf222bd1b02 100644 --- a/MakieRecipes/src/bezier.jl +++ b/MakieRecipes/src/bezier.jl @@ -53,8 +53,8 @@ function bezier_value(pts::AbstractVector, t::Real) end -function to_bezier(p::Vector{Point2f0}, npoints::Int) - curves = Point2f0[] +function to_bezier(p::Vector{Point2f}, npoints::Int) + curves = Point2f[] rawvecs = [getindex.(p, n) for n in 1:2] @@ -63,9 +63,9 @@ function to_bezier(p::Vector{Point2f0}, npoints::Int) xs = map(t -> bezier_value(getindex.(rng, 1), t), ts) ys = map(t -> bezier_value(getindex.(rng, 2), t), ts) - append!(curves, Point2f0.(xs, ys)) + append!(curves, Point2f.(xs, ys)) - push!(curves, Point2f0(NaN)) + push!(curves, Point2f(NaN)) end return curves diff --git a/MakieRecipes/src/pipeline_integration.jl b/MakieRecipes/src/pipeline_integration.jl index ff43d130986..79834b38dea 100644 --- a/MakieRecipes/src/pipeline_integration.jl +++ b/MakieRecipes/src/pipeline_integration.jl @@ -118,7 +118,7 @@ makie_args(::SurfaceLike, plotattributes) = (plotattributes[:x], plotattributes[ makie_args(::Type{<: Contour}, plotattributes) = (plotattributes[:x], plotattributes[:y], plotattributes[:z].surf) function makie_args(::Type{<: Poly}, plotattributes) - return (from_nansep_vec(Point2f0.(plotattributes[:x], plotattributes[:y])),) + return (from_nansep_vec(Point2f.(plotattributes[:x], plotattributes[:y])),) end function translate_to_makie!(st, pa) @@ -300,7 +300,7 @@ function plot_series_annotations!(plt, args, pt, plotattributes) sa = plotattributes[:series_annotations] - positions = Point2f0.(plotattributes[:x], plotattributes[:y]) + positions = Point2f.(plotattributes[:x], plotattributes[:y]) strs = sa[1] @@ -318,7 +318,7 @@ function plot_annotations!(plt, args, pt, plotattributes) sa = plotattributes[:annotations] - positions = Point2f0.(plotattributes[:x], plotattributes[:y]) + positions = Point2f.(plotattributes[:x], plotattributes[:y]) strs = string.(getindex.(sa, 3)) diff --git a/Project.toml b/Project.toml index aa07c46dbc9..45d896464ec 100644 --- a/Project.toml +++ b/Project.toml @@ -64,8 +64,8 @@ FixedPointNumbers = "0.6, 0.7, 0.8" Formatting = "0.4" FreeType = "3.0, 4.0" FreeTypeAbstraction = "0.8, 0.9" -GeometryBasics = "0.3.5" -GridLayoutBase = "0.5.5" +GeometryBasics = "0.4.1" +GridLayoutBase = "0.6" ImageIO = "0.2, 0.3, 0.4, 0.5" IntervalSets = "0.3, 0.4, 0.5" Isoband = "0.1" diff --git a/ReferenceTests/src/runtests.jl b/ReferenceTests/src/runtests.jl index 4e7bb8e36d9..10586d72c84 100644 --- a/ReferenceTests/src/runtests.jl +++ b/ReferenceTests/src/runtests.jl @@ -40,7 +40,7 @@ function compare_media(a, b; sigma=[1,1]) @warn "images don't have the same size, difference will be Inf" return Inf end - conv(x) = convert(Matrix{RGBf0}, x) + conv(x) = convert(Matrix{RGBf}, x) return compare_media(conv(imga), conv(imgb), sigma=sigma) elseif ext in (".mp4", ".gif") aframes, bframes = get_frames(a, b) diff --git a/ReferenceTests/src/tests/attributes.jl b/ReferenceTests/src/tests/attributes.jl index 662f4f617b2..e1c8ce4d3fc 100644 --- a/ReferenceTests/src/tests/attributes.jl +++ b/ReferenceTests/src/tests/attributes.jl @@ -48,7 +48,7 @@ end end @cell "shading" begin - mesh(Sphere(Point3f0(0), 1f0), color=:orange, shading=false) + mesh(Sphere(Point3f(0), 1f0), color=:orange, shading=false) end @cell "visible" begin diff --git a/ReferenceTests/src/tests/examples2d.jl b/ReferenceTests/src/tests/examples2d.jl index 76dba490a68..15edd53a8cd 100644 --- a/ReferenceTests/src/tests/examples2d.jl +++ b/ReferenceTests/src/tests/examples2d.jl @@ -4,16 +4,16 @@ using CategoricalArrays: categorical, levelcode @cell "Test heatmap + image overlap" begin heatmap(RNG.rand(32, 32)) - image!(map(x -> RGBAf0(x, 0.5, 0.5, 0.8), RNG.rand(32, 32))) + image!(map(x -> RGBAf(x, 0.5, 0.5, 0.8), RNG.rand(32, 32))) current_figure() end @cell "poly and colormap" begin # example by @Paulms from JuliaPlots/Makie.jl#310 - points = Point2f0[[0.0, 0.0], [0.1, 0.0], [0.1, 0.1], [0.0, 0.1]] + points = Point2f[[0.0, 0.0], [0.1, 0.0], [0.1, 0.1], [0.0, 0.1]] colors = [0.0 ,0.0, 0.5, 0.0] fig, ax, polyplot = poly(points, color=colors, colorrange=(0.0, 1.0)) - points = Point2f0[[0.1, 0.1], [0.2, 0.1], [0.2, 0.2], [0.1, 0.2]] + points = Point2f[[0.1, 0.1], [0.2, 0.1], [0.2, 0.2], [0.1, 0.2]] colors = [0.5,0.5,1.0,0.3] poly!(ax, points, color=colors, colorrange=(0.0, 1.0)) fig @@ -25,9 +25,9 @@ end end @cell "Arrows on hemisphere" begin - s = Sphere(Point3f0(0), 0.9f0) + s = Sphere(Point3f(0), 0.9f0) fig, ax, meshplot = mesh(s, transparency=true, alpha=0.05) - pos = decompose(Point3f0, s) + pos = decompose(Point3f, s) dirs = decompose_normals(s) arrows!(ax, pos, dirs, arrowcolor=:red, arrowsize=0.1, linecolor=:red) fig @@ -110,9 +110,9 @@ end end # @cell "Subscenes" begin -# img = RNG.rand(RGBAf0, 100, 100) +# img = RNG.rand(RGBAf, 100, 100) # scene = image(img, show_axis=false) -# subscene = Scene(scene, IRect(100, 100, 300, 300)) +# subscene = Scene(scene, Recti(100, 100, 300, 300)) # scatter!(subscene, RNG.rand(100) * 200, RNG.rand(100) * 200, markersize=4) # scene # end @@ -127,14 +127,14 @@ end end @cell "Polygons" begin - points = decompose(Point2f0, Circle(Point2f0(50), 50f0)) + points = decompose(Point2f, Circle(Point2f(50), 50f0)) fig, ax, pol = poly(points, color=:gray, strokewidth=10, strokecolor=:red) # Optimized forms - poly!(ax, [Circle(Point2f0(50 + 300), 50f0)], color=:gray, strokewidth=10, strokecolor=:red) - poly!(ax, [Circle(Point2f0(50 + i, 50 + i), 10f0) for i = 1:100:400], color=:red) - poly!(ax, [FRect2D(50 + i, 50 + i, 20, 20) for i = 1:100:400], strokewidth=2, strokecolor=:green) + poly!(ax, [Circle(Point2f(50 + 300), 50f0)], color=:gray, strokewidth=10, strokecolor=:red) + poly!(ax, [Circle(Point2f(50 + i, 50 + i), 10f0) for i = 1:100:400], color=:red) + poly!(ax, [Rect2f(50 + i, 50 + i, 20, 20) for i = 1:100:400], strokewidth=2, strokecolor=:green) linesegments!(ax, - [Point2f0(50 + i, 50 + i) => Point2f0(i + 70, i + 70) for i = 1:100:400], linewidth=8, color=:purple + [Point2f(50 + i, 50 + i) => Point2f(i + 70, i + 70) for i = 1:100:400], linewidth=8, color=:purple ) fig end @@ -153,7 +153,7 @@ end fig = Figure() ax = fig[1, 1] = Axis(fig) pos = (500, 500) - posis = Point2f0[] + posis = Point2f[] for r in range(0, stop=2pi, length=20) p = pos .+ (sin(r) * 100.0, cos(r) * 100) push!(posis, p) @@ -200,7 +200,7 @@ end fig, ax, lineplot = lines(RNG.rand(10); linewidth=10) N = 20 Record(fig, 1:N; framerate=20) do i - lineplot.color = RGBf0(i / N, (N - i) / N, 0) # animate scene + lineplot.color = RGBf(i / N, (N - i) / N, 0) # animate scene end end @@ -213,7 +213,7 @@ let end @cell "streamplot" begin P = FitzhughNagumo(0.1, 0.0, 1.5, 0.8) - f(x, P::FitzhughNagumo) = Point2f0( + f(x, P::FitzhughNagumo) = Point2f( (x[1] - x[2] - x[1]^3 + P.s) / P.ϵ, P.γ * x[1] - x[2] + P.β ) @@ -236,7 +236,7 @@ end lines!(ax, xs, ys; color=colors[i], - limits=FRect((0, 0), (10, 10)), + limits=Rectf((0, 0), (10, 10)), linewidth=5 ) # plot lines with colors end @@ -246,7 +246,7 @@ end for (i, rot) in enumerate(LinRange(0, π / 2, N)) Makie.rotate!(plots[i], rot) arc!(ax, - Point2f0(0), + Point2f(0), (8 - i), pi / 2, (pi / 2 - rot); @@ -298,7 +298,7 @@ end @cell "intersecting polygon" begin x = LinRange(0, 2pi, 100) - poly(Point2f0.(zip(sin.(x), sin.(2x))), color = :white, strokecolor = :blue, strokewidth = 10) + poly(Point2f.(zip(sin.(x), sin.(2x))), color = :white, strokecolor = :blue, strokewidth = 10) end diff --git a/ReferenceTests/src/tests/examples3d.jl b/ReferenceTests/src/tests/examples3d.jl index ebd73d519d6..ca840176f52 100644 --- a/ReferenceTests/src/tests/examples3d.jl +++ b/ReferenceTests/src/tests/examples3d.jl @@ -5,15 +5,15 @@ using Makie: Record, volume @cell "Image on Geometry (Moon)" begin moon = loadasset("moon.png") - fig, ax, meshplot = mesh(Sphere(Point3f0(0), 1f0), color=moon, shading=false, show_axis=false, center=false) - update_cam!(ax.scene, Vec3f0(-2, 2, 2), Vec3f0(0)) + fig, ax, meshplot = mesh(Sphere(Point3f(0), 1f0), color=moon, shading=false, show_axis=false, center=false) + update_cam!(ax.scene, Vec3f(-2, 2, 2), Vec3f(0)) ax.scene.center = false # prevent to recenter on display fig end @cell "Image on Geometry (Earth)" begin earth = loadasset("earth.png") - m = uv_mesh(Tesselation(Sphere(Point3f0(0), 1f0), 60)) + m = uv_mesh(Tesselation(Sphere(Point3f(0), 1f0), 60)) mesh(m, color=earth, shading=false) end @@ -24,11 +24,11 @@ end return GeometryBasics.pointmeta(mesh1; color=fill(color, npoints)) end # create an array of differently colored boxes in the direction of the 3 axes - x = Vec3f0(0); baselen = 0.2f0; dirlen = 1f0 + x = Vec3f(0); baselen = 0.2f0; dirlen = 1f0 rectangles = [ - (Rect(Vec3f0(x), Vec3f0(dirlen, baselen, baselen)), RGBAf0(1, 0, 0, 1)), - (Rect(Vec3f0(x), Vec3f0(baselen, dirlen, baselen)), RGBAf0(0, 1, 0, 1)), - (Rect(Vec3f0(x), Vec3f0(baselen, baselen, dirlen)), RGBAf0(0, 0, 1, 1)) + (Rect(Vec3f(x), Vec3f(dirlen, baselen, baselen)), RGBAf(1, 0, 0, 1)), + (Rect(Vec3f(x), Vec3f(baselen, dirlen, baselen)), RGBAf(0, 1, 0, 1)), + (Rect(Vec3f(x), Vec3f(baselen, baselen, dirlen)), RGBAf(0, 0, 1, 1)) ] meshes = map(colormesh, rectangles) @@ -37,7 +37,7 @@ end center!(scene) cam = cameracontrols(scene) dir = widths(scene_limits(scene)) ./ 2. - dir_scaled = Vec3f0( + dir_scaled = Vec3f( dir[1] * scene.transformation.scale[][1], 0.0, dir[3] * scene.transformation.scale[][2], @@ -84,7 +84,7 @@ end end @cell "Wireframe of Sphere" begin - wireframe(Sphere(Point3f0(0), 1f0)) + wireframe(Sphere(Point3f(0), 1f0)) end @cell "Wireframe of a Surface" begin @@ -109,15 +109,15 @@ end surf_func(i) = [Float32(xy_data(x * i, y * i)) for x = xrange, y = xrange] surface( xrange, xrange, surf_func(10), - color=RNG.rand(RGBAf0, 124, 124) + color=RNG.rand(RGBAf, 124, 124) ) end @cell "Meshscatter Function" begin - large_sphere = Sphere(Point3f0(0), 1f0) - positions = decompose(Point3f0, large_sphere) - colS = [RGBAf0(RNG.rand(), RNG.rand(), RNG.rand(), 1.0) for i = 1:length(positions)] - sizesS = [RNG.rand(Point3f0) .* 0.05f0 for i = 1:length(positions)] + large_sphere = Sphere(Point3f(0), 1f0) + positions = decompose(Point3f, large_sphere) + colS = [RGBAf(RNG.rand(), RNG.rand(), RNG.rand(), 1.0) for i = 1:length(positions)] + sizesS = [RNG.rand(Point3f) .* 0.05f0 for i = 1:length(positions)] meshscatter(positions, color=colS, markersize=sizesS) end @@ -132,7 +132,7 @@ end @cell "Record Video" begin f(t, v, s) = (sin(v + t) * s, cos(v + t) * s, (cos(v + t) + sin(v)) * s) t = Node(Base.time()) # create a life signal - limits = FRect3D(Vec3f0(-1.5, -1.5, -3), Vec3f0(3, 3, 6)) + limits = Rect3f(Vec3f(-1.5, -1.5, -3), Vec3f(3, 3, 6)) fig, ax, p1 = meshscatter(lift(t -> f.(t, range(0, stop=2pi, length=50), 1), t), markersize=0.05) p2 = meshscatter!(ax, lift(t -> f.(t * 2.0, range(0, stop=2pi, length=50), 1.5), t), markersize=0.05) @@ -179,7 +179,7 @@ end x = @.r * sin(θ) * cos(ϕ) y = @.r * sin(θ) * sin(ϕ) z = @.r * cos(θ) - Point3f0.(x, y, z) + Point3f.(x, y, z) end n = 100^2 # number of points to generate r = ones(n); @@ -197,15 +197,15 @@ end y = [sinpi(φ) * sinpi(θ) for θ in θ, φ in φ] z = [cospi(θ) for θ in θ, φ in φ] RNG.rand([-1f0, 1f0], 3) - pts = vec(Point3f0.(x, y, z)) + pts = vec(Point3f.(x, y, z)) surface(x, y, z, color=Makie.logo(), transparency=true) end @cell "Arrows on Sphere" begin n = 20 f = (x, y, z) -> x * exp(cos(y) * z) - ∇f = (x, y, z) -> Point3f0(exp(cos(y) * z), -sin(y) * z * x * exp(cos(y) * z), x * cos(y) * exp(cos(y) * z)) - ∇ˢf = (x, y, z) -> ∇f(x, y, z) - Point3f0(x, y, z) * dot(Point3f0(x, y, z), ∇f(x, y, z)) + ∇f = (x, y, z) -> Point3f(exp(cos(y) * z), -sin(y) * z * x * exp(cos(y) * z), x * cos(y) * exp(cos(y) * z)) + ∇ˢf = (x, y, z) -> ∇f(x, y, z) - Point3f(x, y, z) * dot(Point3f(x, y, z), ∇f(x, y, z)) θ = [0;(0.5:n - 0.5) / n;1] φ = [(0:2n - 2) * 2 / (2n - 1);2] @@ -213,7 +213,7 @@ end y = [sinpi(φ) * sinpi(θ) for θ in θ, φ in φ] z = [cospi(θ) for θ in θ, φ in φ] - pts = vec(Point3f0.(x, y, z)) + pts = vec(Point3f.(x, y, z)) ∇ˢF = vec(∇ˢf.(x, y, z)) .* 0.1f0 surface(x, y, z) arrows!( @@ -238,7 +238,7 @@ end @cell "FEM mesh 3D" begin cat = loadasset("cat.obj") - vertices = decompose(Point3f0, cat) + vertices = decompose(Point3f, cat) faces = decompose(TriangleFace{Int}, cat) coordinates = [vertices[i][j] for i = 1:length(vertices), j = 1:3] connectivity = [faces[i][j] for i = 1:length(faces), j = 1:3] @@ -279,7 +279,7 @@ end font="helvetica", raw=:true ) - c = lines!(scene, Circle(Point2f0(0.1, 0.5), 0.1f0), color=:red, offset=Vec3f0(0, 0, 1)) + c = lines!(scene, Circle(Point2f(0.1, 0.5), 0.1f0), color=:red, offset=Vec3f(0, 0, 1)) scene # update surface # TODO explain and improve the situation here @@ -292,30 +292,30 @@ end perturbfactor = 4e1 N = 3; nbfacese = 30; radius = 0.02 - large_sphere = Sphere(Point3f0(0), 1f0) - positions = decompose(Point3f0, large_sphere, 30) + large_sphere = Sphere(Point3f(0), 1f0) + positions = decompose(Point3f, large_sphere, 30) np = length(positions) pts = [positions[k][l] for k = 1:length(positions), l = 1:3] pts = vcat(pts, 1.1 .* pts + RNG.randn(size(pts)) / perturbfactor) # light position influence ? edges = hcat(collect(1:np), collect(1:np) .+ np) ne = size(edges, 1); np = size(pts, 1) - cylinder = Cylinder(Point3f0(0), Point3f0(0, 0, 1.0), 1f0) + cylinder = Cylinder(Point3f(0), Point3f(0, 0, 1.0), 1f0) # define markers meshes meshC = normal_mesh(Tesselation(cylinder, nbfacese)) meshS = normal_mesh(Tesselation(large_sphere, 20)) # define colors, markersizes and rotations - pG = [Point3f0(pts[k, 1], pts[k, 2], pts[k, 3]) for k = 1:np] + pG = [Point3f(pts[k, 1], pts[k, 2], pts[k, 3]) for k = 1:np] lengthsC = sqrt.(sum((pts[edges[:,1], :] .- pts[edges[:, 2], :]).^2, dims=2)) - sizesC = [Vec3f0(radius, radius, lengthsC[i]) for i = 1:ne] - sizesC = [Vec3f0(1) for i = 1:ne] + sizesC = [Vec3f(radius, radius, lengthsC[i]) for i = 1:ne] + sizesC = [Vec3f(1) for i = 1:ne] colorsp = [RGBA{Float32}(RNG.rand(), RNG.rand(), RNG.rand(), 1.0) for i = 1:np] colorsC = [(colorsp[edges[i, 1]] .+ colorsp[edges[i, 2]]) / 2.0 for i = 1:ne] - sizesC = [Vec3f0(radius, radius, lengthsC[i]) for i = 1:ne] + sizesC = [Vec3f(radius, radius, lengthsC[i]) for i = 1:ne] Qlist = zeros(ne, 4) for k = 1:ne ct = Cylinder( - Point3f0(pts[edges[k, 1], 1], pts[edges[k, 1], 2], pts[edges[k, 1], 3]), - Point3f0(pts[edges[k, 2], 1], pts[edges[k, 2], 2], pts[edges[k, 2], 3]), + Point3f(pts[edges[k, 1], 1], pts[edges[k, 1], 2], pts[edges[k, 1], 3]), + Point3f(pts[edges[k, 2], 1], pts[edges[k, 2], 2], pts[edges[k, 2], 3]), 1f0 ) Q = GeometryBasics.rotation(ct) @@ -325,7 +325,7 @@ end Qlist[k, 3] = (Q[2, 1] .- Q[1, 2]) / (4 .* r) end - rotationsC = [Vec4f0(Qlist[i, 1], Qlist[i, 2], Qlist[i, 3], Qlist[i, 4]) for i = 1:ne] + rotationsC = [Vec4f(Qlist[i, 1], Qlist[i, 2], Qlist[i, 3], Qlist[i, 4]) for i = 1:ne] # plot fig, ax, meshplot = meshscatter( pG[edges[:, 1]], @@ -340,14 +340,14 @@ end end @cell "Connected Sphere" begin - large_sphere = Sphere(Point3f0(0), 1f0) - positions = decompose(Point3f0, large_sphere) + large_sphere = Sphere(Point3f(0), 1f0) + positions = decompose(Point3f, large_sphere) linepos = view(positions, RNG.rand(1:length(positions), 1000)) fig, ax, lineplot = lines(linepos, linewidth=0.1, color=:black, transparency=true) scatter!( ax, positions, markersize=50, strokewidth=2, strokecolor=:white, - color=RGBAf0(0.9, 0.2, 0.4, 0.5) + color=RGBAf(0.9, 0.2, 0.4, 0.5) ) fig end @@ -355,7 +355,7 @@ end @cell "image scatter" begin scatter( 1:10, 1:10, RNG.rand(10, 10) .* 10, - rotations=normalize.(RNG.rand(Quaternionf0, 10 * 10)), + rotations=normalize.(RNG.rand(Quaternionf, 10 * 10)), markersize=1, # can also be an array of images for each point # need to be the same size for best performance, though @@ -364,9 +364,9 @@ end end @cell "Simple meshscatter" begin - large_sphere = Sphere(Point3f0(0), 1f0) - positions = decompose(Point3f0, large_sphere) - meshscatter(positions, color=RGBAf0(0.9, 0.2, 0.4, 1), markersize=0.05) + large_sphere = Sphere(Point3f(0), 1f0) + positions = decompose(Point3f, large_sphere) + meshscatter(positions, color=RGBAf(0.9, 0.2, 0.4, 1), markersize=0.05) end @cell "Animated surface and wireframe" begin @@ -392,7 +392,7 @@ end @cell "Normals of a Cat" begin x = loadasset("cat.obj") mesh(x, color=:black) - pos = map(decompose(Point3f0, x), GeometryBasics.normals(x)) do p, n + pos = map(decompose(Point3f, x), GeometryBasics.normals(x)) do p, n p => p .+ (normalize(n) .* 0.05f0) end linesegments!(pos, color=:blue) @@ -400,7 +400,7 @@ end end @cell "Sphere Mesh" begin - mesh(Sphere(Point3f0(0), 1f0), color=:blue) + mesh(Sphere(Point3f(0), 1f0), color=:blue) end @cell "Stars" begin @@ -408,19 +408,19 @@ end scene = Scene(backgroundcolor=:black) scatter!( scene, - map(i -> (RNG.randn(Point3f0) .- 0.5) .* 10, 1:stars), + map(i -> (RNG.randn(Point3f) .- 0.5) .* 10, 1:stars), color=RNG.rand(stars), colormap=[(:white, 0.4), (:blue, 0.4), (:yellow, 0.4)], strokewidth=0, markersize=RNG.rand(range(10, stop=100, length=100), stars), show_axis=false ) - update_cam!(scene, FRect3D(Vec3f0(-5), Vec3f0(10))) + update_cam!(scene, Rect3f(Vec3f(-5), Vec3f(10))) scene.center = false scene end @cell "Unicode Marker" begin - scatter(Point3f0[(1, 0, 0), (0, 1, 0), (0, 0, 1)], marker=[:x, :circle, :cross], + scatter(Point3f[(1, 0, 0), (0, 1, 0), (0, 0, 1)], marker=[:x, :circle, :cross], markersize=100) end @@ -431,11 +431,11 @@ end return GeometryBasics.pointmeta(mesh1; color=fill(color, npoints)) end # create an array of differently colored boxes in the direction of the 3 axes - x = Vec3f0(0); baselen = 0.2f0; dirlen = 1f0 + x = Vec3f(0); baselen = 0.2f0; dirlen = 1f0 rectangles = [ - (Rect(Vec3f0(x), Vec3f0(dirlen, baselen, baselen)), RGBAf0(1, 0, 0, 1)), - (Rect(Vec3f0(x), Vec3f0(baselen, dirlen, baselen)), RGBAf0(0, 1, 0, 1)), - (Rect(Vec3f0(x), Vec3f0(baselen, baselen, dirlen)), RGBAf0(0, 0, 1, 1)) + (Rect(Vec3f(x), Vec3f(dirlen, baselen, baselen)), RGBAf(1, 0, 0, 1)), + (Rect(Vec3f(x), Vec3f(baselen, dirlen, baselen)), RGBAf(0, 1, 0, 1)), + (Rect(Vec3f(x), Vec3f(baselen, baselen, dirlen)), RGBAf(0, 0, 1, 1)) ] meshes = map(colormesh, rectangles) @@ -445,7 +445,7 @@ end @cell "Line GIF" begin us = range(0, stop=1, length=100) scene = Scene() - linesegments!(scene, FRect3D(Vec3f0(0, -1, 0), Vec3f0(1, 2, 2))) + linesegments!(scene, Rect3f(Vec3f(0, -1, 0), Vec3f(1, 2, 2))) p = lines!(scene, us, sin.(us .+ time()), zeros(100), linewidth=3, transparency=true) lineplots = [p] Makie.translate!(p, 0, 0, 0) @@ -497,7 +497,7 @@ let @cell "Streamplot 3D" begin P = FitzhughNagumo(0.1, 0.0, 1.5, 0.8) - f(x, P::FitzhughNagumo) = Point3f0( + f(x, P::FitzhughNagumo) = Point3f( (x[1] - x[2] - x[1]^3 + P.s) / P.ϵ, P.γ * x[2] - x[2] + P.β, P.γ * x[1] - x[3] - P.β, diff --git a/ReferenceTests/src/tests/recipes.jl b/ReferenceTests/src/tests/recipes.jl index 60a2133df40..944b82d3ca7 100644 --- a/ReferenceTests/src/tests/recipes.jl +++ b/ReferenceTests/src/tests/recipes.jl @@ -1,6 +1,6 @@ import Makie: Plot, default_theme, plot!, to_value struct Simulation - grid::Vector{Point3f0} + grid::Vector{Point3f} end # Probably worth having a macro for this! function Makie.default_theme(scene::SceneLike, ::Type{<: Plot(Simulation)}) @@ -15,7 +15,7 @@ function Makie.plot!(p::Plot(Simulation)) sim = to_value(p[1]) # first argument is the SimulationResult # when advance changes, get new positions from the simulation mpos = lift(p[:advance]) do i - sim.grid .+ RNG.rand(Point3f0, length(sim.grid)) .* 0.01f0 + sim.grid .+ RNG.rand(Point3f, length(sim.grid)) .* 0.01f0 end # size shouldn't change, so we might as well get the value instead of signal pos = to_value(mpos) @@ -45,13 +45,13 @@ end # To write out a video of the whole simulation n = 5 r = range(-1, stop=1, length=n) - grid = Point3f0.(r, reshape(r, (1, n, 1)), reshape(r, (1, 1, n))) + grid = Point3f.(r, reshape(r, (1, n, 1)), reshape(r, (1, 1, n))) molecules = map(1:(n^3) * 3) do i i3 = ((i - 1) ÷ 3) + 1 xy = 0.1; z = 0.08 i % 3 == 1 && return grid[i3] - i % 3 == 2 && return grid[i3] + Point3f0(xy, xy, z) - i % 3 == 0 && return grid[i3] + Point3f0(-xy, xy, z) + i % 3 == 2 && return grid[i3] + Point3f(xy, xy, z) + i % 3 == 0 && return grid[i3] + Point3f(-xy, xy, z) end result = Simulation(molecules) fig, ax, molecule_plot = plot(result) diff --git a/ReferenceTests/src/tests/short_tests.jl b/ReferenceTests/src/tests/short_tests.jl index fd66dd271cc..c68eb0beb0e 100644 --- a/ReferenceTests/src/tests/short_tests.jl +++ b/ReferenceTests/src/tests/short_tests.jl @@ -1,8 +1,8 @@ -@cell arc(Point2f0(0), 10f0, 0f0, pi, linewidth=20) +@cell arc(Point2f(0), 10f0, 0f0, pi, linewidth=20) -@cell mesh(IRect(0, 0, 200, 200)) +@cell mesh(Recti(0, 0, 200, 200)) -@cell poly(IRect(0, 0, 200, 200), strokewidth=20, strokecolor=:red, color=(:black, 0.4)) +@cell poly(Recti(0, 0, 200, 200), strokewidth=20, strokecolor=:red, color=(:black, 0.4)) @cell begin scene = poly([Rect(0, 0, 20, 20)]) @@ -12,19 +12,19 @@ end @cell begin lines(Rect(0, 0, 1, 1), linewidth=4, scale_plot=false) - scatter!([Point2f0(0.5, 0.5)], markersize=1, markerspace=SceneSpace, marker='I', scale_plot=false) + scatter!([Point2f(0.5, 0.5)], markersize=1, markerspace=SceneSpace, marker='I', scale_plot=false) current_figure() end @cell lines(RNG.rand(10), RNG.rand(10), color=RNG.rand(10), linewidth=10) -@cell lines(RNG.rand(10), RNG.rand(10), color=RNG.rand(RGBAf0, 10), linewidth=10) +@cell lines(RNG.rand(10), RNG.rand(10), color=RNG.rand(RGBAf, 10), linewidth=10) @cell scatter(0..1, RNG.rand(10), markersize=RNG.rand(10) .* 20) @cell scatter(LinRange(0, 1, 10), RNG.rand(10)) @cell scatter(RNG.rand(10), LinRange(0, 1, 10)) @cell begin angles = range(0, stop=2pi, length=20) - pos = Point2f0.(sin.(angles), cos.(angles)) + pos = Point2f.(sin.(angles), cos.(angles)) scatter(pos, markersize=0.2, markerspace=SceneSpace, rotations=-angles, marker='▲', axis=(;aspect = DataAspect())) scatter!(pos, markersize=10, color=:red, axis=(;aspect = DataAspect())) current_figure() @@ -46,7 +46,7 @@ end colorrange=(0.2, 0.8) ) -@cell lines(Circle(Point2f0(0), Float32(1)); scale_plot=false, resolution=(800, 1000)) +@cell lines(Circle(Point2f(0), Float32(1)); scale_plot=false, resolution=(800, 1000)) @cell begin v(x::Point2{T}) where T = Point2{T}(x[2], 4 * x[1]) @@ -60,20 +60,20 @@ end r = range(-3pi, stop=3pi, length=100) fig, ax, vplot = volume(r, r, r, (x, y, z) -> cos(x) + sin(y) + cos(z), algorithm=:iso, isorange=0.1f0, show_axis=false) v2 = volume!(ax, r, r, r, (x, y, z) -> cos(x) + sin(y) + cos(z), algorithm=:mip, show_axis=false) - translate!(v2, Vec3f0(6pi, 0, 0)) + translate!(v2, Vec3f(6pi, 0, 0)) fig end @cell meshscatter(RNG.rand(10), RNG.rand(10), RNG.rand(10), color=RNG.rand(10)) -@cell meshscatter(RNG.rand(10), RNG.rand(10), RNG.rand(10), color=RNG.rand(RGBAf0, 10)) +@cell meshscatter(RNG.rand(10), RNG.rand(10), RNG.rand(10), color=RNG.rand(RGBAf, 10)) @cell begin - s1 = uv_mesh(Sphere(Point3f0(0), 1f0)) - mesh(uv_mesh(Sphere(Point3f0(0), 1f0)), color=RNG.rand(50, 50)) + s1 = uv_mesh(Sphere(Point3f(0), 1f0)) + mesh(uv_mesh(Sphere(Point3f(0), 1f0)), color=RNG.rand(50, 50)) # ugh, bug In GeometryTypes for UVs of non unit spheres. - s2 = uv_mesh(Sphere(Point3f0(0), 1f0)) - s2.position .= s2.position .+ (Point3f0(0, 2, 0),) - mesh!(s2, color=RNG.rand(RGBAf0, 50, 50)) + s2 = uv_mesh(Sphere(Point3f(0), 1f0)) + s2.position .= s2.position .+ (Point3f(0, 2, 0),) + mesh!(s2, color=RNG.rand(RGBAf, 50, 50)) current_figure() end diff --git a/ReferenceTests/src/tests/text.jl b/ReferenceTests/src/tests/text.jl index 8f8781bd363..1d847b86523 100644 --- a/ReferenceTests/src/tests/text.jl +++ b/ReferenceTests/src/tests/text.jl @@ -9,7 +9,7 @@ using LaTeXStrings text!(ax, string.(round.(vec(values'), digits = 2)), - position = [Point2f0(x, y) for x in 1:10 for y in 1:10], + position = [Point2f(x, y) for x in 1:10 for y in 1:10], align = (:center, :center), color = ifelse.(vec(values') .< 0.3, :white, :black), textsize = 12) @@ -17,7 +17,7 @@ using LaTeXStrings end @cell "data space" begin - pos = [Point2f0(0, 0), Point2f0(10, 10)] + pos = [Point2f(0, 0), Point2f(10, 10)] fig = text( ["0 is the ORIGIN of this", "10 says hi"], position = pos, @@ -115,7 +115,7 @@ end t1 = text!(scene, fill("makie", 4), - position = [(200, 200) .+ 60 * Point2f0(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4], + position = [(200, 200) .+ 60 * Point2f(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4], rotation = pi/4:pi/2:7pi/4, align = (:left, :center), textsize = 30, @@ -126,7 +126,7 @@ end t2 = text!(scene, fill("makie", 4), - position = [(200, 600) .+ 60 * Point2f0(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4], + position = [(200, 600) .+ 60 * Point2f(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4], rotation = pi/4:pi/2:7pi/4, align = (:left, :center), textsize = 30, @@ -145,7 +145,7 @@ end t = text!(scene, "makie", - position = (200, 200) .+ 60 * Point2f0(cos(a), sin(a)), + position = (200, 200) .+ 60 * Point2f(cos(a), sin(a)), rotation = a, align = (:left, :center), textsize = 30, @@ -156,7 +156,7 @@ end t2 = text!(scene, "makie", - position = (200, 600) .+ 60 * Point2f0(cos(a), sin(a)), + position = (200, 600) .+ 60 * Point2f(cos(a), sin(a)), rotation = a, align = (:left, :center), textsize = 30, @@ -174,7 +174,7 @@ end text( fill("Makie", 7), rotation = [i / 7 * 1.5pi for i in 1:7], - position = [Point3f0(0, 0, i/2) for i in 1:7], + position = [Point3f(0, 0, i/2) for i in 1:7], color = [cgrad(:viridis)[x] for x in LinRange(0, 1, 7)], align = (:left, :baseline), textsize = 1, @@ -200,7 +200,7 @@ end @cell "3D screenspace annotations" begin - positions = RNG.rand(Point3f0, 10) + positions = RNG.rand(Point3f, 10) fig, ax, p = meshscatter(positions, color=:white) text!( fill("Annotation", 10), @@ -221,21 +221,21 @@ end offset = [(0, -10), (0, -20)], align = (:center, :top), color = :white) - scatter(f[1, 2], Point2f0(0, 0)) + scatter(f[1, 2], Point2f(0, 0)) text!("hello", position = (0, 0), offset = (40, 0), align = (:left, :center)) text!("hello", position = (0, 0), offset = (40, 0), align = (:left, :center), rotation = -pi/4) text!("hello", position = (0, 0), offset = (40, 0), align = (:left, :center), rotation = pi/4) - scatter(f[2, 1], Point2f0[(0, 0), (10, 0), (20, 10)]) + scatter(f[2, 1], Point2f[(0, 0), (10, 0), (20, 10)]) text!("ABC", space = :data, offset = (0, 0), color = (:red, 0.3), align = (:left, :baseline)) text!("ABC", space = :data, offset = (10, 0), color = (:green, 0.3), align = (:left, :baseline)) text!("ABC", space = :data, offset = (20, 10), color = (:blue, 0.3), align = (:left, :baseline)) LScene(f[2, 2], scenekw = (show_axis = false,)) - scatter!(Point3f0[(0, 0, 0), (2, 2, 2)]) - text!("hello", position = Point3f0(1, 1, 1), offset = (10, 10)) + scatter!(Point3f[(0, 0, 0), (2, 2, 2)]) + text!("hello", position = Point3f(1, 1, 1), offset = (10, 10)) f end @@ -278,7 +278,7 @@ end s = Scene(camera = campixel!) t = text!(s, L"\int_0^5x^2+2ab", - position = Point2f0(50, 50), + position = Point2f(50, 50), rotation = 0.0, show_axis = false, space = :data) @@ -290,7 +290,7 @@ end s = Scene(camera = campixel!) st = Stepper(s) textnode = Node([L"\int_0^5x^2+2ab", L"\int_0^5x^2+2ab"]) - posnode = Node(Point2f0[(50, 50), (100, 100)]) + posnode = Node(Point2f[(50, 50), (100, 100)]) t = text!(s, textnode, @@ -302,7 +302,7 @@ end Makie.step!(st) ## change lengths textnode.val = push!(textnode[], L"\int_0^5x^2+2ab") - posnode[] = push!(posnode[], Point2f0(150, 150)) + posnode[] = push!(posnode[], Point2f(150, 150)) Makie.step!(st) st end @@ -311,8 +311,8 @@ end s = Scene(camera = campixel!) st = Stepper(s) textposnode = Node([ - (L"\int_0^5x^2+2ab", Point2f0(50, 50)), - (L"\int_0^5x^2+2ab", Point2f0(100, 100)), + (L"\int_0^5x^2+2ab", Point2f(50, 50)), + (L"\int_0^5x^2+2ab", Point2f(100, 100)), ]) t = text!(s, @@ -322,7 +322,7 @@ end Makie.step!(st) ## change lengths - textposnode[] = push!(textposnode[], (L"\int_0^5x^2+2ab", Point2f0(150, 150))) + textposnode[] = push!(textposnode[], (L"\int_0^5x^2+2ab", Point2f(150, 150))) Makie.step!(st) st end diff --git a/WGLMakie/Project.toml b/WGLMakie/Project.toml index 80270f2fe17..a46e8c227f6 100644 --- a/WGLMakie/Project.toml +++ b/WGLMakie/Project.toml @@ -21,7 +21,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Colors = "0.11, 0.12" FileIO = "1.1" FreeTypeAbstraction = "0.8, 0.9" -GeometryBasics = "0.3" +GeometryBasics = "0.4.1" Hyperscript = "0.0.3, 0.0.4" ImageMagick = "1.1" JSServe = "1.2" diff --git a/WGLMakie/README.md b/WGLMakie/README.md index 404b9b20d81..96d749f644d 100644 --- a/WGLMakie/README.md +++ b/WGLMakie/README.md @@ -20,11 +20,11 @@ function dom_handler(session, request) return DOM.div( DOM.h1("Some Makie Plots:"), meshscatter(1:4, color=1:4), - meshscatter(1:4, color=rand(RGBAf0, 4)), - meshscatter(1:4, color=rand(RGBf0, 4)), + meshscatter(1:4, color=rand(RGBAf, 4)), + meshscatter(1:4, color=rand(RGBf, 4)), meshscatter(1:4, color=:red), - meshscatter(rand(Point3f0, 10), color=rand(RGBf0, 10)), - meshscatter(rand(Point3f0, 10), marker=Pyramid(Point3f0(0), 1f0, 1f0)), + meshscatter(rand(Point3f, 10), color=rand(RGBf, 10)), + meshscatter(rand(Point3f, 10), marker=Pyramid(Point3f(0), 1f0, 1f0)), ) end isdefined(Main, :app) && close(app) diff --git a/WGLMakie/src/imagelike.jl b/WGLMakie/src/imagelike.jl index a34c0ae9bf6..11707b2f7ec 100644 --- a/WGLMakie/src/imagelike.jl +++ b/WGLMakie/src/imagelike.jl @@ -4,7 +4,7 @@ using Makie: el32convert, surface_normals, get_dim # but the convert leaves them at nothing -.- # TODO clean this up in Makie nothing_or_color(c) = to_color(c) -nothing_or_color(c::Nothing) = RGBAf0(0, 0, 0, 1) +nothing_or_color(c::Nothing) = RGBAf(0, 0, 0, 1) function draw_mesh(mscene::Scene, mesh, plot; uniforms...) uniforms = Dict(uniforms) @@ -15,7 +15,7 @@ function draw_mesh(mscene::Scene, mesh, plot; uniforms...) end colorrange = if haskey(plot, :colorrange) - uniforms[:colorrange] = lift(Vec2f0, plot.colorrange) + uniforms[:colorrange] = lift(Vec2f, plot.colorrange) end get!(uniforms, :colormap, false) @@ -46,20 +46,20 @@ function limits_to_uvmesh(plot) rect = lift(px, py) do x, y xmin, xmax = x ymin, ymax = y - return Rect2D(xmin, ymin, xmax - xmin, ymax - ymin) + return Rect2(xmin, ymin, xmax - xmin, ymax - ymin) end - positions = Buffer(lift(rect-> decompose(Point2f0, rect), rect)) + positions = Buffer(lift(rect-> decompose(Point2f, rect), rect)) faces = Buffer(lift(rect -> decompose(GLTriangleFace, rect), rect)) uv = Buffer(lift(decompose_uv, rect)) else function grid(x, y, z, trans) g = map(CartesianIndices((length(x), length(y)))) do i - p = Point3f0(get_dim(x, i, 1, size(z)), get_dim(y, i, 2, size(z)), 0.0) + p = Point3f(get_dim(x, i, 1, size(z)), get_dim(y, i, 2, size(z)), 0.0) return apply_transform(trans, p) end return vec(g) end - rect = lift(z -> Tesselation(Rect2D(0f0, 0f0, 1f0, 1f0), size(z) .+ 1), pz) + rect = lift(z -> Tesselation(Rect2(0f0, 0f0, 1f0, 1f0), size(z) .+ 1), pz) positions = Buffer(lift(grid, px, py, pz, t)) faces = Buffer(lift(r -> decompose(GLTriangleFace, r), rect)) uv = Buffer(lift(decompose_uv, rect)) @@ -75,14 +75,14 @@ function create_shader(mscene::Scene, plot::Surface) px, py, pz = plot[1], plot[2], plot[3] function grid(x, y, z, trans) g = map(CartesianIndices(z)) do i - p = Point3f0(get_dim(x, i, 1, size(z)), get_dim(y, i, 2, size(z)), z[i]) + p = Point3f(get_dim(x, i, 1, size(z)), get_dim(y, i, 2, size(z)), z[i]) return apply_transform(trans, p) end return vec(g) end positions = Buffer(lift(grid, px, py, pz, transform_func_obs(plot))) - rect = lift(z -> Tesselation(Rect2D(0f0, 0f0, 1f0, 1f0), size(z)), pz) + rect = lift(z -> Tesselation(Rect2(0f0, 0f0, 1f0, 1f0), size(z)), pz) faces = Buffer(lift(r -> decompose(GLTriangleFace, r), rect)) uv = Buffer(lift(decompose_uv, rect)) pcolor = if haskey(plot, :color) && plot.color[] isa AbstractArray @@ -95,10 +95,10 @@ function create_shader(mscene::Scene, plot::Surface) normals = Buffer(lift(surface_normals, px, py, pz)) vertices = GeometryBasics.meta(positions; uv=uv, normals=normals) mesh = GeometryBasics.Mesh(vertices, faces) - return draw_mesh(mscene, mesh, plot; uniform_color=color, color=Vec4f0(0), + return draw_mesh(mscene, mesh, plot; uniform_color=color, color=Vec4f(0), shading=plot.shading, ambient=plot.ambient, diffuse=plot.diffuse, specular=plot.specular, shininess=plot.shininess, - lightposition=Vec3f0(1), + lightposition=Vec3f(1), highclip=lift(nothing_or_color, plot.highclip), lowclip=lift(nothing_or_color, plot.lowclip), nan_color=lift(nothing_or_color, plot.nan_color)) @@ -110,11 +110,11 @@ function create_shader(mscene::Scene, plot::Union{Heatmap,Image}) minfilter=to_value(get(plot, :interpolate, false)) ? :linear : :nearest) mesh = limits_to_uvmesh(plot) - return draw_mesh(mscene, mesh, plot; uniform_color=color, color=Vec4f0(0), - normals=Vec3f0(0), shading=false, ambient=plot.ambient, + return draw_mesh(mscene, mesh, plot; uniform_color=color, color=Vec4f(0), + normals=Vec3f(0), shading=false, ambient=plot.ambient, diffuse=plot.diffuse, specular=plot.specular, colorrange=haskey(plot, :colorrange) ? plot.colorrange : false, - shininess=plot.shininess, lightposition=Vec3f0(1), + shininess=plot.shininess, lightposition=Vec3f(1), highclip=lift(nothing_or_color, plot.highclip), lowclip=lift(nothing_or_color, plot.lowclip), nan_color=lift(nothing_or_color, plot.nan_color)) @@ -122,14 +122,14 @@ end function create_shader(mscene::Scene, plot::Volume) x, y, z, vol = plot[1], plot[2], plot[3], plot[4] - box = GeometryBasics.mesh(FRect3D(Vec3f0(0), Vec3f0(1))) + box = GeometryBasics.mesh(Rect3f(Vec3f(0), Vec3f(1))) cam = cameracontrols(mscene) model2 = lift(plot.model, x, y, z) do m, xyz... mi = minimum.(xyz) maxi = maximum.(xyz) w = maxi .- mi - m2 = Mat4f0(w[1], 0, 0, 0, 0, w[2], 0, 0, 0, 0, w[3], 0, mi[1], mi[2], mi[3], 1) - return convert(Mat4f0, m) * m2 + m2 = Mat4f(w[1], 0, 0, 0, 0, w[2], 0, 0, 0, 0, w[3], 0, mi[1], mi[2], mi[3], 1) + return convert(Mat4f, m) * m2 end modelinv = lift(inv, model2) @@ -138,7 +138,7 @@ function create_shader(mscene::Scene, plot::Volume) return Program(WebGL(), lasset("volume.vert"), lasset("volume.frag"), box, volumedata=Sampler(lift(Makie.el32convert, vol)), modelinv=modelinv, colormap=Sampler(lift(to_colormap, plot.colormap)), - colorrange=lift(Vec2f0, plot.colorrange), + colorrange=lift(Vec2f, plot.colorrange), isovalue=lift(Float32, plot.isovalue), isorange=lift(Float32, plot.isorange), absorption=lift(Float32, get(plot, :absorption, Observable(1f0))), @@ -147,5 +147,5 @@ function create_shader(mscene::Scene, plot::Volume) model=model2, # these get filled in later by serialization, but we need them # as dummy values here, so that the correct uniforms are emitted - lightposition=Vec3f0(1), eyeposition=Vec3f0(1)) + lightposition=Vec3f(1), eyeposition=Vec3f(1)) end diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 549d55046ec..24970449b15 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -57,8 +57,8 @@ function create_shader(scene::Scene, plot::Union{Lines,LineSegments}) uniforms[:resolution] = scene.camera.resolution uniforms[:model] = plot.model - positions = meta(Point2f0[(0, -1), (0, 1), (1, -1), (1, 1)], - uv=Vec2f0[(0, 0), (0, 0), (0, 0), (0, 0)]) + positions = meta(Point2f[(0, -1), (0, 1), (1, -1), (1, 1)], + uv=Vec2f[(0, 0), (0, 0), (0, 0), (0, 0)]) instance = GeometryBasics.Mesh(positions, GLTriangleFace[(1, 2, 3), (2, 4, 3)]) return InstancedProgram(WebGL(), lasset("line_segments.vert"), lasset("line_segments.frag"), instance, diff --git a/WGLMakie/src/meshes.jl b/WGLMakie/src/meshes.jl index 7bb1ef4ced6..333265e60d9 100644 --- a/WGLMakie/src/meshes.jl +++ b/WGLMakie/src/meshes.jl @@ -14,12 +14,12 @@ function facebuffer(x::AbstractArray{GLTriangleFace}) end function array2color(colors, cmap, crange) - cmap = RGBAf0.(Colors.color.(to_colormap(cmap)), 1.0) + cmap = RGBAf.(Colors.color.(to_colormap(cmap)), 1.0) return Makie.interpolated_getindex.((cmap,), colors, (crange,)) end function array2color(colors::AbstractArray{<:Colorant}, cmap, crange) - return RGBAf0.(colors) + return RGBAf.(colors) end function converted_attribute(plot::AbstractPlot, key::Symbol) @@ -38,7 +38,7 @@ function create_shader(scene::Scene, plot::Makie.Mesh) uniforms = Dict{Symbol,Any}() attributes = Dict{Symbol,Any}() - for (key, default) in (:uv => Vec2f0(0), :normals => Vec3f0(0)) + for (key, default) in (:uv => Vec2f(0), :normals => Vec3f(0)) if haskey(data, key) attributes[key] = Buffer(get_attribute(mesh_signal, key)) else @@ -86,7 +86,7 @@ function create_shader(scene::Scene, plot::Makie.Mesh) end if !haskey(attributes, :color) - uniforms[:color] = Vec4f0(0) # make sure we have a color attribute + uniforms[:color] = Vec4f(0) # make sure we have a color attribute end uniforms[:shading] = plot.shading @@ -102,11 +102,11 @@ function create_shader(scene::Scene, plot::Makie.Mesh) get!(uniforms, :colorrange, true) get!(uniforms, :colormap, true) get!(uniforms, :model, plot.model) - get!(uniforms, :lightposition, Vec3f0(1)) + get!(uniforms, :lightposition, Vec3f(1)) - get!(uniforms, :nan_color, RGBAf0(0, 0, 0, 0)) - get!(uniforms, :highclip, RGBAf0(0, 0, 0, 0)) - get!(uniforms, :lowclip, RGBAf0(0, 0, 0, 0)) + get!(uniforms, :nan_color, RGBAf(0, 0, 0, 0)) + get!(uniforms, :highclip, RGBAf(0, 0, 0, 0)) + get!(uniforms, :lowclip, RGBAf(0, 0, 0, 0)) uniforms[:normalmatrix] = map(scene.camera.view, plot.model) do v, m i = SOneTo(3) diff --git a/WGLMakie/src/particles.jl b/WGLMakie/src/particles.jl index 82ea29ddf01..7002502c327 100644 --- a/WGLMakie/src/particles.jl +++ b/WGLMakie/src/particles.jl @@ -54,7 +54,7 @@ function create_shader(scene::Scene, plot::MeshScatter) instance = convert_attribute(plot.marker[], key"marker"(), key"meshscatter"()) if !hasproperty(instance, :uv) - uniform_dict[:uv] = Vec2f0(0) + uniform_dict[:uv] = Vec2f(0) end return InstancedProgram(WebGL(), lasset("particles.vert"), lasset("particles.frag"), @@ -66,7 +66,7 @@ end primitive_shape(::Union{String,Char,Vector{Char}}) = Cint(DISTANCEFIELD) primitive_shape(x::X) where {X} = Cint(primitive_shape(X)) primitive_shape(::Type{<:Circle}) = Cint(CIRCLE) -primitive_shape(::Type{<:Rect2D}) = Cint(RECTANGLE) +primitive_shape(::Type{<:Rect2}) = Cint(RECTANGLE) primitive_shape(::Type{T}) where {T} = error("Type $(T) not supported") primitive_shape(x::Shape) = Cint(x) @@ -121,7 +121,7 @@ function scatter_shader(scene::Scene, attributes) lift(x -> Makie.glyph_uv_width!(to_spritemarker(x)), attributes[:marker]) else - Vec4f0(0) + Vec4f(0) end end end @@ -132,7 +132,7 @@ function scatter_shader(scene::Scene, attributes) end handle_color!(uniform_dict, per_instance) - instance = uv_mesh(Rect2D(-0.5f0, -0.5f0, 1f0, 1f0)) + instance = uv_mesh(Rect2(-0.5f0, -0.5f0, 1f0, 1f0)) uniform_dict[:resolution] = scene.camera.resolution return InstancedProgram(WebGL(), lasset("simple.vert"), lasset("sprites.frag"), instance, VertexArray(; per_instance...); uniform_dict...) @@ -161,7 +161,7 @@ value_or_first(x) = x function create_shader(scene::Scene, plot::Makie.Text{<:Tuple{<:Union{<:Makie.GlyphCollection, <:AbstractVector{<:Makie.GlyphCollection}}}}) glyphcollection = plot[1] - res = map(x->Vec2f0(widths(x)), pixelarea(scene)) + res = map(x->Vec2f(widths(x)), pixelarea(scene)) projview = scene.camera.projectionview transfunc = Makie.transform_func_obs(scene) pos = plot.position @@ -195,7 +195,7 @@ function create_shader(scene::Scene, plot::Makie.Text{<:Tuple{<:Union{<:Makie.Gl uniform_color = lift(glyphcollection) do gc if gc isa AbstractArray reduce(vcat, (Makie.collect_vector(g.colors, length(g.glyphs)) for g in gc), - init = RGBAf0[]) + init = RGBAf[]) else Makie.collect_vector(gc.colors, length(gc.glyphs)) end @@ -204,7 +204,7 @@ function create_shader(scene::Scene, plot::Makie.Text{<:Tuple{<:Union{<:Makie.Gl uniform_rotation = lift(glyphcollection) do gc if gc isa AbstractArray reduce(vcat, (Makie.collect_vector(g.rotations, length(g.glyphs)) for g in gc), - init = Quaternionf0[]) + init = Quaternionf[]) else Makie.collect_vector(gc.rotations, length(gc.glyphs)) end diff --git a/WGLMakie/src/serialization.jl b/WGLMakie/src/serialization.jl index 5369dc71999..94d4d9ebb42 100644 --- a/WGLMakie/src/serialization.jl +++ b/WGLMakie/src/serialization.jl @@ -28,13 +28,13 @@ tlength(T) = length(T) tlength(::Type{<:Real}) = 1 serialize_three(val::Number) = val -serialize_three(val::Vec2f0) = convert(Vector{Float32}, val) -serialize_three(val::Vec3f0) = convert(Vector{Float32}, val) -serialize_three(val::Vec4f0) = convert(Vector{Float32}, val) +serialize_three(val::Vec2f) = convert(Vector{Float32}, val) +serialize_three(val::Vec3f) = convert(Vector{Float32}, val) +serialize_three(val::Vec4f) = convert(Vector{Float32}, val) serialize_three(val::Quaternion) = convert(Vector{Float32}, collect(val.data)) serialize_three(val::RGB) = Float32[red(val), green(val), blue(val)] serialize_three(val::RGBA) = Float32[red(val), green(val), blue(val), alpha(val)] -serialize_three(val::Mat4f0) = vec(val) +serialize_three(val::Mat4f) = vec(val) serialize_three(val::Mat3) = vec(val) function serialize_three(observable::Observable) @@ -301,8 +301,8 @@ function serialize_three(scene::Scene, plot::AbstractPlot) if haskey(plot, :lightposition) eyepos = scene.camera.eyeposition - lightpos = lift(Vec3f0, plot.lightposition, eyepos) do pos, eyepos - return ifelse(pos == :eyeposition, eyepos, pos)::Vec3f0 + lightpos = lift(Vec3f, plot.lightposition, eyepos) do pos, eyepos + return ifelse(pos == :eyeposition, eyepos, pos)::Vec3f end uniforms[:lightposition] = serialize_three(lightpos[]) on(lightpos) do value diff --git a/docs/documentation/animation.md b/docs/documentation/animation.md index 7771ce4bddc..f6a5383aca6 100644 --- a/docs/documentation/animation.md +++ b/docs/documentation/animation.md @@ -100,7 +100,7 @@ For example, to make a line with color dependent on time, you could write: ```julia:color_animation_2 time = Node(0.0) -color_observable = @lift(RGBf0($time, 0, 0)) +color_observable = @lift(RGBf($time, 0, 0)) fig = lines(0..10, sin, color = color_observable) @@ -120,7 +120,7 @@ it is better to make a `Node` with a vector of `Point`s, so that the number of `x` and `y` values can not go out of sync. ```julia:append_animation -points = Node(Point2f0[(0, 0)]) +points = Node(Point2f[(0, 0)]) fig, ax = scatter(points) limits!(ax, 0, 30, 0, 30) @@ -129,7 +129,7 @@ frames = 1:30 record(fig, joinpath(@OUTPUT, "append_animation.mp4"), frames; framerate = 30) do frame - new_point = Point2f0(frame, frame) + new_point = Point2f(frame, frame) points[] = push!(points[], new_point) end nothing # hide @@ -143,7 +143,7 @@ You can animate a live plot easily using a loop. Update all `Observables` that you need and then add a short sleep interval so that the display can refresh: ```julia -points = Node(Point2f0[randn(2)]) +points = Node(Point2f[randn(2)]) fig, ax = scatter(points) limits!(ax, -4, 4, -4, 4) @@ -152,7 +152,7 @@ fps = 60 nframes = 120 for i = 1:nframes - new_point = Point2f0(randn(2)) + new_point = Point2f(randn(2)) points[] = push!(points[], new_point) sleep(1/fps) # refreshes the display! end diff --git a/docs/documentation/events.md b/docs/documentation/events.md index 9cf2cd35fac..b55f38b8c86 100644 --- a/docs/documentation/events.md +++ b/docs/documentation/events.md @@ -51,7 +51,7 @@ struct. You can access it from any scene via `events(scene)` and via `events(figure.scene)` or `events(axis.scene)` from a figure or axis. The struct contains the following fields you may react to. -- `window_area::PriorityObservable{IRect2D}`: Contains the current size of the window in pixels. +- `window_area::PriorityObservable{Rect2i}`: Contains the current size of the window in pixels. - `window_dpi::PriorityObservable{Float64}`: Contains the DPI of the window. - `window_open::PriorityObservable{Bool}`: Contains `true` as long as the window is open. - `hasfocus::PriorityObservable{Bool}`: Contains `true` if the window is focused (in the foreground). diff --git a/docs/documentation/inspector.md b/docs/documentation/inspector.md index 65ffbba9a36..f38a5bffad4 100644 --- a/docs/documentation/inspector.md +++ b/docs/documentation/inspector.md @@ -15,7 +15,7 @@ The `inspector = DataInspector(fig)` contains the following attributes: - `range = 10`: Controls the snapping range for selecting an element of a plot. - `enabled = true`: Disables inspection of plots when set to false. Can also be adjusted with `enable!(inspector)` and `disable!(inspector)`. -- `text_padding = Vec4f0(5, 5, 3, 3)`: Padding for the box drawn around the tooltip text. (left, right, bottom, top) +- `text_padding = Vec4f(5, 5, 3, 3)`: Padding for the box drawn around the tooltip text. (left, right, bottom, top) - `text_align = (:left, :bottom)`: Alignment of text within the tooltip. This does not affect the alignment of the tooltip relative to the cursor. - `textcolor = :black`: Tooltip text color. - `textsize = 20`: Tooltip text size. @@ -28,7 +28,7 @@ The `inspector = DataInspector(fig)` contains the following attributes: - `indicator_linewidth = 2`: Linewidth of the selection indicator. - `indicator_linestyle = nothing`: Linestyle of the selection indicator - `tooltip_align = (:center, :top)`: Default position of the tooltip relative to the cursor or current selection. The real align may adjust to keep the tooltip in view. -- `tooltip_offset = Vec2f0(20)`: Offset from the indicator to the tooltip. +- `tooltip_offset = Vec2f(20)`: Offset from the indicator to the tooltip. - `depth = 9e3`: Depth value of the tooltip. This should be high so that the tooltip is always in front. - `priority = 100`: The priority of creating a tooltip on a mouse movement or scrolling event. @@ -88,7 +88,7 @@ function show_barplot(inspector::DataInspector, plot::BarPlot, idx) # Get the hovered world-space position pos = plot[1][][idx] # project to screen space and shift it to be correct on the root scene - proj_pos = shift_project(scene, to_ndim(Point3f0, pos, 0)) + proj_pos = shift_project(scene, to_ndim(Point3f, pos, 0)) # anchor the tooltip at the projected position update_tooltip_alignment!(inspector, proj_pos) @@ -120,11 +120,11 @@ function show_barplot(inspector::DataInspector, plot::BarPlot, idx) scene = parent_scene(plot) pos = plot[1][][idx] - proj_pos = shift_project(scene, to_ndim(Point3f0, pos, 0)) + proj_pos = shift_project(scene, to_ndim(Point3f, pos, 0)) update_tooltip_alignment!(inspector, proj_pos) # Get the rectangle BarPlot generated for Poly - # `_bbox2D` is a node meant for saving a `Rect2D` indicator. There is also + # `_bbox2D` is a node meant for saving a `Rect2` indicator. There is also # a `_bbox3D`. Here we keep `_bbox2D` updated and use it as a source for # our custom indicator. a._bbox2D[] = plot.plots[1][1][][idx] @@ -147,7 +147,7 @@ function show_barplot(inspector::DataInspector, plot::BarPlot, idx) ) # Make sure this draws on top - translate!(p, Vec3f0(0, 0, a.depth[])) + translate!(p, Vec3f(0, 0, a.depth[])) # register this indicator for later cleanup. push!(inspector.temp_plots, p) diff --git a/docs/documentation/layoutables.md b/docs/documentation/layoutables.md index 073c58b501a..46116ff1d7a 100644 --- a/docs/documentation/layoutables.md +++ b/docs/documentation/layoutables.md @@ -47,7 +47,7 @@ scene Sometimes you just want to place a `Layoutable` in a specific location, without it being controlled by a dynamic layout. You can do this by setting the `bbox` parameter, which is usually controlled by the layout, manually. The boundingbox should be a 2D `Rect`, and can also be an Observable if you plan to change it dynamically. -The function `BBox` creates an `FRect2D`, but instead of passing origin and widths, you pass left, right, bottom and top boundaries directly. +The function `BBox` creates an `Rect2f`, but instead of passing origin and widths, you pass left, right, bottom and top boundaries directly. Here's an example where two axes are placed manually: diff --git a/docs/documentation/lighting.md b/docs/documentation/lighting.md index ed95157e164..36754fba282 100644 --- a/docs/documentation/lighting.md +++ b/docs/documentation/lighting.md @@ -2,12 +2,12 @@ For 3D scenes, `GLMakie` offers several attributes to control the lighting of the scene. These are set per plot. -- `ambient::Vec3f0`: Objects should never be completely dark; we use an ambient light to simulate background lighting, and give the object some color. Each element of the vector represents the intensity of color in R, G or B respectively. -- `diffuse::Vec3f0`: Simulates the directional impact which the light source has on the plot object. This is the most visually significant component of the lighting model; the more a part of an object faces the light source, the brighter it becomes. Each element of the vector represents the intensity of color in R, G or B respectively. -- `specular::Vec3f0`: Simulates the bright spot of a light that appears on shiny objects. Specular highlights are more inclined to the color of the light than the color of the object. Each element of the vector represents the intensity of color in R, G or B respectively. +- `ambient::Vec3f`: Objects should never be completely dark; we use an ambient light to simulate background lighting, and give the object some color. Each element of the vector represents the intensity of color in R, G or B respectively. +- `diffuse::Vec3f`: Simulates the directional impact which the light source has on the plot object. This is the most visually significant component of the lighting model; the more a part of an object faces the light source, the brighter it becomes. Each element of the vector represents the intensity of color in R, G or B respectively. +- `specular::Vec3f`: Simulates the bright spot of a light that appears on shiny objects. Specular highlights are more inclined to the color of the light than the color of the object. Each element of the vector represents the intensity of color in R, G or B respectively. - `shininess::Float32`: Controls the shininess of the object. Higher shininess reduces the size of the highlight, and makes it sharper. This value must be positive. -- `lightposition::Vec3f0`: The location of the main light source; by default, the light source is at the location of the camera. +- `lightposition::Vec3f`: The location of the main light source; by default, the light source is at the location of the camera. You can find more information on how these were implemented [here](https://learnopengl.com/Lighting/Basic-Lighting). @@ -50,17 +50,17 @@ surface!( scene, xs, ys, zs, colormap = (:white, :white), # Light comes from (0, 0, 15), i.e the sphere - lightposition = Vec3f0(0, 0, 15), + lightposition = Vec3f(0, 0, 15), # base light of the plot only illuminates red colors - ambient = Vec3f0(0.3, 0, 0), + ambient = Vec3f(0.3, 0, 0), # light from source (sphere) illuminates yellow colors - diffuse = Vec3f0(0.4, 0.4, 0), + diffuse = Vec3f(0.4, 0.4, 0), # reflections illuminate blue colors - specular = Vec3f0(0, 0, 1.0), + specular = Vec3f(0, 0, 1.0), # Reflections are sharp shininess = 128f0 ) -mesh!(scene, Sphere(Point3f0(0, 0, 15), 1f0), color=RGBf0(1, 0.7, 0.3)) +mesh!(scene, Sphere(Point3f(0, 0, 15), 1f0), color=RGBf(1, 0.7, 0.3)) scene ``` \end{examplefigure} @@ -84,8 +84,8 @@ scene[:SSAO][:radius][] = 5.0 scene[:SSAO][:blur][] = 3 scene[:SSAO][:bias][] = 0.025 -box = Rect3D(Point3f0(-0.5), Vec3f0(1)) -positions = [Point3f0(x, y, rand()) for x in -5:5 for y in -5:5] +box = Rect3(Point3f(-0.5), Vec3f(1)) +positions = [Point3f(x, y, rand()) for x in -5:5 for y in -5:5] meshscatter!(scene, positions, marker=box, markersize=1, color=:lightblue, ssao=true) scene diff --git a/docs/documentation/nodes.md b/docs/documentation/nodes.md index 3132d4783df..2dd5d801c28 100644 --- a/docs/documentation/nodes.md +++ b/docs/documentation/nodes.md @@ -196,4 +196,4 @@ ys[] = rand(11) # trigger listeners of ys (in this case the same as xs) Use this technique sparingly, as it increases the complexity of your code and can make reasoning about it more difficult. It also only works if you can still trigger all listeners correctly. For example, if another observable listened only to `xs`, we wouldn't have updated it correctly in the above workaround. -Often, you can avoid length change problems by using arrays of containers like `Point2f0` or `Vec3f0` instead of synchronizing two or three observables of single element vectors manually. +Often, you can avoid length change problems by using arrays of containers like `Point2f` or `Vec3f` instead of synchronizing two or three observables of single element vectors manually. diff --git a/docs/documentation/recipes.md b/docs/documentation/recipes.md index b7b54d2c385..8391fc59754 100644 --- a/docs/documentation/recipes.md +++ b/docs/documentation/recipes.md @@ -202,7 +202,7 @@ function Makie.plot!( # and barplots we need to draw # this is necessary because in Makie we want every recipe to be interactively updateable # and therefore need to connect the observable machinery to do so - linesegs = Node(Point2f0[]) + linesegs = Node(Point2f[]) bar_froms = Node(Float32[]) bar_tos = Node(Float32[]) colors = Node(Bool[]) @@ -220,8 +220,8 @@ function Makie.plot!( # then refill them with our updated values for (t, s) in zip(times, stockvalues) - push!(linesegs[], Point2f0(t, s.low)) - push!(linesegs[], Point2f0(t, s.high)) + push!(linesegs[], Point2f(t, s.low)) + push!(linesegs[], Point2f(t, s.high)) push!(bar_froms[], s.open) push!(bar_tos[], s.close) end @@ -241,7 +241,7 @@ function Makie.plot!( # colored according to a 2-element colormap # we build this colormap out of our `downcolor` and `upcolor` # we give the observable element type `Any` so it will not error when we change - # a color from a symbol like :red to a different type like RGBf0(1, 0, 1) + # a color from a symbol like :red to a different type like RGBf(1, 0, 1) colormap = lift(Any, sc.downcolor, sc.upcolor) do dc, uc [dc, uc] end diff --git a/docs/examples/layoutables/axis.md b/docs/examples/layoutables/axis.md index e1b4d17f6d4..05ef781ffcd 100644 --- a/docs/examples/layoutables/axis.md +++ b/docs/examples/layoutables/axis.md @@ -82,7 +82,7 @@ axes = [Axis(f[i, j]) for j in 1:3, i in 1:2] for (i, ax) in enumerate(axes) ax.title = "Axis $i" - poly!(ax, Point2f0[(9, 9), (3, 1), (1, 3)], + poly!(ax, Point2f[(9, 9), (3, 1), (1, 3)], color = cgrad(:inferno, 6, categorical = true)[i]) end @@ -484,13 +484,13 @@ a_width = Animation([1, 7], [1200.0, 800], sineio(n=2, yoyo=true, postwait=0.5)) a_height = Animation([2.5, 8.5], [1200.0, 800], sineio(n=2, yoyo=true, postwait=0.5)) scene_area = lift(t) do t - IRect(0, 0, round(Int, a_width(t)), round(Int, a_height(t))) + Recti(0, 0, round(Int, a_width(t)), round(Int, a_height(t))) end scene = Scene(container_scene, scene_area, camera = campixel!) rect = poly!(scene, scene_area, - raw=true, color=RGBf0(0.97, 0.97, 0.97), strokecolor=:transparent, strokewidth=0) + raw=true, color=RGBf(0.97, 0.97, 0.97), strokecolor=:transparent, strokewidth=0) outer_layout = GridLayout(scene, alignmode = Outside(30)) @@ -506,7 +506,7 @@ titles = ["aspect enforced\nvia layout", "axis aspect\nset directly", "no aspect axs = layout[1:2, 1:2] = [Axis(scene, title = t) for t in titles] for a in axs - lines!(a, Circle(Point2f0(0, 0), 100f0)) + lines!(a, Circle(Point2f(0, 0), 100f0)) end rowsize!(layout, 1, Fixed(400)) diff --git a/docs/examples/layoutables/intervalslider.md b/docs/examples/layoutables/intervalslider.md index 2086a3429e8..1ab23f9e745 100644 --- a/docs/examples/layoutables/intervalslider.md +++ b/docs/examples/layoutables/intervalslider.md @@ -42,7 +42,7 @@ end Label(f[1, 3], labeltext2, tellheight = false, rotation = pi/2) -points = rand(Point2f0, 300) +points = rand(Point2f, 300) # color points differently if they are within the two intervals colors = lift(rs_h.interval, rs_v.interval) do h_int, v_int diff --git a/docs/examples/layoutables/legend.md b/docs/examples/layoutables/legend.md index b6cac369324..9f3cfe2e700 100644 --- a/docs/examples/layoutables/legend.md +++ b/docs/examples/layoutables/legend.md @@ -107,7 +107,7 @@ f = Figure() Axis(f[1, 1]) xs = 0:0.1:10 -lins = [lines!(xs, sin.(xs .+ 3v), color = RGBf0(v, 0, 1-v)) for v in 0:0.1:1] +lins = [lines!(xs, sin.(xs .+ 3v), color = RGBf(v, 0, 1-v)) for v in 0:0.1:1] Legend(f[1, 2], lins, string.(1:length(lins)), nbanks = 3) @@ -218,13 +218,13 @@ elem_2 = [PolyElement(color = :red, strokecolor = :blue, strokewidth = 1), LineElement(color = :black, linestyle = :dash)] elem_3 = LineElement(color = :green, linestyle = nothing, - points = Point2f0[(0, 0), (0, 1), (1, 0), (1, 1)]) + points = Point2f[(0, 0), (0, 1), (1, 0), (1, 1)]) elem_4 = MarkerElement(color = :blue, marker = 'π', markersize = 15, - points = Point2f0[(0.2, 0.2), (0.5, 0.8), (0.8, 0.2)]) + points = Point2f[(0.2, 0.2), (0.5, 0.8), (0.8, 0.2)]) elem_5 = PolyElement(color = :green, strokecolor = :black, strokewidth = 2, - points = Point2f0[(0, 0), (1, 0), (0, 1)]) + points = Point2f[(0, 0), (1, 0), (0, 1)]) Legend(f[1, 2], [elem_1, elem_2, elem_3, elem_4, elem_5], diff --git a/docs/examples/layoutables/slider.md b/docs/examples/layoutables/slider.md index 3727e49c8c3..eaad098ecb7 100644 --- a/docs/examples/layoutables/slider.md +++ b/docs/examples/layoutables/slider.md @@ -25,7 +25,7 @@ sl_x = Slider(fig[2, 1], range = 0:0.01:10, startvalue = 3) sl_y = Slider(fig[1, 2], range = 0:0.01:10, horizontal = false, startvalue = 6) point = lift(sl_x.value, sl_y.value) do x, y - Point2f0(x, y) + Point2f(x, y) end scatter!(point, color = :red, markersize = 20) diff --git a/docs/examples/plotting_functions/arrows.md b/docs/examples/plotting_functions/arrows.md index 9f01645eabf..e6782ab769d 100644 --- a/docs/examples/plotting_functions/arrows.md +++ b/docs/examples/plotting_functions/arrows.md @@ -6,9 +6,9 @@ - `arrowhead = automatic`: Defines the marker (2D) or mesh (3D) that is used as the arrow head. The default for is `'▲'` in 2D and a cone mesh in 3D. For the - latter the mesh should start at `Point3f0(0)` and point in positive z-direction. + latter the mesh should start at `Point3f(0)` and point in positive z-direction. - `arrowtail = automatic`: Defines the mesh used to draw the arrow tail in 3D. - It should start at `Point3f0(0)` and extend in negative z-direction. The default + It should start at `Point3f(0)` and extend in negative z-direction. The default is a cylinder. This has no effect on the 2D plot. - `quality = 32`: Defines the number of angle subdivisions used when generating the arrow head and tail meshes. Consider lowering this if you have performance @@ -17,7 +17,7 @@ represented by a line in 2D. - `arrowcolor = linecolor`: Sets the color of the arrow head. - `arrowsize = automatic`: Scales the size of the arrow head. This defaults to - `0.3` in the 2D case and `Vec3f0(0.2, 0.2, 0.3)` in the 3D case. For the latter + `0.3` in the 2D case and `Vec3f(0.2, 0.2, 0.3)` in the 3D case. For the latter the first two components scale the radius (in x/y direction) and the last scales the length of the cone. If the arrowsize is set to 1, the cone will have a diameter and length of 1. @@ -64,12 +64,12 @@ using GLMakie GLMakie.activate!() # hide Makie.inline!(true) # hide -ps = [Point3f0(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5] -ns = map(p -> 0.1 * Vec3f0(p[2], p[3], p[1]), ps) +ps = [Point3f(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5] +ns = map(p -> 0.1 * Vec3f(p[2], p[3], p[1]), ps) arrows( ps, ns, fxaa=true, # turn on anti-aliasing linecolor = :gray, arrowcolor = :black, - linewidth = 0.1, arrowsize = Vec3f0(0.3, 0.3, 0.4), + linewidth = 0.1, arrowsize = Vec3f(0.3, 0.3, 0.4), align = :center, axis=(type=Axis3,) ) ``` @@ -82,13 +82,13 @@ GLMakie.activate!() # hide Makie.inline!(true) # hide using LinearAlgebra -ps = [Point3f0(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5] -ns = map(p -> 0.1 * Vec3f0(p[2], p[3], p[1]), ps) +ps = [Point3f(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5] +ns = map(p -> 0.1 * Vec3f(p[2], p[3], p[1]), ps) lengths = norm.(ns) arrows( ps, ns, fxaa=true, # turn on anti-aliasing color=lengths, - linewidth = 0.1, arrowsize = Vec3f0(0.3, 0.3, 0.4), + linewidth = 0.1, arrowsize = Vec3f(0.3, 0.3, 0.4), align = :center, axis=(type=Axis3,) ) ``` diff --git a/docs/examples/plotting_functions/band.md b/docs/examples/plotting_functions/band.md index a7f1f56c4f6..f34c307ff8e 100644 --- a/docs/examples/plotting_functions/band.md +++ b/docs/examples/plotting_functions/band.md @@ -51,8 +51,8 @@ f using GLMakie GLMakie.activate!() # hide Makie.inline!(true) # hide -lower = fill(Point3f0(0,0,0), 100) -upper = [Point3f0(sin(x), cos(x), 1.0) for x in range(0,2pi, length=100)] +lower = fill(Point3f(0,0,0), 100) +upper = [Point3f(sin(x), cos(x), 1.0) for x in range(0,2pi, length=100)] col = repeat([1:50;50:-1:1],outer=2) band(lower, upper, color=col, axis=(type=Axis3,)) ``` diff --git a/docs/examples/plotting_functions/poly.md b/docs/examples/plotting_functions/poly.md index 3f41e60652c..7e95d888680 100644 --- a/docs/examples/plotting_functions/poly.md +++ b/docs/examples/plotting_functions/poly.md @@ -14,7 +14,7 @@ Makie.inline!(true) # hide f = Figure() Axis(f[1, 1]) -poly!(Point2f0[(0, 0), (2, 0), (3, 1), (1, 1)], color = :red, strokecolor = :black, strokewidth = 1) +poly!(Point2f[(0, 0), (2, 0), (3, 1), (1, 1)], color = :red, strokecolor = :black, strokewidth = 1) f ``` @@ -32,8 +32,8 @@ Axis(f[1, 1]) # polygon with hole p = Polygon( - Point2f0[(0, 0), (2, 0), (3, 1), (1, 1)], - [Point2f0[(0.75, 0.25), (1.75, 0.25), (2.25, 0.75), (1.25, 0.75)]] + Point2f[(0, 0), (2, 0), (3, 1), (1, 1)], + [Point2f[(0.75, 0.25), (1.75, 0.25), (2.25, 0.75), (1.25, 0.75)]] ) poly!(p, color = :blue) @@ -74,7 +74,7 @@ f = Figure() Axis(f[1, 1], aspect = DataAspect()) # shape decomposition -poly!(Circle(Point2f0(0, 0), 15f0), color = :pink) +poly!(Circle(Point2f(0, 0), 15f0), color = :pink) f ``` @@ -91,10 +91,10 @@ f = Figure() Axis(f[1, 1]) # vector of polygons -ps = [Polygon(rand(Point2f0, 3) .+ Point2f0(i, j)) +ps = [Polygon(rand(Point2f, 3) .+ Point2f(i, j)) for i in 1:5 for j in 1:10] -poly!(ps, color = rand(RGBf0, length(ps)), +poly!(ps, color = rand(RGBf, length(ps)), axis = (backgroundcolor = :gray15,)) f diff --git a/docs/examples/plotting_functions/series.md b/docs/examples/plotting_functions/series.md index 60719ee27f9..0bf05fc7924 100644 --- a/docs/examples/plotting_functions/series.md +++ b/docs/examples/plotting_functions/series.md @@ -24,7 +24,7 @@ fig \begin{examplefigure}{} ```julia -pointvectors = [Point2f0.(1:100, cumsum(randn(100))) for i in 1:4] +pointvectors = [Point2f.(1:100, cumsum(randn(100))) for i in 1:4] series(pointvectors, markersize=5, color=:Set1) ``` diff --git a/docs/examples/plotting_functions/stem.md b/docs/examples/plotting_functions/stem.md index e64b0ef772d..991f83a5cf4 100644 --- a/docs/examples/plotting_functions/stem.md +++ b/docs/examples/plotting_functions/stem.md @@ -73,7 +73,7 @@ f = Figure() xs = LinRange(0, 4pi, 30) stem(f[1, 1], 0.5xs, 2 .* sin.(xs), 2 .* cos.(xs), - offset = Point3f0.(0.5xs, sin.(xs), cos.(xs)), + offset = Point3f.(0.5xs, sin.(xs), cos.(xs)), stemcolor = LinRange(0, 1, 30), stemcolormap = :Spectral, stemcolorrange = (0, 0.5)) f diff --git a/docs/examples/plotting_functions/streamplot.md b/docs/examples/plotting_functions/streamplot.md index 7bff1d3221e..920e09c547c 100644 --- a/docs/examples/plotting_functions/streamplot.md +++ b/docs/examples/plotting_functions/streamplot.md @@ -19,7 +19,7 @@ end P = FitzhughNagumo(0.1, 0.0, 1.5, 0.8) -f(x, P::FitzhughNagumo) = Point2f0( +f(x, P::FitzhughNagumo) = Point2f( (x[1]-x[2]-x[1]^3+P.s)/P.ϵ, P.γ*x[1]-x[2] + P.β ) diff --git a/docs/examples/plotting_functions/text.md b/docs/examples/plotting_functions/text.md index 4d6b3b502b5..e587ce78db1 100644 --- a/docs/examples/plotting_functions/text.md +++ b/docs/examples/plotting_functions/text.md @@ -21,7 +21,7 @@ f = Figure() Axis(f[1, 1], aspect = DataAspect(), backgroundcolor = :gray50) -scatter!(Point2f0(0, 0)) +scatter!(Point2f(0, 0)) text!("center", position = (0, 0), align = (:center, :center)) circlepoints = [(cos(a), sin(a)) for a in LinRange(0, 2pi, 16)[1:end-1]] @@ -55,7 +55,7 @@ LScene(f[1, 1]) text!( fill("Makie", 7), rotation = [i / 7 * 1.5pi for i in 1:7], - position = [Point3f0(0, 0, i/2) for i in 1:7], + position = [Point3f(0, 0, i/2) for i in 1:7], color = [cgrad(:viridis)[x] for x in LinRange(0, 1, 7)], align = (:left, :baseline), textsize = 1, diff --git a/docs/tutorials/layout-tutorial.md b/docs/tutorials/layout-tutorial.md index 7f535196111..bf7078a1173 100644 --- a/docs/tutorials/layout-tutorial.md +++ b/docs/tutorials/layout-tutorial.md @@ -32,7 +32,7 @@ CairoMakie.activate!() # hide noto_sans = assetpath("fonts", "NotoSans-Regular.ttf") noto_sans_bold = assetpath("fonts", "NotoSans-Bold.ttf") -f = Figure(backgroundcolor = RGBf0(0.98, 0.98, 0.98), +f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98), resolution = (1000, 700), font = noto_sans) ``` \end{examplefigure} diff --git a/src/Makie.jl b/src/Makie.jl index f545c670867..c5ca8c6766c 100644 --- a/src/Makie.jl +++ b/src/Makie.jl @@ -60,8 +60,8 @@ using Observables: listeners, to_value, notify const RealVector{T} = AbstractVector{T} where T <: Number const Node = Observable # shorthand -const RGBAf0 = RGBA{Float32} -const RGBf0 = RGB{Float32} +const RGBAf = RGBA{Float32} +const RGBf = RGB{Float32} const NativeFont = FreeTypeAbstraction.FTFont include("documentation/docstringextension.jl") @@ -142,6 +142,8 @@ include("interaction/inspector.jl") include("documentation/documentation.jl") include("display.jl") +# deprecated types and methods +include("deprecated.jl") # help functions and supporting functions export help, help_attributes, help_arguments @@ -217,11 +219,11 @@ export Billboard # Reexports of # Color/Vector types convenient for 3d/2d graphics -export Quaternion, Quaternionf0, qrotation -export RGBAf0, RGBf0, VecTypes, RealVector, FRect, FRect2D, IRect2D -export FRect3D, IRect3D, Rect3D, Transformation -export IRect, FRect, Rect, Rect2D, Sphere, Circle -export Vec4f0, Vec3f0, Vec2f0, Point4f0, Point3f0, Point2f0 +export Quaternion, Quaternionf, qrotation +export RGBAf, RGBf, VecTypes, RealVector, Rectf, Rect2f, Rect2i +export Rect3f, Rect3i, Rect3, Transformation +export Recti, Rectf, Rect, Rect2, Sphere, Circle +export Vec4f, Vec3f, Vec2f, Point4f, Point3f, Point2f export Vec, Vec2, Vec3, Vec4, Point, Point2, Point3, Point4 export (..), GLNormalUVMesh diff --git a/src/basic_recipes/arc.jl b/src/basic_recipes/arc.jl index 5cd9c20397d..b1ce522fd06 100644 --- a/src/basic_recipes/arc.jl +++ b/src/basic_recipes/arc.jl @@ -8,8 +8,8 @@ from `start_angle` to `stop_angle`. Examples: -`arc(Point2f0(0), 1, 0.0, π)` -`arc(Point2f0(1, 2), 0.3. π, -π)` +`arc(Point2f(0), 1, 0.0, π)` +`arc(Point2f(1, 2), 0.3. π, -π)` ## Attributes $(ATTRIBUTES) @@ -25,7 +25,7 @@ function plot!(p::Arc) args = getindex.(p, (:origin, :radius, :start_angle, :stop_angle, :resolution)) positions = lift(args...) do origin, radius, start_angle, stop_angle, resolution map(range(start_angle, stop=stop_angle, length=resolution)) do angle - origin .+ Point2f0((cos(angle), sin(angle)) .* radius) + origin .+ Point2f((cos(angle), sin(angle)) .* radius) end end lines!(p, Attributes(p), positions) diff --git a/src/basic_recipes/arrows.jl b/src/basic_recipes/arrows.jl index 1fd136075cb..45211b1b311 100644 --- a/src/basic_recipes/arrows.jl +++ b/src/basic_recipes/arrows.jl @@ -58,8 +58,8 @@ function arrow_head(N, marker::Automatic, quality) return '▲' else merge([ - _circle(Point3f0(0), 0.5f0, Vec3f0(0,0,-1), quality), - _mantle(Point3f0(0), Point3f0(0,0,1), 0.5f0, 0f0, quality) + _circle(Point3f(0), 0.5f0, Vec3f(0,0,-1), quality), + _mantle(Point3f(0), Point3f(0,0,1), 0.5f0, 0f0, quality) ]) end end @@ -70,8 +70,8 @@ function arrow_tail(N, marker::Automatic, quality) nothing else merge([ - _circle(Point3f0(0,0,-1), 0.5f0, Vec3f0(0,0,-1), quality), - _mantle(Point3f0(0,0,-1), Point3f0(0), 0.5f0, 0.5f0, quality) + _circle(Point3f(0,0,-1), 0.5f0, Vec3f(0,0,-1), quality), + _mantle(Point3f(0,0,-1), Point3f(0), 0.5f0, 0.5f0, quality) ]) end end @@ -87,15 +87,15 @@ function _mantle(origin, extremity, r1, r2, N) xy = 1.0 / sqrt(temp^2 + 1) z = temp / sqrt(temp^2 + 1) - coords = Vector{Point3f0}(undef, 2N) - normals = Vector{Vec3f0}(undef, 2N) + coords = Vector{Point3f}(undef, 2N) + normals = Vector{Vec3f}(undef, 2N) faces = Vector{GLTriangleFace}(undef, 2N) for (i, phi) in enumerate(0:dphi:2pi-0.5dphi) - coords[2i - 1] = origin .+ r1 * Vec3f0(cos(phi), sin(phi), 0) - coords[2i] = extremity .+ r2 * Vec3f0(cos(phi), sin(phi), 0) - normals[2i - 1] = Vec3f0(xy*cos(phi), xy*sin(phi), z) - normals[2i] = Vec3f0(xy*cos(phi), xy*sin(phi), z) + coords[2i - 1] = origin .+ r1 * Vec3f(cos(phi), sin(phi), 0) + coords[2i] = extremity .+ r2 * Vec3f(cos(phi), sin(phi), 0) + normals[2i - 1] = Vec3f(xy*cos(phi), xy*sin(phi), z) + normals[2i] = Vec3f(xy*cos(phi), xy*sin(phi), z) faces[2i - 1] = GLTriangleFace(2i-1, mod1(2i+1, 2N), 2i) faces[2i] = GLTriangleFace(mod1(2i+1, 2N), mod1(2i+2, 2N), 2i) end @@ -103,16 +103,16 @@ function _mantle(origin, extremity, r1, r2, N) GeometryBasics.Mesh(meta(coords; normals=normals), faces) end -# GeometryBasics.Circle doesn't work with Point3f0... +# GeometryBasics.Circle doesn't work with Point3f... function _circle(origin, r, normal, N) dphi = 2pi / N - coords = Vector{Point3f0}(undef, N+1) + coords = Vector{Point3f}(undef, N+1) normals = fill(normal, N+1) faces = Vector{GLTriangleFace}(undef, N) for (i, phi) in enumerate(0:dphi:2pi-0.5dphi) - coords[i] = origin .+ r * Vec3f0(cos(phi), sin(phi), 0) + coords[i] = origin .+ r * Vec3f(cos(phi), sin(phi), 0) faces[i] = GLTriangleFace(N+1, mod1(i+1, N), i) end coords[N+1] = origin @@ -121,11 +121,11 @@ function _circle(origin, r, normal, N) end -convert_arguments(::Type{<: Arrows}, x, y, u, v) = (Point2f0.(x, y), Vec2f0.(u, v)) +convert_arguments(::Type{<: Arrows}, x, y, u, v) = (Point2f.(x, y), Vec2f.(u, v)) function convert_arguments(::Type{<: Arrows}, x::AbstractVector, y::AbstractVector, u::AbstractMatrix, v::AbstractMatrix) - (vec(Point2f0.(x, y')), vec(Vec2f0.(u, v))) + (vec(Point2f.(x, y')), vec(Vec2f.(u, v))) end -convert_arguments(::Type{<: Arrows}, x, y, z, u, v, w) = (Point3f0.(x, y, z), Vec3f0.(u, v, w)) +convert_arguments(::Type{<: Arrows}, x, y, z, u, v, w) = (Point3f.(x, y, z), Vec3f.(u, v, w)) function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) where {N, T, V} @extract arrowplot ( @@ -148,9 +148,9 @@ function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) w if align in (:head, :lineend, :tailend, :headstart, :center) shift = s .* dir else - shift = Vec2f0(0) + shift = Vec2f(0) end - Point2f0(p1 .- shift) => Point2f0(p1 .- shift .+ (dir .* s)) + Point2f(p1 .- shift) => Point2f(p1 .- shift .+ (dir .* s)) end end @@ -199,11 +199,11 @@ function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) w start = lift(points, directions, align, lengthscale) do points, dirs, align, s map(points, dirs) do p, dir if align in (:head, :lineend, :tailend, :headstart, :center) - shift = Vec3f0(0) + shift = Vec3f(0) else shift = -s .* dir end - Point3f0(p .- shift) + Point3f(p .- shift) end end meshscatter!( @@ -213,9 +213,9 @@ function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) w markersize = lift(directions, normalize, linewidth, lengthscale) do dirs, n, linewidth, ls lw = linewidth === automatic ? 0.05f0 : linewidth if n - Vec3f0(lw, lw, ls) + Vec3f(lw, lw, ls) else - map(dir -> Vec3f0(lw, lw, norm(dir) * ls), dirs) + map(dir -> Vec3f(lw, lw, norm(dir) * ls), dirs) end end, color = line_c, colormap = colormap, @@ -229,7 +229,7 @@ function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) w start, rotations = directions, marker = @lift(arrow_head(3, $arrowhead, $quality)), markersize = lift(Any, arrowsize) do as - as === automatic ? Vec3f0(0.2, 0.2, 0.3) : as + as === automatic ? Vec3f(0.2, 0.2, 0.3) : as end, color = arrow_c, colormap = colormap, fxaa = fxaa_bool, ssao = ssao, diff --git a/src/basic_recipes/axis.jl b/src/basic_recipes/axis.jl index 0e5efb12b2c..47fe73ec67f 100644 --- a/src/basic_recipes/axis.jl +++ b/src/basic_recipes/axis.jl @@ -30,12 +30,12 @@ $(ATTRIBUTES) """ @recipe(Axis3D) do scene - q1 = qrotation(Vec3f0(1, 0, 0), -0.5f0*pi) - q2 = qrotation(Vec3f0(0, 0, 1), 1f0*pi) + q1 = qrotation(Vec3f(1, 0, 0), -0.5f0*pi) + q2 = qrotation(Vec3f(0, 0, 1), 1f0*pi) tickrotations3d = ( - qrotation(Vec3f0(0,0,1), -1.5pi), + qrotation(Vec3f(0,0,1), -1.5pi), q2, - qrotation(Vec3f0(1, 0, 0), -0.5pi) * q2 + qrotation(Vec3f(1, 0, 0), -0.5pi) * q2 ) axisnames_rotation3d = tickrotations3d tickalign3d = ( @@ -44,8 +44,8 @@ $(ATTRIBUTES) (:right, :center), # z axis ) axisnames_align3d = tickalign3d - tick_color = RGBAf0(0.5, 0.5, 0.5, 0.6) - grid_color = RGBAf0(0.5, 0.5, 0.5, 0.4) + tick_color = RGBAf(0.5, 0.5, 0.5, 0.6) + grid_color = RGBAf(0.5, 0.5, 0.5, 0.4) grid_thickness = 1 axis_linewidth = 1.5 gridthickness = ntuple(x-> 1f0, Val(3)) @@ -56,7 +56,7 @@ $(ATTRIBUTES) showticks = (true, true, true), showaxis = (true, true, true), showgrid = (true, true, true), - scale = Vec3f0(1), + scale = Vec3f(1), padding = 0.1, inspectable = false, diff --git a/src/basic_recipes/band.jl b/src/basic_recipes/band.jl index ffae26bf83d..51180c2dc93 100644 --- a/src/basic_recipes/band.jl +++ b/src/basic_recipes/band.jl @@ -15,7 +15,7 @@ $(ATTRIBUTES) ) end -convert_arguments(::Type{<: Band}, x, ylower, yupper) = (Point2f0.(x, ylower), Point2f0.(x, yupper)) +convert_arguments(::Type{<: Band}, x, ylower, yupper) = (Point2f.(x, ylower), Point2f.(x, yupper)) function band_connect(n) ns = 1:n-1 diff --git a/src/basic_recipes/barplot.jl b/src/basic_recipes/barplot.jl index 921b9559f70..a34e083677f 100644 --- a/src/basic_recipes/barplot.jl +++ b/src/basic_recipes/barplot.jl @@ -50,11 +50,11 @@ function bar_rectangle(x, y, width, fillto, in_y_direction) ymin = min(fillto, y) ymax = max(fillto, y) w = abs(width) - rect = FRect(x - (w / 2f0), ymin, w, ymax - ymin) + rect = Rectf(x - (w / 2f0), ymin, w, ymax - ymin) return in_y_direction ? rect : flip(rect) end -flip(r::Rect2D) = Rect2D(reverse(origin(r)), reverse(widths(r))) +flip(r::Rect2) = Rect2(reverse(origin(r)), reverse(widths(r))) function xw_from_dodge(x, width, minimum_distance, x_gap, dodge, n_dodge, dodge_gap) width === automatic && (width = (1 - x_gap) * minimum_distance) @@ -119,9 +119,9 @@ function stack_grouped_from_to(i_stack, y, grp) end function text_attributes(values, in_y_direction, flip_labels_at, color_over_background, color_over_bar, label_offset) - aligns = Vec2f0[] - offsets = Vec2f0[] - text_colors = RGBAf0[] + aligns = Vec2f[] + offsets = Vec2f[] + text_colors = RGBAf[] swap(x, y) = in_y_direction ? (x, y) : (y, x) geti(x::AbstractArray, i) = x[i] geti(x, i) = x @@ -165,7 +165,7 @@ function barplot_labels(xpositions, ypositions, bar_labels, in_y_direction, flip if length(bar_labels) == length(xpositions) attributes = text_attributes(ypositions, in_y_direction, flip_labels_at, color_over_background, color_over_bar, label_offset) label_pos = map(xpositions, ypositions, bar_labels) do x, y, l - return (string(l), in_y_direction ? Point2f0(x, y) : Point2f0(y, x)) + return (string(l), in_y_direction ? Point2f(x, y) : Point2f(y, x)) end return (label_pos, attributes...) else @@ -177,10 +177,10 @@ function barplot_labels(xpositions, ypositions, bar_labels, in_y_direction, flip end function Makie.plot!(p::BarPlot) - labels = Observable(Tuple{String, Point2f0}[]) - label_aligns = Observable(Vec2f0[]) - label_offsets = Observable(Vec2f0[]) - label_colors = Observable(RGBAf0[]) + labels = Observable(Tuple{String, Point2f}[]) + label_aligns = Observable(Vec2f[]) + label_offsets = Observable(Vec2f[]) + label_colors = Observable(RGBAf[]) function calculate_bars(xy, fillto, offset, width, dodge, n_dodge, x_gap, dodge_gap, stack, dir, bar_labels, flip_labels_at, label_color, color_over_background, color_over_bar, label_formatter, label_offset) diff --git a/src/basic_recipes/buffers.jl b/src/basic_recipes/buffers.jl index c2b19e30baf..a2affc760a6 100644 --- a/src/basic_recipes/buffers.jl +++ b/src/basic_recipes/buffers.jl @@ -5,7 +5,7 @@ efficiently append + push new values to them function LinesegmentBuffer( scene::SceneLike, ::Type{Point{N}} = Point{2}; - color = RGBAf0[], linewidth = Float32[], raw = true, + color = RGBAf[], linewidth = Float32[], raw = true, kw_args... ) where N linesegments!( @@ -44,11 +44,11 @@ end function TextBuffer( scene::SceneLike, ::Type{Point{N}} = Point{2}; - rotation = [Quaternionf0(0,0,0,1)], - color = RGBAf0[RGBAf0(0,0,0,0)], + rotation = [Quaternionf(0,0,0,1)], + color = RGBAf[RGBAf(0,0,0,0)], textsize = Float32[0], font = [defaultfont()], - align = [Vec2f0(0)], + align = [Vec2f(0)], raw = true, kw_args... ) where N diff --git a/src/basic_recipes/contourf.jl b/src/basic_recipes/contourf.jl index 460af965110..66157528653 100644 --- a/src/basic_recipes/contourf.jl +++ b/src/basic_recipes/contourf.jl @@ -75,25 +75,25 @@ function Makie.plot!(c::Contourf{<:Tuple{<:AbstractVector{<:Real}, <:AbstractVec end - lowcolor = lift(Union{Nothing, RGBAf0}, c.extendlow) do el + lowcolor = lift(Union{Nothing, RGBAf}, c.extendlow) do el if el === nothing nothing elseif el === automatic || el == :auto - RGBAf0(get(c._computed_colormap[], 0)) + RGBAf(get(c._computed_colormap[], 0)) else - convert_attribute(el, key"color"())::RGBAf0 + convert_attribute(el, key"color"())::RGBAf end end c.attributes[:_computed_extendlow] = lowcolor is_extended_low = lift(x -> !isnothing(x), lowcolor) - highcolor = lift(Union{Nothing, RGBAf0}, c.extendhigh) do eh + highcolor = lift(Union{Nothing, RGBAf}, c.extendhigh) do eh if eh === nothing nothing elseif eh === automatic || eh == :auto - RGBAf0(get(c._computed_colormap[], 1)) + RGBAf(get(c._computed_colormap[], 1)) else - convert_attribute(eh, key"color"())::RGBAf0 + convert_attribute(eh, key"color"())::RGBAf end end c.attributes[:_computed_extendhigh] = highcolor @@ -101,7 +101,7 @@ function Makie.plot!(c::Contourf{<:Tuple{<:AbstractVector{<:Real}, <:AbstractVec - PolyType = typeof(Polygon(Point2f0[], [Point2f0[]])) + PolyType = typeof(Polygon(Point2f[], [Point2f[]])) polys = Observable(PolyType[]) colors = Observable(Float64[]) @@ -122,13 +122,13 @@ function Makie.plot!(c::Contourf{<:Tuple{<:AbstractVector{<:Real}, <:AbstractVec # zs needs to be transposed to match rest of makie isos = Isoband.isobands(xs, ys, zs', lows, highs) - allvertices = Point2f0[] + allvertices = Point2f[] allfaces = NgonFace{3,OffsetInteger{-1,UInt32}}[] allids = Int[] levelcenters = (highs .+ lows) ./ 2 for (i, (center, group)) in enumerate(zip(levelcenters, isos)) - points = Point2f0.(group.x, group.y) + points = Point2f.(group.x, group.y) polygroups = _group_polys(points, group.id) for polygroup in polygroups outline = polygroup[1] @@ -190,7 +190,7 @@ function _group_polys(points, ids) # each group has first an outer polygon, and then its holes # TODO: don't specifically type this 2f0? - groups = Vector{Vector{Point2f0}}[] + groups = Vector{Vector{Point2f}}[] # a dict that maps index in `polys` to index in `groups` for outer polys outerindex_groupdict = Dict{Int, Int}() diff --git a/src/basic_recipes/contours.jl b/src/basic_recipes/contours.jl index d93ae8f0619..c4a7b027a76 100644 --- a/src/basic_recipes/contours.jl +++ b/src/basic_recipes/contours.jl @@ -36,12 +36,12 @@ $(ATTRIBUTES) end function contourlines(::Type{<: Contour}, contours, cols) - result = Point2f0[] + result = Point2f[] colors = RGBA{Float32}[] for (color, c) in zip(cols, Contours.levels(contours)) for elem in Contours.lines(c) append!(result, elem.vertices) - push!(result, Point2f0(NaN32)) + push!(result, Point2f(NaN32)) append!(colors, fill(color, length(elem.vertices) + 1)) end end @@ -49,14 +49,14 @@ function contourlines(::Type{<: Contour}, contours, cols) end function contourlines(::Type{<: Contour3d}, contours, cols) - result = Point3f0[] + result = Point3f[] colors = RGBA{Float32}[] for (color, c) in zip(cols, Contours.levels(contours)) for elem in Contours.lines(c) for p in elem.vertices - push!(result, Point3f0(p[1], p[2], c.level)) + push!(result, Point3f(p[1], p[2], c.level)) end - push!(result, Point3f0(NaN32)) + push!(result, Point3f(NaN32)) append!(colors, fill(color, length(elem.vertices) + 1)) end end @@ -99,7 +99,7 @@ function plot!(plot::Contour{<: Tuple{X, Y, Z, Vol}}) where {X, Y, Z, Vol} (isoval in v_interval) || return false v0 || (abs(level - isoval) <= iso_eps) end - RGBAf0(Colors.color(c), line ? alpha : 0.0) + RGBAf(Colors.color(c), line ? alpha : 0.0) end end volume!( @@ -137,7 +137,7 @@ function color_per_level(::Nothing, colormap, colorrange, a, levels) cmap = to_colormap(colormap) map(levels) do level c = interpolated_getindex(cmap, level, colorrange) - RGBAf0(color(c), alpha(c) * a) + RGBAf(color(c), alpha(c) * a) end end diff --git a/src/basic_recipes/convenience_functions.jl b/src/basic_recipes/convenience_functions.jl index 410e056b71c..e1158af2e1b 100644 --- a/src/basic_recipes/convenience_functions.jl +++ b/src/basic_recipes/convenience_functions.jl @@ -1,6 +1,6 @@ function Makie.plot!(plot::Plot(AbstractVector{<: Complex})) plot[:axis, :labels] = ("Re(x)", "Im(x)") - lines!(plot, lift(im-> Point2f0.(real.(im), imag.(im)), x[1])) + lines!(plot, lift(im-> Point2f.(real.(im), imag.(im)), x[1])) end @@ -60,7 +60,7 @@ function showgradients( text!( scene, cmapstr, - position = Point2f0(-0.1, 0.5 + h), + position = Point2f(-0.1, 0.5 + h), align = (:right, :center), show_axis = false, textsize = textsize diff --git a/src/basic_recipes/error_and_rangebars.jl b/src/basic_recipes/error_and_rangebars.jl index 01b959d1016..9a9bf17d790 100644 --- a/src/basic_recipes/error_and_rangebars.jl +++ b/src/basic_recipes/error_and_rangebars.jl @@ -59,48 +59,48 @@ end function Makie.convert_arguments(::Type{<:Errorbars}, x, y, error_both) xyerr = broadcast(x, y, error_both) do x, y, e - Vec4f0(x, y, e, e) + Vec4f(x, y, e, e) end (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, x, y, error_low, error_high) - xyerr = broadcast(Vec4f0, x, y, error_low, error_high) + xyerr = broadcast(Vec4f, x, y, error_low, error_high) (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, x, y, error_low_high::AbstractVector{<:VecTypes{2}}) xyerr = broadcast(x, y, error_low_high) do x, y, (el, eh) - Vec4f0(x, y, el, eh) + Vec4f(x, y, el, eh) end (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, xy::AbstractVector{<:VecTypes{2}}, error_both) xyerr = broadcast(xy, error_both) do (x, y), e - Vec4f0(x, y, e, e) + Vec4f(x, y, e, e) end (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, xy::AbstractVector{<:VecTypes{2}}, error_low, error_high) xyerr = broadcast(xy, error_low, error_high) do (x, y), el, eh - Vec4f0(x, y, el, eh) + Vec4f(x, y, el, eh) end (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, xy::AbstractVector{<:VecTypes{2}}, error_low_high::AbstractVector{<:VecTypes{2}}) xyerr = broadcast(xy, error_low_high) do (x, y), (el, eh) - Vec4f0(x, y, el, eh) + Vec4f(x, y, el, eh) end (xyerr,) end function Makie.convert_arguments(::Type{<:Errorbars}, xy_error_both::AbstractVector{<:VecTypes{3}}) xyerr = broadcast(xy_error_both) do (x, y, e) - Vec4f0(x, y, e, e) + Vec4f(x, y, e, e) end (xyerr,) end @@ -108,13 +108,13 @@ end ### conversions for rangebars function Makie.convert_arguments(::Type{<:Rangebars}, val, low, high) - val_low_high = broadcast(Vec3f0, val, low, high) + val_low_high = broadcast(Vec3f, val, low, high) (val_low_high,) end function Makie.convert_arguments(::Type{<:Rangebars}, val, low_high) val_low_high = broadcast(val, low_high) do val, (low, high) - Vec3f0(val, low, high) + Vec3f(val, low, high) end (val_low_high,) end @@ -140,8 +140,8 @@ function Makie.plot!(plot::Errorbars{T}) where T <: Tuple{AbstractVector{<:VecTy map(x_y_low_high) do (x, y, l, h) in_y ? - (Point2f0(x, y - l), Point2f0(x, y + h)) : - (Point2f0(x - l, y), Point2f0(x + h, y)) + (Point2f(x, y - l), Point2f(x, y + h)) : + (Point2f(x - l, y), Point2f(x + h, y)) end end @@ -167,8 +167,8 @@ function Makie.plot!(plot::Rangebars{T}) where T <: Tuple{AbstractVector{<:VecTy map(vlh) do (v, l, h) in_y ? - (Point2f0(v, l), Point2f0(v, h)) : - (Point2f0(l, v), Point2f0(h, v)) + (Point2f(v, l), Point2f(v, h)) : + (Point2f(l, v), Point2f(h, v)) end end @@ -231,28 +231,28 @@ function _plot_bars!(plot, linesegpairs, is_in_y_direction) end function scene_to_screen(pts, scene) - p4 = to_ndim.(Vec4f0, to_ndim.(Vec3f0, pts, 0.0), 1.0) + p4 = to_ndim.(Vec4f, to_ndim.(Vec3f, pts, 0.0), 1.0) p1m1 = Ref(scene.camera.projectionview[]) .* p4 projected = Ref(inv(scene.camera.pixel_space[])) .* p1m1 [Point2.(p[1:2]...) for p in projected] end function screen_to_scene(pts, scene) - p4 = to_ndim.(Vec4f0, to_ndim.(Vec3f0, pts, 0.0), 1.0) + p4 = to_ndim.(Vec4f, to_ndim.(Vec3f, pts, 0.0), 1.0) p1m1 = Ref(scene.camera.pixel_space[]) .* p4 projected = Ref(inv(scene.camera.projectionview[])) .* p1m1 [Point2.(p[1:2]...) for p in projected] end function scene_to_screen(p::T, scene) where T <: Point - p4 = to_ndim(Vec4f0, to_ndim(Vec3f0, p, 0.0), 1.0) + p4 = to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) p1m1 = scene.camera.projectionview[] * p4 projected = inv(scene.camera.pixel_space[]) * p1m1 T(projected[1:2]...) end function screen_to_scene(p::T, scene) where T <: Point - p4 = to_ndim(Vec4f0, to_ndim(Vec3f0, p, 0.0), 1.0) + p4 = to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) p1m1 = scene.camera.pixel_space[] * p4 projected = inv(scene.camera.projectionview[]) * p1m1 T(projected[1:2]...) diff --git a/src/basic_recipes/pie.jl b/src/basic_recipes/pie.jl index e636e209a3d..9e93f1954cd 100644 --- a/src/basic_recipes/pie.jl +++ b/src/basic_recipes/pie.jl @@ -44,18 +44,18 @@ function plot!(plot::Pie) # curve points points = map(LinRange(sta, en, nvertices)) do rad - Point2f0(cos(rad + offset), sin(rad + offset)) .* radius + Point2f(cos(rad + offset), sin(rad + offset)) .* radius end # add inner points (either curve or one point) if inner_radius != 0 inner_points = map(LinRange(en, sta, nvertices)) do rad - Point2f0(cos(rad + offset), sin(rad + offset)) .* inner_radius + Point2f(cos(rad + offset), sin(rad + offset)) .* inner_radius end append!(points, inner_points) else - push!(points, Point2f0(0, 0)) + push!(points, Point2f(0, 0)) end points diff --git a/src/basic_recipes/poly.jl b/src/basic_recipes/poly.jl index f85a50d1348..37d8d3a3939 100644 --- a/src/basic_recipes/poly.jl +++ b/src/basic_recipes/poly.jl @@ -91,21 +91,21 @@ to_line_segments(polygon) = convert_arguments(PointBased(), polygon)[1] to_line_segments(polygon::GeometryBasics.Mesh) = convert_arguments(PointBased(), polygon)[1] function to_line_segments(meshes::AbstractVector) - line = Point2f0[] + line = Point2f[] for (i, mesh) in enumerate(meshes) points = to_line_segments(mesh) append!(line, points) # push!(line, points[1]) # dont need to separate the last line segment if i != length(meshes) - push!(line, Point2f0(NaN)) + push!(line, Point2f(NaN)) end end return line end function to_line_segments(polygon::AbstractVector{<: VecTypes}) - result = Point2f0.(polygon) + result = Point2f.(polygon) push!(result, polygon[1]) return result end @@ -153,10 +153,10 @@ function plot!(plot::Mesh{<: Tuple{<: AbstractVector{P}}}) where P <: Union{Abst else to_color.(colors) end - real_colors = RGBAf0[] + real_colors = RGBAf[] # Map one single color per mesh to each vertex for (mesh, color) in zip(meshes, single_colors) - append!(real_colors, Iterators.repeated(RGBAf0(color), length(coordinates(mesh)))) + append!(real_colors, Iterators.repeated(RGBAf(color), length(coordinates(mesh)))) end # real_colors[] = real_colors[] if P <: AbstractPolygon diff --git a/src/basic_recipes/series.jl b/src/basic_recipes/series.jl index bcbbe7245d5..6a237171346 100644 --- a/src/basic_recipes/series.jl +++ b/src/basic_recipes/series.jl @@ -70,13 +70,13 @@ end function convert_arguments(::Type{<: Series}, x::AbstractVector, ys::AbstractMatrix) return (map(1:size(ys, 1)) do i - Point2f0.(replace_missing.(x), replace_missing.(view(ys, i, :))) + Point2f.(replace_missing.(x), replace_missing.(view(ys, i, :))) end,) end function convert_arguments(::Type{<: Series}, arg::AbstractVector{<: Tuple{X, Y}}) where {X, Y} return (map(arg) do (x, y) - Point2f0.(replace_missing.(x), replace_missing.(y)) + Point2f.(replace_missing.(x), replace_missing.(y)) end,) end @@ -86,7 +86,7 @@ end function convert_arguments(::Type{<: Series}, arg::AbstractVector{<: AbstractVector{<:Point2}}) return (map(arg) do points - Point2f0.(replace_missing.(first.(points)), replace_missing.(last.(points))) + Point2f.(replace_missing.(first.(points)), replace_missing.(last.(points))) end,) end diff --git a/src/basic_recipes/spy.jl b/src/basic_recipes/spy.jl index c4d7debf402..83044486d5a 100644 --- a/src/basic_recipes/spy.jl +++ b/src/basic_recipes/spy.jl @@ -39,14 +39,14 @@ function plot!(p::Spy) rect = lift(p.x, p.y) do x, y xe = extrema(x) ye = extrema(y) - FRect2D((xe[1], ye[1]), (xe[2] - xe[1], ye[2] - ye[1])) + Rect2f((xe[1], ye[1]), (xe[2] - xe[1], ye[2] - ye[1])) end # TODO FastPixel isn't accepting marker size in data coordinates # but instead in pixel - so we need to fix that in GLMakie for consistency # and make this nicer when redoing unit support markersize = lift(p.markersize, rect, p.z) do msize, rect, z if msize === automatic - widths(rect) ./ Vec2f0(size(z)) + widths(rect) ./ Vec2f(size(z)) else msize end @@ -55,7 +55,7 @@ function plot!(p::Spy) xycol = lift(rect, p.z, markersize) do rect, z, markersize x, y, color = SparseArrays.findnz(z) points = map(x, y) do x, y - (((Point2f0(x, y) .- 1) ./ Point2f0(size(z) .- 1)) .* + (((Point2f(x, y) .- 1) ./ Point2f(size(z) .- 1)) .* widths(rect) .+ minimum(rect)) end points, convert(Vector{Float32}, color) diff --git a/src/basic_recipes/stairs.jl b/src/basic_recipes/stairs.jl index c43d803a79b..10e7f27dec6 100644 --- a/src/basic_recipes/stairs.jl +++ b/src/basic_recipes/stairs.jl @@ -27,33 +27,33 @@ function plot!(p::Stairs{<:Tuple{<:AbstractVector{<:Point2}}}) steppoints = lift(points, p.step) do points, step if step == :pre - s_points = Vector{Point2f0}(undef, length(points) * 2 - 1) + s_points = Vector{Point2f}(undef, length(points) * 2 - 1) s_points[1] = point = points[1] for i in 1:length(points)-1 nextpoint = points[i + 1] - s_points[2i] = Point2f0(point[1], nextpoint[2]) + s_points[2i] = Point2f(point[1], nextpoint[2]) s_points[2i + 1] = nextpoint point = nextpoint end s_points elseif step == :post - s_points = Vector{Point2f0}(undef, length(points) * 2 - 1) + s_points = Vector{Point2f}(undef, length(points) * 2 - 1) s_points[1] = point = points[1] for i in 1:length(points)-1 nextpoint = points[i+1] - s_points[2i] = Point2f0(nextpoint[1], point[2]) + s_points[2i] = Point2f(nextpoint[1], point[2]) s_points[2i + 1] = nextpoint point = nextpoint end s_points elseif step == :center - s_points = Vector{Point2f0}(undef, length(points) * 2) + s_points = Vector{Point2f}(undef, length(points) * 2) s_points[1] = point = points[1] for i in 1:length(points)-1 nextpoint = points[i+1] halfx = (point[1] + nextpoint[1]) / 2 - s_points[2i] = Point2f0(halfx, point[2]) - s_points[2i + 1] = Point2f0(halfx, nextpoint[2]) + s_points[2i] = Point2f(halfx, point[2]) + s_points[2i + 1] = Point2f(halfx, nextpoint[2]) point = nextpoint end s_points[end] = point diff --git a/src/basic_recipes/streamplot.jl b/src/basic_recipes/streamplot.jl index ae682eb4b32..f6f4eca7842 100644 --- a/src/basic_recipes/streamplot.jl +++ b/src/basic_recipes/streamplot.jl @@ -7,7 +7,7 @@ f must return a Point2. Example: ```julia -v(x::Point2{T}) where T = Point2f0(x[2], 4*x[1]) +v(x::Point2{T}) where T = Point2f(x[2], 4*x[1]) streamplot(v, -2..2, -2..2) ``` ## Attributes @@ -42,8 +42,8 @@ function convert_arguments(::Type{<: StreamPlot}, f::Function, xrange, yrange, z xmin, xmax = extrema(xrange) ymin, ymax = extrema(yrange) zmin, zmax = extrema(zrange) - mini = Vec3f0(xmin, ymin, zmin) - maxi = Vec3f0(xmax, ymax, zmax) + mini = Vec3f(xmin, ymin, zmin) + maxi = Vec3f(xmax, ymax, zmax) return (f, Rect(mini, maxi .- mini)) end @@ -159,7 +159,7 @@ end function plot!(p::StreamPlot) data = lift(p.f, p.limits, p.gridsize, p.stepsize, p.maxsteps, p.density) do f, limits, resolution, stepsize, maxsteps, density - P = if applicable(f, Point2f0(0)) || applicable(f, Point3f0(0)) + P = if applicable(f, Point2f(0)) || applicable(f, Point3f(0)) Point else Number diff --git a/src/basic_recipes/text.jl b/src/basic_recipes/text.jl index 85058ccf4aa..797981c26e1 100644 --- a/src/basic_recipes/text.jl +++ b/src/basic_recipes/text.jl @@ -66,7 +66,7 @@ function plot!(plot::Text{<:Tuple{<:AbstractArray{<:Tuple{<:AbstractString, <:Po strings_and_positions = plot[1] strings = Node(first.(strings_and_positions[])) - positions = Node(to_ndim.(Ref(Point3f0), last.(strings_and_positions[]), 0)) + positions = Node(to_ndim.(Ref(Point3f), last.(strings_and_positions[]), 0)) attrs = plot.attributes pop!(attrs, :position) @@ -76,7 +76,7 @@ function plot!(plot::Text{<:Tuple{<:AbstractArray{<:Tuple{<:AbstractString, <:Po # update both text and positions together on(strings_and_positions) do str_pos strs = first.(str_pos) - poss = to_ndim.(Ref(Point3f0), last.(str_pos), 0) + poss = to_ndim.(Ref(Point3f), last.(str_pos), 0) # first mutate strings without triggering redraw t[1].val = strs # then update positions with trigger @@ -99,7 +99,7 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr if latexstring isa AbstractVector tex_elements = [] glyphcollections = GlyphCollection[] - offsets = Point2f0[] + offsets = Point2f[] broadcast_foreach(latexstring, ts, al, rot, color, scolor, swidth) do latexstring, ts, al, rot, color, scolor, swidth @@ -119,7 +119,7 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr glyphcollection = @lift($lineels_glyphcollection_offset[2]) - linepairs = Node(Tuple{Point2f0, Point2f0}[]) + linepairs = Node(Tuple{Point2f, Point2f}[]) linewidths = Node(Float32[]) scene = Makie.parent_scene(plot) @@ -143,7 +143,7 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr allels = [allels] end broadcast_foreach(allels, offs, pos, ts, rot) do allels, offs, pos, ts, rot - offset = Point2f0(pos) + offset = Point2f(pos) els = map(allels) do el el[1] isa VLine || el[1] isa HLine || return nothing @@ -153,16 +153,16 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr ps = if el[1] isa VLine h = el[1].height - (Point2f0(p[1], p[2]) .* ts, Point2f0(p[1], p[2] + h) .* ts) .- Ref(offs) + (Point2f(p[1], p[2]) .* ts, Point2f(p[1], p[2] + h) .* ts) .- Ref(offs) else w = el[1].width - (Point2f0(p[1], p[2]) .* ts, Point2f0(p[1] + w, p[2]) .* ts) .- Ref(offs) + (Point2f(p[1], p[2]) .* ts, Point2f(p[1] + w, p[2]) .* ts) .- Ref(offs) end - ps = Ref(rot) .* to_ndim.(Point3f0, ps, 0) + ps = Ref(rot) .* to_ndim.(Point3f, ps, 0) # TODO the points need to be projected to work inside Axis # ps = project ps with projview somehow - ps = Point2f0.(ps) .+ Ref(offset) + ps = Point2f.(ps) .+ Ref(offset) ps, t end pairs = filter(!isnothing, els) @@ -189,9 +189,9 @@ function texelems_and_glyph_collection(str::LaTeXString, fontscale_px, halign, v els = filter(x -> x[1] isa TeXChar, all_els) # hacky, but attr per char needs to be fixed - fs = Vec2f0(first(fontscale_px)) + fs = Vec2f(first(fontscale_px)) - scales_2d = [Vec2f0(x[3] * Vec2f0(fs)) for x in els] + scales_2d = [Vec2f(x[3] * Vec2f(fs)) for x in els] chars = [x[1].char for x in els] fonts = [x[1].font for x in els] @@ -200,18 +200,18 @@ function texelems_and_glyph_collection(str::LaTeXString, fontscale_px, halign, v bboxes = map(extents, fonts, scales_2d) do ext, font, scale unscaled_hi_bb = FreeTypeAbstraction.height_insensitive_boundingbox(ext, font) - return FRect2D( + return Rect2f( origin(unscaled_hi_bb) * scale, widths(unscaled_hi_bb) * scale ) end - basepositions = [to_ndim(Vec3f0, fs, 0) .* to_ndim(Point3f0, x[2], 0) + basepositions = [to_ndim(Vec3f, fs, 0) .* to_ndim(Point3f, x[2], 0) for x in els] bb = isempty(bboxes) ? BBox(0, 0, 0, 0) : begin mapreduce(union, zip(bboxes, basepositions)) do (b, pos) - FRect2D(FRect3D(b) + pos) + Rect2f(Rect3f(b) + pos) end end @@ -231,13 +231,13 @@ function texelems_and_glyph_collection(str::LaTeXString, fontscale_px, halign, v minimum(bb)[2] end - positions = basepositions .- Ref(Point3f0(xshift, yshift, 0)) + positions = basepositions .- Ref(Point3f(xshift, yshift, 0)) positions .= Ref(rot) .* positions pre_align_gl = GlyphCollection( chars, fonts, - Point3f0.(positions), + Point3f.(positions), extents, scales_2d, rot, @@ -246,7 +246,7 @@ function texelems_and_glyph_collection(str::LaTeXString, fontscale_px, halign, v strokewidth, ) - all_els, pre_align_gl, Point2f0(xshift, yshift) + all_els, pre_align_gl, Point2f(xshift, yshift) end MakieLayout.iswhitespace(l::LaTeXString) = MakieLayout.iswhitespace(l.s[2:end-1]) diff --git a/src/basic_recipes/timeseries.jl b/src/basic_recipes/timeseries.jl index 10ddf75e2a5..ff99afd08a6 100644 --- a/src/basic_recipes/timeseries.jl +++ b/src/basic_recipes/timeseries.jl @@ -27,7 +27,7 @@ end ) end -signal2point(signal::Number, start) = Point2f0(time() - start, signal) +signal2point(signal::Number, start) = Point2f(time() - start, signal) signal2point(signal::Point2, start) = signal signal2point(signal, start) = error(""" Signal needs to be of type Number or Point. Found: $(typeof(signal)) @@ -37,7 +37,7 @@ Found: $(typeof(signal)) function Makie.plot!(plot::TimeSeries) # normal plotting code, building on any previously defined recipes # or atomic plotting operations, and adding to the combined `plot`: - points = Node(fill(Point2f0(NaN), plot.history[])) + points = Node(fill(Point2f(NaN), plot.history[])) buffer = copy(points[]) lines!(plot, points) start = time() diff --git a/src/basic_recipes/volumeslices.jl b/src/basic_recipes/volumeslices.jl index 2c140b47e77..1a6a86b48d8 100644 --- a/src/basic_recipes/volumeslices.jl +++ b/src/basic_recipes/volumeslices.jl @@ -36,7 +36,7 @@ function plot!(plot::VolumeSlices) v[4], v[6], v[4], v[7], v[6], v[8], v[7], v[8], ] # bounding box - col = RGBAf0(.5, .5, .5, .5) + col = RGBAf(.5, .5, .5, .5) linesegments!(plot, getindex.(s, 1), getindex.(s, 2), getindex.(s, 3), color=col, inspectable = false) axes = :x, :y, :z diff --git a/src/basic_recipes/wireframe.jl b/src/basic_recipes/wireframe.jl index 73c55f313fe..05d6d9ec13c 100644 --- a/src/basic_recipes/wireframe.jl +++ b/src/basic_recipes/wireframe.jl @@ -27,10 +27,10 @@ yvector(x::AbstractMatrix, len) = x function plot!(plot::Wireframe{<: Tuple{<: Any, <: Any, <: AbstractMatrix}}) points_faces = lift(plot[1:3]...) do x, y, z M, N = size(z) - points = vec(Point3f0.(xvector(x, M), yvector(y, N), z)) + points = vec(Point3f.(xvector(x, M), yvector(y, N), z)) # Connect the vetices with faces, as one would use for a 2D Rectangle # grid with M,N grid points - faces = decompose(LineFace{GLIndex}, Tesselation(Rect2D(0, 0, 1, 1), (M, N))) + faces = decompose(LineFace{GLIndex}, Tesselation(Rect2(0, 0, 1, 1), (M, N))) connect(points, faces) end linesegments!(plot, Attributes(plot), points_faces) @@ -40,7 +40,7 @@ function plot!(plot::Wireframe{Tuple{T}}) where T points = lift(plot[1]) do g # get the point representation of the geometry indices = decompose(LineFace{GLIndex}, g) - points = decompose(Point3f0, g) + points = decompose(Point3f, g) return connect(points, indices) end linesegments!(plot, Attributes(plot), points) diff --git a/src/camera/camera.jl b/src/camera/camera.jl index f747f16587c..59240a86719 100644 --- a/src/camera/camera.jl +++ b/src/camera/camera.jl @@ -65,11 +65,11 @@ function Camera(px_area) end Camera( pixel_space, - Node(Mat4f0(I)), - Node(Mat4f0(I)), - Node(Mat4f0(I)), - lift(a-> Vec2f0(widths(a)), px_area), - Node(Vec3f0(1)), + Node(Mat4f(I)), + Node(Mat4f(I)), + Node(Mat4f(I)), + lift(a-> Vec2f(widths(a)), px_area), + Node(Vec3f(1)), ObserverFunction[] ) end diff --git a/src/camera/camera2d.jl b/src/camera/camera2d.jl index 3eed1e1b08f..74d22a39d3b 100644 --- a/src/camera/camera2d.jl +++ b/src/camera/camera2d.jl @@ -1,5 +1,5 @@ struct Camera2D <: AbstractCamera - area::Node{FRect2D} + area::Node{Rect2f} zoomspeed::Node{Float32} zoombutton::Node{ButtonTypes} panbutton::Node{Union{ButtonTypes, Vector{ButtonTypes}}} @@ -16,7 +16,7 @@ Creates a 2D camera for the given Scene. function cam2d!(scene::SceneLike; kw_args...) cam_attributes = merged_get!(:cam2d, scene, Attributes(kw_args)) do Attributes( - area = Node(FRect(0, 0, 1, 1)), + area = Node(Rectf(0, 0, 1, 1)), zoomspeed = 0.10f0, zoombutton = nothing, panbutton = Mouse.right, @@ -55,7 +55,7 @@ Useful when using the `Node` pipeline. update_cam!(scene::SceneLike) = update_cam!(scene, cameracontrols(scene), limits(scene)[]) function update_cam!(scene::Scene, cam::Camera2D, area3d::Rect) - area = FRect2D(area3d) + area = Rect2f(area3d) area = positive_widths(area) # ignore rects with width almost 0 any(x-> x ≈ 0.0, widths(area)) && return @@ -71,7 +71,7 @@ function update_cam!(scene::Scene, cam::Camera2D, area3d::Rect) # so we make the minimum 1.0, and grow in the other dimension s = ratio ./ minimum(ratio) newwh = s .* widths(area) - cam.area[] = FRect(minimum(area), newwh) + cam.area[] = Rectf(minimum(area), newwh) end update_cam!(scene, cam) end @@ -81,7 +81,7 @@ function update_cam!(scene::SceneLike, cam::Camera2D) w, h = widths(cam.area[]) ./ 2f0 # These nodes should be final, no one should do map(cam.projection), # so we don't push! and just update the value in place - view = translationmatrix(Vec3f0(-x - w, -y - h, 0)) + view = translationmatrix(Vec3f(-x - w, -y - h, 0)) projection = orthographicprojection(-w, w, -h, h, -10_000f0, 10_000f0) camera(scene).view[] = view camera(scene).projection[] = projection @@ -96,7 +96,7 @@ function correct_ratio!(scene, cam) change = neww .- cam.last_area[] if !(change ≈ Vec(0.0, 0.0)) s = 1.0 .+ (change ./ cam.last_area[]) - camrect = FRect(minimum(cam.area[]), widths(cam.area[]) .* s) + camrect = Rectf(minimum(cam.area[]), widths(cam.area[]) .* s) cam.area[] = camrect update_cam!(scene, cam) end @@ -125,7 +125,7 @@ function add_pan!(scene::SceneLike, cam::Camera2D) startpos[] = mp area = cam.area[] diff = Vec(diff) .* wscale(pixelarea(scene)[], area) - cam.area[] = FRect(minimum(area) .+ diff, widths(area)) + cam.area[] = Rectf(minimum(area) .+ diff, widths(area)) update_cam!(scene, cam) active[] = false return Consume(true) @@ -144,7 +144,7 @@ function add_pan!(scene::SceneLike, cam::Camera2D) startpos[] = pos area = cam.area[] diff = Vec(diff) .* wscale(pixelarea(scene)[], area) - cam.area[] = FRect(minimum(area) .+ diff, widths(area)) + cam.area[] = Rectf(minimum(area) .+ diff, widths(area)) update_cam!(scene, cam) return Consume(true) end @@ -160,13 +160,13 @@ function add_zoom!(scene::SceneLike, cam::Camera2D) if zoom != 0 && ispressed(scene, zoombutton) && is_mouseinside(scene) pa = pixelarea(scene)[] z = (1f0 - zoomspeed)^zoom - mp = Vec2f0(e.mouseposition[]) - minimum(pa) + mp = Vec2f(e.mouseposition[]) - minimum(pa) mp = (mp .* wscale(pa, area)) + minimum(area) p1, p2 = minimum(area), maximum(area) p1, p2 = p1 - mp, p2 - mp # translate to mouse position p1, p2 = z * p1, z * p2 p1, p2 = p1 + mp, p2 + mp - cam.area[] = FRect(p1, p2 - p1) + cam.area[] = Rectf(p1, p2 - p1) update_cam!(scene, cam) return Consume(true) end @@ -184,12 +184,12 @@ function absrect(rect) xy = ntuple(Val(2)) do i wh[i] < 0 ? xy[i] + wh[i] : xy[i] end - return FRect(Vec2f0(xy), Vec2f0(abs.(wh))) + return Rectf(Vec2f(xy), Vec2f(abs.(wh))) end function selection_rect!(scene, cam, key) - rect = RefValue(FRect(NaN, NaN, NaN, NaN)) + rect = RefValue(Rectf(NaN, NaN, NaN, NaN)) lw = 2f0 scene_unscaled = Scene( scene, transformation = Transformation(), @@ -214,7 +214,7 @@ function selection_rect!(scene, cam, key) if event.action == Mouse.press waspressed[] = true rect_vis[:visible] = true # start displaying - rect[] = FRect(mp, 0, 0) + rect[] = Rectf(mp, 0, 0) rect_vis[1] = rect[] return Consume(true) end @@ -226,7 +226,7 @@ function selection_rect!(scene, cam, key) if w > 0.0 && h > 0.0 update_cam!(scene, cam, r) end - rect[] = FRect(NaN, NaN, NaN, NaN) + rect[] = Rectf(NaN, NaN, NaN, NaN) rect_vis[1] = rect[] return Consume(true) end @@ -241,7 +241,7 @@ function selection_rect!(scene, cam, key) # this is only true after a mousebutton update if ispressed(scene, key) && is_mouseinside(scene) mini = minimum(rect[]) - rect[] = FRect(mini, mp - mini) + rect[] = Rectf(mini, mp - mini) rect_vis[1] = rect[] return Consume(true) end @@ -260,25 +260,25 @@ function reset!(cam, boundingbox, preserveratio = true) ratio = w2 ./ w1 w1 = if ratio[1] > ratio[2] s = w2[1] ./ w2[2] - Vec2f0(s * w1[2], w1[2]) + Vec2f(s * w1[2], w1[2]) else s = w2[2] ./ w2[1] - Vec2f0(w1[1], s * w1[1]) + Vec2f(w1[1], s * w1[1]) end end p = minimum(w1) .* 0.001 # 2mm padding - update_cam!(cam, FRect(-p, -p, w1 .+ 2p)) + update_cam!(cam, Rectf(-p, -p, w1 .+ 2p)) return end -function add_restriction!(cam, window, rarea::Rect2D, minwidths::Vec) +function add_restriction!(cam, window, rarea::Rect2, minwidths::Vec) area_ref = Base.RefValue(cam[Area]) restrict_action = paused_action(1.0) do t o = lerp(origin(area_ref[]), origin(cam[Area]), t) wh = lerp(widths(area_ref[]), widths(cam[Area]), t) - update_cam!(cam, FRect(o, wh)) + update_cam!(cam, Rectf(o, wh)) end on(window, Mouse.Drag) do drag if drag == Mouse.up && !isplaying(restrict_action) @@ -296,7 +296,7 @@ function add_restriction!(cam, window, rarea::Rect2D, minwidths::Vec) scale = max(scale, stmp) end newwh = newwh * scale - area_ref[] = FRect(newo, newwh) + area_ref[] = Rectf(newo, newwh) if area_ref[] != cam[Area] play!(restrict_action) end @@ -314,7 +314,7 @@ Creates a pixel-level camera for the `Scene`. No controls! """ function campixel!(scene) scene.updated = Node(false) - camera(scene).view[] = Mat4f0(I) + camera(scene).view[] = Mat4f(I) update_once = Observable(false) on(camera(scene), update_once, pixelarea(scene)) do u, window_size nearclip = -10_000f0 diff --git a/src/camera/camera3d.jl b/src/camera/camera3d.jl index b7ba59ca0b1..5a73955ee00 100644 --- a/src/camera/camera3d.jl +++ b/src/camera/camera3d.jl @@ -1,7 +1,7 @@ struct Camera3D <: AbstractCamera - eyeposition::Node{Vec3f0} - lookat::Node{Vec3f0} - upvector::Node{Vec3f0} + eyeposition::Node{Vec3f} + lookat::Node{Vec3f} + upvector::Node{Vec3f} zoom_mult::Node{Float32} fov::Node{Float32} # WGLMakie compat @@ -28,7 +28,7 @@ The 3D camera is (or can be) unrestricted in terms of rotations and translations - `zoom_shift_lookat = true`: If true attempts to keep data under the cursor in view when zooming. - `cad = false`: If true rotates the view around `lookat` when zooming off-center. -The camera view follows from the position of the camera `eyeposition`, the point which the camera focuses `lookat` and the up direction of the camera `upvector`. These can be accessed as `cam.eyeposition` etc and adjusted via `update_cam!(scene, cameracontrols(scene), eyeposition, lookat[, upvector = Vec3f0(0, 0, 1)])`. They can also be passed as keyword arguments when the camera is constructed. +The camera view follows from the position of the camera `eyeposition`, the point which the camera focuses `lookat` and the up direction of the camera `upvector`. These can be accessed as `cam.eyeposition` etc and adjusted via `update_cam!(scene, cameracontrols(scene), eyeposition, lookat[, upvector = Vec3f(0, 0, 1)])`. They can also be passed as keyword arguments when the camera is constructed. The camera can be controlled by keyboard and mouse. The keyboard has the following available attributes @@ -73,12 +73,12 @@ There are also a few generally applicable controls: - `fix_x_key = Keyboard.x` sets the key for fixing translations and rotations to the (world/plot) x-axis. - `fix_y_key = Keyboard.y` sets the key for fixing translations and rotations to the (world/plot) y-axis. - `fix_z_key = Keyboard.z` sets the key for fixing translations and rotations to the (world/plot) z-axis. -- `reset = Keyboard.home` sets the key for fully resetting the camera. This equivalent to setting `lookat = Vec3f0(0)`, `upvector = Vec3f0(0, 0, 1)`, `eyeposition = Vec3f0(3)` and then calling `center!(scene)`. +- `reset = Keyboard.home` sets the key for fully resetting the camera. This equivalent to setting `lookat = Vec3f(0)`, `upvector = Vec3f(0, 0, 1)`, `eyeposition = Vec3f(3)` and then calling `center!(scene)`. You can also make adjustments to the camera position, rotation and zoom by calling relevant functions: - `translate_cam!(scene, v)` will translate the camera by the given world/plot space vector `v`. -- `rotate_cam!(scene, angles)` will rotate the camera around its axes with the corresponding angles. The first angle will rotate around the cameras "right" that is the screens horizontal axis, the second around the up vector/vertical axis or `Vec3f0(0, 0, +-1)` if `fixed_axis = true`, and the third will rotate around the view direction i.e. the axis out of the screen. The rotation respects the the current `rotation_center` of the camera. +- `rotate_cam!(scene, angles)` will rotate the camera around its axes with the corresponding angles. The first angle will rotate around the cameras "right" that is the screens horizontal axis, the second around the up vector/vertical axis or `Vec3f(0, 0, +-1)` if `fixed_axis = true`, and the third will rotate around the view direction i.e. the axis out of the screen. The rotation respects the the current `rotation_center` of the camera. - `zoom!(scene, zoom_step)` will change the zoom level of the scene without translating or rotating the scene. `zoom_step` applies multiplicatively to `cam.zoom_mult` which is used as a multiplier to the fov (perspective projection) or width and height (orthographic projection). """ function Camera3D(scene; kwargs...) @@ -135,9 +135,9 @@ function Camera3D(scene; kwargs...) end cam = Camera3D( - pop!(attr, :eyeposition, Vec3f0(3)), - pop!(attr, :lookat, Vec3f0(0)), - pop!(attr, :upvector, Vec3f0(0, 0, 1)), + pop!(attr, :eyeposition, Vec3f(3)), + pop!(attr, :lookat, Vec3f(0)), + pop!(attr, :upvector, Vec3f(0, 0, 1)), Node(1f0), Node(attr[:fov][]), @@ -204,9 +204,9 @@ function Camera3D(scene; kwargs...) # center keeps the rotation of the camera so we reset that here # might make sense to keep user set lookat, upvector, eyeposition # around somewhere for this? - cam.lookat[] = Vec3f0(0) - cam.upvector[] = Vec3f0(0,0,1) - cam.eyeposition[] = Vec3f0(3) + cam.lookat[] = Vec3f(0) + cam.upvector[] = Vec3f(0,0,1) + cam.eyeposition[] = Vec3f(3) center!(scene) return Consume(true) end @@ -236,13 +236,13 @@ function add_translation!(scene, cam::Camera3D) button = cam.attributes[:translation_button] mod = cam.attributes[:translation_modifier] - last_mousepos = RefValue(Vec2f0(0, 0)) + last_mousepos = RefValue(Vec2f(0, 0)) dragging = RefValue(false) function compute_diff(delta) if cam.attributes[:projectiontype][] == Orthographic aspect = Float32((/)(widths(scene.px_area[])...)) - aspect_scale = Vec2f0(1f0 + aspect, 1f0 + 1f0 / aspect) + aspect_scale = Vec2f(1f0 + aspect, 1f0 + 1f0 / aspect) return cam.zoom_mult[] * delta .* aspect_scale ./ widths(scene.px_area[]) else viewdir = cam.lookat[] - cam.eyeposition[] @@ -262,7 +262,7 @@ function add_translation!(scene, cam::Camera3D) diff = compute_diff(last_mousepos[] - mousepos) last_mousepos[] = mousepos dragging[] = false - translate_cam!(scene, cam, translationspeed[] * Vec3f0(diff[1], diff[2], 0f0)) + translate_cam!(scene, cam, translationspeed[] * Vec3f(diff[1], diff[2], 0f0)) update_cam!(scene, cam) return Consume(true) end @@ -276,7 +276,7 @@ function add_translation!(scene, cam::Camera3D) mousepos = screen_relative(scene, mp) diff = compute_diff(last_mousepos[] - mousepos) last_mousepos[] = mousepos - translate_cam!(scene, cam, translationspeed[] * Vec3f0(diff[1], diff[2], 0f0)) + translate_cam!(scene, cam, translationspeed[] * Vec3f(diff[1], diff[2], 0f0)) update_cam!(scene, cam) return Consume(true) end @@ -298,7 +298,7 @@ function add_rotation!(scene, cam::Camera3D) rotationspeed = cam.attributes[:mouse_rotationspeed] button = cam.attributes[:rotation_button] mod = cam.attributes[:rotation_modifier] - last_mousepos = RefValue(Vec2f0(0, 0)) + last_mousepos = RefValue(Vec2f(0, 0)) dragging = RefValue(false) e = events(scene) @@ -315,7 +315,7 @@ function add_rotation!(scene, cam::Camera3D) rot_scaling = rotationspeed[] * (e.window_dpi[] * 0.005) mp = (last_mousepos[] - mousepos) * 0.01f0 * rot_scaling last_mousepos[] = mousepos - rotate_cam!(scene, cam, Vec3f0(-mp[2], mp[1], 0f0), true) + rotate_cam!(scene, cam, Vec3f(-mp[2], mp[1], 0f0), true) update_cam!(scene, cam) return Consume(true) end @@ -330,7 +330,7 @@ function add_rotation!(scene, cam::Camera3D) rot_scaling = rotationspeed[] * (e.window_dpi[] * 0.005) mp = (last_mousepos[] .- mousepos) * 0.01f0 * rot_scaling last_mousepos[] = mousepos - rotate_cam!(scene, cam, Vec3f0(-mp[2], mp[1], 0f0), true) + rotate_cam!(scene, cam, Vec3f(-mp[2], mp[1], 0f0), true) update_cam!(scene, cam) return Consume(true) end @@ -354,7 +354,7 @@ function on_pulse(scene, cam, timestep) if translating # translation in camera space x/y/z direction translation = attr[:keyboard_translationspeed][] * timestep * - Vec3f0(right - left, up - down, backward - forward) + Vec3f(right - left, up - down, backward - forward) viewdir = cam.lookat[] - cam.eyeposition[] translate_cam!(scene, cam, cam.zoom_mult[] * norm(viewdir) * translation) end @@ -371,7 +371,7 @@ function on_pulse(scene, cam, timestep) if rotating # rotations around camera space x/y/z axes angles = attr[:keyboard_rotationspeed][] * timestep * - Vec3f0(up - down, left - right, counterclockwise - clockwise) + Vec3f(up - down, left - right, counterclockwise - clockwise) rotate_cam!(scene, cam, angles) end @@ -422,7 +422,7 @@ function translate_cam!(scene, cam, t) fix_y = ispressed(scene, cam.attributes[:fix_y_key][]) fix_z = ispressed(scene, cam.attributes[:fix_z_key][]) if fix_x || fix_y || fix_z - trans = Vec3f0(fix_x, fix_y, fix_z) .* trans + trans = Vec3f(fix_x, fix_y, fix_z) .* trans end cam.eyeposition[] = eyepos + trans @@ -441,14 +441,14 @@ function rotate_cam!(scene, cam::Camera3D, angles::VecTypes, from_mouse=false) right = cross(viewdir, up) # +x x_axis = right - y_axis = cam.attributes[:fixed_axis][] ? Vec3f0(0, 0, sign(up[3])) : up + y_axis = cam.attributes[:fixed_axis][] ? Vec3f(0, 0, sign(up[3])) : up z_axis = -viewdir fix_x = ispressed(scene, cam.attributes[:fix_x_key][]) fix_y = ispressed(scene, cam.attributes[:fix_y_key][]) fix_z = ispressed(scene, cam.attributes[:fix_z_key][]) cx, cy, cz = cam.attributes[:circular_rotation][] - rotation = Quaternionf0(0, 0, 0, 1) + rotation = Quaternionf(0, 0, 0, 1) if !xor(fix_x, fix_y, fix_z) # if there are more or less than one restriction apply all rotations rotation *= qrotation(y_axis, angles[2]) @@ -463,11 +463,11 @@ function rotate_cam!(scene, cam::Camera3D, angles::VecTypes, from_mouse=false) past_half = 0.5f0 .* widths(scene.px_area[]) .> mp flip = 2f0 * past_half .- 1f0 angle = flip[1] * angles[1] + flip[2] * angles[2] - angles = Vec3f0(-angle, angle, -angle) + angles = Vec3f(-angle, angle, -angle) # only one fix is true so this only rotates around one axis rotation *= qrotation( - Vec3f0(fix_x, fix_z, fix_y) .* Vec3f0(sign(right[1]), viewdir[2], sign(up[3])), - dot(Vec3f0(fix_x, fix_y, fix_z), angles) + Vec3f(fix_x, fix_z, fix_y) .* Vec3f(sign(right[1]), viewdir[2], sign(up[3])), + dot(Vec3f(fix_x, fix_y, fix_z), angles) ) else # restrict total quaternion rotation to one axis @@ -475,7 +475,7 @@ function rotate_cam!(scene, cam::Camera3D, angles::VecTypes, from_mouse=false) rotation *= qrotation(x_axis, angles[1]) rotation *= qrotation(z_axis, angles[3]) # the first three components are related to rotations around the x/y/z-axis - rotation = Quaternionf0(rotation.data .* (fix_x, fix_y, fix_z, 1)) + rotation = Quaternionf(rotation.data .* (fix_x, fix_y, fix_z, 1)) end end @@ -571,7 +571,7 @@ end function update_cam!(scene::Scene, camera::Camera3D, area3d::Rect) @extractvalue camera (lookat, eyeposition, upvector) - bb = FRect3D(area3d) + bb = Rect3f(area3d) width = widths(bb) half_width = width/2f0 middle = maximum(bb) - half_width @@ -579,7 +579,7 @@ function update_cam!(scene::Scene, camera::Camera3D, area3d::Rect) camera.lookat[] = middle neweyepos = middle .+ (1.2*norm(width) .* old_dir) camera.eyeposition[] = neweyepos - camera.upvector[] = Vec3f0(0,0,1) + camera.upvector[] = Vec3f(0,0,1) if camera.attributes[:near][] === automatic camera.near[] = 0.1f0 * norm(widths(bb)) end @@ -595,10 +595,10 @@ function update_cam!(scene::Scene, camera::Camera3D, area3d::Rect) return end -function update_cam!(scene::Scene, camera::Camera3D, eyeposition, lookat, up = Vec3f0(0, 0, 1)) - camera.lookat[] = Vec3f0(lookat) - camera.eyeposition[] = Vec3f0(eyeposition) - camera.upvector[] = Vec3f0(up) +function update_cam!(scene::Scene, camera::Camera3D, eyeposition, lookat, up = Vec3f(0, 0, 1)) + camera.lookat[] = Vec3f(lookat) + camera.eyeposition[] = Vec3f(eyeposition) + camera.upvector[] = Vec3f(up) update_cam!(scene, camera) return end diff --git a/src/camera/old_camera3d.jl b/src/camera/old_camera3d.jl index 76413c2376a..3c6030711b9 100644 --- a/src/camera/old_camera3d.jl +++ b/src/camera/old_camera3d.jl @@ -4,9 +4,9 @@ struct OldCamera3D <: AbstractCamera rotationspeed::Node{Float32} translationspeed::Node{Float32} - eyeposition::Node{Vec3f0} - lookat::Node{Vec3f0} - upvector::Node{Vec3f0} + eyeposition::Node{Vec3f} + lookat::Node{Vec3f} + upvector::Node{Vec3f} fov::Node{Float32} near::Node{Float32} far::Node{Float32} @@ -28,9 +28,9 @@ function old_cam3d_cad!(scene; kw_args...) Attributes( rotationspeed = 0.01, translationspeed = 1.0, - eyeposition = Vec3f0(3), - lookat = Vec3f0(0), - upvector = Vec3f0(0, 0, 1), + eyeposition = Vec3f(3), + lookat = Vec3f(0), + upvector = Vec3f(0, 0, 1), fov = 45f0, near = 0.01f0, far = 100f0, @@ -64,9 +64,9 @@ function old_cam3d_turntable!(scene; kw_args...) Attributes( rotationspeed = 0.01, translationspeed = 1.0, - eyeposition = Vec3f0(3), - lookat = Vec3f0(0), - upvector = Vec3f0(0, 0, 1), + eyeposition = Vec3f(3), + lookat = Vec3f(0), + upvector = Vec3f(0, 0, 1), fov = 45f0, near = 0.01f0, far = 100f0, @@ -99,7 +99,7 @@ the plot's axis. const old_cam3d! = old_cam3d_turntable! function projection_switch( - wh::Rect2D, + wh::Rect2, fov::T, near::T, far::T, projectiontype::ProjectionEnum, zoom::T ) where T <: Real @@ -138,7 +138,7 @@ end # TODO switch button and key because this is the wrong order function add_translation!(scene, cam, key, button, zoom_shift_lookat::Bool) - last_mousepos = RefValue(Vec2f0(0, 0)) + last_mousepos = RefValue(Vec2f(0, 0)) dragging = RefValue(false) on(camera(scene), scene.events.mousebutton) do event if event.button == key[] && ispressed(scene, button[]) @@ -151,7 +151,7 @@ function add_translation!(scene, cam, key, button, zoom_shift_lookat::Bool) dragging[] = false diff = (last_mousepos[] - mousepos) * cam.translationspeed[] last_mousepos[] = mousepos - translate_cam!(scene, cam, Vec3f0(0f0, diff[1], diff[2])) + translate_cam!(scene, cam, Vec3f(0f0, diff[1], diff[2])) return Consume(true) end end @@ -163,7 +163,7 @@ function add_translation!(scene, cam, key, button, zoom_shift_lookat::Bool) mousepos = screen_relative(scene, mp) diff = (last_mousepos[] .- mousepos) * cam.translationspeed[] last_mousepos[] = mousepos - translate_cam!(scene, cam, Vec3f0(0f0, diff[1], diff[2])) + translate_cam!(scene, cam, Vec3f(0f0, diff[1], diff[2])) return Consume(true) end return Consume(false) @@ -171,7 +171,7 @@ function add_translation!(scene, cam, key, button, zoom_shift_lookat::Bool) on(camera(scene), scene.events.scroll) do scroll if ispressed(scene, button[]) && is_mouseinside(scene) - cam_res = Vec2f0(widths(scene.px_area[])) + cam_res = Vec2f(widths(scene.px_area[])) mouse_pos_normalized = mouseposition_px(scene) ./ cam_res mouse_pos_normalized = 2*mouse_pos_normalized .- 1f0 zoom_step = scroll[2] @@ -183,7 +183,7 @@ function add_translation!(scene, cam, key, button, zoom_shift_lookat::Bool) end function add_rotation!(scene, cam, button, key, fixed_axis::Bool) - last_mousepos = RefValue(Vec2f0(0, 0)) + last_mousepos = RefValue(Vec2f(0, 0)) dragging = RefValue(false) e = events(scene) @@ -199,7 +199,7 @@ function add_rotation!(scene, cam, button, key, fixed_axis::Bool) rot_scaling = cam.rotationspeed[] * (e.window_dpi[] * 0.005) mp = (last_mousepos[] - mousepos) * rot_scaling last_mousepos[] = mousepos - rotate_cam!(scene, cam, Vec3f0(mp[1], -mp[2], 0f0), fixed_axis) + rotate_cam!(scene, cam, Vec3f(mp[1], -mp[2], 0f0), fixed_axis) return Consume(true) end end @@ -212,7 +212,7 @@ function add_rotation!(scene, cam, button, key, fixed_axis::Bool) rot_scaling = cam.rotationspeed[] * (e.window_dpi[] * 0.005) mp = (last_mousepos[] .- mousepos) * rot_scaling last_mousepos[] = mousepos - rotate_cam!(scene, cam, Vec3f0(mp[1], -mp[2], 0f0), fixed_axis) + rotate_cam!(scene, cam, Vec3f(mp[1], -mp[2], 0f0), fixed_axis) return Consume(true) end return Consume(false) @@ -226,17 +226,17 @@ Translate the camera to the given coordinates. """ translate_cam!(scene::Scene, translation::VecTypes) = translate_cam!(scene, cameracontrols(scene), translation) function translate_cam!(scene::Scene, cam::OldCamera3D, _translation::VecTypes) - translation = Vec3f0(_translation) - translation == Vec3f0(0) && return + translation = Vec3f(_translation) + translation == Vec3f(0) && return @extractvalue cam (projectiontype, lookat, eyeposition, upvector) dir = eyeposition - lookat dir_len = norm(dir) - cam_res = Vec2f0(widths(scene.px_area[])) + cam_res = Vec2f(widths(scene.px_area[])) z, x, y = translation z *= 0.1f0 * dir_len - x, y = (Vec2f0(x, y) ./ cam_res) .* dir_len + x, y = (Vec2f(x, y) ./ cam_res) .* dir_len dir_norm = normalize(dir) right = normalize(cross(dir_norm, upvector)) @@ -263,9 +263,9 @@ function zoom!(scene, point::VecTypes, zoom_step, shift_lookat::Bool) # split zoom into two components: # the offset perpendicular to `eyeposition - lookat`, based on mouse offset ~ ray_dir # the offset parallel to `eyeposition - lookat` ~ dir - ray_eye = inv(scene.camera.projection[]) * Vec4f0(point[1],point[2],0,0) - ray_eye = Vec4f0(ray_eye[1:2]...,0,0) - ray_dir = Vec3f0((inv(scene.camera.view[]) * ray_eye)) + ray_eye = inv(scene.camera.projection[]) * Vec4f(point[1],point[2],0,0) + ray_eye = Vec4f(ray_eye[1:2]...,0,0) + ray_dir = Vec3f((inv(scene.camera.view[]) * ray_eye)) dir = eyeposition - lookat @@ -299,14 +299,14 @@ the camera according to the Euler angles (α, β, γ). rotate_cam!(scene::Scene, theta_v::Number...) = rotate_cam!(scene, cameracontrols(scene), theta_v) rotate_cam!(scene::Scene, theta_v::VecTypes) = rotate_cam!(scene, cameracontrols(scene), theta_v) function rotate_cam!(scene::Scene, cam::OldCamera3D, _theta_v::VecTypes, fixed_axis::Bool = true) - theta_v = Vec3f0(_theta_v) - theta_v == Vec3f0(0) && return #nothing to do! + theta_v = Vec3f(_theta_v) + theta_v == Vec3f(0) && return #nothing to do! @extractvalue cam (eyeposition, lookat, upvector) dir = normalize(eyeposition - lookat) right_v = normalize(cross(upvector, dir)) upvector = normalize(cross(dir, right_v)) - axis = fixed_axis ? Vec3f0(0, 0, sign(upvector[3])) : upvector + axis = fixed_axis ? Vec3f(0, 0, sign(upvector[3])) : upvector rotation = rotate_cam(theta_v, right_v, axis, dir) r_eyepos = lookat + rotation * (eyeposition - lookat) r_up = normalize(rotation * upvector) @@ -334,7 +334,7 @@ end function update_cam!(scene::Scene, camera::OldCamera3D, area3d::Rect) @extractvalue camera (fov, near, lookat, eyeposition, upvector) - bb = FRect3D(area3d) + bb = Rect3f(area3d) width = widths(bb) half_width = width/2f0 middle = maximum(bb) - half_width @@ -342,7 +342,7 @@ function update_cam!(scene::Scene, camera::OldCamera3D, area3d::Rect) camera.lookat[] = middle neweyepos = middle .+ (1.2*norm(width) .* old_dir) camera.eyeposition[] = neweyepos - camera.upvector[] = Vec3f0(0,0,1) + camera.upvector[] = Vec3f(0,0,1) camera.near[] = 0.1f0 * norm(widths(bb)) camera.far[] = 3f0 * norm(widths(bb)) update_cam!(scene, camera) @@ -350,16 +350,16 @@ function update_cam!(scene::Scene, camera::OldCamera3D, area3d::Rect) end """ - update_cam!(scene::Scene, eyeposition, lookat, up = Vec3f0(0, 0, 1)) + update_cam!(scene::Scene, eyeposition, lookat, up = Vec3f(0, 0, 1)) Updates the camera's controls to point to the specified location. """ -update_cam!(scene::Scene, eyeposition, lookat, up = Vec3f0(0, 0, 1)) = update_cam!(scene, cameracontrols(scene), eyeposition, lookat, up) +update_cam!(scene::Scene, eyeposition, lookat, up = Vec3f(0, 0, 1)) = update_cam!(scene, cameracontrols(scene), eyeposition, lookat, up) -function update_cam!(scene::Scene, camera::OldCamera3D, eyeposition, lookat, up = Vec3f0(0, 0, 1)) - camera.lookat[] = Vec3f0(lookat) - camera.eyeposition[] = Vec3f0(eyeposition) - camera.upvector[] = Vec3f0(up) +function update_cam!(scene::Scene, camera::OldCamera3D, eyeposition, lookat, up = Vec3f(0, 0, 1)) + camera.lookat[] = Vec3f(lookat) + camera.eyeposition[] = Vec3f(eyeposition) + camera.upvector[] = Vec3f(up) update_cam!(scene, camera) return end diff --git a/src/camera/projection_math.jl b/src/camera/projection_math.jl index 831010d3acc..ce9dbbb2629 100644 --- a/src/camera/projection_math.jl +++ b/src/camera/projection_math.jl @@ -111,12 +111,12 @@ end projection ratio in terms of the rectangular view size `rect` rather than the aspect ratio. """ -function perspectiveprojection(wh::Rect2D, fov::T, near::T, far::T) where T +function perspectiveprojection(wh::Rect2, fov::T, near::T, far::T) where T perspectiveprojection(fov, T(wh.w/wh.h), near, far) end function perspectiveprojection( - ::Type{T}, wh::Rect2D, fov::Number, near::Number, far::Number + ::Type{T}, wh::Rect2, fov::Number, near::Number, far::Number ) where T perspectiveprojection(T(fov), T(wh.w/wh.h), T(near), T(far)) end @@ -146,12 +146,12 @@ function lookat(::Type{T}, eyePos::Vec{3}, lookAt::Vec{3}, up::Vec{3}) where T lookat(Vec{3,T}(eyePos), Vec{3,T}(lookAt), Vec{3,T}(up)) end -function orthographicprojection(wh::Rect2D, near::T, far::T) where T +function orthographicprojection(wh::Rect2, near::T, far::T) where T orthographicprojection(zero(T), T(wh.w), zero(T), T(wh.h), near, far) end function orthographicprojection( - ::Type{T}, wh::Rect2D, near::Number, far::Number + ::Type{T}, wh::Rect2, near::Number, far::Number ) where T orthographicprojection(wh, T(near), T(far)) end @@ -218,7 +218,7 @@ end function transformationmatrix(translation, scale, rotation::Quaternion) trans_scale = transformationmatrix(translation, scale) - rotation = Mat4f0(rotation) + rotation = Mat4f(rotation) trans_scale*rotation end @@ -231,14 +231,14 @@ end function transformationmatrix( translation::Vec{3}, scale::Vec{3}, rotation::Quaternion, - align, flip::NTuple{3, Bool}, boundingbox::Rect3D + align, flip::NTuple{3, Bool}, boundingbox::Rect3 ) full_width = widths(boundingbox) mini = minimum(boundingbox) half_width = full_width ./ 2 to_origin = (half_width + mini) if isnan(to_origin) - to_origin = Vec3f0(0) + to_origin = Vec3f(0) end align_middle = translationmatrix(-to_origin) align_back = translationmatrix(to_origin) @@ -246,7 +246,7 @@ function transformationmatrix( flipped = align_back * scalematrix(flipsign) * align_middle aligned = flipped #translationmatrix(align .* full_width) * flipped trans_scale = transformationmatrix(translation, scale) - rotation = Mat4f0(rotation) + rotation = Mat4f(rotation) aligned * trans_scale * rotation end @@ -284,7 +284,7 @@ function to_world(scene::Scene, point::T) where T <: StaticVector inv(cam.projection[]), T(widths(pixelarea(scene)[])) ) - Point2f0(x[1], x[2]) + Point2f(x[1], x[2]) end w_component(x::Point) = 1.0 @@ -320,29 +320,29 @@ function project(scene::Scene, point::T) where T<:StaticVector cam.projection[] * cam.view[] * transformationmatrix(scene)[], - Vec2f0(widths(pixelarea(scene)[])), point + Vec2f(widths(pixelarea(scene)[])), point ) end -function project(matrix::Mat4f0, p::T, dim4 = 1.0) where T <: VecTypes - p = to_ndim(Vec4f0, to_ndim(Vec3f0, p, 0.0), dim4) +function project(matrix::Mat4f, p::T, dim4 = 1.0) where T <: VecTypes + p = to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), dim4) p = matrix * p to_ndim(T, p, 0.0) end -function project(proj_view::Mat4f0, resolution::Vec2, point::Point) - p4d = to_ndim(Vec4f0, to_ndim(Vec3f0, point, 0f0), 1f0) +function project(proj_view::Mat4f, resolution::Vec2, point::Point) + p4d = to_ndim(Vec4f, to_ndim(Vec3f, point, 0f0), 1f0) clip = proj_view * p4d p = (clip / clip[4])[Vec(1, 2)] - p = Vec2f0(p[1], p[2]) + p = Vec2f(p[1], p[2]) return (((p .+ 1f0) / 2f0) .* (resolution .- 1f0)) .+ 1f0 end function project_point2(mat4::Mat4, point2::Point2) - Point2f0(mat4 * to_ndim(Point4f0, to_ndim(Point3f0, point2, 0), 1)) + Point2f(mat4 * to_ndim(Point4f, to_ndim(Point3f, point2, 0), 1)) end function transform(model::Mat4, x::T) where T - x4d = to_ndim(Vec4f0, x, 0.0) + x4d = to_ndim(Vec4f, x, 0.0) to_ndim(T, model * x4d, 0.0) end diff --git a/src/colorsampler.jl b/src/colorsampler.jl index 993dcc92c06..8d2d8b12448 100644 --- a/src/colorsampler.jl +++ b/src/colorsampler.jl @@ -11,7 +11,7 @@ Scaling() = Scaling(identity, nothing) const NoScaling = Scaling{typeof(identity), Nothing} -struct Sampler{N, V} <: AbstractArray{RGBAf0, 1} +struct Sampler{N, V} <: AbstractArray{RGBAf, 1} # the colors to sample from! colors::AbstractArray{T, N} where T # or an array of values, which are used to index into colors via interpolation! @@ -83,7 +83,7 @@ function apply_scaling(value::Number, scaling::Scaling)::Float64 end end -function Base.getindex(sampler::Sampler, i)::RGBAf0 +function Base.getindex(sampler::Sampler, i)::RGBAf value = sampler.values[i] scaled = apply_scaling(value, sampler.scaling) c = if sampler.interpolation == Linear @@ -91,10 +91,10 @@ function Base.getindex(sampler::Sampler, i)::RGBAf0 else nearest_getindex(sampler.colors, scaled) end - return RGBAf0(color(c), alpha(c) * sampler.alpha) + return RGBAf(color(c), alpha(c) * sampler.alpha) end -function Base.getindex(sampler::Sampler{2, <: AbstractVector{Vec2f0}}, i)::RGBAf0 +function Base.getindex(sampler::Sampler{2, <: AbstractVector{Vec2f}}, i)::RGBAf uv = sampler.values[i] colors = sampler.colors # indexing confirming to OpenGL uv indexing @@ -102,7 +102,7 @@ function Base.getindex(sampler::Sampler{2, <: AbstractVector{Vec2f0}}, i)::RGBAf wh = wsize .- 1 x, y = round.(Int, Tuple(uv) .* wh) .+ 1 c = colors[size(colors, 1) - (y - 1), x] - return RGBAf0(color(c), alpha(c) * sampler.alpha) + return RGBAf(color(c), alpha(c) * sampler.alpha) end function sampler(cmap::Union{Symbol, String}, n::Int = 20; @@ -122,7 +122,7 @@ end function sampler(cmap::Vector{<: Colorant}, values::AbstractVector{<: AbstractFloat}; scaling=Scaling(), alpha=1.0, interpolation=Linear) - return Sampler(RGBAf0.(cmap), values, alpha, interpolation, scaling) + return Sampler(RGBAf.(cmap), values, alpha, interpolation, scaling) end function sampler(cmap::AbstractVector, values, crange; @@ -130,7 +130,7 @@ function sampler(cmap::AbstractVector, values, crange; return Sampler(to_color.(cmap), values, alpha, interpolation, Scaling(identity, crange)) end # uv texture sampler -function sampler(cmap::Matrix{<: Colorant}, uv::AbstractVector{Vec2f0}; +function sampler(cmap::Matrix{<: Colorant}, uv::AbstractVector{Vec2f}; alpha=1.0, interpolation=Linear) return Sampler(cmap, uv, alpha, interpolation, Scaling()) end diff --git a/src/conversions.jl b/src/conversions.jl index cb54be0f146..7877259d525 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -102,7 +102,7 @@ Enables to use scatter like a surface plot with x::Vector, y::Vector, z::Matrix spanning z over the grid spanned by x y """ function convert_arguments(::PointBased, x::AbstractVector, y::AbstractVector, z::AbstractMatrix) - (vec(Point3f0.(x, y', z)),) + (vec(Point3f.(x, y', z)),) end """ convert_arguments(P, x, y, z)::(Vector) @@ -111,7 +111,7 @@ Takes vectors `x`, `y`, and `z` and turns it into a vector of 3D points of the v from `x`, `y`, and `z`. `P` is the plot Type (it is optional). """ -convert_arguments(::PointBased, x::RealVector, y::RealVector, z::RealVector) = (Point3f0.(x, y, z),) +convert_arguments(::PointBased, x::RealVector, y::RealVector, z::RealVector) = (Point3f.(x, y, z),) """ convert_arguments(P, x)::(Vector) @@ -125,9 +125,9 @@ function convert_arguments(::PointBased, pos::AbstractMatrix{<: Number}) (to_vertices(pos),) end -convert_arguments(P::PointBased, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}) = (Point2f0.(x, y),) +convert_arguments(P::PointBased, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}) = (Point2f.(x, y),) -convert_arguments(P::PointBased, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}, z::AbstractVector{<:Real}) = (Point3f0.(x, y, z),) +convert_arguments(P::PointBased, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}, z::AbstractVector{<:Real}) = (Point3f.(x, y, z),) """ convert_arguments(P, y)::Vector @@ -146,7 +146,7 @@ from `x` and `y`. `P` is the plot Type (it is optional). """ -#convert_arguments(::PointBased, x::RealVector, y::RealVector) = (Point2f0.(x, y),) +#convert_arguments(::PointBased, x::RealVector, y::RealVector) = (Point2f.(x, y),) convert_arguments(P::PointBased, x::ClosedInterval, y::RealVector) = convert_arguments(P, LinRange(extrema(x)..., length(y)), y) convert_arguments(P::PointBased, x::RealVector, y::ClosedInterval) = convert_arguments(P, x, LinRange(extrema(y)..., length(x))) @@ -158,13 +158,13 @@ Takes an input `Rect` `x` and decomposes it to points. `P` is the plot Type (it is optional). """ -function convert_arguments(P::PointBased, x::Rect2D) +function convert_arguments(P::PointBased, x::Rect2) # TODO fix the order of decompose - return convert_arguments(P, decompose(Point2f0, x)[[1, 2, 4, 3, 1]]) + return convert_arguments(P, decompose(Point2f, x)[[1, 2, 4, 3, 1]]) end function convert_arguments(P::PointBased, mesh::AbstractMesh) - return convert_arguments(P, decompose(Point3f0, mesh)) + return convert_arguments(P, decompose(Point3f, mesh)) end function convert_arguments(PB::PointBased, linesegments::FaceView{<:Line, P}) where {P<:AbstractPoint} @@ -172,13 +172,13 @@ function convert_arguments(PB::PointBased, linesegments::FaceView{<:Line, P}) wh return convert_arguments(PB, collect(reinterpret(P, linesegments))) end -function convert_arguments(P::PointBased, x::Rect3D) +function convert_arguments(P::PointBased, x::Rect3) inds = [ 1, 2, 3, 4, 5, 6, 7, 8, 1, 5, 5, 7, 7, 3, 1, 3, 4, 8, 8, 6, 2, 4, 2, 6 ] - convert_arguments(P, decompose(Point3f0, x)[inds]) + convert_arguments(P, decompose(Point3f, x)[inds]) end """ @@ -199,7 +199,7 @@ Takes an input `Array{LineString}` or a `MultiLineString` and decomposes it to p function convert_arguments(PB::PointBased, linestring::Union{Array{<:LineString}, MultiLineString}) arr = copy(convert_arguments(PB, linestring[1])[1]) for ls in 2:length(linestring) - push!(arr, Point2f0(NaN)) + push!(arr, Point2f(NaN)) append!(arr, convert_arguments(PB, linestring[ls])[1]) end return (arr,) @@ -216,7 +216,7 @@ function convert_arguments(PB::PointBased, pol::Polygon) return convert_arguments(PB, pol.exterior) else arr = copy(convert_arguments(PB, pol.exterior)[1]) - push!(arr, Point2f0(NaN)) + push!(arr, Point2f(NaN)) append!(arr, convert_arguments(PB, pol.interiors)[1]) return (arr,) end @@ -231,7 +231,7 @@ Takes an input `Array{Polygon}` or a `MultiPolygon` and decomposes it to points. function convert_arguments(PB::PointBased, mp::Union{Array{<:Polygon}, MultiPolygon}) arr = copy(convert_arguments(PB, mp[1])[1]) for p in 2:length(mp) - push!(arr, Point2f0(NaN)) + push!(arr, Point2f(NaN)) append!(arr, convert_arguments(PB, mp[p])[1]) end return (arr,) @@ -418,9 +418,9 @@ function convert_arguments(::Type{<: LineSegments}, positions::AbstractVector{E} (elconvert(Point{N, Float32}, reinterpret(Point{N, T}, positions)),) end -function convert_arguments(::Type{<: LineSegments}, x::Rect2D) +function convert_arguments(::Type{<: LineSegments}, x::Rect2) # TODO fix the order of decompose - points = decompose(Point2f0, x) + points = decompose(Point2f, x) return (points[[1, 2, 2, 4, 4, 3, 3, 1]],) end @@ -450,7 +450,7 @@ function convert_arguments( T::Type{<:Mesh}, x::RealVector, y::RealVector, z::RealVector ) - convert_arguments(T, Point3f0.(x, y, z)) + convert_arguments(T, Point3f.(x, y, z)) end """ convert_arguments(Mesh, xyz::AbstractVector)::GLNormalMesh @@ -473,7 +473,7 @@ function convert_arguments(::Type{<:Mesh}, mesh::GeometryBasics.Mesh{N}) where { n = normals(mesh) # Normals can be nothing, when it's impossible to calculate the normals (e.g. 2d mesh) if n !== nothing - mesh = GeometryBasics.pointmeta(mesh, decompose(Vec3f0, n)) + mesh = GeometryBasics.pointmeta(mesh, decompose(Vec3f, n)) end end return (GeometryBasics.mesh(mesh, pointtype=Point{N, Float32}, facetype=GLTriangleFace),) @@ -510,7 +510,7 @@ function convert_arguments( x::RealVector, y::RealVector, z::RealVector, indices::AbstractVector ) - return convert_arguments(T, Point3f0.(x, y, z), indices) + return convert_arguments(T, Point3f.(x, y, z), indices) end """ @@ -635,7 +635,7 @@ end to_vertices(v) Converts a representation of vertices `v` to its canonical representation as a -`Vector{Point3f0}`. `v` can be: +`Vector{Point3f}`. `v` can be: - An `AbstractVector` of 3-element `Tuple`s or `StaticVector`s, @@ -647,12 +647,12 @@ Converts a representation of vertices `v` to its canonical representation as a - otherwise if `v` has 2 or 3 columns, it will treat each row as a vertex. """ function to_vertices(verts::AbstractVector{<: VecTypes{3, T}}) where T - vert3f0 = T != Float32 ? Point3f0.(verts) : verts - return reinterpret(Point3f0, vert3f0) + vert3f0 = T != Float32 ? Point3f.(verts) : verts + return reinterpret(Point3f, vert3f0) end function to_vertices(verts::AbstractVector{<: VecTypes}) - to_vertices(to_ndim.(Point3f0, verts, 0.0)) + to_vertices(to_ndim.(Point3f, verts, 0.0)) end function to_vertices(verts::AbstractMatrix{<: Number}) @@ -672,7 +672,7 @@ function to_vertices(verts::AbstractMatrix{T}, ::Val{1}) where T <: Number else let N = Val(N), lverts = verts broadcast(1:size(verts, 2), N) do vidx, n - to_ndim(Point3f0, ntuple(i-> lverts[i, vidx], n), 0.0) + to_ndim(Point3f, ntuple(i-> lverts[i, vidx], n), 0.0) end end end @@ -681,7 +681,7 @@ end function to_vertices(verts::AbstractMatrix{T}, ::Val{2}) where T <: Number let N = Val(size(verts, 2)), lverts = verts broadcast(1:size(verts, 1), N) do vidx, n - to_ndim(Point3f0, ntuple(i-> lverts[vidx, i], n), 0.0) + to_ndim(Point3f, ntuple(i-> lverts[vidx, i], n), 0.0) end end end @@ -737,7 +737,7 @@ function convert_attribute(c::String, ::key"color") return parse(RGBA{Float32}, c) end -# Do we really need all colors to be RGBAf0?! +# Do we really need all colors to be RGBAf?! convert_attribute(c::AbstractArray{<: Colorant}, k::key"color") = el32convert(c) convert_attribute(c::AbstractArray, k::key"color") = to_color.(c) @@ -747,7 +747,7 @@ convert_attribute(c::Tuple, k::key"color") = convert_attribute.(c, k) convert_attribute(p::AbstractPattern, k::key"color") = p function convert_attribute(c::Tuple{T, F}, k::key"color") where {T, F <: Number} - RGBAf0(Colors.color(to_color(c[1])), c[2]) + RGBAf(Colors.color(to_color(c[1])), c[2]) end convert_attribute(b::Billboard{Float32}, ::key"rotations") = to_rotation(b.rotation) @@ -759,16 +759,16 @@ convert_attribute(r, ::key"rotations") = to_rotation(r) convert_attribute(c, ::key"markersize", ::key"scatter") = to_2d_scale(c) convert_attribute(c, k1::key"markersize", k2::key"meshscatter") = to_3d_scale(c) -convert_attribute(x, ::key"uv_offset_width") = Vec4f0(x) -convert_attribute(x::AbstractVector{Vec4f0}, ::key"uv_offset_width") = x +convert_attribute(x, ::key"uv_offset_width") = Vec4f(x) +convert_attribute(x::AbstractVector{Vec4f}, ::key"uv_offset_width") = x -to_2d_scale(x::Number) = Vec2f0(x) -to_2d_scale(x::VecTypes) = to_ndim(Vec2f0, x, 1) -to_2d_scale(x::Tuple{<:Number, <:Number}) = to_ndim(Vec2f0, x, 1) +to_2d_scale(x::Number) = Vec2f(x) +to_2d_scale(x::VecTypes) = to_ndim(Vec2f, x, 1) +to_2d_scale(x::Tuple{<:Number, <:Number}) = to_ndim(Vec2f, x, 1) to_2d_scale(x::AbstractVector) = to_2d_scale.(x) -to_3d_scale(x::Number) = Vec3f0(x) -to_3d_scale(x::VecTypes) = to_ndim(Vec3f0, x, 1) +to_3d_scale(x::Number) = Vec3f(x) +to_3d_scale(x::VecTypes) = to_ndim(Vec3f, x, 1) to_3d_scale(x::AbstractVector) = to_3d_scale.(x) convert_attribute(c::Number, ::key"glowwidth") = Float32(c) @@ -887,15 +887,15 @@ function convert_attribute(f::Symbol, ::key"frames") end convert_attribute(f::Tuple{Tuple{Bool,Bool},Tuple{Bool,Bool}}, ::key"frames") = f -convert_attribute(c::Tuple{<: Number, <: Number}, ::key"position") = Point2f0(c[1], c[2]) -convert_attribute(c::Tuple{<: Number, <: Number, <: Number}, ::key"position") = Point3f0(c) +convert_attribute(c::Tuple{<: Number, <: Number}, ::key"position") = Point2f(c[1], c[2]) +convert_attribute(c::Tuple{<: Number, <: Number, <: Number}, ::key"position") = Point3f(c) convert_attribute(c::VecTypes{N}, ::key"position") where N = Point{N, Float32}(c) """ Text align, e.g.: """ -convert_attribute(x::Tuple{Symbol, Symbol}, ::key"align") = Vec2f0(alignment2num.(x)) -convert_attribute(x::Vec2f0, ::key"align") = x +convert_attribute(x::Tuple{Symbol, Symbol}, ::key"align") = Vec2f(alignment2num.(x)) +convert_attribute(x::Vec2f, ::key"align") = x const _font_cache = Dict{String, NativeFont}() @@ -941,35 +941,35 @@ convert_attribute(x::NativeFont, k::key"font") = x to_rotation(b, tuple_float) to_rotation(b, vec4) """ -convert_attribute(s::Quaternionf0, ::key"rotation") = s -convert_attribute(s::Quaternion, ::key"rotation") = Quaternionf0(s.data...) +convert_attribute(s::Quaternionf, ::key"rotation") = s +convert_attribute(s::Quaternion, ::key"rotation") = Quaternionf(s.data...) function convert_attribute(s::VecTypes{N}, ::key"rotation") where N if N == 4 - Quaternionf0(s...) + Quaternionf(s...) elseif N == 3 - rotation_between(Vec3f0(0, 0, 1), to_ndim(Vec3f0, s, 0.0)) + rotation_between(Vec3f(0, 0, 1), to_ndim(Vec3f, s, 0.0)) elseif N == 2 - rotation_between(Vec3f0(0, 1, 0), to_ndim(Vec3f0, s, 0.0)) + rotation_between(Vec3f(0, 1, 0), to_ndim(Vec3f, s, 0.0)) else error("The $N dimensional vector $s can't be converted to a rotation.") end end function convert_attribute(s::Tuple{VecTypes, AbstractFloat}, ::key"rotation") - qrotation(to_ndim(Vec3f0, s[1], 0.0), s[2]) + qrotation(to_ndim(Vec3f, s[1], 0.0), s[2]) end -convert_attribute(angle::AbstractFloat, ::key"rotation") = qrotation(Vec3f0(0, 0, 1), Float32(angle)) +convert_attribute(angle::AbstractFloat, ::key"rotation") = qrotation(Vec3f(0, 0, 1), Float32(angle)) convert_attribute(r::AbstractVector, k::key"rotation") = to_rotation.(r) -convert_attribute(r::AbstractVector{<: Quaternionf0}, k::key"rotation") = r +convert_attribute(r::AbstractVector{<: Quaternionf}, k::key"rotation") = r -convert_attribute(x, k::key"colorrange") = x==nothing ? nothing : Vec2f0(x) +convert_attribute(x, k::key"colorrange") = x==nothing ? nothing : Vec2f(x) convert_attribute(x, k::key"textsize") = Float32(x) convert_attribute(x::AbstractVector, k::key"textsize") = convert_attribute.(x, k) convert_attribute(x::AbstractVector{T}, k::key"textsize") where T <: Number = el32convert(x) -convert_attribute(x::AbstractVector{T}, k::key"textsize") where T <: VecTypes = elconvert(Vec2f0, x) +convert_attribute(x::AbstractVector{T}, k::key"textsize") where T <: VecTypes = elconvert(Vec2f, x) convert_attribute(x, k::key"linewidth") = Float32(x) convert_attribute(x::AbstractVector, k::key"linewidth") = el32convert(x) @@ -1036,11 +1036,11 @@ function convert_attribute(cs::Union{Tuple, Pair}, ::key"colormap", n::Int=2) end function convert_attribute(cs::Tuple{<: Union{Symbol, AbstractString}, Real}, ::key"colormap", n::Int=30) - return RGBAf0.(to_colormap(cs[1]), cs[2]) # We need to rework this to conform to the backend interface. + return RGBAf.(to_colormap(cs[1]), cs[2]) # We need to rework this to conform to the backend interface. end function convert_attribute(cs::NamedTuple{(:colormap, :alpha, :n), Tuple{Union{Symbol, AbstractString}, Real, Int}}, ::key"colormap") - return RGBAf0.(to_colormap(cs.colormap, cs.n), cs.alpha) + return RGBAf.(to_colormap(cs.colormap, cs.n), cs.alpha) end to_colormap(x, n::Integer) = convert_attribute(x, key"colormap"(), n) @@ -1165,8 +1165,8 @@ struct FastPixel end to_spritemarker(x::FastPixel) = x to_spritemarker(x::Circle) = x -to_spritemarker(::Type{<: Circle}) = Circle(Point2f0(0), 1f0) -to_spritemarker(::Type{<: Rect}) = Rect(Vec2f0(0), Vec2f0(1)) +to_spritemarker(::Type{<: Circle}) = Circle(Point2f(0), 1f0) +to_spritemarker(::Type{<: Rect}) = Rect(Vec2f(0), Vec2f(1)) to_spritemarker(x::Rect) = x """ @@ -1220,7 +1220,7 @@ convert_attribute(value, ::key"isorange", ::key"volume") = Float32(value) function convert_attribute(value::Symbol, ::key"marker", ::key"meshscatter") if value == :Sphere - return normal_mesh(Sphere(Point3f0(0), 1f0)) + return normal_mesh(Sphere(Point3f(0), 1f0)) else error("Unsupported marker: $(value)") end diff --git a/src/deprecated.jl b/src/deprecated.jl new file mode 100644 index 00000000000..3d102b689b1 --- /dev/null +++ b/src/deprecated.jl @@ -0,0 +1,3 @@ +Base.@deprecate_binding Quaternionf0 Quaternionf +Base.@deprecate_binding RGBf0 RGBf +Base.@deprecate_binding RGBAf0 RGBAf diff --git a/src/display.jl b/src/display.jl index 6e26d810fbb..609352c3e2f 100644 --- a/src/display.jl +++ b/src/display.jl @@ -136,12 +136,12 @@ end mutable struct RamStepper scene::Scene - images::Vector{Matrix{RGBf0}} + images::Vector{Matrix{RGBf}} format::Symbol end Stepper(scene::FigureLike, path::String, step::Int; format=:png) = FolderStepper(get_scene(scene), path, format, step) -Stepper(scene::FigureLike; format=:png) = RamStepper(get_scene(scene), Matrix{RGBf0}[], format) +Stepper(scene::FigureLike; format=:png) = RamStepper(get_scene(scene), Matrix{RGBf}[], format) function Stepper(scene::FigureLike, path::String; format = :png) ispath(path) || mkpath(path) @@ -161,7 +161,7 @@ function step!(s::FolderStepper) end function step!(s::RamStepper) - img = convert(Matrix{RGBf0}, colorbuffer(s.scene)) + img = convert(Matrix{RGBf}, colorbuffer(s.scene)) push!(s.images, img) return s end @@ -551,7 +551,7 @@ If you want a more tweakable interface, consider using [`VideoStream`](@ref) and fig, ax, p = lines(rand(10)) record(fig, "test.gif") do io for i in 1:255 - p[:color] = RGBf0(i/255, (255 - i)/255, 0) # animate figure + p[:color] = RGBf(i/255, (255 - i)/255, 0) # animate figure recordframe!(io) end end @@ -560,7 +560,7 @@ or ```julia fig, ax, p = lines(rand(10)) record(fig, "test.gif", 1:255) do i - p[:color] = RGBf0(i/255, (255 - i)/255, 0) # animate figure + p[:color] = RGBf(i/255, (255 - i)/255, 0) # animate figure end ``` diff --git a/src/interaction/inspector.jl b/src/interaction/inspector.jl index 8bdb8830060..4a20fe491ce 100644 --- a/src/interaction/inspector.jl +++ b/src/interaction/inspector.jl @@ -7,7 +7,7 @@ vec2string(p::StaticVector{3}) = @sprintf("(%0.3f, %0.3f, %0.3f)", p[1], p[2], p position2string(p::StaticVector{2}) = @sprintf("x: %0.6f\ny: %0.6f", p[1], p[2]) position2string(p::StaticVector{3}) = @sprintf("x: %0.6f\ny: %0.6f\nz: %0.6f", p[1], p[2], p[3]) -function bbox2string(bbox::Rect3D) +function bbox2string(bbox::Rect3) p0 = origin(bbox) p1 = p0 .+ widths(bbox) @sprintf( @@ -21,7 +21,7 @@ function bbox2string(bbox::Rect3D) ) end -function bbox2string(bbox::Rect2D) +function bbox2string(bbox::Rect2) p0 = origin(bbox) p1 = p0 .+ widths(bbox) @sprintf( @@ -37,7 +37,7 @@ end color2text(c::AbstractFloat) = @sprintf("%0.3f", c) color2text(c::Symbol) = string(c) color2text(c) = color2text(to_color(c)) -function color2text(c::RGBAf0) +function color2text(c::RGBAf) if c.alpha == 1.0 @sprintf("RGB(%0.2f, %0.2f, %0.2f)", c.r, c.g, c.b) else @@ -55,9 +55,9 @@ end ### dealing with markersize and rotations ######################################## -_to_scale(f::AbstractFloat, idx) = Vec3f0(f) -_to_scale(v::Vec2f0, idx) = Vec3f0(v[1], v[2], 1) -_to_scale(v::Vec3f0, idx) = v +_to_scale(f::AbstractFloat, idx) = Vec3f(f) +_to_scale(v::Vec2f, idx) = Vec3f(v[1], v[2], 1) +_to_scale(v::Vec3f, idx) = v _to_scale(v::Vector, idx) = _to_scale(v[idx], idx) _to_rotation(x, idx) = to_rotation(x) @@ -67,7 +67,7 @@ _to_rotation(x::Vector, idx) = to_rotation(x[idx]) ### Selecting a point on a nearby line ######################################## -function closest_point_on_line(p0::Point2f0, p1::Point2f0, r::Point2f0) +function closest_point_on_line(p0::Point2f, p1::Point2f, r::Point2f) # This only works in 2D AP = P .- A; AB = B .- A A .+ AB * dot(AP, AB) / dot(AB, AB) @@ -77,20 +77,20 @@ function view_ray(scene) inv_projview = inv(camera(scene).projectionview[]) view_ray(inv_projview, events(scene).mouseposition[], pixelarea(scene)[]) end -function view_ray(inv_view_proj, mpos, area::Rect2D) +function view_ray(inv_view_proj, mpos, area::Rect2) # This figures out the camera view direction from the projectionview matrix (?) # and computes a ray from a near and a far point. # Based on ComputeCameraRay from ImGuizmo mp = 2f0 .* (mpos .- minimum(area)) ./ widths(area) .- 1f0 - v = inv_view_proj * Vec4f0(0, 0, -10, 1) + v = inv_view_proj * Vec4f(0, 0, -10, 1) reversed = v[3] < v[4] near = reversed ? 1f0 - 1e-6 : 0f0 far = reversed ? 0f0 : 1f0 - 1e-6 - origin = inv_view_proj * Vec4f0(mp[1], mp[2], near, 1f0) + origin = inv_view_proj * Vec4f(mp[1], mp[2], near, 1f0) origin = origin[SOneTo(3)] ./ origin[4] - p = inv_view_proj * Vec4f0(mp[1], mp[2], far, 1f0) + p = inv_view_proj * Vec4f(mp[1], mp[2], far, 1f0) p = p[SOneTo(3)] ./ p[4] dir = normalize(p - origin) @@ -101,13 +101,13 @@ end # These work in 2D and 3D function closest_point_on_line(A, B, origin, dir) closest_point_on_line( - to_ndim(Point3f0, A, 0), - to_ndim(Point3f0, B, 0), - to_ndim(Point3f0, origin, 0), - to_ndim(Vec3f0, dir, 0) + to_ndim(Point3f, A, 0), + to_ndim(Point3f, B, 0), + to_ndim(Point3f, origin, 0), + to_ndim(Vec3f, dir, 0) ) end -function closest_point_on_line(A::Point3f0, B::Point3f0, origin::Point3f0, dir::Vec3f0) +function closest_point_on_line(A::Point3f, B::Point3f, origin::Point3f, dir::Vec3f) # See: # https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection AB_norm = norm(B .- A) @@ -131,9 +131,9 @@ function ray_triangle_intersection(A, B, C, origin, dir) e = 1e-3 if (A1 > -e && A2 > -e && A3 > -e) || (A1 < e && A2 < e && A3 < e) - Point3f0((A1 * A .+ A2 * B .+ A3 * C) / (A1 + A2 + A3)) + Point3f((A1 * A .+ A2 * B .+ A3 * C) / (A1 + A2 + A3)) else - Point3f0(NaN) + Point3f(NaN) end end @@ -151,7 +151,7 @@ surface_y(ys::AbstractMatrix, i, j, N) = ys[i, j] function surface_pos(xs, ys, zs, i, j) N, M = size(zs) - Point3f0(surface_x(xs, i, j, N), surface_y(ys, i, j, M), zs[i, j]) + Point3f(surface_x(xs, i, j, N), surface_y(ys, i, j, M), zs[i, j]) end @@ -186,16 +186,16 @@ end ######################################## function Bbox_from_glyphcollection(text, gc) - bbox = FRect2D(0, 0, 0, 0) - bboxes = FRect2D[] + bbox = Rect2f(0, 0, 0, 0) + bboxes = Rect2f[] broadcast_foreach(gc.extents, gc.fonts, gc.scales) do extent, font, scale b = FreeTypeAbstraction.height_insensitive_boundingbox(extent, font) * scale push!(bboxes, b) end for (c, o, bb) in zip(text, gc.origins, bboxes) c == '\n' && continue - bbox2 = FRect2D(o[Vec(1,2)] .+ origin(bb), widths(bb)) - if bbox == FRect2D(0, 0, 0, 0) + bbox2 = Rect2f(o[Vec(1,2)] .+ origin(bb), widths(bb)) + if bbox == Rect2f(0, 0, 0, 0) bbox = bbox2 else bbox = union(bbox, bbox2) @@ -211,9 +211,9 @@ end function shift_project(scene, plot, pos) project( camera(scene).projectionview[], - Vec2f0(widths(pixelarea(scene)[])), + Vec2f(widths(pixelarea(scene)[])), apply_transform(transform_func_obs(plot)[], pos) - ) .+ Vec2f0(origin(pixelarea(scene)[])) + ) .+ Vec2f(origin(pixelarea(scene)[])) end @@ -227,13 +227,13 @@ end # Attributes starting with _ are modified internally Attributes( # Text - text_padding = Vec4f0(5, 5, 3, 3), # LRBT + text_padding = Vec4f(5, 5, 3, 3), # LRBT text_align = (:left, :bottom), textcolor = :black, textsize = 18, font = theme(scene, :font), _display_text = " ", - _text_position = Point2f0(0), + _text_position = Point2f(0), # Background background_color = :white, @@ -245,24 +245,24 @@ end indicator_color = :red, indicator_linewidth = 2, indicator_linestyle = nothing, - _bbox2D = FRect2D(Vec2f0(0), Vec2f0(0)), + _bbox2D = Rect2f(Vec2f(0), Vec2f(0)), _px_bbox_visible = true, # general tooltip_align = (:center, :top), # default tooltip position relative to cursor - tooltip_offset = Vec2f0(20), # default offset in alignment direction + tooltip_offset = Vec2f(20), # default offset in alignment direction depth = 9e3, enabled = true, range = 10, - _root_px_projection = Mat4f0(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), - _model = Mat4f0(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), + _root_px_projection = Mat4f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), + _model = Mat4f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), _visible = true, _tooltip_align = (:center, :top), - _bbox3D = FRect3D(Vec3f0(0), Vec3f0(0)), + _bbox3D = Rect3f(Vec3f(0), Vec3f(0)), _bbox_visible = true, - _position = Point3f0(0), - _color = RGBAf0(0,0,0,0) + _position = Point3f(0), + _color = RGBAf(0,0,0,0) ) end @@ -277,8 +277,8 @@ function plot!(plot::_Inspector) ) # tooltip text - _aligned_text_position = Node(Point2f0(0)) - id = Mat4f0(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1) + _aligned_text_position = Node(Point2f(0)) + id = Mat4f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1) text_plot = text!(plot, _display_text, position = _aligned_text_position, visible = _visible, align = text_align, color = textcolor, font = font, textsize = textsize, show_axis = false, @@ -293,9 +293,9 @@ function plot!(plot::_Inspector) bbox = map(text_plot.plots[1][1], text_plot.position, text_padding) do gc, pos, pad rect = Bbox_from_glyphcollection(_display_text[], gc) l, r, b, t = pad - FRect2D( - origin(rect) .+ Vec2f0(pos[1] - l, pos[2] - b), - widths(rect) .+ Vec2f0(l + r, b + t) + Rect2f( + origin(rect) .+ Vec2f(pos[1] - l, pos[2] - b), + widths(rect) .+ Vec2f(l + r, b + t) ) end onany(_text_position, _tooltip_align, tooltip_offset, bbox) do pos, align, offset, bbox @@ -316,7 +316,7 @@ function plot!(plot::_Inspector) elseif valign == :bottom dy = -wy - oy end - new_pos = pos .+ Point2f0(dx, dy) + new_pos = pos .+ Point2f(dx, dy) if new_pos != _aligned_text_position[] _aligned_text_position[] = new_pos end @@ -348,10 +348,10 @@ function plot!(plot::_Inspector) # To make sure inspector plots end up in front on(depth) do d - translate!(background, Vec3f0(0,0,d+1)) - translate!(outline, Vec3f0(0,0,d+2)) - translate!(text_plot, Vec3f0(0,0,d+3)) - translate!(px_bbox, Vec3f0(0,0,d)) + translate!(background, Vec3f(0,0,d+1)) + translate!(outline, Vec3f(0,0,d+2)) + translate!(text_plot, Vec3f(0,0,d+3)) + translate!(px_bbox, Vec3f(0,0,d)) end depth[] = depth[] nothing @@ -406,7 +406,7 @@ when you hover over a plot. If you wish to exclude a plot you may set - `range = 10`: Controls the snapping range for selecting an element of a plot. - `enabled = true`: Disables inspection of plots when set to false. Can also be adjusted with `enable!(inspector)` and `disable!(inspector)`. -- `text_padding = Vec4f0(5, 5, 3, 3)`: Padding for the box drawn around the +- `text_padding = Vec4f(5, 5, 3, 3)`: Padding for the box drawn around the tooltip text. (left, right, bottom, top) - `text_align = (:left, :bottom)`: Alignment of text within the tooltip. This does not affect the alignment of the tooltip relative to the cursor. @@ -423,7 +423,7 @@ when you hover over a plot. If you wish to exclude a plot you may set - `tooltip_align = (:center, :top)`: Default position of the tooltip relative to the cursor or current selection. The real align may adjust to keep the tooltip in view. -- `tooltip_offset = Vec2f0(20)`: Offset from the indicator to the tooltip. +- `tooltip_offset = Vec2f(20)`: Offset from the indicator to the tooltip. - `depth = 9e3`: Depth value of the tooltip. This should be high so that the tooltip is always in front. - `priority = 100`: The priority of creating a tooltip on a mouse movement or @@ -435,7 +435,7 @@ end function DataInspector(scene::Scene; priority = 100, kwargs...) parent = root(scene) - @assert origin(pixelarea(parent)[]) == Vec2f0(0) + @assert origin(pixelarea(parent)[]) == Vec2f(0) plot = _inspector!( parent, 1, @@ -537,12 +537,12 @@ function show_data(inspector::DataInspector, plot::Scatter, idx) a = inspector.plot.attributes scene = parent_scene(plot) - proj_pos = shift_project(scene, plot, to_ndim(Point3f0, plot[1][][idx], 0)) + proj_pos = shift_project(scene, plot, to_ndim(Point3f, plot[1][][idx], 0)) update_tooltip_alignment!(inspector, proj_pos) ms = plot.markersize[] a._display_text[] = position2string(plot[1][][idx]) - a._bbox2D[] = FRect2D(proj_pos .- 0.5 .* ms .- Vec2f0(5), Vec2f0(ms) .+ Vec2f0(10)) + a._bbox2D[] = Rect2f(proj_pos .- 0.5 .* ms .- Vec2f(5), Vec2f(ms) .+ Vec2f(10)) a._px_bbox_visible[] = true a._bbox_visible[] = false a._visible[] = true @@ -555,7 +555,7 @@ function show_data(inspector::DataInspector, plot::MeshScatter, idx) a = inspector.plot.attributes scene = parent_scene(plot) - proj_pos = shift_project(scene, plot, to_ndim(Point3f0, plot[1][][idx], 0)) + proj_pos = shift_project(scene, plot, to_ndim(Point3f, plot[1][][idx], 0)) update_tooltip_alignment!(inspector, proj_pos) bbox = Rect{3, Float32}(convert_attribute( plot.marker[], Key{:marker}(), Key{Makie.plotkey(plot)}() @@ -610,11 +610,11 @@ function show_data(inspector::DataInspector, plot::Union{Lines, LineSegments}, i pos = closest_point_on_line(p0, p1, origin, dir) lw = plot.linewidth[] isa Vector ? plot.linewidth[][idx] : plot.linewidth[] - proj_pos = shift_project(scene, plot, to_ndim(Point3f0, pos, 0)) + proj_pos = shift_project(scene, plot, to_ndim(Point3f, pos, 0)) update_tooltip_alignment!(inspector, proj_pos) a._display_text[] = position2string(typeof(p0)(pos)) - a._bbox2D[] = FRect2D(proj_pos .- 0.5 .* lw .- Vec2f0(5), Vec2f0(lw) .+ Vec2f0(10)) + a._bbox2D[] = Rect2f(proj_pos .- 0.5 .* lw .- Vec2f(5), Vec2f(lw) .+ Vec2f(10)) a._px_bbox_visible[] = true a._bbox_visible[] = false a._visible[] = true @@ -628,7 +628,7 @@ function show_data(inspector::DataInspector, plot::Mesh, idx) scene = parent_scene(plot) bbox = boundingbox(plot) - proj_pos = Point2f0(mouseposition_px(inspector.root)) + proj_pos = Point2f(mouseposition_px(inspector.root)) update_tooltip_alignment!(inspector, proj_pos) a._bbox3D[] = bbox @@ -667,7 +667,7 @@ function show_data(inspector::DataInspector, plot::Surface, idx) a = inspector.plot.attributes scene = parent_scene(plot) - proj_pos = Point2f0(mouseposition_px(inspector.root)) + proj_pos = Point2f(mouseposition_px(inspector.root)) update_tooltip_alignment!(inspector, proj_pos) xs = plot[1][] @@ -678,7 +678,7 @@ function show_data(inspector::DataInspector, plot::Surface, idx) # This isn't the most accurate so we include some neighboring faces origin, dir = view_ray(scene) - pos = Point3f0(NaN) + pos = Point3f(NaN) for i in _i-1:_i+1, j in _j-1:_j+1 (1 <= i <= w) && (1 <= j < h) || continue @@ -706,7 +706,7 @@ function show_data(inspector::DataInspector, plot::Surface, idx) if !isnan(pos) a._display_text[] = position2string(pos) a._text_position[] = proj_pos - a._bbox2D[] = FRect2D(proj_pos .- Vec2f0(5), Vec2f0(10)) + a._bbox2D[] = Rect2f(proj_pos .- Vec2f(5), Vec2f(10)) a._bbox_visible[] = false a._px_bbox_visible[] = true a._visible[] = true @@ -747,8 +747,8 @@ function show_imagelike(inspector, plot, name, edge_based) z end - a._position[] = to_ndim(Point3f0, mpos, 0) - proj_pos = Point2f0(mouseposition_px(inspector.root)) + a._position[] = to_ndim(Point3f, mpos, 0) + proj_pos = Point2f(mouseposition_px(inspector.root)) update_tooltip_alignment!(inspector, proj_pos) if plot.interpolate[] @@ -762,7 +762,7 @@ function show_imagelike(inspector, plot, name, edge_based) strokecolor = a.indicator_color, strokewidth = a.indicator_linewidth #, linestyle = a.indicator_linestyle no? ) - translate!(p, Vec3f0(0, 0, a.depth[])) + translate!(p, Vec3f(0, 0, a.depth[])) push!(inspector.temp_plots, p) # Hacky? push!( @@ -773,14 +773,14 @@ function show_imagelike(inspector, plot, name, edge_based) a._display_text[] = color2text(name, mpos[1], mpos[2], z) else a._bbox2D[] = _pixelated_image_bbox(plot[1][], plot[2][], plot[3][], i, j, edge_based) - if inspector.selection != plot || !(inspector.temp_plots[1][1][] isa Rect2D) + if inspector.selection != plot || !(inspector.temp_plots[1][1][] isa Rect2) clear_temporary_plots!(inspector, plot) p = wireframe!( scene, a._bbox2D, model = a._model, color = a.indicator_color, strokewidth = a.indicator_linewidth, linestyle = a.indicator_linestyle, visible = a._bbox_visible, show_axis = false, inspectable = false ) - translate!(p, Vec3f0(0, 0, a.depth[])) + translate!(p, Vec3f(0, 0, a.depth[])) push!(inspector.temp_plots, p) end a._display_text[] = color2text(name, i, j, z) @@ -846,11 +846,11 @@ function _pixelated_image_bbox(xs, ys, img, i::Integer, j::Integer, edge_based) x0, x1 = extrema(xs) y0, y1 = extrema(ys) nw, nh = ((x1 - x0), (y1 - y0)) ./ size(img) - FRect2D(x0 + nw * (i-1), y0 + nh * (j-1), nw, nh) + Rect2f(x0 + nw * (i-1), y0 + nh * (j-1), nw, nh) end function _pixelated_image_bbox(xs::Vector, ys::Vector, img, i::Integer, j::Integer, edge_based) if edge_based - FRect2D(xs[i], ys[j], xs[i+1] - xs[i], ys[j+1] - ys[j]) + Rect2f(xs[i], ys[j], xs[i+1] - xs[i], ys[j+1] - ys[j]) else _pixelated_image_bbox( minimum(xs)..maximum(xs), minimum(ys)..maximum(ys), @@ -885,7 +885,7 @@ function show_data(inspector::DataInspector, plot::BarPlot, idx) scene = parent_scene(plot) pos = plot[1][][idx] - proj_pos = shift_project(scene, plot, to_ndim(Point3f0, pos, 0)) + proj_pos = shift_project(scene, plot, to_ndim(Point3f, pos, 0)) update_tooltip_alignment!(inspector, proj_pos) a._model[] = plot.model[] a._bbox2D[] = plot.plots[1][1][][idx] @@ -897,7 +897,7 @@ function show_data(inspector::DataInspector, plot::BarPlot, idx) strokewidth = a.indicator_linewidth, linestyle = a.indicator_linestyle, visible = a._bbox_visible, show_axis = false, inspectable = false ) - translate!(p, Vec3f0(0, 0, a.depth[])) + translate!(p, Vec3f(0, 0, a.depth[])) push!(inspector.temp_plots, p) end @@ -917,9 +917,9 @@ function show_data(inspector::DataInspector, plot::Arrows, idx, source) scene = parent_scene(plot) pos = plot[1][][idx] - proj_pos = shift_project(scene, plot, to_ndim(Point3f0, pos, 0)) + proj_pos = shift_project(scene, plot, to_ndim(Point3f, pos, 0)) - mpos = Point2f0(mouseposition_px(inspector.root)) + mpos = Point2f(mouseposition_px(inspector.root)) update_tooltip_alignment!(inspector, mpos) p = vec2string(pos) @@ -927,7 +927,7 @@ function show_data(inspector::DataInspector, plot::Arrows, idx, source) a._text_position[] = mpos a._display_text[] = "Position:\n $p\nDirection\n $v" - a._bbox2D[] = FRect2D(proj_pos .- Vec2f0(5), Vec2f0(10)) + a._bbox2D[] = Rect2f(proj_pos .- Vec2f(5), Vec2f(10)) a._bbox_visible[] = false a._px_bbox_visible[] = true a._visible[] = true @@ -943,7 +943,7 @@ function show_data(inspector::DataInspector, plot::Contourf, idx, source::Mesh) idx, ext = show_poly(inspector, plot.plots[1], idx, source) level = plot.plots[1].color[][idx] - a._text_position[] = Point2f0(mouseposition_px(inspector.root)) + a._text_position[] = Point2f(mouseposition_px(inspector.root)) a._display_text[] = @sprintf("level = %0.3f", level) return true end @@ -972,7 +972,7 @@ function show_poly(inspector, plot, idx, source) strokewidth = a.indicator_linewidth, linestyle = a.indicator_linestyle, visible = a._visible, show_axis = false, inspectable = false ) - translate!(p, Vec3f0(0,0,a.depth[])) + translate!(p, Vec3f(0,0,a.depth[])) push!(inspector.temp_plots, p) for int in plot[1][][idx].interiors @@ -981,7 +981,7 @@ function show_poly(inspector, plot, idx, source) strokewidth = a.indicator_linewidth, linestyle = a.indicator_linestyle, visible = a._visible, show_axis = false, inspectable = false ) - translate!(p, Vec3f0(0,0,a.depth[])) + translate!(p, Vec3f(0,0,a.depth[])) push!(inspector.temp_plots, p) end @@ -996,7 +996,7 @@ function show_data(inspector::DataInspector, plot::VolumeSlices, idx, child::Hea a = inspector.plot.attributes scene = parent_scene(plot) - proj_pos = Point2f0(mouseposition_px(inspector.root)) + proj_pos = Point2f(mouseposition_px(inspector.root)) update_tooltip_alignment!(inspector, proj_pos) qs = extrema(child[1][]) @@ -1007,29 +1007,29 @@ function show_data(inspector::DataInspector, plot::VolumeSlices, idx, child::Hea child_idx = findfirst(isequal(child), plot.plots) if child_idx == 2 vs = [ # clockwise - Point3f0(trans[1], qs[1], ps[1]), - Point3f0(trans[1], qs[1], ps[2]), - Point3f0(trans[1], qs[2], ps[2]), - Point3f0(trans[1], qs[2], ps[1]) + Point3f(trans[1], qs[1], ps[1]), + Point3f(trans[1], qs[1], ps[2]), + Point3f(trans[1], qs[2], ps[2]), + Point3f(trans[1], qs[2], ps[1]) ] elseif child_idx == 3 vs = [ # clockwise - Point3f0(qs[1], trans[2], ps[1]), - Point3f0(qs[1], trans[2], ps[2]), - Point3f0(qs[2], trans[2], ps[2]), - Point3f0(qs[2], trans[2], ps[1]) + Point3f(qs[1], trans[2], ps[1]), + Point3f(qs[1], trans[2], ps[2]), + Point3f(qs[2], trans[2], ps[2]), + Point3f(qs[2], trans[2], ps[1]) ] else vs = [ # clockwise - Point3f0(qs[1], ps[1], trans[3]), - Point3f0(qs[1], ps[2], trans[3]), - Point3f0(qs[2], ps[2], trans[3]), - Point3f0(qs[2], ps[1], trans[3]) + Point3f(qs[1], ps[1], trans[3]), + Point3f(qs[1], ps[2], trans[3]), + Point3f(qs[2], ps[2], trans[3]), + Point3f(qs[2], ps[1], trans[3]) ] end origin, dir = view_ray(scene) - pos = Point3f0(NaN) + pos = Point3f(NaN) pos = ray_triangle_intersection(vs[1], vs[2], vs[3], origin, dir) if isnan(pos) pos = ray_triangle_intersection(vs[3], vs[4], vs[1], origin, dir) @@ -1052,7 +1052,7 @@ function show_data(inspector::DataInspector, plot::VolumeSlices, idx, child::Hea pos[1], pos[2], pos[3], val ) a._text_position[] = proj_pos - a._bbox2D[] = FRect2D(proj_pos .- Vec2f0(5), Vec2f0(10)) + a._bbox2D[] = Rect2f(proj_pos .- Vec2f(5), Vec2f(10)) a._bbox_visible[] = false a._px_bbox_visible[] = true a._visible[] = true diff --git a/src/interaction/interactive_api.jl b/src/interaction/interactive_api.jl index 1202e00160f..3b1695f3b79 100644 --- a/src/interaction/interactive_api.jl +++ b/src/interaction/interactive_api.jl @@ -122,11 +122,11 @@ function pick_closest(scene::SceneLike, screen, xy, range) x1, y1 = min.([w, h], floor.(Int, xy .+ range)) dx = x1 - x0; dy = y1 - y0 - picks = pick(scene, screen, IRect2D(x0, y0, dx, dy)) + picks = pick(scene, screen, Rect2i(x0, y0, dx, dy)) min_dist = range^2 selected = (0, 0) - x, y = xy .+ 1 .- Vec2f0(x0, y0) + x, y = xy .+ 1 .- Vec2f(x0, y0) for i in 1:dx, j in 1:dy d = (x-i)^2 + (y-j)^2 if (d < min_dist) && (picks[i, j][1] != nothing) @@ -159,11 +159,11 @@ function pick_sorted(scene::SceneLike, screen, xy, range) x1, y1 = min.([w, h], floor.(Int, xy .+ range)) dx = x1 - x0; dy = y1 - y0 - picks = pick(scene, screen, IRect2D(x0, y0, dx, dy)) + picks = pick(scene, screen, Rect2i(x0, y0, dx, dy)) selected = filter(x -> x[1] != nothing, unique(vec(picks))) distances = [range^2 for _ in selected] - x, y = xy .+ 1 .- Vec2f0(x0, y0) + x, y = xy .+ 1 .- Vec2f(x0, y0) for i in 1:dx, j in 1:dy if picks[i, j][1] != nothing d = (x-i)^2 + (y-j)^2 @@ -182,12 +182,12 @@ function pick_sorted(scene::SceneLike, screen, xy, range) end """ - pick(scene::Scene, rect::IRect2D) + pick(scene::Scene, rect::Rect2i) Return all `(plot, index)` pairs within the given rect. The rect must be within screen boundaries. """ -function pick(scene::SceneLike, rect::IRect2D) +function pick(scene::SceneLike, rect::Rect2i) screen = getscreen(scene) screen === nothing && return Tuple{AbstractPlot, Int}[] return pick(scene, screen, rect) @@ -199,7 +199,7 @@ end Normalizes mouse position `pos` relative to the screen rectangle. """ function screen_relative(scene::Scene, mpos) - return Point2f0(mpos) .- Point2f0(minimum(pixelarea(scene)[])) + return Point2f(mpos) .- Point2f(minimum(pixelarea(scene)[])) end """ @@ -249,12 +249,12 @@ The `kwargs...` are propagated into `lines!` which plots the selected rectangle. function select_rectangle(scene; blocking = false, priority = 2, strokewidth = 3.0, kwargs...) key = Mouse.left waspressed = Node(false) - rect = Node(FRect(0, 0, 1, 1)) # plotted rectangle - rect_ret = Node(FRect(0, 0, 1, 1)) # returned rectangle + rect = Node(Rectf(0, 0, 1, 1)) # plotted rectangle + rect_ret = Node(Rectf(0, 0, 1, 1)) # returned rectangle # Create an initially hidden rectangle plotted_rect = poly!( - scene, rect, raw = true, visible = false, color = RGBAf0(0, 0, 0, 0), strokecolor = RGBAf0(0.1, 0.1, 0.8, 0.5), strokewidth = strokewidth, kwargs..., + scene, rect, raw = true, visible = false, color = RGBAf(0, 0, 0, 0), strokecolor = RGBAf(0.1, 0.1, 0.8, 0.5), strokewidth = strokewidth, kwargs..., ) on(events(scene).mousebutton, priority=priority) do event @@ -263,7 +263,7 @@ function select_rectangle(scene; blocking = false, priority = 2, strokewidth = 3 mp = mouseposition(scene) waspressed[] = true plotted_rect[:visible] = true # start displaying - rect[] = FRect(mp, 0.0, 0.0) + rect[] = Rectf(mp, 0.0, 0.0) return Consume(blocking) end end @@ -287,7 +287,7 @@ function select_rectangle(scene; blocking = false, priority = 2, strokewidth = 3 if waspressed[] mp = mouseposition(scene) mini = minimum(rect[]) - rect[] = FRect(mini, mp - mini) + rect[] = Rectf(mini, mp - mini) return Consume(blocking) end return Consume(false) @@ -313,11 +313,11 @@ The `kwargs...` are propagated into `lines!` which plots the selected line. function select_line(scene; blocking = false, priority = 2, kwargs...) key = Mouse.left waspressed = Node(false) - line = Node([Point2f0(0,0), Point2f0(1,1)]) - line_ret = Node([Point2f0(0,0), Point2f0(1,1)]) + line = Node([Point2f(0,0), Point2f(1,1)]) + line_ret = Node([Point2f(0,0), Point2f(1,1)]) # Create an initially hidden arrow plotted_line = lines!( - scene, line; visible = false, color = RGBAf0(0.1, 0.1, 0.8, 0.5), + scene, line; visible = false, color = RGBAf(0.1, 0.1, 0.8, 0.5), linewidth = 4, kwargs..., ) @@ -373,14 +373,14 @@ The `kwargs...` are propagated into `scatter!` which plots the selected point. """ function select_point(scene; blocking = false, priority=2, kwargs...) key = Mouse.left - pmarker = Circle(Point2f0(0, 0), Float32(1)) + pmarker = Circle(Point2f(0, 0), Float32(1)) waspressed = Node(false) - point = Node([Point2f0(0,0)]) - point_ret = Node(Point2f0(0,0)) + point = Node([Point2f(0,0)]) + point_ret = Node(Point2f(0,0)) # Create an initially hidden arrow plotted_point = scatter!( scene, point; visible = false, marker = pmarker, markersize = 20px, - color = RGBAf0(0.1, 0.1, 0.8, 0.5), kwargs..., + color = RGBAf(0.1, 0.1, 0.8, 0.5), kwargs..., ) on(events(scene).mousebutton, priority=priority) do event diff --git a/src/interfaces.jl b/src/interfaces.jl index fb4c30b6b2d..c418d875ef4 100644 --- a/src/interfaces.jl +++ b/src/interfaces.jl @@ -9,12 +9,12 @@ function default_theme(scene) visible = true, transparency = false, overdraw = false, - ambient = Vec3f0(0.55), - diffuse = Vec3f0(0.4), - specular = Vec3f0(0.2), + ambient = Vec3f(0.55), + diffuse = Vec3f(0.4), + specular = Vec3f(0.2), shininess = 32f0, lightposition = :eyeposition, - nan_color = RGBAf0(0,0,0,0), + nan_color = RGBAf(0,0,0,0), ssao = false, inspectable = theme(scene, :inspectable) ) diff --git a/src/jl_rasterizer/main.jl b/src/jl_rasterizer/main.jl index eb173ac6d36..d677782fca2 100644 --- a/src/jl_rasterizer/main.jl +++ b/src/jl_rasterizer/main.jl @@ -27,7 +27,7 @@ mutable struct FixedGeomView{GeomOut, VT} end function FixedGeomView(T, max_primitives, primitive_in, primitive_out) - buffer = Vector{Tuple{Point4f0, T}}(max_primitives) + buffer = Vector{Tuple{Point4f, T}}(max_primitives) # TODO implement primitive_in and out correctly # this is for triangle_strip and 4 max_primitives if max_primitives != 4 || primitive_out != :triangle_strip @@ -167,7 +167,7 @@ function (r::JLRasterizer{Vert, Args, FragN})( canvas, vertex_array::AbstractArray{Vert}, uniforms::Args ) where {Vert, Args, FragN} framebuffers = canvas.color; depthbuffer = canvas.depth - resolution = Vec2f0(size(framebuffers[1])) + resolution = Vec2f(size(framebuffers[1])) # hoisting out functions... Seems to help inference a bit. Or not? vshader = r.vertexshader gshader = r.geometryshader @@ -247,11 +247,11 @@ function smoothstep(edge0, edge1, x::T) where T return t * t * (T(3) - T(2) * t) end function aastep(threshold1::T, value) where T - afwidth = norm(Vec2f0(dFdx(value), dFdy(value))) * T(1.05); + afwidth = norm(Vec2f(dFdx(value), dFdy(value))) * T(1.05); smoothstep(threshold1 - afwidth, threshold1 + afwidth, value) end function aastep(threshold1::T, threshold2::T, value::T) where T - afwidth = norm(Vec2f0(dFdx(value), dFdy(value))) * T(1.05); + afwidth = norm(Vec2f(dFdx(value), dFdy(value))) * T(1.05); return ( smoothstep(threshold1 - afwidth, threshold1 + afwidth, value) - smoothstep(threshold2 - afwidth, threshold2 + afwidth, value) @@ -268,38 +268,38 @@ dFdx(value::T) where {T} = T(0.001) # just default to a small gradient if it's c dFdy(value::T) where {T} = T(0.001) # just default to a small gradient if it's called on the CPU mutable struct Uniforms{F} - projection::Mat4f0 - strokecolor::Vec4f0 - glowcolor::Vec4f0 + projection::Mat4f + strokecolor::Vec4f + glowcolor::Vec4f distance_func::F end mutable struct TextUniforms - projection::Mat4f0 - strokecolor::Vec4f0 - glowcolor::Vec4f0 + projection::Mat4f + strokecolor::Vec4f + glowcolor::Vec4f end struct VertexCS{N, T} position::Vec{N, T} - color::Vec4f0 - scale::Vec2f0 + color::Vec4f + scale::Vec2f end struct Vertex2Geom - uvrect::Vec4f0 - color::Vec4f0 - rect::Vec4f0 + uvrect::Vec4f + color::Vec4f + rect::Vec4f end function vert_particles(vertex, uniforms) p = vertex.position scale = vertex.scale return Vertex2Geom( - Vec4f0(0,0,1,1), + Vec4f(0,0,1,1), vertex.color, - Vec4f0(p[1], p[2], scale[1], scale[2]) + Vec4f(p[1], p[2], scale[1], scale[2]) ) end @@ -308,8 +308,8 @@ end Emits a vertex with """ function emit_vertex(emit!, vertex, uv, arg, pos, uniforms) - datapoint = uniforms.projection * Vec4f0(pos[1], pos[2], 0, 1) - final_position = uniforms.projection * Vec4f0(vertex[1], vertex[2], 0, 0) + datapoint = uniforms.projection * Vec4f(pos[1], pos[2], 0, 1) + final_position = uniforms.projection * Vec4f(vertex[1], vertex[2], 0, 0) emit!(datapoint .+ final_position, (uv, arg.color)) return end @@ -333,7 +333,7 @@ function geom_particles(emit!, vertex_out, uniforms) pos_scale = arg.rect pos = pos_scale[Vec(1, 2)] scale = pos_scale[Vec(3, 4)] - quad = Vec4f0(0f0, 0f0, scale[1], scale[2]) + quad = Vec4f(0f0, 0f0, scale[1], scale[2]) uv = arg.uvrect emit_vertex(emit!, quad[Vec(1, 2)], uv[Vec(1, 4)], arg, pos, uniforms) emit_vertex(emit!, quad[Vec(1, 4)], uv[Vec(1, 2)], arg, pos, uniforms) @@ -350,21 +350,21 @@ end function frag_particles(geom_out, uniforms, image) uv = geom_out[1]; color = geom_out[2] dist = -image[uv][1] - bg_color = Vec4f0(0f0, 0f0, 0f0, 0f0) + bg_color = Vec4f(0f0, 0f0, 0f0, 0f0) (sdf2color(dist, bg_color, color), ) end function frag_particles(geom_out, uniforms) uv = geom_out[1]; color = geom_out[2] dist = uniforms.distance_func(uv) - bg_color = Vec4f0(0f0, 0f0, 0f0, 0f0) + bg_color = Vec4f(0f0, 0f0, 0f0, 0f0) (sdf2color(dist, bg_color, color), ) end -function orthographicprojection(wh::Rect2D, near::T, far::T) where T +function orthographicprojection(wh::Rect2, near::T, far::T) where T orthographicprojection(zero(T), T(wh.w), zero(T), T(wh.h), near, far) end function orthographicprojection( - ::Type{T}, wh::Rect2D, near::Number, far::Number + ::Type{T}, wh::Rect2, near::Number, far::Number ) where T orthographicprojection(wh, T(near), T(far)) end @@ -395,23 +395,23 @@ function orthographicprojection(::Type{T}, ) end -proj = orthographicprojection(Rect2D(0, 0, resolution...), -10_000f0, 10_000f0) +proj = orthographicprojection(Rect2(0, 0, resolution...), -10_000f0, 10_000f0) uniforms = Uniforms( proj, - Vec4f0(1, 0, 0, 1), - Vec4f0(1, 0, 1, 1), + Vec4f(1, 0, 0, 1), + Vec4f(1, 0, 1, 1), circle ) N = 10 -middle = Vec2f0(resolution) / 2f0 +middle = Vec2f(resolution) / 2f0 radius = min(resolution...) / 2f0 vertices = [(VertexCS( - Vec2f0((sin(2pi * (i / N)) , cos(2pi * (i / N))) .* radius) .+ middle, - Vec4f0(1, i/N, 0, 1), - Vec2f0(40, 40) + Vec2f((sin(2pi * (i / N)) , cos(2pi * (i / N))) .* radius) .+ middle, + Vec4f(1, i/N, 0, 1), + Vec2f(40, 40) ),) for i = 1:N] diff --git a/src/layouting/boundingbox.jl b/src/layouting/boundingbox.jl index cd0e8972c3b..61406d26f5b 100644 --- a/src/layouting/boundingbox.jl +++ b/src/layouting/boundingbox.jl @@ -18,7 +18,7 @@ raw_boundingbox(x::Combined) = raw_boundingbox(x.plots) boundingbox(x) = raw_boundingbox(x) function combined_modelmatrix(x) - m = Mat4f0(I) + m = Mat4f(I) while true m = modelmatrix(x) * m if parent(x) !== nothing && parent(x) isa Combined @@ -59,9 +59,9 @@ function raw_boundingbox(scene::Scene) end function raw_boundingbox(plots::Vector) - isempty(plots) && return FRect3D() + isempty(plots) && return Rect3f() plot_idx = iterate(plots) - bb = FRect3D() + bb = Rect3f() while plot_idx !== nothing plot, idx = plot_idx plot_idx = iterate(plots, idx) @@ -80,38 +80,38 @@ function project_widths(matrix, vec) return pr - zero end -function rotate_bbox(bb::FRect3D, rot) - points = decompose(Point3f0, bb) - FRect3D(Ref(rot) .* points) +function rotate_bbox(bb::Rect3f, rot) + points = decompose(Point3f, bb) + Rect3f(Ref(rot) .* points) end function gl_bboxes(gl::GlyphCollection) - scales = gl.scales.sv isa Vec2f0 ? (gl.scales.sv for _ in gl.extents) : gl.scales.sv + scales = gl.scales.sv isa Vec2f ? (gl.scales.sv for _ in gl.extents) : gl.scales.sv map(gl.extents, gl.fonts, scales) do ext, font, scale unscaled_hi_bb = height_insensitive_boundingbox(ext, font) - hi_bb = FRect2D( + hi_bb = Rect2f( Makie.origin(unscaled_hi_bb) * scale, widths(unscaled_hi_bb) * scale ) end end -function boundingbox(glyphcollection::GlyphCollection, position::Point3f0, rotation::Quaternion) +function boundingbox(glyphcollection::GlyphCollection, position::Point3f, rotation::Quaternion) if isempty(glyphcollection.glyphs) - return FRect3D(position, Vec3f0(0, 0, 0)) + return Rect3f(position, Vec3f(0, 0, 0)) end chars = glyphcollection.glyphs glyphorigins = glyphcollection.origins glyphbbs = gl_bboxes(glyphcollection) - bb = FRect3D() + bb = Rect3f() for (char, charo, glyphbb) in zip(chars, glyphorigins, glyphbbs) # ignore line breaks # char in ('\r', '\n') && continue - charbb = rotate_bbox(FRect3D(glyphbb), rotation) + charo + position + charbb = rotate_bbox(Rect3f(glyphbb), rotation) + charo + position if !isfinite_rect(bb) bb = charbb else @@ -125,9 +125,9 @@ end function boundingbox(layouts::AbstractArray{<:GlyphCollection}, positions, rotations) if isempty(layouts) - FRect3D((0, 0, 0), (0, 0, 0)) + Rect3f((0, 0, 0), (0, 0, 0)) else - bb = FRect3D() + bb = Rect3f() broadcast_foreach(layouts, positions, rotations) do layout, pos, rot if !isfinite_rect(bb) bb = boundingbox(layout, pos, rot) @@ -143,7 +143,7 @@ end function boundingbox(x::Text{<:Tuple{<:GlyphCollection}}) boundingbox( x[1][], - to_ndim(Point3f0, x.position[], 0), + to_ndim(Point3f, x.position[], 0), to_rotation(x.rotation[]) ) end @@ -151,17 +151,17 @@ end function boundingbox(x::Text{<:Tuple{<:AbstractArray{<:GlyphCollection}}}) boundingbox( x[1][], - to_ndim.(Point3f0, x.position[], 0), + to_ndim.(Point3f, x.position[], 0), to_rotation(x.rotation[]) ) end function text_bb(str, font, size) - rot = Quaternionf0(0,0,0,1) + rot = Quaternionf(0,0,0,1) layout = layout_text( - str, size, font, Vec2f0(0), rot, 0.5, 1.0, - RGBAf0(0, 0, 0, 0), RGBAf0(0, 0, 0, 0), 0f0) - return boundingbox(layout, Point3f0(0), rot) + str, size, font, Vec2f(0), rot, 0.5, 1.0, + RGBAf(0, 0, 0, 0), RGBAf(0, 0, 0, 0), 0f0) + return boundingbox(layout, Point3f(0), rot) end """ @@ -186,5 +186,5 @@ function rotatedrect(rect::Rect{2}, angle) rmins = minimum(rotated, dims = 2) rmaxs = maximum(rotated, dims = 2) - return Rect2D(rmins..., (rmaxs .- rmins)...) + return Rect2(rmins..., (rmaxs .- rmins)...) end diff --git a/src/layouting/data_limits.jl b/src/layouting/data_limits.jl index e50aa6ced3d..39555a8cec6 100644 --- a/src/layouting/data_limits.jl +++ b/src/layouting/data_limits.jl @@ -61,10 +61,10 @@ function xyz_boundingbox(transform_func, mesh::GeometryBasics.Mesh) end function xyz_boundingbox(transform_func, xyz) - isempty(xyz) && return FRect3D() + isempty(xyz) && return Rect3f() mini, maxi = extrema_nan((apply_transform(transform_func, point) for point in xyz)) w = maxi .- mini - return FRect3D(to_ndim(Vec3f0, mini, 0), to_ndim(Vec3f0, w, 0)) + return Rect3f(to_ndim(Vec3f, mini, 0), to_ndim(Vec3f, w, 0)) end const NumOrArray = Union{AbstractArray, Number} @@ -82,11 +82,11 @@ function xyz_boundingbox(transform_func, x::NumOrArray, y::NumOrArray, z::NumOrA end function xyz_boundingbox(transform_func, x, y, z = 0) - isempty(x) && return FRect3D() + isempty(x) && return Rect3f() minmax = extrema_nan.(apply_transform.((transform_func,), (x, y, z))) mini, maxi = Vec(first.(minmax)), Vec(last.(minmax)) w = maxi .- mini - return FRect3D(to_ndim(Vec3f0, mini, 0), to_ndim(Vec3f0, w, 0)) + return Rect3f(to_ndim(Vec3f, mini, 0), to_ndim(Vec3f, w, 0)) end const ImageLike{Arg} = Union{Heatmap{Arg}, Image{Arg}} @@ -101,16 +101,16 @@ function data_limits(x::Volume) end function text_limits(x::VecTypes) - p = to_ndim(Vec3f0, x, 0.0) - return FRect3D(p, p) + p = to_ndim(Vec3f, x, 0.0) + return Rect3f(p, p) end function text_limits(x::AbstractVector) - return FRect3D(x) + return Rect3f(x) end -FRect3D_from_point(p::VecTypes{2}) = FRect3D(Point3f0(p..., 0), Point3f0(0, 0, 0)) -FRect3D_from_point(p::VecTypes{3}) = FRect3D(Point3f0(p...), Point3f0(0, 0, 0)) +FRect3D_from_point(p::VecTypes{2}) = Rect3f(Point3f(p..., 0), Point3f(0, 0, 0)) +FRect3D_from_point(p::VecTypes{3}) = Rect3f(Point3f(p...), Point3f(0, 0, 0)) function atomic_limits(x::Text{<:Tuple{<:GlyphCollection}}) @@ -128,7 +128,7 @@ function atomic_limits(x::Text{<:Tuple{<:AbstractArray{<:GlyphCollection}}}) boundingbox(x) elseif x.space[] == :screen if isempty(x.position[]) - FRect3D() + Rect3f() else bb = FRect3D_from_point(x.position[][1]) for p in x.position[][2:end] @@ -146,14 +146,14 @@ isfinite_rect(x::Rect) = all(isfinite.(minimum(x))) && all(isfinite.(maximum(x) function data_limits(plots::Vector) isempty(plots) && return - bb = FRect3D() + bb = Rect3f() plot_idx = iterate(plots) while plot_idx !== nothing plot, idx = plot_idx plot_idx = iterate(plots, idx) # axis shouldn't be part of the data limit isaxis(plot) && continue - bb2 = data_limits(plot)::FRect3D + bb2 = data_limits(plot)::Rect3f isfinite_rect(bb) || (bb = bb2) isfinite_rect(bb2) || continue bb = union(bb, bb2) diff --git a/src/layouting/layouting.jl b/src/layouting/layouting.jl index 193a543c935..58af0cac873 100644 --- a/src/layouting/layouting.jl +++ b/src/layouting/layouting.jl @@ -67,8 +67,8 @@ function glyph_collection(str::AbstractString, font_per_char, fontscale_px, hali lineheight_factor, justification, rotation, color, strokecolor, strokewidth) isempty(str) && return GlyphCollection( - [], [], Point3f0[],FreeTypeAbstraction.FontExtent{Float32}[], - Vec2f0[], Float32[], RGBAf0[], RGBAf0[], Float32[]) + [], [], Point3f[],FreeTypeAbstraction.FontExtent{Float32}[], + Vec2f[], Float32[], RGBAf[], RGBAf[], Float32[]) # collect information about every character in the string charinfos = broadcast([c for c in str], font_per_char, fontscale_px) do char, font, scale @@ -76,7 +76,7 @@ function glyph_collection(str::AbstractString, font_per_char, fontscale_px, hali unscaled_extent = get_extent(font, char) lineheight = Float32(font.height / font.units_per_EM * lineheight_factor * scale) unscaled_hi_bb = height_insensitive_boundingbox(unscaled_extent, font) - hi_bb = FRect2D( + hi_bb = Rect2f( Makie.origin(unscaled_hi_bb) * scale, widths(unscaled_hi_bb) * scale) (char = char, font = font, scale = scale, hadvance = hadvance(unscaled_extent) * scale, @@ -203,7 +203,7 @@ function glyph_collection(str::AbstractString, font_per_char, fontscale_px, hali # compute the origins for each character by rotating each character around the common origin # which is the alignment anchor and now [0, 0] # use 3D coordinates already because later they will be required in that format anyway - charorigins = [Ref(rotation) .* Point3f0.(xsgroup, y, 0) for (xsgroup, y) in zip(xs_aligned, ys_aligned)] + charorigins = [Ref(rotation) .* Point3f.(xsgroup, y, 0) for (xsgroup, y) in zip(xs_aligned, ys_aligned)] # return a GlyphCollection, which contains each character's origin, height-insensitive # boundingbox and horizontal advance value @@ -215,7 +215,7 @@ function glyph_collection(str::AbstractString, font_per_char, fontscale_px, hali [x.font for x in charinfos], reduce(vcat, charorigins), [x.extent for x in charinfos], - [Vec2f0(x.scale) for x in charinfos], + [Vec2f(x.scale) for x in charinfos], [rotation for x in charinfos], [color for x in charinfos], [strokecolor for x in charinfos], @@ -228,14 +228,14 @@ function preprojected_glyph_arrays( position::VecTypes, glyphcollection::Makie.GlyphCollection, space::Symbol, projview, resolution, offset::VecTypes, transfunc ) - offset = to_ndim(Point3f0, offset, 0) - pos3f0 = to_ndim(Point3f0, position, 0) + offset = to_ndim(Point3f, offset, 0) + pos3f0 = to_ndim(Point3f, position, 0) if space == :data - positions = apply_transform(transfunc, Point3f0[pos3f0 + offset + o for o in glyphcollection.origins]) + positions = apply_transform(transfunc, Point3f[pos3f0 + offset + o for o in glyphcollection.origins]) elseif space == :screen projected = Makie.project(projview, resolution, apply_transform(transfunc, pos3f0)) - positions = Point3f0[to_ndim(Point3f0, projected, 0) + offset + o for o in glyphcollection.origins] + positions = Point3f[to_ndim(Point3f, projected, 0) + offset + o for o in glyphcollection.origins] else error("Unknown space $space, only :data or :screen allowed") end @@ -247,14 +247,14 @@ function preprojected_glyph_arrays( space::Symbol, projview, resolution, offsets::Vector, transfunc ) - offsets = to_ndim.(Point3f0, offsets, 0) - pos3f0 = to_ndim(Point3f0, position, 0) + offsets = to_ndim.(Point3f, offsets, 0) + pos3f0 = to_ndim(Point3f, position, 0) if space == :data positions = apply_transform(transfunc, [pos3f0 + offset + o for (o, offset) in zip(glyphcollection.origins, offsets)]) elseif space == :screen projected = Makie.project(projview, resolution, apply_transform(transfunc, pos3f0)) - positions = Point3f0[to_ndim(Point3f0, projected, 0) + offset + o for (o, offset) in zip(glyphcollection.origins, offsets)] + positions = Point3f[to_ndim(Point3f, projected, 0) + offset + o for (o, offset) in zip(glyphcollection.origins, offsets)] else error("Unknown space $space, only :data or :screen allowed") end @@ -267,29 +267,29 @@ function preprojected_glyph_arrays( ) if offset isa VecTypes - offset = [to_ndim(Point3f0, offset, 0)] + offset = [to_ndim(Point3f, offset, 0)] end if space == :data allpos = broadcast(positions, glyphcollections, offset) do pos, glyphcollection, offs - p = to_ndim(Point3f0, pos, 0) + p = to_ndim(Point3f, pos, 0) apply_transform( transfunc, - Point3f0[p .+ to_ndim(Point3f0, offs, 0) .+ o for o in glyphcollection.origins] + Point3f[p .+ to_ndim(Point3f, offs, 0) .+ o for o in glyphcollection.origins] ) end elseif space == :screen allpos = broadcast(positions, glyphcollections, offset) do pos, glyphcollection, offs projected = to_ndim( - Point3f0, + Point3f, Makie.project( projview, resolution, - apply_transform(transfunc, to_ndim(Point3f0, pos, 0)) + apply_transform(transfunc, to_ndim(Point3f, pos, 0)) ), 0) - return Point3f0[projected .+ to_ndim(Point3f0, offs, 0) + o + return Point3f[projected .+ to_ndim(Point3f, offs, 0) + o for o in glyphcollection.origins] end else @@ -307,9 +307,9 @@ end function text_quads(positions, glyphs::AbstractVector, fonts::AbstractVector, textsizes::ScalarOrVector{<:Vec2}) atlas = get_texture_atlas() - offsets = Vec2f0[] - uv = Vec4f0[] - scales = Vec2f0[] + offsets = Vec2f[] + uv = Vec4f[] + scales = Vec2f[] broadcast_foreach(positions, glyphs, fonts, textsizes) do offs, c, font, pixelsize # for (c, font, pixelsize) in zipx(glyphs, fonts, textsizes) push!(uv, glyph_uv_width!(atlas, c, font)) @@ -323,9 +323,9 @@ end function text_quads(positions, glyphs, fonts, textsizes::Vector{<:ScalarOrVector}) atlas = get_texture_atlas() - offsets = Vec2f0[] - uv = Vec4f0[] - scales = Vec2f0[] + offsets = Vec2f[] + uv = Vec4f[] + scales = Vec2f[] broadcast_foreach(positions, glyphs, fonts, textsizes) do positions, glyphs, fonts, textsizes broadcast_foreach(positions, glyphs, fonts, textsizes) do offs, c, font, pixelsize @@ -336,7 +336,7 @@ function text_quads(positions, glyphs, fonts, textsizes::Vector{<:ScalarOrVector end end - return reduce(vcat, positions, init = Point3f0[]), offsets, uv, scales + return reduce(vcat, positions, init = Point3f[]), offsets, uv, scales end diff --git a/src/layouting/transformation.jl b/src/layouting/transformation.jl index e6ec4220034..db35435295a 100644 --- a/src/layouting/transformation.jl +++ b/src/layouting/transformation.jl @@ -1,14 +1,14 @@ function Transformation(transform_func=identity) flip = Node((false, false, false)) - scale = Node(Vec3f0(1)) + scale = Node(Vec3f(1)) scale = lift(flip, scale) do f, s map((f, s)-> f ? -s : s, Vec(f), s) end translation, rotation, align = ( - Node(Vec3f0(0)), - Node(Quaternionf0(0, 0, 0, 1)), - Node(Vec2f0(0)) + Node(Vec3f(0)), + Node(Quaternionf(0, 0, 0, 1)), + Node(Vec2f(0)) ) trans = nothing model = map_once(scale, translation, rotation, align, flip) do s, o, q, a, flip @@ -32,11 +32,11 @@ end function Transformation(scene::SceneLike) flip = Node((false, false, false)) - scale = Node(Vec3f0(1)) + scale = Node(Vec3f(1)) translation, rotation, align = ( - Node(Vec3f0(0)), - Node(Quaternionf0(0, 0, 0, 1)), - Node(Vec2f0(0)) + Node(Vec3f(0)), + Node(Quaternionf(0, 0, 0, 1)), + Node(Vec2f(0)) ) pmodel = transformationmatrix(scene) trans = nothing @@ -77,8 +77,8 @@ end function transform!( scene::SceneLike; - translation = Vec3f0(0), - scale = Vec3f0(1), + translation = Vec3f(0), + scale = Vec3f(1), rotation = 0.0, ) translate!(scene, translation) @@ -94,7 +94,7 @@ transformation(t::Transformation) = t scale(t::Transformable) = transformation(t).scale -scale!(t::Transformable, s) = (scale(t)[] = to_ndim(Vec3f0, Float32.(s), 1)) +scale!(t::Transformable, s) = (scale(t)[] = to_ndim(Vec3f, Float32.(s), 1)) """ scale!(t::Transformable, x, y) @@ -156,7 +156,7 @@ This is the default setting. struct Absolute end function translate!(::Type{T}, scene::Transformable, t) where T - offset = to_ndim(Vec3f0, Float32.(t), 0) + offset = to_ndim(Vec3f, Float32.(t), 0) if T === Accum translation(scene)[] = translation(scene)[] .+ offset elseif T === Absolute @@ -189,11 +189,11 @@ function transform!(scene::Transformable, x::Tuple{Symbol, <: Number}) if all(x-> x in ('x', 'y'), plane) # xy plane translate!(scene, 0, 0, dimval) elseif all(x-> x in ('x', 'z'), plane) # xz plane - rotate!(scene, Vec3f0(1, 0, 0), 0.5pi) + rotate!(scene, Vec3f(1, 0, 0), 0.5pi) translate!(scene, 0, dimval, 0) else #yz plane - r1 = qrotation(Vec3f0(0, 1, 0), 0.5pi) - r2 = qrotation(Vec3f0(1, 0, 0), 0.5pi) + r1 = qrotation(Vec3f(0, 1, 0), 0.5pi) + r2 = qrotation(Vec3f(1, 0, 0), 0.5pi) rotate!(scene, r2 * r1) translate!(scene, dimval, 0, 0) end diff --git a/src/makielayout/MakieLayout.jl b/src/makielayout/MakieLayout.jl index d2eb4e7e957..c09bd8c57b4 100644 --- a/src/makielayout/MakieLayout.jl +++ b/src/makielayout/MakieLayout.jl @@ -1,8 +1,8 @@ module MakieLayout using ..Makie -using ..Makie: Rect2D -import ..Makie: IRect2D +using ..Makie: Rect2 +import ..Makie: Rect2i using ..Makie.Keyboard using ..Makie.Mouse using ..Makie: ispressed, is_mouseinside, get_scene, FigureLike @@ -22,8 +22,8 @@ import Showoff using Colors const FPS = Node(30) -const COLOR_ACCENT = Ref(RGBf0(((79, 122, 214) ./ 255)...)) -const COLOR_ACCENT_DIMMED = Ref(RGBf0(((174, 192, 230) ./ 255)...)) +const COLOR_ACCENT = Ref(RGBf(((79, 122, 214) ./ 255)...)) +const COLOR_ACCENT_DIMMED = Ref(RGBf(((174, 192, 230) ./ 255)...)) # Make GridLayoutBase default row and colgaps themeable when using MakieLayout # This mutates module-level state so it could mess up other libraries using diff --git a/src/makielayout/defaultattributes.jl b/src/makielayout/defaultattributes.jl index 10d36624fce..2a407adf42e 100644 --- a/src/makielayout/defaultattributes.jl +++ b/src/makielayout/defaultattributes.jl @@ -104,9 +104,9 @@ function default_attributes(::Type{Axis}, scene) "The width of the ytick marks." ytickwidth = 1f0 "The color of the xtick marks." - xtickcolor = RGBf0(0, 0, 0) + xtickcolor = RGBf(0, 0, 0) "The color of the ytick marks." - ytickcolor = RGBf0(0, 0, 0) + ytickcolor = RGBf(0, 0, 0) "Locks interactive panning in the x direction." xpanlock = false "Locks interactive panning in the y direction." @@ -130,9 +130,9 @@ function default_attributes(::Type{Axis}, scene) "The width of the y grid lines." ygridwidth = 1f0 "The color of the x grid lines." - xgridcolor = RGBAf0(0, 0, 0, 0.12) + xgridcolor = RGBAf(0, 0, 0, 0.12) "The color of the y grid lines." - ygridcolor = RGBAf0(0, 0, 0, 0.12) + ygridcolor = RGBAf(0, 0, 0, 0.12) "The linestyle of the x grid lines." xgridstyle = nothing "The linestyle of the y grid lines." @@ -146,9 +146,9 @@ function default_attributes(::Type{Axis}, scene) "The width of the y minor grid lines." yminorgridwidth = 1f0 "The color of the x minor grid lines." - xminorgridcolor = RGBAf0(0, 0, 0, 0.05) + xminorgridcolor = RGBAf(0, 0, 0, 0.05) "The color of the y minor grid lines." - yminorgridcolor = RGBAf0(0, 0, 0, 0.05) + yminorgridcolor = RGBAf(0, 0, 0, 0.05) "The linestyle of the x minor grid lines." xminorgridstyle = nothing "The linestyle of the y minor grid lines." @@ -309,7 +309,7 @@ function default_attributes(::Type{Colorbar}, scene) "The line width of the tick marks." tickwidth = 1f0 "The color of the tick marks." - tickcolor = RGBf0(0, 0, 0) + tickcolor = RGBf(0, 0, 0) "The horizontal and vertical alignment of the tick labels." ticklabelalign = Makie.automatic "The rotation of the ticklabels" @@ -325,13 +325,13 @@ function default_attributes(::Type{Colorbar}, scene) "Controls if the bottom spine is visible." bottomspinevisible = true "The color of the top spine." - topspinecolor = RGBf0(0, 0, 0) + topspinecolor = RGBf(0, 0, 0) "The color of the left spine." - leftspinecolor = RGBf0(0, 0, 0) + leftspinecolor = RGBf(0, 0, 0) "The color of the right spine." - rightspinecolor = RGBf0(0, 0, 0) + rightspinecolor = RGBf(0, 0, 0) "The color of the bottom spine." - bottomspinecolor = RGBf0(0, 0, 0) + bottomspinecolor = RGBf(0, 0, 0) "The vertical alignment of the colorbar in its suggested bounding box." valign = :center "The horizontal alignment of the colorbar in its suggested bounding box." @@ -450,7 +450,7 @@ function default_attributes(::Type{Box}, scene) "Controls if the rectangle is visible." visible = true "The color of the rectangle." - color = RGBf0(0.9, 0.9, 0.9) + color = RGBf(0.9, 0.9, 0.9) "The vertical alignment of the rectangle in its suggested boundingbox" valign = :center "The horizontal alignment of the rectangle in its suggested boundingbox" @@ -462,7 +462,7 @@ function default_attributes(::Type{Box}, scene) "Controls if the border of the rectangle is visible." strokevisible = true "The color of the border." - strokecolor = RGBf0(0, 0, 0) + strokecolor = RGBf(0, 0, 0) "The width setting of the rectangle." width = nothing "The height setting of the rectangle." @@ -519,7 +519,7 @@ function default_attributes(::Type{Button}, scene) "The color of the button border." strokecolor = :transparent "The color of the button." - buttoncolor = RGBf0(0.94, 0.94, 0.94) + buttoncolor = RGBf(0.94, 0.94, 0.94) "The color of the label." labelcolor = lift_parent_attribute(scene, :textcolor, :black) "The color of the label when the mouse hovers over the button." @@ -550,14 +550,14 @@ Button function default_attributes(::Type{LineAxis}) Attributes( - endpoints = (Point2f0(0, 0), Point2f0(100, 0)), + endpoints = (Point2f(0, 0), Point2f(100, 0)), trimspine = false, limits = (0f0, 100f0), flipped = false, flip_vertical_label = false, ticksize = 6f0, tickwidth = 1f0, - tickcolor = RGBf0(0, 0, 0), + tickcolor = RGBf(0, 0, 0), tickalign = 0f0, ticks = Makie.automatic, tickformat = Makie.automatic, @@ -565,12 +565,12 @@ function default_attributes(::Type{LineAxis}) ticksvisible = true, ticklabelrotation = 0f0, ticklabelsize = 20f0, - ticklabelcolor = RGBf0(0, 0, 0), + ticklabelcolor = RGBf(0, 0, 0), ticklabelsvisible = true, spinewidth = 1f0, label = "label", labelsize = 20f0, - labelcolor = RGBf0(0, 0, 0), + labelcolor = RGBf(0, 0, 0), labelvisible = true, ticklabelspace = Makie.automatic, ticklabelpad = 3f0, @@ -613,7 +613,7 @@ function default_attributes(::Type{Slider}, scene) "The color of the slider when the mouse clicks and drags the slider." color_active = COLOR_ACCENT[] "The color of the slider when it is not interacted with." - color_inactive = RGBf0(0.94, 0.94, 0.94) + color_inactive = RGBf(0.94, 0.94, 0.94) "Controls if the slider has a horizontal orientation or not." horizontal = true "The align mode of the slider in its parent GridLayout." @@ -661,7 +661,7 @@ function default_attributes(::Type{IntervalSlider}, scene) "The color of the slider when the mouse clicks and drags the slider." color_active = COLOR_ACCENT[] "The color of the slider when it is not interacted with." - color_inactive = RGBf0(0.94, 0.94, 0.94) + color_inactive = RGBf(0.94, 0.94, 0.94) "Controls if the slider has a horizontal orientation or not." horizontal = true "The align mode of the slider in its parent GridLayout." @@ -702,10 +702,10 @@ function default_attributes(::Type{Toggle}, scene) # strokewidth = 2f0 # strokecolor = :transparent "The color of the border when the toggle is inactive." - framecolor_inactive = RGBf0(0.94, 0.94, 0.94) + framecolor_inactive = RGBf(0.94, 0.94, 0.94) "The color of the border when the toggle is hovered." framecolor_active = COLOR_ACCENT_DIMMED[] - # buttoncolor = RGBf0(0.2, 0.2, 0.2) + # buttoncolor = RGBf(0.2, 0.2, 0.2) "The color of the toggle button." buttoncolor = COLOR_ACCENT[] "Indicates if the toggle is active or not." @@ -800,7 +800,7 @@ function default_attributes(::Type{Legend}, scene) "The gap between the patch and the label of each legend entry." patchlabelgap = 5 "The default points used for LineElements in normalized coordinates relative to each label patch." - linepoints = [Point2f0(0, 0.5), Point2f0(1, 0.5)] + linepoints = [Point2f(0, 0.5), Point2f(1, 0.5)] "The default line width used for LineElements." linewidth = theme(scene, :linewidth) "The default line color used for LineElements" @@ -812,7 +812,7 @@ function default_attributes(::Type{Legend}, scene) "The default marker for MarkerElements" marker = theme(scene, :marker) "The default marker points used for MarkerElements in normalized coordinates relative to each label patch." - markerpoints = [Point2f0(0.5, 0.5)] + markerpoints = [Point2f(0.5, 0.5)] "The default marker size used for MarkerElements." markersize = theme(scene, :markersize) "The default marker stroke width used for MarkerElements." @@ -820,7 +820,7 @@ function default_attributes(::Type{Legend}, scene) "The default marker stroke color used for MarkerElements." markerstrokecolor = theme(scene, :markerstrokecolor) "The default poly points used for PolyElements in normalized coordinates relative to each label patch." - polypoints = [Point2f0(0, 0), Point2f0(1, 0), Point2f0(1, 1), Point2f0(0, 1)] + polypoints = [Point2f(0, 0), Point2f(1, 0), Point2f(1, 1), Point2f(0, 1)] "The default poly stroke width used for PolyElements." polystrokewidth = theme(scene, :patchstrokewidth) "The default poly color used for PolyElements." @@ -936,7 +936,7 @@ function default_attributes(::Type{Textbox}, scene) "Text color." textcolor = lift_parent_attribute(scene, :textcolor, :black) "Text color for the placeholder." - textcolor_placeholder = RGBf0(0.5, 0.5, 0.5) + textcolor_placeholder = RGBf(0.5, 0.5, 0.5) "Font family." font = lift_parent_attribute(scene, :font, "DejaVu Sans") "Color of the box." @@ -944,17 +944,17 @@ function default_attributes(::Type{Textbox}, scene) "Color of the box when focused." boxcolor_focused = :transparent "Color of the box when focused." - boxcolor_focused_invalid = RGBAf0(1, 0, 0, 0.3) + boxcolor_focused_invalid = RGBAf(1, 0, 0, 0.3) "Color of the box when hovered." boxcolor_hover = :transparent "Color of the box border." - bordercolor = RGBf0(0.80, 0.80, 0.80) + bordercolor = RGBf(0.80, 0.80, 0.80) "Color of the box border when hovered." bordercolor_hover = COLOR_ACCENT_DIMMED[] "Color of the box border when focused." bordercolor_focused = COLOR_ACCENT[] "Color of the box border when focused and invalid." - bordercolor_focused_invalid = RGBf0(1, 0, 0) + bordercolor_focused_invalid = RGBf(1, 0, 0) "Width of the box border." borderwidth = 2f0 "Padding of the text against the box." @@ -1102,11 +1102,11 @@ function default_attributes(::Type{Axis3}, scene) "The z ticklabel font" zticklabelfont = lift_parent_attribute(scene, :font, "DejaVu Sans") "The x grid color" - xgridcolor = RGBAf0(0, 0, 0, 0.12) + xgridcolor = RGBAf(0, 0, 0, 0.12) "The y grid color" - ygridcolor = RGBAf0(0, 0, 0, 0.12) + ygridcolor = RGBAf(0, 0, 0, 0.12) "The z grid color" - zgridcolor = RGBAf0(0, 0, 0, 0.12) + zgridcolor = RGBAf(0, 0, 0, 0.12) "The x grid width" xgridwidth = 1 "The y grid width" @@ -1202,7 +1202,7 @@ function default_attributes(::Type{Axis3}, scene) "Controls if the xz panel is visible" xzpanelvisible = true "The limits that the axis tries to set given other constraints like aspect. Don't set this directly, use `xlims!`, `ylims!` or `limits!` instead." - targetlimits = FRect3D(Vec3f0(0, 0, 0), Vec3f0(1, 1, 1)) + targetlimits = Rect3f(Vec3f(0, 0, 0), Vec3f(1, 1, 1)) "The limits that the user has manually set. They are reinstated when calling `reset_limits!` and are set to nothing by `autolimits!`. Can be either a tuple (xlow, xhigh, ylow, high, zlow, zhigh) or a tuple (nothing_or_xlims, nothing_or_ylims, nothing_or_zlims). Are set by `xlims!`, `ylims!`, `zlims!` and `limits!`." limits = (nothing, nothing, nothing) "The relative margins added to the autolimits in x direction." diff --git a/src/makielayout/geometrybasics_extension.jl b/src/makielayout/geometrybasics_extension.jl index 34b25d76e5f..3edcc050fbe 100644 --- a/src/makielayout/geometrybasics_extension.jl +++ b/src/makielayout/geometrybasics_extension.jl @@ -1,21 +1,21 @@ -left(rect::Rect2D) = minimum(rect)[1] -right(rect::Rect2D) = maximum(rect)[1] -bottom(rect::Rect2D) = minimum(rect)[2] -top(rect::Rect2D) = maximum(rect)[2] +left(rect::Rect2) = minimum(rect)[1] +right(rect::Rect2) = maximum(rect)[1] +bottom(rect::Rect2) = minimum(rect)[2] +top(rect::Rect2) = maximum(rect)[2] -bottomleft(bbox::Rect2D) = Point(left(bbox), bottom(bbox)) -topleft(bbox::Rect2D) = Point(left(bbox), top(bbox)) -bottomright(bbox::Rect2D) = Point(right(bbox), bottom(bbox)) -topright(bbox::Rect2D) = Point(right(bbox), top(bbox)) +bottomleft(bbox::Rect2) = Point(left(bbox), bottom(bbox)) +topleft(bbox::Rect2) = Point(left(bbox), top(bbox)) +bottomright(bbox::Rect2) = Point(right(bbox), bottom(bbox)) +topright(bbox::Rect2) = Point(right(bbox), top(bbox)) -topline(bbox::Rect2D) = (topleft(bbox), topright(bbox)) -bottomline(bbox::Rect2D) = (bottomleft(bbox), bottomright(bbox)) -leftline(bbox::Rect2D) = (bottomleft(bbox), topleft(bbox)) -rightline(bbox::Rect2D) = (bottomright(bbox), topright(bbox)) +topline(bbox::Rect2) = (topleft(bbox), topright(bbox)) +bottomline(bbox::Rect2) = (bottomleft(bbox), bottomright(bbox)) +leftline(bbox::Rect2) = (bottomleft(bbox), topleft(bbox)) +rightline(bbox::Rect2) = (bottomright(bbox), topright(bbox)) function shrinkbymargin(rect, margin) - return IRect(minimum(rect) .+ margin, (widths(rect) .- 2 .* margin)) + return Recti(minimum(rect) .+ margin, (widths(rect) .- 2 .* margin)) end function limits(r::Rect{N, T}) where {N, T} @@ -30,18 +30,18 @@ end xlimits(r::Rect) = limits(r, 1) ylimits(r::Rect) = limits(r, 2) -function enlarge(bbox::Rect2D, l, r, b, t) +function enlarge(bbox::Rect2, l, r, b, t) BBox(left(bbox) - l, right(bbox) + r, bottom(bbox) - b, top(bbox) + t) end -function center(bbox::Rect2D) +function center(bbox::Rect2) Point2((right(bbox) + left(bbox)) / 2, (top(bbox) + bottom(bbox)) / 2) end """ Converts a point in fractions of rect dimensions into real coordinates. """ -function fractionpoint(bbox::FRect2D, point::T) where T <: Point2 +function fractionpoint(bbox::Rect2f, point::T) where T <: Point2 T(left(bbox) + point[1] * width(bbox), bottom(bbox) + point[2] * height(bbox)) end diff --git a/src/makielayout/helpers.jl b/src/makielayout/helpers.jl index bcf375477bf..9fa14d9124b 100644 --- a/src/makielayout/helpers.jl +++ b/src/makielayout/helpers.jl @@ -12,7 +12,7 @@ end function sceneareanode!(finalbbox, limits, aspect) - scenearea = Node(IRect(0, 0, 100, 100)) + scenearea = Node(Recti(0, 0, 100, 100)) onany(finalbbox, limits, aspect) do bbox, limits, aspect @@ -172,7 +172,7 @@ function layoutscene(nrows::Int, ncols::Int, padding = 30; inspectable = false, end -GridLayoutBase.GridLayout(scene::Scene, args...; kwargs...) = GridLayout(args...; bbox = lift(x -> FRect2D(x), pixelarea(scene)), kwargs...) +GridLayoutBase.GridLayout(scene::Scene, args...; kwargs...) = GridLayout(args...; bbox = lift(x -> Rect2f(x), pixelarea(scene)), kwargs...) function axislines!(scene, rect, spinewidth, topspinevisible, rightspinevisible, leftspinevisible, bottomspinevisible, topspinecolor, leftspinecolor, @@ -414,9 +414,9 @@ function hvlines!(ax::Axis, direction::Int, datavals, axmins, axmaxs; attributes xfrac(f) = xlims[1] + f * (xlims[2] - xlims[1]) segs = broadcast(datavals, axmins, axmaxs) do dataval, axmin, axmax if direction == 1 - (Point2f0(xfrac(axmin), dataval), Point2f0(xfrac(axmax), dataval)) + (Point2f(xfrac(axmin), dataval), Point2f(xfrac(axmax), dataval)) elseif direction == 2 - (Point2f0(dataval, xfrac(axmin)), Point2f0(dataval, xfrac(axmax))) + (Point2f(dataval, xfrac(axmin)), Point2f(dataval, xfrac(axmax))) else error("direction must be 1 or 2") end @@ -460,7 +460,7 @@ function abline!(axis::Axis, a::Number, b::Number; kwargs...) f(x) = x * b + a line = map(axis.finallimits) do limits xmin, xmax = first.(extrema(limits)) - return [Point2f0(xmin, f(xmin)), Point2f0(xmax, f(xmax))] + return [Point2f(xmin, f(xmin)), Point2f(xmax, f(xmax))] end return linesegments!(axis, line; xautolimits=false, yautolimits=false, kwargs...) end diff --git a/src/makielayout/interactions.jl b/src/makielayout/interactions.jl index d0bf228d029..258bfbde1ff 100644 --- a/src/makielayout/interactions.jl +++ b/src/makielayout/interactions.jl @@ -109,21 +109,21 @@ end function _chosen_limits(rz, ax) - r = positivize(FRect2D(rz.from, rz.to .- rz.from)) + r = positivize(Rect2f(rz.from, rz.to .- rz.from)) lims = ax.finallimits[] # restrict to y change if rz.restrict_x || !ax.xrectzoom[] - r = FRect2D(lims.origin[1], r.origin[2], widths(lims)[1], widths(r)[2]) + r = Rect2f(lims.origin[1], r.origin[2], widths(lims)[1], widths(r)[2]) end # restrict to x change if rz.restrict_y || !ax.yrectzoom[] - r = FRect2D(r.origin[1], lims.origin[2], widths(r)[1], widths(lims)[2]) + r = Rect2f(r.origin[1], lims.origin[2], widths(r)[1], widths(lims)[2]) end return r end function _selection_vertices(outer, inner) - _clamp(p, plow, phigh) = Point2f0(clamp(p[1], plow[1], phigh[1]), clamp(p[2], plow[2], phigh[2])) + _clamp(p, plow, phigh) = Point2f(clamp(p[1], plow[1], phigh[1]), clamp(p[2], plow[2], phigh[2])) outer = positivize(outer) inner = positivize(inner) @@ -203,11 +203,11 @@ function process_interaction(r::RectangleZoom, event::KeysEvent, ax::Axis) end -function positivize(r::FRect2D) +function positivize(r::Rect2f) negwidths = r.widths .< 0 newori = ifelse.(negwidths, r.origin .+ r.widths, r.origin) newwidths = ifelse.(negwidths, -r.widths, r.widths) - FRect2D(newori, newwidths) + Rect2f(newori, newwidths) end function process_interaction(l::LimitReset, event::MouseEvent, ax::Axis) @@ -245,7 +245,7 @@ function process_interaction(s::ScrollZoom, event::ScrollEvent, ax::Axis) z = (1f0 - s.speed)^zoom - mp_axscene = Vec4f0((e.mouseposition[] .- pa.origin)..., 0, 1) + mp_axscene = Vec4f((e.mouseposition[] .- pa.origin)..., 0, 1) # first to normal -1..1 space mp_axfraction = (cam.pixel_space[] * mp_axscene)[1:2] .* @@ -275,11 +275,11 @@ function process_interaction(s::ScrollZoom, event::ScrollEvent, ax::Axis) timed_ticklabelspace_reset(ax, s.reset_timer, s.prev_xticklabelspace, s.prev_yticklabelspace, s.reset_delay) newrect_trans = if ispressed(scene, xzoomkey[]) - FRect(newxorigin, yorigin, newxwidth, ywidth) + Rectf(newxorigin, yorigin, newxwidth, ywidth) elseif ispressed(scene, yzoomkey[]) - FRect(xorigin, newyorigin, xwidth, newywidth) + Rectf(xorigin, newyorigin, xwidth, newywidth) else - FRect(newxorigin, newyorigin, newxwidth, newywidth) + Rectf(newxorigin, newyorigin, newxwidth, newywidth) end inv_transf = Makie.inverse_transform(transf) @@ -307,8 +307,8 @@ function process_interaction(dp::DragPan, event::MouseEvent, ax) cam = camera(scene) pa = pixelarea(scene)[] - mp_axscene = Vec4f0((event.px .- pa.origin)..., 0, 1) - mp_axscene_prev = Vec4f0((event.prev_px .- pa.origin)..., 0, 1) + mp_axscene = Vec4f((event.px .- pa.origin)..., 0, 1) + mp_axscene_prev = Vec4f((event.prev_px .- pa.origin)..., 0, 1) mp_axfraction, mp_axfraction_prev = map((mp_axscene, mp_axscene_prev)) do mp # first to normal -1..1 space @@ -346,7 +346,7 @@ function process_interaction(dp::DragPan, event::MouseEvent, ax) timed_ticklabelspace_reset(ax, dp.reset_timer, dp.prev_xticklabelspace, dp.prev_yticklabelspace, dp.reset_delay) inv_transf = Makie.inverse_transform(transf) - newrect_trans = FRect(Vec2f0(xori, yori), widths(tlimits_trans)) + newrect_trans = Rectf(Vec2f(xori, yori), widths(tlimits_trans)) tlimits[] = Makie.apply_transform(inv_transf, newrect_trans) return Consume(true) diff --git a/src/makielayout/layoutables/axis.jl b/src/makielayout/layoutables/axis.jl index 33523d10794..766793d9165 100644 --- a/src/makielayout/layoutables/axis.jl +++ b/src/makielayout/layoutables/axis.jl @@ -49,8 +49,8 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n # initialize either with user limits, or pick defaults based on scales # so that we don't immediately error - targetlimits = Node{FRect2D}(defaultlimits(limits[], attrs.xscale[], attrs.yscale[])) - finallimits = Node{FRect2D}(targetlimits[]) + targetlimits = Node{Rect2f}(defaultlimits(limits[], attrs.xscale[], attrs.yscale[])) + finallimits = Node{Rect2f}(targetlimits[]) # the first thing to do when setting a new scale is # resetting the limits because simply through expanding they might be invalid for log @@ -85,7 +85,7 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n campixel!(scene) - xgridnode = Node(Point2f0[]) + xgridnode = Node(Point2f[]) xgridlines = linesegments!( topscene, xgridnode, linewidth = xgridwidth, show_axis = false, visible = xgridvisible, color = xgridcolor, linestyle = xgridstyle, inspectable = false @@ -94,7 +94,7 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n translate!(xgridlines, 0, 0, -10) decorations[:xgridlines] = xgridlines - xminorgridnode = Node(Point2f0[]) + xminorgridnode = Node(Point2f[]) xminorgridlines = linesegments!( topscene, xminorgridnode, linewidth = xminorgridwidth, show_axis = false, visible = xminorgridvisible, color = xminorgridcolor, linestyle = xminorgridstyle, inspectable = false @@ -103,7 +103,7 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n translate!(xminorgridlines, 0, 0, -10) decorations[:xminorgridlines] = xminorgridlines - ygridnode = Node(Point2f0[]) + ygridnode = Node(Point2f[]) ygridlines = linesegments!( topscene, ygridnode, linewidth = ygridwidth, show_axis = false, visible = ygridvisible, color = ygridcolor, linestyle = ygridstyle, inspectable = false @@ -112,7 +112,7 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n translate!(ygridlines, 0, 0, -10) decorations[:ygridlines] = ygridlines - yminorgridnode = Node(Point2f0[]) + yminorgridnode = Node(Point2f[]) yminorgridlines = linesegments!( topscene, yminorgridnode, linewidth = yminorgridwidth, show_axis = false, visible = yminorgridvisible, color = yminorgridcolor, linestyle = yminorgridstyle, inspectable = false @@ -147,9 +147,9 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n xaxis_endpoints = lift(xaxisposition, scene.px_area) do xaxisposition, area if xaxisposition == :bottom - bottomline(FRect2D(area)) + bottomline(Rect2f(area)) elseif xaxisposition == :top - topline(FRect2D(area)) + topline(Rect2f(area)) else error("Invalid xaxisposition $xaxisposition") end @@ -157,9 +157,9 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n yaxis_endpoints = lift(yaxisposition, scene.px_area) do yaxisposition, area if yaxisposition == :left - leftline(FRect2D(area)) + leftline(Rect2f(area)) elseif yaxisposition == :right - rightline(FRect2D(area)) + rightline(Rect2f(area)) else error("Invalid yaxisposition $yaxisposition") end @@ -278,28 +278,28 @@ function layoutable(::Type{<:Axis}, fig_or_scene::Union{Figure, Scene}; bbox = n on(xaxis.tickpositions) do tickpos pxheight = height(scene.px_area[]) offset = xaxisposition[] == :bottom ? pxheight : -pxheight - opposite_tickpos = tickpos .+ Ref(Point2f0(0, offset)) + opposite_tickpos = tickpos .+ Ref(Point2f(0, offset)) xgridnode[] = interleave_vectors(tickpos, opposite_tickpos) end on(yaxis.tickpositions) do tickpos pxwidth = width(scene.px_area[]) offset = yaxisposition[] == :left ? pxwidth : -pxwidth - opposite_tickpos = tickpos .+ Ref(Point2f0(offset, 0)) + opposite_tickpos = tickpos .+ Ref(Point2f(offset, 0)) ygridnode[] = interleave_vectors(tickpos, opposite_tickpos) end on(xaxis.minortickpositions) do tickpos pxheight = height(scene.px_area[]) offset = xaxisposition[] == :bottom ? pxheight : -pxheight - opposite_tickpos = tickpos .+ Ref(Point2f0(0, offset)) + opposite_tickpos = tickpos .+ Ref(Point2f(0, offset)) xminorgridnode[] = interleave_vectors(tickpos, opposite_tickpos) end on(yaxis.minortickpositions) do tickpos pxwidth = width(scene.px_area[]) offset = yaxisposition[] == :left ? pxwidth : -pxwidth - opposite_tickpos = tickpos .+ Ref(Point2f0(offset, 0)) + opposite_tickpos = tickpos .+ Ref(Point2f(offset, 0)) yminorgridnode[] = interleave_vectors(tickpos, opposite_tickpos) end @@ -546,9 +546,9 @@ function reset_limits!(ax; xauto = true, yauto = true, zauto = true) if ax isa Axis ax.targetlimits[] = BBox(xlims..., ylims...) elseif ax isa Axis3 - ax.targetlimits[] = FRect3D( - Vec3f0(xlims[1], ylims[1], zlims[1]), - Vec3f0(xlims[2] - xlims[1], ylims[2] - ylims[1], zlims[2] - zlims[1]), + ax.targetlimits[] = Rect3f( + Vec3f(xlims[1], ylims[1], zlims[1]), + Vec3f(xlims[2] - xlims[1], ylims[2] - ylims[1], zlims[2] - zlims[1]), ) end nothing @@ -695,7 +695,7 @@ function expandbboxwithfractionalmargins(bb, margins) newwidths = bb.widths .* (1f0 .+ margins) diffs = newwidths .- bb.widths neworigin = bb.origin .- (0.5f0 .* diffs) - FRect2D(neworigin, newwidths) + Rect2f(neworigin, newwidths) end function limitunion(lims1, lims2) @@ -750,7 +750,7 @@ function getlimits(la::Axis, dim) plots_with_autolimits) # get all data limits - bboxes = [FRect2D(Makie.data_limits(p)) for p in visible_plots] + bboxes = [Rect2f(Makie.data_limits(p)) for p in visible_plots] # filter out bboxes that are invalid somehow finite_bboxes = filter(Makie.isfinite_rect, bboxes) @@ -1221,12 +1221,12 @@ function limits!(ax::Axis, x1, x2, y1, y2) end """ - limits!(ax::Axis, rect::Rect2D) + limits!(ax::Axis, rect::Rect2) Set the axis limits to `rect`. If limits are ordered high-low, this reverses the axis orientation. """ -function limits!(ax::Axis, rect::Rect2D) +function limits!(ax::Axis, rect::Rect2) xmin, ymin = minimum(rect) xmax, ymax = maximum(rect) Makie.xlims!(ax, xmin, xmax) diff --git a/src/makielayout/layoutables/axis3d.jl b/src/makielayout/layoutables/axis3d.jl index e294c8221b9..4aade60f801 100644 --- a/src/makielayout/layoutables/axis3d.jl +++ b/src/makielayout/layoutables/axis3d.jl @@ -26,7 +26,7 @@ function layoutable(::Type{<:Axis3}, fig_or_scene::Union{Figure, Scene}; bbox = notify(protrusions) - finallimits = Node(FRect3D(Vec3f0(0f0, 0f0, 0f0), Vec3f0(100f0, 100f0, 100f0))) + finallimits = Node(Rect3f(Vec3f(0f0, 0f0, 0f0), Vec3f(100f0, 100f0, 100f0))) scenearea = lift(round_to_IRect2D, layoutobservables.computedbbox) @@ -217,7 +217,7 @@ function calculate_matrices(limits, px_area, elev, azim, perspectiveness, aspect # for eyeposition dependent algorithms, we need to present the position as if # there was no scaling applied - eyeposition = Vec3f0(inv(scale_matrix) * Vec4f0(eyepos..., 1)) + eyeposition = Vec3f(inv(scale_matrix) * Vec4f(eyepos..., 1)) view_matrix, projection_matrix, eyeposition end @@ -236,9 +236,9 @@ function projectionmatrix(viewmatrix, limits, eyepos, radius, azim, elev, angle, pm = Makie.perspectiveprojection(Float64, angle, aspect_ratio, near, far) if viewmode in (:fitzoom, :stretch) - points = decompose(Point3f0, limits) + points = decompose(Point3f, limits) # @show points - projpoints = Ref(pm * viewmatrix) .* to_ndim.(Point4f0, points, 1) + projpoints = Ref(pm * viewmatrix) .* to_ndim.(Point4f, points, 1) maxx = maximum(x -> abs(x[1] / x[4]), projpoints) maxy = maximum(x -> abs(x[2] / x[4]), projpoints) @@ -289,15 +289,15 @@ function autolimits!(ax::Axis3) ylims = getlimits(ax, 2) zlims = getlimits(ax, 3) - ori = Vec3f0(xlims[1], ylims[1], zlims[1]) - widths = Vec3f0(xlims[2] - xlims[1], ylims[2] - ylims[1], zlims[2] - zlims[1]) + ori = Vec3f(xlims[1], ylims[1], zlims[1]) + widths = Vec3f(xlims[2] - xlims[1], ylims[2] - ylims[1], zlims[2] - zlims[1]) enlarge_factor = 0.1 nori = ori .- (0.5 * enlarge_factor) * widths nwidths = widths .* (1 + enlarge_factor) - lims = FRect3D(nori, nwidths) + lims = Rect3f(nori, nwidths) ax.finallimits[] = lims nothing @@ -445,10 +445,10 @@ end # small z value function to_topscene_z_2d(p3d, scene) o = scene.px_area[].origin - p2d = Point2f0(o + Makie.project(scene, p3d)) + p2d = Point2f(o + Makie.project(scene, p3d)) # -10000 is an arbitrary weird constant that in preliminary testing didn't seem # to clip into plot objects anymore - Point3f0(p2d..., -10000) + Point3f(p2d..., -10000) end function add_ticks_and_ticklabels!(topscene, scene, dim::Int, limits, ticknode, miv, min1, min2, attrs, azimuth) @@ -514,16 +514,16 @@ function add_ticks_and_ticklabels!(topscene, scene, dim::Int, limits, ticknode, o = pxa.origin points = map(ticksegs) do (tstart, tend) - tstartp = Point2f0(o + Makie.project(scene, tstart)) - tendp = Point2f0(o + Makie.project(scene, tend)) + tstartp = Point2f(o + Makie.project(scene, tstart)) + tendp = Point2f(o + Makie.project(scene, tend)) offset = pad * Makie.GeometryBasics.normalize( - Point2f0(tendp - tstartp)) + Point2f(tendp - tstartp)) tendp + offset end v = collect(zip(ticklabs, points)) - v::Vector{Tuple{String, Point2f0}} + v::Vector{Tuple{String, Point2f}} end align = lift(miv, min1, min2) do mv, m1, m2 @@ -558,8 +558,8 @@ function add_ticks_and_ticklabels!(topscene, scene, dim::Int, limits, ticknode, p2 = dpoint(maximum(lims)[dim], f1, f2) # project them into screen space - pp1 = Point2f0(o + Makie.project(scene, p1)) - pp2 = Point2f0(o + Makie.project(scene, p2)) + pp1 = Point2f(o + Makie.project(scene, p1)) + pp2 = Point2f(o + Makie.project(scene, p2)) # find the midpoint midpoint = (pp1 + pp2) / 2 @@ -576,7 +576,7 @@ function add_ticks_and_ticklabels!(topscene, scene, dim::Int, limits, ticknode, a = pi/2 # get the vector pointing from the axis in the direction of the label anchor - offset_vec = (Makie.Mat2f0(cos(a), sin(a), -sin(a), cos(a)) * + offset_vec = (Makie.Mat2f(cos(a), sin(a), -sin(a), cos(a)) * Makie.GeometryBasics.normalize(diffsign * diff)) # calculate the label offset from the axis midpoint @@ -895,12 +895,12 @@ function limits!(ax::Axis3, x1, x2, y1, y2, z1, z2) end """ - limits!(ax::Axis3, rect::Rect3D) + limits!(ax::Axis3, rect::Rect3) Set the axis limits to `rect`. If limits are ordered high-low, this reverses the axis orientation. """ -function limits!(ax::Axis3, rect::Rect3D) +function limits!(ax::Axis3, rect::Rect3) xmin, ymin, zmin = minimum(rect) xmax, ymax, zmax = maximum(rect) Makie.xlims!(ax, xmin, xmax) diff --git a/src/makielayout/layoutables/box.jl b/src/makielayout/layoutables/box.jl index 2223a661c94..265136f1507 100644 --- a/src/makielayout/layoutables/box.jl +++ b/src/makielayout/layoutables/box.jl @@ -13,7 +13,7 @@ function layoutable(::Type{Box}, fig_or_scene; bbox = nothing, kwargs...) halign, valign, attrs.alignmode; suggestedbbox = bbox) strokecolor_with_visibility = lift(strokecolor, strokevisible) do col, vis - vis ? col : RGBAf0(0, 0, 0, 0) + vis ? col : RGBAf(0, 0, 0, 0) end ibbox = @lift(round_to_IRect2D($(layoutobservables.computedbbox))) diff --git a/src/makielayout/layoutables/button.jl b/src/makielayout/layoutables/button.jl index 467ba0322c6..055ea8b2282 100644 --- a/src/makielayout/layoutables/button.jl +++ b/src/makielayout/layoutables/button.jl @@ -16,7 +16,7 @@ function layoutable(::Type{Button}, fig_or_scene::FigureLike; bbox = nothing, kw layoutobservables = LayoutObservables{Button}(attrs.width, attrs.height, attrs.tellwidth, attrs.tellheight, halign, valign, attrs.alignmode; suggestedbbox = bbox) - textpos = Node(Point2f0(0, 0)) + textpos = Node(Point2f(0, 0)) subarea = lift(layoutobservables.computedbbox) do bbox round_to_IRect2D(bbox) @@ -31,7 +31,7 @@ function layoutable(::Type{Button}, fig_or_scene::FigureLike; bbox = nothing, kw end on(buttonrect) do rect - textpos[] = Point2f0(left(rect) + 0.5f0 * width(rect), bottom(rect) + 0.5f0 * height(rect)) + textpos[] = Point2f(left(rect) + 0.5f0 * width(rect), bottom(rect) + 0.5f0 * height(rect)) end roundedrectpoints = lift(roundedrectvertices, buttonrect, cornerradius, cornersegments) @@ -58,7 +58,7 @@ function layoutable(::Type{Button}, fig_or_scene::FigureLike; bbox = nothing, kw onany(label, textsize, font, padding) do label, textsize, font, padding - textbb = FRect2D(boundingbox(labeltext)) + textbb = Rect2f(boundingbox(labeltext)) autowidth = width(textbb) + padding[1] + padding[2] autoheight = height(textbb) + padding[3] + padding[4] layoutobservables.autosize[] = (autowidth, autoheight) diff --git a/src/makielayout/layoutables/colorbar.jl b/src/makielayout/layoutables/colorbar.jl index 60c0817683a..bdd13a29ed7 100644 --- a/src/makielayout/layoutables/colorbar.jl +++ b/src/makielayout/layoutables/colorbar.jl @@ -230,11 +230,11 @@ function layoutable(::Type{<:Colorbar}, fig_or_scene; bbox = nothing, kwargs...) lb, rb = topline(box) l = lb r = rb - t = ((l .+ r) ./ 2) .+ Point2f0(0, sqrt(sum((r .- l) .^ 2)) * sin(pi/3)) + t = ((l .+ r) ./ 2) .+ Point2f(0, sqrt(sum((r .- l) .^ 2)) * sin(pi/3)) [l, r, t] else b, t = rightline(box) - r = ((b .+ t) ./ 2) .+ Point2f0(sqrt(sum((t .- b) .^ 2)) * sin(pi/3), 0) + r = ((b .+ t) ./ 2) .+ Point2f(sqrt(sum((t .- b) .^ 2)) * sin(pi/3), 0) [t, b, r] end end @@ -257,11 +257,11 @@ function layoutable(::Type{<:Colorbar}, fig_or_scene; bbox = nothing, kwargs...) lb, rb = bottomline(box) l = lb r = rb - t = ((l .+ r) ./ 2) .- Point2f0(0, sqrt(sum((r .- l) .^ 2)) * sin(pi/3)) + t = ((l .+ r) ./ 2) .- Point2f(0, sqrt(sum((r .- l) .^ 2)) * sin(pi/3)) [l, r, t] else b, t = leftline(box) - l = ((b .+ t) ./ 2) .- Point2f0(sqrt(sum((t .- b) .^ 2)) * sin(pi/3), 0) + l = ((b .+ t) ./ 2) .- Point2f(sqrt(sum((t .- b) .^ 2)) * sin(pi/3), 0) [b, t, l] end end diff --git a/src/makielayout/layoutables/intervalslider.jl b/src/makielayout/layoutables/intervalslider.jl index 9b7dd367533..6439b3b28b4 100644 --- a/src/makielayout/layoutables/intervalslider.jl +++ b/src/makielayout/layoutables/intervalslider.jl @@ -36,12 +36,12 @@ function layoutable(::Type{IntervalSlider}, fig_or_scene; bbox = nothing, kwargs if horizontal y = bottom(bb) + h / 2 - [Point2f0(left(bb) + h/2, y), - Point2f0(right(bb) - h/2, y)] + [Point2f(left(bb) + h/2, y), + Point2f(right(bb) - h/2, y)] else x = left(bb) + w / 2 - [Point2f0(x, bottom(bb) + w/2), - Point2f0(x, top(bb) - w/2)] + [Point2f(x, bottom(bb) + w/2), + Point2f(x, top(bb) - w/2)] end end @@ -90,7 +90,7 @@ function layoutable(::Type{IntervalSlider}, fig_or_scene; bbox = nothing, kwargs end middlepoints = lift(endpoints, displayed_sliderfractions) do ep, sfs - [Point2f0(ep[1] .+ sf .* (ep[2] .- ep[1])) for sf in sfs] + [Point2f(ep[1] .+ sf .* (ep[2] .- ep[1])) for sf in sfs] end linepoints = lift(endpoints, middlepoints) do eps, middles diff --git a/src/makielayout/layoutables/label.jl b/src/makielayout/layoutables/label.jl index 0e5fc8b2005..7287eb05783 100644 --- a/src/makielayout/layoutables/label.jl +++ b/src/makielayout/layoutables/label.jl @@ -15,7 +15,7 @@ function layoutable(::Type{Label}, fig_or_scene; bbox = nothing, kwargs...) layoutobservables = LayoutObservables{Label}(attrs.width, attrs.height, attrs.tellwidth, attrs.tellheight, halign, valign, attrs.alignmode; suggestedbbox = bbox) - textpos = Node(Point3f0(0, 0, 0)) + textpos = Node(Point3f(0, 0, 0)) # this is just a hack until boundingboxes in Makie are perfect alignnode = lift(halign, rotation) do h, rot @@ -33,7 +33,7 @@ function layoutable(::Type{Label}, fig_or_scene; bbox = nothing, kwargs...) textbb = Ref(BBox(0, 1, 0, 1)) onany(text, textsize, font, rotation, padding) do text, textsize, font, rotation, padding - textbb[] = FRect2D(boundingbox(t)) + textbb[] = Rect2f(boundingbox(t)) autowidth = width(textbb[]) + padding[1] + padding[2] autoheight = height(textbb[]) + padding[3] + padding[4] layoutobservables.autosize[] = (autowidth, autoheight) @@ -56,7 +56,7 @@ function layoutable(::Type{Label}, fig_or_scene; bbox = nothing, kwargs...) end ty = boy + padding[3] + 0.5 * th - textpos[] = Point3f0(tx, ty, 0) + textpos[] = Point3f(tx, ty, 0) end diff --git a/src/makielayout/layoutables/legend.jl b/src/makielayout/layoutables/legend.jl index 94822b292e6..5cf7774f81c 100644 --- a/src/makielayout/layoutables/legend.jl +++ b/src/makielayout/layoutables/legend.jl @@ -263,7 +263,7 @@ function layoutable(::Type{Legend}, end -function legendelement_plots!(scene, element::MarkerElement, bbox::Node{FRect2D}, defaultattrs::Attributes) +function legendelement_plots!(scene, element::MarkerElement, bbox::Node{Rect2f}, defaultattrs::Attributes) merge!(element.attributes, defaultattrs) attrs = element.attributes @@ -276,7 +276,7 @@ function legendelement_plots!(scene, element::MarkerElement, bbox::Node{FRect2D} [scat] end -function legendelement_plots!(scene, element::LineElement, bbox::Node{FRect2D}, defaultattrs::Attributes) +function legendelement_plots!(scene, element::LineElement, bbox::Node{Rect2f}, defaultattrs::Attributes) merge!(element.attributes, defaultattrs) attrs = element.attributes @@ -288,7 +288,7 @@ function legendelement_plots!(scene, element::LineElement, bbox::Node{FRect2D}, [lin] end -function legendelement_plots!(scene, element::PolyElement, bbox::Node{FRect2D}, defaultattrs::Attributes) +function legendelement_plots!(scene, element::PolyElement, bbox::Node{Rect2f}, defaultattrs::Attributes) merge!(element.attributes, defaultattrs) attrs = element.attributes diff --git a/src/makielayout/layoutables/menu.jl b/src/makielayout/layoutables/menu.jl index b705aa34bb2..6e2d6b9941c 100644 --- a/src/makielayout/layoutables/menu.jl +++ b/src/makielayout/layoutables/menu.jl @@ -25,11 +25,11 @@ function default_attributes(::Type{Menu}, scene) "Cell color when active" cell_color_active = COLOR_ACCENT[] "Cell color when inactive even" - cell_color_inactive_even = RGBf0(0.97, 0.97, 0.97) + cell_color_inactive_even = RGBf(0.97, 0.97, 0.97) "Cell color when inactive odd" - cell_color_inactive_odd = RGBf0(0.97, 0.97, 0.97) + cell_color_inactive_odd = RGBf(0.97, 0.97, 0.97) "Selection cell color when inactive" - selection_cell_color_inactive = RGBf0(0.94, 0.94, 0.94) + selection_cell_color_inactive = RGBf(0.94, 0.94, 0.94) "Color of the dropdown arrow" dropdown_arrow_color = (:black, 0.2) "Size of the dropdown arrow" @@ -150,7 +150,7 @@ function layoutable(::Type{Menu}, fig_or_scene; bbox = nothing, kwargs...) translate!(scene, 0, 0, 21) contentgrid = GridLayout( - bbox = lift(x -> FRect2D(Makie.zero_origin(x)), scenearea), + bbox = lift(x -> Rect2f(Makie.zero_origin(x)), scenearea), valign = @lift($_direction == :down ? :top : :bottom)) selectionrect = Box(scene, width = nothing, height = nothing, @@ -217,7 +217,7 @@ function layoutable(::Type{Menu}, fig_or_scene; bbox = nothing, kwargs...) dropdown_arrow = scatter!(scene, - lift(x -> [Point2f0(width(x) - 20, (top(x) + bottom(x)) / 2)], selectionrect.layoutobservables.computedbbox), + lift(x -> [Point2f(width(x) - 20, (top(x) + bottom(x)) / 2)], selectionrect.layoutobservables.computedbbox), marker = @lift($is_open ? '▴' : '▾'), markersize = dropdown_arrow_size, color = dropdown_arrow_color, diff --git a/src/makielayout/layoutables/slider.jl b/src/makielayout/layoutables/slider.jl index af2caaee1d8..320ec14f59a 100644 --- a/src/makielayout/layoutables/slider.jl +++ b/src/makielayout/layoutables/slider.jl @@ -36,12 +36,12 @@ function layoutable(::Type{Slider}, fig_or_scene; bbox = nothing, kwargs...) if horizontal y = bottom(bb) + h / 2 - [Point2f0(left(bb) + h/2, y), - Point2f0(right(bb) - h/2, y)] + [Point2f(left(bb) + h/2, y), + Point2f(right(bb) - h/2, y)] else x = left(bb) + w / 2 - [Point2f0(x, bottom(bb) + w/2), - Point2f0(x, top(bb) - w/2)] + [Point2f(x, bottom(bb) + w/2), + Point2f(x, top(bb) - w/2)] end end @@ -84,7 +84,7 @@ function layoutable(::Type{Slider}, fig_or_scene; bbox = nothing, kwargs...) selected_index[] = closest_index(sliderrange[], startvalue[]) middlepoint = lift(endpoints, displayed_sliderfraction) do ep, sf - Point2f0(ep[1] .+ sf .* (ep[2] .- ep[1])) + Point2f(ep[1] .+ sf .* (ep[2] .- ep[1])) end linepoints = lift(endpoints, middlepoint) do eps, middle diff --git a/src/makielayout/layoutables/textbox.jl b/src/makielayout/layoutables/textbox.jl index ae701f03a99..098ebd98d4c 100644 --- a/src/makielayout/layoutables/textbox.jl +++ b/src/makielayout/layoutables/textbox.jl @@ -31,7 +31,7 @@ function layoutable(::Type{Textbox}, fig_or_scene; bbox = nothing, kwargs...) - bbox = lift(FRect2D ∘ Makie.zero_origin, scenearea) + bbox = lift(Rect2f ∘ Makie.zero_origin, scenearea) roundedrectpoints = lift(roundedrectvertices, scenearea, cornerradius, cornersegments) @@ -111,7 +111,7 @@ function layoutable(::Type{Textbox}, fig_or_scene; bbox = nothing, kwargs...) elseif ci == 0 [leftline(bbs[1])...] else - [leftline(bbs[ci])...] .+ Point2f0(hadvances[ci], 0) + [leftline(bbs[ci])...] .+ Point2f(hadvances[ci], 0) end end @@ -274,11 +274,11 @@ function charbbs(text) if !(gc isa Makie.GlyphCollection) error("Expected a single GlyphCollection from the textbox string, got a $(typeof(gc)).") end - pos = Point2f0(text.position[]) - bbs = FRect2D[] + pos = Point2f(text.position[]) + bbs = Rect2f[] broadcast_foreach(gc.extents, gc.scales, gc.origins, gc.fonts) do ext, sc, ori, font bb = Makie.FreeTypeAbstraction.height_insensitive_boundingbox(ext, font) * sc - fr = FRect2D(Point2f0(ori) + bb.origin + pos, bb.widths) + fr = Rect2f(Point2f(ori) + bb.origin + pos, bb.widths) push!(bbs, fr) end bbs diff --git a/src/makielayout/layoutables/toggle.jl b/src/makielayout/layoutables/toggle.jl index 6ef112ddb84..31a8da3ccd7 100644 --- a/src/makielayout/layoutables/toggle.jl +++ b/src/makielayout/layoutables/toggle.jl @@ -20,12 +20,12 @@ function layoutable(::Type{Toggle}, fig_or_scene; bbox = nothing, kwargs...) button_endpoint_inactive = lift(markersize) do ms bbox = layoutobservables.computedbbox[] - Point2f0(left(bbox) + ms / 2, bottom(bbox) + ms / 2) + Point2f(left(bbox) + ms / 2, bottom(bbox) + ms / 2) end button_endpoint_active = lift(markersize) do ms bbox = layoutobservables.computedbbox[] - Point2f0(right(bbox) - ms / 2, bottom(bbox) + ms / 2) + Point2f(right(bbox) - ms / 2, bottom(bbox) + ms / 2) end buttonvertices = lift(markersize, cornersegments) do ms, cs diff --git a/src/makielayout/lineaxis.jl b/src/makielayout/lineaxis.jl index 98f7edac0de..67a4b28b64c 100644 --- a/src/makielayout/lineaxis.jl +++ b/src/makielayout/lineaxis.jl @@ -28,7 +28,7 @@ function LineAxis(parent::Scene; kwargs...) end end - ticksnode = Node(Point2f0[]) + ticksnode = Node(Point2f[]) ticklines = linesegments!( parent, ticksnode, linewidth = tickwidth, color = tickcolor, linestyle = nothing, show_axis = false, visible = ticksvisible, inspectable = false @@ -36,7 +36,7 @@ function LineAxis(parent::Scene; kwargs...) decorations[:ticklines] = ticklines translate!(ticklines, 0, 0, 10) - minorticksnode = Node(Point2f0[]) + minorticksnode = Node(Point2f[]) minorticklines = linesegments!( parent, minorticksnode, linewidth = minortickwidth, color = minortickcolor, linestyle = nothing, @@ -81,16 +81,16 @@ function LineAxis(parent::Scene; kwargs...) end end - ticklabelannosnode = Node(Tuple{AbstractString, Point2f0}[]) + ticklabelannosnode = Node(Tuple{AbstractString, Point2f}[]) ticklabels = nothing ticklabel_ideal_space = lift(Float32, ticklabelannosnode, ticklabelalign, ticklabelrotation, ticklabelfont, ticklabelsvisible) do args... maxwidth = if pos_extents_horizontal[][3] # height - ticklabelsvisible[] ? (ticklabels === nothing ? 0f0 : height(FRect2D(boundingbox(ticklabels)))) : 0f0 + ticklabelsvisible[] ? (ticklabels === nothing ? 0f0 : height(Rect2f(boundingbox(ticklabels)))) : 0f0 else # width - ticklabelsvisible[] ? (ticklabels === nothing ? 0f0 : width(FRect2D(boundingbox(ticklabels)))) : 0f0 + ticklabelsvisible[] ? (ticklabels === nothing ? 0f0 : width(Rect2f(boundingbox(ticklabels)))) : 0f0 end # in case there is no string in the annotations and the boundingbox comes back all NaN if !isfinite(maxwidth) @@ -187,7 +187,7 @@ function LineAxis(parent::Scene; kwargs...) get_ticks(ticks, scale, tickformat, limits...) end - tickpositions = Node(Point2f0[]) + tickpositions = Node(Point2f[]) tickstrings = Node(AbstractString[]) onany(tickvalues_labels_unfiltered, reversed) do tickvalues_labels_unfiltered, reversed @@ -233,7 +233,7 @@ function LineAxis(parent::Scene; kwargs...) end minortickvalues = Node(Float32[]) - minortickpositions = Node(Point2f0[]) + minortickpositions = Node(Point2f[]) onany(tickvalues, minorticks) do tickvalues, minorticks minortickvalues[] = get_minor_tickvalues(minorticks, attrs.scale[], tickvalues, limits[]...) @@ -270,12 +270,12 @@ function LineAxis(parent::Scene; kwargs...) position, extents, horizontal = pos_extents_horizontal[] if horizontal - tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f0(0f0, tickalign * ticksize - 0.5f0 * spinewidth) for tp in tickpositions] - tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f0(0f0, -ticksize) for t in tickstarts] + tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f(0f0, tickalign * ticksize - 0.5f0 * spinewidth) for tp in tickpositions] + tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f(0f0, -ticksize) for t in tickstarts] minorticksnode[] = interleave_vectors(tickstarts, tickends) else - tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f0(tickalign * ticksize - 0.5f0 * spinewidth, 0f0) for tp in tickpositions] - tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f0(-ticksize, 0f0) for t in tickstarts] + tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f(tickalign * ticksize - 0.5f0 * spinewidth, 0f0) for tp in tickpositions] + tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f(-ticksize, 0f0) for t in tickstarts] minorticksnode[] = interleave_vectors(tickstarts, tickends) end end @@ -292,9 +292,9 @@ function LineAxis(parent::Scene; kwargs...) ticklabelgap = spinewidth[] + tickspace[] + ticklabelpad[] shift = if horizontal - Point2f0(0f0, flipped ? ticklabelgap : -ticklabelgap) + Point2f(0f0, flipped ? ticklabelgap : -ticklabelgap) else - Point2f0(flipped ? ticklabelgap : -ticklabelgap, 0f0) + Point2f(flipped ? ticklabelgap : -ticklabelgap, 0f0) end ticklabelpositions = tickpositions[] .+ Ref(shift) @@ -307,12 +307,12 @@ function LineAxis(parent::Scene; kwargs...) position, extents, horizontal = pos_extents_horizontal[] if horizontal - tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f0(0f0, tickalign * ticksize - 0.5f0 * spinewidth) for tp in tickpositions] - tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f0(0f0, -ticksize) for t in tickstarts] + tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f(0f0, tickalign * ticksize - 0.5f0 * spinewidth) for tp in tickpositions] + tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f(0f0, -ticksize) for t in tickstarts] ticksnode[] = interleave_vectors(tickstarts, tickends) else - tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f0(tickalign * ticksize - 0.5f0 * spinewidth, 0f0) for tp in tickpositions] - tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f0(-ticksize, 0f0) for t in tickstarts] + tickstarts = [tp + (flipped[] ? -1f0 : 1f0) * Point2f(tickalign * ticksize - 0.5f0 * spinewidth, 0f0) for tp in tickpositions] + tickends = [t + (flipped[] ? -1f0 : 1f0) * Point2f(-ticksize, 0f0) for t in tickstarts] ticksnode[] = interleave_vectors(tickstarts, tickends) end end @@ -323,19 +323,19 @@ function LineAxis(parent::Scene; kwargs...) if !trimspine if horizontal y = position - p1 = Point2f0(extents[1] - 0.5sw, y) - p2 = Point2f0(extents[2] + 0.5sw, y) + p1 = Point2f(extents[1] - 0.5sw, y) + p2 = Point2f(extents[2] + 0.5sw, y) [p1, p2] else x = position - p1 = Point2f0(x, extents[1] - 0.5sw) - p2 = Point2f0(x, extents[2] + 0.5sw) + p1 = Point2f(x, extents[1] - 0.5sw) + p2 = Point2f(x, extents[2] + 0.5sw) [p1, p2] end else [tickpositions[1], tickpositions[end]] .+ [ - (horizontal ? Point2f0(-0.5f0 * tickwidth, 0) : Point2f0(0, -0.5f0 * tickwidth)), - (horizontal ? Point2f0(0.5f0 * tickwidth, 0) : Point2f0(0, 0.5f0 * tickwidth)), + (horizontal ? Point2f(-0.5f0 * tickwidth, 0) : Point2f(0, -0.5f0 * tickwidth)), + (horizontal ? Point2f(0.5f0 * tickwidth, 0) : Point2f(0, 0.5f0 * tickwidth)), ] end end @@ -416,10 +416,10 @@ function tight_ticklabel_spacing!(la::LineAxis) tls = la.elements[:ticklabels] maxwidth = if horizontal # height - tls.visible[] ? height(FRect2D(boundingbox(tls))) : 0f0 + tls.visible[] ? height(Rect2f(boundingbox(tls))) : 0f0 else # width - tls.visible[] ? width(FRect2D(boundingbox(tls))) : 0f0 + tls.visible[] ? width(Rect2f(boundingbox(tls))) : 0f0 end la.attributes.ticklabelspace = maxwidth end diff --git a/src/makielayout/mousestatemachine.jl b/src/makielayout/mousestatemachine.jl index ece99c0384f..f48ed61dec4 100644 --- a/src/makielayout/mousestatemachine.jl +++ b/src/makielayout/mousestatemachine.jl @@ -47,11 +47,11 @@ Fields: struct MouseEvent type::MouseEventType t::Float64 - data::Point2f0 - px::Point2f0 + data::Point2f + px::Point2f prev_t::Float64 - prev_data::Point2f0 - prev_px::Point2f0 + prev_data::Point2f + prev_px::Point2f end struct MouseEventHandle @@ -116,7 +116,7 @@ function addmouseevents!(scene, elements...; priority = Int8(1)) is_mouse_over_relevant_area() = isempty(elements) ? Makie.is_mouseinside(scene) : mouseover(scene, elements...) _addmouseevents!(scene, is_mouse_over_relevant_area, priority) end -function addmouseevents!(scene, bbox::Observables.AbstractObservable{<: Rect2D}; priority = Int8(1)) +function addmouseevents!(scene, bbox::Observables.AbstractObservable{<: Rect2}; priority = Int8(1)) is_mouse_over_relevant_area() = Makie.mouseposition_px(scene) in bbox[] _addmouseevents!(scene, is_mouse_over_relevant_area, priority) end @@ -127,7 +127,7 @@ function _addmouseevents!(scene, is_mouse_over_relevant_area, priority) dblclick_max_interval = 0.2 mouseevent = Makie.PriorityObservable{MouseEvent}( - MouseEvent(MouseEventTypes.out, 0.0, Point2f0(0, 0), Point2f0(0, 0), 0.0, Point2f0(0, 0), Point2f0(0, 0)) + MouseEvent(MouseEventTypes.out, 0.0, Point2f(0, 0), Point2f(0, 0), 0.0, Point2f(0, 0), Point2f(0, 0)) ) diff --git a/src/makielayout/roundedrect.jl b/src/makielayout/roundedrect.jl index dccd8de00c1..feddad3cef8 100644 --- a/src/makielayout/roundedrect.jl +++ b/src/makielayout/roundedrect.jl @@ -4,8 +4,8 @@ cornerradius = 5, cornersegments = 10, raw = true, - color = RGBf0(0.9, 0.9, 0.9), - strokecolor = RGBf0(0, 0, 0) + color = RGBf(0.9, 0.9, 0.9), + strokecolor = RGBf(0, 0, 0) ) end diff --git a/src/makielayout/types.jl b/src/makielayout/types.jl index bae3fac630a..afb1508c1c0 100644 --- a/src/makielayout/types.jl +++ b/src/makielayout/types.jl @@ -115,10 +115,10 @@ mutable struct LineAxis protrusion::Node{Float32} attributes::Attributes elements::Dict{Symbol, Any} - tickpositions::Node{Vector{Point2f0}} + tickpositions::Node{Vector{Point2f}} tickvalues::Node{Vector{Float32}} ticklabels::Node{Vector{String}} - minortickpositions::Node{Vector{Point2f0}} + minortickpositions::Node{Vector{Point2f}} minortickvalues::Node{Vector{Float32}} end @@ -129,14 +129,14 @@ mutable struct RectangleZoom active::Observable{Bool} restrict_x::Bool restrict_y::Bool - from::Union{Nothing, Point2f0} - to::Union{Nothing, Point2f0} - rectnode::Observable{FRect2D} + from::Union{Nothing, Point2f} + to::Union{Nothing, Point2f} + rectnode::Observable{Rect2f} end function RectangleZoom(callback::Function; restrict_x=false, restrict_y=false) return RectangleZoom(callback, Observable(false), restrict_x, restrict_y, - nothing, nothing, Observable(FRect2D(0, 0, 1, 1))) + nothing, nothing, Observable(Rect2f(0, 0, 1, 1))) end struct ScrollZoom @@ -170,8 +170,8 @@ end scene::Scene xaxislinks::Vector{Axis} yaxislinks::Vector{Axis} - targetlimits::Node{FRect2D} - finallimits::Node{FRect2D} + targetlimits::Node{Rect2f} + finallimits::Node{Rect2f} block_limit_linking::Node{Bool} mouseeventhandle::MouseEventHandle scrollevents::Observable{ScrollEvent} @@ -255,7 +255,7 @@ end @Layoutable Axis3 begin scene::Scene - finallimits::Node{FRect3D} + finallimits::Node{Rect3f} mouseeventhandle::MouseEventHandle scrollevents::Observable{ScrollEvent} keysevents::Observable{KeysEvent} diff --git a/src/patterns.jl b/src/patterns.jl index b6dd18ab1da..d33889b6560 100644 --- a/src/patterns.jl +++ b/src/patterns.jl @@ -59,8 +59,8 @@ Multiple `direction`s, `width`s and `shift`s can also be given to create more complex patterns, e.g. a cross-hatching pattern. """ function LinePattern(; - direction = Vec2f0(1), width = 2f0, tilesize = (10,10), - shift = map(w -> Vec2f0(0.5 - 0.5(w%2)), width), + direction = Vec2f(1), width = 2f0, tilesize = (10,10), + shift = map(w -> Vec2f(0.5 - 0.5(w%2)), width), linecolor = RGBA(0,0,0,1), background_color = RGBA(1,1,1,0) ) N = 1 @@ -87,17 +87,17 @@ to the keyword arguments for [`LinePattern`](@ref). Pattern(style::String; kwargs...) = Pattern(style[1]; kwargs...) function Pattern(style::Char = '/'; kwargs...) if style == '/' - LinePattern(direction=Vec2f0(1); kwargs...) + LinePattern(direction=Vec2f(1); kwargs...) elseif style == '\\' - LinePattern(direction=Vec2f0(1, -1); kwargs...) + LinePattern(direction=Vec2f(1, -1); kwargs...) elseif style == '-' - LinePattern(direction=Vec2f0(1, 0); kwargs...) + LinePattern(direction=Vec2f(1, 0); kwargs...) elseif style == '|' - LinePattern(direction=Vec2f0(0, 1); kwargs...) + LinePattern(direction=Vec2f(0, 1); kwargs...) elseif style == 'x' - LinePattern(direction=[Vec2f0(1), Vec2f0(1, -1)]; kwargs...) + LinePattern(direction=[Vec2f(1), Vec2f(1, -1)]; kwargs...) elseif style == '+' - LinePattern(direction=[Vec2f0(1, 0), Vec2f0(0, 1)]; kwargs...) + LinePattern(direction=[Vec2f(1, 0), Vec2f(0, 1)]; kwargs...) else LinePattern(; kwargs...) end diff --git a/src/precompile.jl b/src/precompile.jl index 26362970f89..9f9e9e362d8 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -14,24 +14,24 @@ function _precompile_() @warnpcfail precompile(Scene, ()) @warnpcfail precompile(update_limits!, (Scene,)) @warnpcfail precompile(update_limits!, (Scene, Automatic)) - @warnpcfail precompile(update_limits!, (Scene, FRect3D)) + @warnpcfail precompile(update_limits!, (Scene, Rect3f)) @warnpcfail precompile(boundingbox, (Scene,)) - Ngonf0 = GeometryBasics.Ngon{2, Float32, 3, Point2f0} + Ngonf0 = GeometryBasics.Ngon{2, Float32, 3, Point2f} # @warnpcfail precompile(boundingbox, (Mesh{Tuple{Vector{GeometryBasics.Mesh{2, Float32, Ngonf0, FaceView{Ngonf0}}}}},)) # doesn't seem to work - @warnpcfail precompile(boundingbox, (Poly{Tuple{Vector{Vector{Point2f0}}}},)) - @warnpcfail precompile(boundingbox, (String, Vector{Point3f0}, Vector{Float32}, Vector{FTFont}, Vec2f0, Vector{Quaternionf0}, SMatrix{4, 4, Float32, 16}, Float64, Float64)) + @warnpcfail precompile(boundingbox, (Poly{Tuple{Vector{Vector{Point2f}}}},)) + @warnpcfail precompile(boundingbox, (String, Vector{Point3f}, Vector{Float32}, Vector{FTFont}, Vec2f, Vector{Quaternionf}, SMatrix{4, 4, Float32, 16}, Float64, Float64)) - @warnpcfail precompile(poly_convert, (Vector{Vector{Point2f0}},)) - @warnpcfail precompile(rotatedrect, (FRect2D, Float32)) + @warnpcfail precompile(poly_convert, (Vector{Vector{Point2f}},)) + @warnpcfail precompile(rotatedrect, (Rect2f, Float32)) - @warnpcfail precompile(plot!, (Scene, Type{Poly{Tuple{IRect2D}}}, Attributes, Tuple{Observable{IRect2D}}, Observable{Tuple{Vector{Vector{Point2f0}}}})) + @warnpcfail precompile(plot!, (Scene, Type{Poly{Tuple{Rect2i}}}, Attributes, Tuple{Observable{Rect2i}}, Observable{Tuple{Vector{Vector{Point2f}}}})) @warnpcfail precompile(plot!, (Mesh{Tuple{Vector{GeometryBasics.Mesh{2, Float32, Ngonf0, FaceView{Ngonf0}}}}},)) - @warnpcfail precompile(plot!, (Scene, Type{Annotations{Tuple{Vector{Tuple{String, Point2f0}}}}}, Attributes, Tuple{Observable{Vector{Tuple{String, Point2f0}}}}, Observable{Tuple{Vector{Tuple{String, Point2f0}}}})) + @warnpcfail precompile(plot!, (Scene, Type{Annotations{Tuple{Vector{Tuple{String, Point2f}}}}}, Attributes, Tuple{Observable{Vector{Tuple{String, Point2f}}}}, Observable{Tuple{Vector{Tuple{String, Point2f}}}})) # A big dump from SnoopCompile. These will go stale rapidly, but until work is done on inferrability this is probably the best we can do - isdefined(Makie, Symbol("#303#305")) && Base.precompile(Tuple{getfield(Makie, Symbol("#303#305")),Int64,FTFont,Tuple{String, Point{2, Float32}},RGBA{Float32},Float32,Vec{2, Float32},Quaternionf0,Float64,Float64}) # time: 0.8072854 - Base.precompile(Tuple{typeof(transformationmatrix),Vec{3, Float32},Vec{3, Float32},Quaternionf0,Observable{Vec{2, Float32}},Tuple{Bool, Bool, Bool},GeometryBasics.HyperRectangle{3, Float32}}) # time: 0.70518523 + isdefined(Makie, Symbol("#303#305")) && Base.precompile(Tuple{getfield(Makie, Symbol("#303#305")),Int64,FTFont,Tuple{String, Point{2, Float32}},RGBA{Float32},Float32,Vec{2, Float32},Quaternionf,Float64,Float64}) # time: 0.8072854 + Base.precompile(Tuple{typeof(transformationmatrix),Vec{3, Float32},Vec{3, Float32},Quaternionf,Observable{Vec{2, Float32}},Tuple{Bool, Bool, Bool},GeometryBasics.HyperRectangle{3, Float32}}) # time: 0.70518523 Base.precompile(Tuple{typeof(update_cam!),Scene,Camera2D,GeometryBasics.HyperRectangle{3, Float32}}) # time: 0.44654787 Base.precompile(Tuple{typeof(scatter),Vector{Float64},Vararg{Vector{Float64}, 100}}) # time: 0.32425407 isdefined(Makie, Symbol("#302#304")) && Base.precompile(Tuple{getfield(Makie, Symbol("#302#304")),SMatrix{4, 4, Float32, 16},Vector{FTFont},Vector{Tuple{String, Point{2, Float32}}},Vector{RGBA{Float32}},Vararg{Any, 100}}) # time: 0.23708302 @@ -45,7 +45,7 @@ function _precompile_() Base.precompile(Tuple{typeof(plot!),Scene,Type{Scatter{Tuple{Vector{Float64}, Vector{Float64}}}},Attributes,Tuple{Observable{Vector{Float64}}, Observable{Vector{Float64}}},Observable{Tuple{Vector{Point{2, Float32}}}}}) # time: 0.096797995 Base.precompile(Tuple{typeof(data_limits),Text{Tuple{String}}}) # time: 0.09453959 Base.precompile(Tuple{typeof(convert_arguments),Type{Annotations{ArgType} where ArgType},Vector{String},Vector{Point{2, Float32}}}) # time: 0.09197935 - isdefined(Makie, Symbol("#719#720")) && Base.precompile(Tuple{getfield(Makie, Symbol("#719#720")),Int64,Quaternionf0,FTFont,Float32}) # time: 0.081979275 + isdefined(Makie, Symbol("#719#720")) && Base.precompile(Tuple{getfield(Makie, Symbol("#719#720")),Int64,Quaternionf,FTFont,Float32}) # time: 0.081979275 let fbody = try Base.bodyfunction(which(convert_arguments, (Type{Scatter{Tuple{Vector{Float64}, Vector{Float64}}}},Vector{Float64},Vararg{Vector{Float64}, 100},))) catch missing end if !ismissing(fbody) precompile(fbody, (Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}},typeof(convert_arguments),Type{Scatter{Tuple{Vector{Float64}, Vector{Float64}}}},Vector{Float64},Vararg{Vector{Float64}, 100},)) @@ -72,7 +72,7 @@ function _precompile_() end # time: 0.029508112 Base.precompile(Tuple{Type{Text{ArgType} where ArgType},Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},Attributes,Tuple{Observable{String}},Observable{Tuple{String}}}) # time: 0.028124427 Base.precompile(Tuple{Core.kwftype(typeof(Type)),NamedTuple{(:ranges_labels, :formatter, :gap, :title_gap, :linewidth, :linecolor, :linestyle, :textcolor, :textsize, :rotation, :align, :font), Tuple{Tuple{Automatic, Automatic}, typeof(Makie.Formatters.plain), Int64, Int64, Tuple{Int64, Int64}, Tuple{Tuple{Symbol, Float64}, Tuple{Symbol, Float64}}, Tuple{Nothing, Nothing}, Tuple{Symbol, Symbol}, Tuple{Int64, Int64}, Tuple{Float64, Float64}, Tuple{Tuple{Symbol, Symbol}, Tuple{Symbol, Symbol}}, Observable{Tuple{String, String}}}},Type{Attributes}}) # time: 0.028094089 - Base.precompile(Tuple{Core.kwftype(typeof(text!)),NamedTuple{(:align, :model, :position, :color, :visible, :textsize, :font, :rotation), Tuple{Vec{2, Float32}, SMatrix{4, 4, Float32, 16}, Vector{Point{3, Float32}}, Vector{RGBA{Float32}}, Observable{Any}, Vector{Float32}, Vector{FTFont}, Vector{Quaternionf0}}},typeof(text!),Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},Vararg{Any, 100}}) # time: 0.027778953 + Base.precompile(Tuple{Core.kwftype(typeof(text!)),NamedTuple{(:align, :model, :position, :color, :visible, :textsize, :font, :rotation), Tuple{Vec{2, Float32}, SMatrix{4, 4, Float32, 16}, Vector{Point{3, Float32}}, Vector{RGBA{Float32}}, Observable{Any}, Vector{Float32}, Vector{FTFont}, Vector{Quaternionf}}},typeof(text!),Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},Vararg{Any, 100}}) # time: 0.027778953 Base.precompile(Tuple{typeof(selection_rect!),Scene,Camera2D,Observable{Any}}) # time: 0.02611231 Base.precompile(Tuple{typeof(map_once),Function,Observable{Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}}},Observable{LineSegments{Tuple{Vector{Point{2, Float32}}}}},Vararg{Observable, 100}}) # time: 0.024804583 let fbody = try Base.bodyfunction(which(map_once, (Function,Observable{Vec{3, Float32}},Observable{Vec{3, Float32}},Vararg{Observable, 100},))) catch missing end @@ -100,7 +100,7 @@ function _precompile_() precompile(fbody, (Nothing,Type,typeof(map_once),Function,Observable{Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}}},Observable{LineSegments{Tuple{Vector{Point{2, Float32}}}}},Vararg{Observable, 100},)) end end # time: 0.012269881 - Base.precompile(Tuple{typeof(lift),Function,Observable{Any},Observable{Union{Nothing, FRect3D, FRect{3}, Rect3D{Float32}}}}) # time: 0.012067013 + Base.precompile(Tuple{typeof(lift),Function,Observable{Any},Observable{Union{Nothing, Rect3f, Rectf{3}, Rect3{Float32}}}}) # time: 0.012067013 isdefined(Makie, Symbol("#89#92")) && Base.precompile(Tuple{getfield(Makie, Symbol("#89#92")),Tuple{Int64, Int64}}) # time: 0.010871829 let fbody = try Base.bodyfunction(which(lift, (Function,Observable{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},))) catch missing end if !ismissing(fbody) @@ -143,9 +143,9 @@ function _precompile_() Base.precompile(Tuple{typeof(lift),Function,Observable{Vector{Float64}},Observable{Vector{Float64}}}) # time: 0.006378372 Base.precompile(Tuple{typeof(setindex!),LineSegments{Tuple{Vector{Point{2, Float32}}}},Observable{Vector{RGBA{Float32}}},Symbol}) # time: 0.006341601 Base.precompile(Tuple{typeof(convert_attribute),Vector{Float32},Key{:textsize}}) # time: 0.006148856 - isdefined(Makie, Symbol("#634#635")) && Base.precompile(Tuple{getfield(Makie, Symbol("#634#635")),Vec{3, Float32},Vec{3, Float32},Quaternionf0,Vec{2, Float32},SMatrix{4, 4, Float32, 16},Tuple{Bool, Bool, Bool}}) # time: 0.006117055 + isdefined(Makie, Symbol("#634#635")) && Base.precompile(Tuple{getfield(Makie, Symbol("#634#635")),Vec{3, Float32},Vec{3, Float32},Quaternionf,Vec{2, Float32},SMatrix{4, 4, Float32, 16},Tuple{Bool, Bool, Bool}}) # time: 0.006117055 Base.precompile(Tuple{typeof(default_labels),Automatic,Tuple{Vector{Float64}, Vector{Float64}},Function}) # time: 0.005572814 - Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:align, :model, :position, :color, :visible, :textsize, :font, :rotation), Tuple{Vec{2, Float32}, SMatrix{4, 4, Float32, 16}, Vector{Point{3, Float32}}, Vector{RGBA{Float32}}, Observable{Any}, Vector{Float32}, Vector{FTFont}, Vector{Quaternionf0}}},typeof(plot!),Type{Text{ArgType} where ArgType},Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},String}) # time: 0.005202268 + Base.precompile(Tuple{Core.kwftype(typeof(plot!)),NamedTuple{(:align, :model, :position, :color, :visible, :textsize, :font, :rotation), Tuple{Vec{2, Float32}, SMatrix{4, 4, Float32, 16}, Vector{Point{3, Float32}}, Vector{RGBA{Float32}}, Observable{Any}, Vector{Float32}, Vector{FTFont}, Vector{Quaternionf}}},typeof(plot!),Type{Text{ArgType} where ArgType},Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}},String}) # time: 0.005202268 let fbody = try Base.bodyfunction(which(lift, (Function,Observable{GeometryBasics.HyperRectangle{2, Int64}},))) catch missing end if !ismissing(fbody) precompile(fbody, (Vec{2, Float32},Type,Symbol,typeof(lift),Function,Observable{GeometryBasics.HyperRectangle{2, Int64}},)) @@ -206,7 +206,7 @@ function _precompile_() end end # time: 0.002528649 Base.precompile(Tuple{typeof(setindex!),Attributes,Observable{Tuple{Tuple{Vector{Float64}, Vector{Float64}}, Tuple{Vector{String}, Vector{String}}}},Symbol}) # time: 0.00244883 - Base.precompile(Tuple{typeof(safe_off),Observable{Quaternionf0},Function}) # time: 0.002366797 + Base.precompile(Tuple{typeof(safe_off),Observable{Quaternionf},Function}) # time: 0.002366797 Base.precompile(Tuple{typeof(to_ndim),Type{Point{3, Float32}},Vec2{Float64},Int64}) # time: 0.002294592 let fbody = try Base.bodyfunction(which(current_default_theme, ())) catch missing end if !ismissing(fbody) @@ -214,9 +214,9 @@ function _precompile_() end end # time: 0.002075753 Base.precompile(Tuple{typeof(safe_off),Observable{Tuple{LineSegments{Tuple{Vector{Point{2, Float32}}}}, LineSegments{Tuple{Vector{Point{2, Float32}}}}}},Function}) # time: 0.001949723 - let fbody = try Base.bodyfunction(which(lift, (Function,Observable{Any},Observable{Union{Nothing, FRect3D, FRect{3}, Rect3D{Float32}}},))) catch missing end + let fbody = try Base.bodyfunction(which(lift, (Function,Observable{Any},Observable{Union{Nothing, Rect3f, Rectf{3}, Rect3{Float32}}},))) catch missing end if !ismissing(fbody) - precompile(fbody, (GeometryBasics.HyperRectangle{3, Float32},Type,Symbol,typeof(lift),Function,Observable{Any},Observable{Union{Nothing, FRect3D, FRect{3}, Rect3D{Float32}}},)) + precompile(fbody, (GeometryBasics.HyperRectangle{3, Float32},Type,Symbol,typeof(lift),Function,Observable{Any},Observable{Union{Nothing, Rect3f, Rectf{3}, Rect3{Float32}}},)) end end # time: 0.001892332 Base.precompile(Tuple{typeof(lift),Function,Observable{Vector{Point{2, Float32}}}}) # time: 0.001853503 @@ -247,13 +247,13 @@ function _precompile_() # DataInspector @warnpcfail precompile(on_hover, (DataInspector, )) for PT in ( - Scatter{Tuple{Vector{Point2f0}}}, - Scatter{Tuple{Vector{Point3f0}}}, - MeshScatter{Tuple{Vector{Point3f0}}}, - Lines{Tuple{Vector{Point2f0}}}, - Lines{Tuple{Vector{Point3f0}}}, - LineSegments{Tuple{Vector{Point2f0}}}, - LineSegments{Tuple{Vector{Point3f0}}}, + Scatter{Tuple{Vector{Point2f}}}, + Scatter{Tuple{Vector{Point3f}}}, + MeshScatter{Tuple{Vector{Point3f}}}, + Lines{Tuple{Vector{Point2f}}}, + Lines{Tuple{Vector{Point3f}}}, + LineSegments{Tuple{Vector{Point2f}}}, + LineSegments{Tuple{Vector{Point3f}}}, # Mesh, Surface{Tuple{IntervalSets.ClosedInterval{Float32}, IntervalSets.ClosedInterval{Float32}, Matrix{Float32}}}, Surface{Tuple{Vector{Float32}, Vector{Float32}, Matrix{Float32}}}, diff --git a/src/scenes.jl b/src/scenes.jl index 9bc9af52a56..80e8f4c88ba 100644 --- a/src/scenes.jl +++ b/src/scenes.jl @@ -16,7 +16,7 @@ mutable struct Scene <: AbstractScene events::Events "The current pixel area of the Scene." - px_area::Node{IRect2D} + px_area::Node{Rect2i} "Whether the scene should be cleared." clear::Bool @@ -31,7 +31,7 @@ mutable struct Scene <: AbstractScene The limits of the data plotted in this scene. Can't be set by user and is only used to store calculated data bounds. """ - data_limits::Node{Union{Nothing,FRect3D}} + data_limits::Node{Union{Nothing,Rect3f}} "The [`Transformation`](@ref) of the Scene." transformation::Transformation @@ -87,7 +87,7 @@ end function Scene( events::Events, - px_area::Node{IRect2D}, + px_area::Node{Rect2i}, clear::Bool, camera::Camera, camera_controls::RefValue, @@ -107,7 +107,7 @@ function Scene( scene = Scene( parent, events, px_area, clear, camera, camera_controls, - Node{Union{Nothing,FRect3D}}(scene_limits), + Node{Union{Nothing,Rect3f}}(scene_limits), transformation, plots, theme, attributes, children, current_screens, updated ) @@ -136,7 +136,7 @@ function Scene(;clear=true, transform_func=identity, scene_attributes...) theme = current_default_theme(; scene_attributes...) attributes = deepcopy(theme) px_area = lift(attributes.resolution) do res - IRect(0, 0, res) + Recti(0, 0, res) end on(events.window_area, priority = typemax(Int8)) do w_area if !any(x -> x ≈ 0.0, widths(w_area)) && px_area[] != w_area @@ -199,7 +199,7 @@ function Scene(parent::Scene, area; clear=false, transform_func=identity, attrib events = parent.events px_area = lift(pixelarea(parent), convert(Node, area)) do p, a # make coordinates relative to parent - IRect2D(minimum(p) .+ minimum(a), widths(a)) + Rect2i(minimum(p) .+ minimum(a), widths(a)) end child = Scene( events, @@ -246,10 +246,10 @@ parent_or_self(scene::Scene) = isroot(scene) ? scene : parent(scene) Base.size(x::Scene) = pixelarea(x) |> to_value |> widths |> Tuple Base.size(x::Scene, i) = size(x)[i] function Base.resize!(scene::Scene, xy::Tuple{Number,Number}) - resize!(scene, IRect(0, 0, xy)) + resize!(scene, Recti(0, 0, xy)) end Base.resize!(scene::Scene, x::Number, y::Number) = resize!(scene, (x, y)) -function Base.resize!(scene::Scene, rect::Rect2D) +function Base.resize!(scene::Scene, rect::Rect2) pixelarea(scene)[] = rect end @@ -306,7 +306,7 @@ getindex(scene::Scene, idx::Integer) = scene.plots[idx] GeometryBasics.widths(scene::Scene) = widths(to_value(pixelarea(scene))) struct OldAxis end -zero_origin(area) = IRect(0, 0, widths(area)) +zero_origin(area) = Recti(0, 0, widths(area)) function child(scene::Scene; attributes...) Scene(scene, lift(zero_origin, pixelarea(scene)); attributes...) @@ -349,7 +349,7 @@ function scene_limits(scene::Scene) if scene.limits[] === automatic return scene.data_limits[] else - return FRect3D(scene.limits[]) + return Rect3f(scene.limits[]) end end @@ -486,7 +486,7 @@ function center!(scene::Scene, padding=0.01) bb = transformationmatrix(scene)[] * bb w = widths(bb) padd = w .* padding - bb = FRect3D(minimum(bb) .- padd, w .+ 2padd) + bb = Rect3f(minimum(bb) .- padd, w .+ 2padd) update_cam!(scene, bb) scene end @@ -501,8 +501,8 @@ function is2d(scene::SceneLike) lims === nothing && return nothing return is2d(lims) end -is2d(lims::Rect2D) = true -is2d(lims::Rect3D) = widths(lims)[3] == 0.0 +is2d(lims::Rect2) = true +is2d(lims::Rect3) = widths(lims)[3] == 0.0 """ update_limits!(scene::Scene, limits::Union{Automatic, Rect} = scene.limits[], padding = scene.padding[]) @@ -514,10 +514,10 @@ it will not update the limits. Call update_limits!(scene, automatic) for that. update_limits!(scene::Scene) = update_limits!(scene, scene.limits[]) function update_limits!(scene::Scene, limits, padding) - update_limits!(scene, limits, to_ndim(Vec3f0, padding, 0.0)) + update_limits!(scene, limits, to_ndim(Vec3f, padding, 0.0)) end -function update_limits!(scene::Scene, ::Automatic, padding::Vec3f0=scene.padding[]) +function update_limits!(scene::Scene, ::Automatic, padding::Vec3f=scene.padding[]) # for when scene is empty dlimits = data_limits(scene) dlimits === nothing && return # nothing to limit if there isn't anything @@ -526,7 +526,7 @@ function update_limits!(scene::Scene, ::Automatic, padding::Vec3f0=scene.padding if !all(x -> all(isfinite, x), (avec, bvec)) @warn "limits of scene contain non finite values: $(avec) .. $(bvec)" mini = map(x -> ifelse(isfinite(x), x, zero(x)), avec) - maxi = Vec3f0(ntuple(3) do i + maxi = Vec3f(ntuple(3) do i x = bvec[i] ifelse(isfinite(x), x, avec[i] + oneunit(avec[i])) end) @@ -535,7 +535,7 @@ function update_limits!(scene::Scene, ::Automatic, padding::Vec3f0=scene.padding end local new_widths let avec = tlims[1], bvec = tlims[2] - new_widths = Vec3f0(ntuple(3) do i + new_widths = Vec3f(ntuple(3) do i a = avec[i]; b = bvec[i] w = b - a # check for widths == 0.0... 3rd dimension is allowed to be 0 though. @@ -545,11 +545,11 @@ function update_limits!(scene::Scene, ::Automatic, padding::Vec3f0=scene.padding ifelse(with0, 1f0, w) end) end - update_limits!(scene, FRect3D(tlims[1], new_widths), padding) + update_limits!(scene, Rect3f(tlims[1], new_widths), padding) end """ - update_limits!(scene::Scene, new_limits::Rect, padding = Vec3f0(0)) + update_limits!(scene::Scene, new_limits::Rect, padding = Vec3f(0)) This function updates the limits of the given `Scene` according to the given Rect. @@ -558,21 +558,21 @@ The first vector defines the origin; the second defines the displacement of the This second vector can be thought of in two dimensions as a vector of width (x-axis) and height (y-axis), and in three dimensions as a vector of the width (x-axis), breadth (y-axis), and height (z-axis). -Such a `Rect` can be constructed using the `FRect` or `FRect3D` functions that are exported by +Such a `Rect` can be constructed using the `Rectf` or `Rect3f` functions that are exported by `Makie.jl`. See their documentation for more information. """ -function update_limits!(scene::Scene, new_limits::Rect, padding::Vec3f0=scene.padding[]) - lims = FRect3D(new_limits) +function update_limits!(scene::Scene, new_limits::Rect, padding::Vec3f=scene.padding[]) + lims = Rect3f(new_limits) lim_w = widths(lims) # use the smallest widths for scaling, to have a consistently wide padding for all sides minw = if lim_w[3] ≈ 0.0 m = min(lim_w[1], lim_w[2]) - Vec3f0(m, m, 0.0) + Vec3f(m, m, 0.0) else - Vec3f0(minimum(lim_w)) + Vec3f(minimum(lim_w)) end - padd_abs = minw .* to_ndim(Vec3f0, padding, 0.0) - scene.data_limits[] = FRect3D(minimum(lims) .- padd_abs, lim_w .+ 2padd_abs) + padd_abs = minw .* to_ndim(Vec3f, padding, 0.0) + scene.data_limits[] = Rect3f(minimum(lims) .- padd_abs, lim_w .+ 2padd_abs) scene end diff --git a/src/shorthands.jl b/src/shorthands.jl index ede8ff379df..7fbf1cc765f 100644 --- a/src/shorthands.jl +++ b/src/shorthands.jl @@ -72,7 +72,7 @@ function setlims!(scene::Scene, min_max::NTuple{2, Real}, dim=1) ``` or code like: ```julia - scene = Scene(limits=FRect2D(0,0,5, 5)) + scene = Scene(limits=Rect2f(0,0,5, 5)) plot!(scene, ...) ``` """ @@ -84,7 +84,7 @@ function setlims!(scene::Scene, min_max::NTuple{2, Real}, dim=1) n_origin = convert(Vector, o_origin) # convert to mutable form n_origin[dim] = min_max[1] # set the new origin in dim n_widths[dim] = min_max[2] - min_max[1] # set the new width in dim - scene.limits[] = FRect3D(n_origin, n_widths) # set the limits of the scene + scene.limits[] = Rect3f(n_origin, n_widths) # set the limits of the scene center!(scene) return end diff --git a/src/stats/boxplot.jl b/src/stats/boxplot.jl index 8011155dc2d..bdddbc998aa 100644 --- a/src/stats/boxplot.jl +++ b/src/stats/boxplot.jl @@ -70,7 +70,7 @@ conversion_trait(x::Type{<:BoxPlot}) = SampleBased() _cycle(v::AbstractVector, idx::Integer) = v[mod1(idx, length(v))] _cycle(v, idx::Integer) = v -_flip_xy(p::Point2f0) = reverse(p) +_flip_xy(p::Point2f) = reverse(p) _flip_xy(r::Rect{2,T}) where {T} = Rect{2,T}(reverse(r.origin), reverse(r.widths)) function Makie.plot!(plot::BoxPlot) @@ -87,14 +87,14 @@ function Makie.plot!(plot::BoxPlot) error("whiskerwidth must be :match or a positive number. Found: $whiskerwidth") end ww = whiskerwidth == :match ? boxwidth : whiskerwidth * boxwidth - outlier_points = Point2f0[] + outlier_points = Point2f[] centers = Float32[] medians = Float32[] boxmin = Float32[] boxmax = Float32[] notchmin = Float32[] notchmax = Float32[] - t_segments = Point2f0[] + t_segments = Point2f[] outlier_indices = Int[] T = color isa AbstractVector ? eltype(color) : typeof(color) boxcolor = T[] diff --git a/src/stats/crossbar.jl b/src/stats/crossbar.jl index b730af9a164..438f962cdb5 100644 --- a/src/stats/crossbar.jl +++ b/src/stats/crossbar.jl @@ -63,7 +63,7 @@ function Makie.plot!(plot::CrossBar) show_notch = show_notch && (nmin !== automatic && nmax !== automatic) # for horizontal crossbars just flip all components - fpoint, frect = Point2f0, FRect + fpoint, frect = Point2f, Rectf if orientation == :horizontal fpoint, frect = _flip_xy ∘ fpoint, _flip_xy ∘ frect end diff --git a/src/stats/density.jl b/src/stats/density.jl index 4eeffdcc040..5ae95bde880 100644 --- a/src/stats/density.jl +++ b/src/stats/density.jl @@ -4,10 +4,10 @@ function convert_arguments(P::PlotFunc, d::KernelDensity.UnivariateKDE) end function convert_arguments(::Type{<:Poly}, d::KernelDensity.UnivariateKDE) - points = Vector{Point2f0}(undef, length(d.x) + 2) - points[1] = Point2f0(d.x[1], 0) - points[2:end-1] .= Point2f0.(d.x, d.density) - points[end] = Point2f0(d.x[end], 0) + points = Vector{Point2f}(undef, length(d.x) + 2) + points[1] = Point2f(d.x[1], 0) + points[2:end-1] .= Point2f.(d.x, d.density) + points[end] = Point2f(d.x[end], 0) (points,) end @@ -63,11 +63,11 @@ function plot!(plot::Density{<:Tuple{<:AbstractVector}}) ) if dir === :x - lowerv = Point2f0.(k.x, offs) - upperv = Point2f0.(k.x, offs .+ k.density) + lowerv = Point2f.(k.x, offs) + upperv = Point2f.(k.x, offs .+ k.density) elseif dir === :y - lowerv = Point2f0.(offs, k.x) - upperv = Point2f0.(offs .+ k.density, k.x) + lowerv = Point2f.(offs, k.x) + upperv = Point2f.(offs .+ k.density, k.x) else error("Invalid direction $dir, only :x or :y allowed") end @@ -86,8 +86,8 @@ function plot!(plot::Density{<:Tuple{<:AbstractVector}}) end end - lower = Node(Point2f0[]) - upper = Node(Point2f0[]) + lower = Node(Point2f[]) + upper = Node(Point2f[]) on(lowerupper) do (l, u) lower.val = l diff --git a/src/stats/hist.jl b/src/stats/hist.jl index b39714e74af..f34c1198b0c 100644 --- a/src/stats/hist.jl +++ b/src/stats/hist.jl @@ -95,7 +95,7 @@ function Makie.plot!(plot::Hist) max = maximum(weights) weights .= weights ./ max .* scale_to end - return Point2f0.(centers, weights) + return Point2f.(centers, weights) end widths = lift(diff, edges) color = lift(plot.color) do color diff --git a/src/stats/violin.jl b/src/stats/violin.jl index 96e80603cb1..f8faca388a4 100644 --- a/src/stats/violin.jl +++ b/src/stats/violin.jl @@ -80,8 +80,8 @@ function plot!(plot::Violin) max_density end - vertices = Vector{Point2f0}[] - lines = Pair{Point2f0, Point2f0}[] + vertices = Vector{Point2f}[] + lines = Pair{Point2f, Point2f}[] colors = RGBA{Float32}[] for spec in specs @@ -98,7 +98,7 @@ function plot!(plot::Violin) else [spec.x; xr; spec.x; xl], [yr[1]; yr; yl[1]; yl] end - verts = Point2f0.(x_coord, y_coord) + verts = Point2f.(x_coord, y_coord) push!(vertices, verts) if show_median @@ -108,8 +108,8 @@ function plot!(plot::Violin) ym₋, ym₊ = spec.kde.density[ip-1], spec.kde.density[ip] xm₋, xm₊ = spec.kde.x[ip-1], spec.kde.x[ip] ym = (xm * (ym₊ - ym₋) + xm₊ * ym₋ - xm₋ * ym₊) / (xm₊ - xm₋) - median_left = Point2f0(spec.side == 1 ? spec.x : spec.x - ym * scale, xm) - median_right = Point2f0(spec.side == -1 ? spec.x : spec.x + ym * scale, xm) + median_left = Point2f(spec.side == 1 ? spec.x : spec.x - ym * scale, xm) + median_right = Point2f(spec.side == -1 ? spec.x : spec.x + ym * scale, xm) push!(lines, median_left => median_right) end diff --git a/src/themes/theme_black.jl b/src/themes/theme_black.jl index a324225aa51..1f0b9965b59 100644 --- a/src/themes/theme_black.jl +++ b/src/themes/theme_black.jl @@ -9,8 +9,8 @@ function theme_black() topspinecolor = :white, leftspinecolor = :white, rightspinecolor = :white, - xgridcolor = RGBAf0(1, 1, 1, 0.16), - ygridcolor = RGBAf0(1, 1, 1, 0.16), + xgridcolor = RGBAf(1, 1, 1, 0.16), + ygridcolor = RGBAf(1, 1, 1, 0.16), xtickcolor = :white, ytickcolor = :white, ), @@ -19,9 +19,9 @@ function theme_black() bgcolor = :black, ), Axis3 = ( - xgridcolor = RGBAf0(1, 1, 1, 0.16), - ygridcolor = RGBAf0(1, 1, 1, 0.16), - zgridcolor = RGBAf0(1, 1, 1, 0.16), + xgridcolor = RGBAf(1, 1, 1, 0.16), + ygridcolor = RGBAf(1, 1, 1, 0.16), + zgridcolor = RGBAf(1, 1, 1, 0.16), xspinecolor_1 = :white, yspinecolor_1 = :white, zspinecolor_1 = :white, diff --git a/src/theming.jl b/src/theming.jl index 04b1ecccbb1..13fbc29f61a 100644 --- a/src/theming.jl +++ b/src/theming.jl @@ -42,7 +42,7 @@ function wong_colors(alpha = 1.0) RGB(213/255, 94/255, 0/255), # vermillion RGB(240/255, 228/255, 66/255), # yellow ] - @. RGBAf0(red(colors), green(colors), blue(colors), alpha) + @. RGBAf(red(colors), green(colors), blue(colors), alpha) end const default_palettes = Attributes( @@ -57,7 +57,7 @@ const minimal_default = Attributes( palette = default_palettes, font = "Dejavu Sans", textcolor = :black, - padding = Vec3f0(0.05), + padding = Vec3f(0.05), figure_padding = 16, rowgap = 24, colgap = 24, @@ -71,7 +71,7 @@ const minimal_default = Attributes( linecolor = :black, linewidth = 1.5, linestyle = nothing, - patchcolor = RGBAf0(0, 0, 0, 0.6), + patchcolor = RGBAf(0, 0, 0, 0.6), patchstrokecolor = :black, patchstrokewidth = 0, resolution = (800, 600), # 4/3 aspect ratio diff --git a/src/types.jl b/src/types.jl index 43ccdc0516e..b3e0d8eb002 100644 --- a/src/types.jl +++ b/src/types.jl @@ -40,9 +40,9 @@ $(TYPEDFIELDS) """ struct Events """ - The area of the window in pixels, as a `Rect2D`. + The area of the window in pixels, as a `Rect2`. """ - window_area::PriorityObservable{IRect2D} + window_area::PriorityObservable{Rect2i} """ The DPI resolution of the window, as a `Float64`. """ @@ -139,7 +139,7 @@ function Events() end return Events( - PriorityObservable(IRect(0, 0, 0, 0)), + PriorityObservable(Recti(0, 0, 0, 0)), PriorityObservable(100.0), PriorityObservable(false), @@ -230,12 +230,12 @@ function Base.getproperty(e::Events, field::Symbol) end mutable struct Camera - pixel_space::Node{Mat4f0} - view::Node{Mat4f0} - projection::Node{Mat4f0} - projectionview::Node{Mat4f0} - resolution::Node{Vec2f0} - eyeposition::Node{Vec3f0} + pixel_space::Node{Mat4f} + view::Node{Mat4f} + projection::Node{Mat4f} + projectionview::Node{Mat4f} + resolution::Node{Vec2f} + eyeposition::Node{Vec3f} steering_nodes::Vector{ObserverFunction} end @@ -246,12 +246,12 @@ $(TYPEDFIELDS) """ struct Transformation <: Transformable parent::RefValue{Transformable} - translation::Node{Vec3f0} - scale::Node{Vec3f0} - rotation::Node{Quaternionf0} - model::Node{Mat4f0} + translation::Node{Vec3f} + scale::Node{Vec3f} + rotation::Node{Quaternionf} + model::Node{Mat4f} flip::Node{NTuple{3, Bool}} - align::Node{Vec2f0} + align::Node{Vec2f} # data conversion node, for e.g. log / log10 etc transform_func::Node{Any} function Transformation(translation, scale, rotation, model, flip, align, transform_func) @@ -315,12 +315,12 @@ Stores information about the glyphs in a string that had a layout calculated for struct GlyphCollection glyphs::Vector{Char} fonts::Vector{FTFont} - origins::Vector{Point3f0} + origins::Vector{Point3f} extents::Vector{FreeTypeAbstraction.FontExtent{Float32}} - scales::ScalarOrVector{Vec2f0} - rotations::ScalarOrVector{Quaternionf0} - colors::ScalarOrVector{RGBAf0} - strokecolors::ScalarOrVector{RGBAf0} + scales::ScalarOrVector{Vec2f} + rotations::ScalarOrVector{Quaternionf} + colors::ScalarOrVector{RGBAf} + strokecolors::ScalarOrVector{RGBAf} strokewidths::ScalarOrVector{Float32} function GlyphCollection(glyphs, fonts, origins, extents, scales, rotations, diff --git a/src/units.jl b/src/units.jl index 00efbe04fe4..f67f8eaa347 100644 --- a/src/units.jl +++ b/src/units.jl @@ -18,7 +18,7 @@ ######### function to_screen(scene::Scene, mpos) - return Point2f0(mpos) .- Point2f0(minimum(pixelarea(scene)[])) + return Point2f(mpos) .- Point2f(minimum(pixelarea(scene)[])) end number(x::Unit) = x.value @@ -102,14 +102,14 @@ function Base.convert(::Type{<: Pixel}, scene::Scene, x::DIP) end function Base.convert(::Type{<: SceneSpace}, scene::Scene, x::Vec{2, <:Pixel}) - zero = to_world(scene, to_screen(scene, Point2f0(0))) + zero = to_world(scene, to_screen(scene, Point2f(0))) s = to_world(scene, to_screen(scene, number.(Point(x)))) SceneSpace.(Vec(s .- zero)) end function Base.convert(::Type{<: SceneSpace}, scene::Scene, x::Pixel) - zero = to_world(scene, to_screen(scene, Point2f0(0))) - s = to_world(scene, to_screen(scene, Point2f0(number(x), 0.0))) + zero = to_world(scene, to_screen(scene, Point2f(0))) + s = to_world(scene, to_screen(scene, Point2f(number(x), 0.0))) SceneSpace(norm(s .- zero)) end @@ -118,9 +118,9 @@ function Base.convert(::Type{<: SceneSpace}, scene::Scene, x::Millimeter) (SceneSpace, mm) end -to_2d_scale(x::Pixel) = Vec2f0(number(x)) -to_2d_scale(x::Tuple{<:Pixel, <:Pixel}) = Vec2f0(number.(x)) -to_2d_scale(x::VecTypes{2, <:Pixel}) = Vec2f0(number.(x)) +to_2d_scale(x::Pixel) = Vec2f(number(x)) +to_2d_scale(x::Tuple{<:Pixel, <:Pixel}) = Vec2f(number.(x)) +to_2d_scale(x::VecTypes{2, <:Pixel}) = Vec2f(number.(x)) # Exports of units export px diff --git a/src/utilities/quaternions.jl b/src/utilities/quaternions.jl index 72f63d0b872..c4f7d701d50 100644 --- a/src/utilities/quaternions.jl +++ b/src/utilities/quaternions.jl @@ -15,7 +15,7 @@ Base.eltype(::Type{Quaternion{T}}) where T = T Base.length(::Type{<: Quaternion}) = 4 Base.length(::Quaternion) = 4 -const Quaternionf0 = Quaternion{Float32} +const Quaternionf = Quaternion{Float32} const SMat{N, L} = Mat{N, N, T, L} where T function Base.show(io::IO, q::Quaternion) diff --git a/src/utilities/texture_atlas.jl b/src/utilities/texture_atlas.jl index d93d6ddf6b7..4fb9db1b47c 100644 --- a/src/utilities/texture_atlas.jl +++ b/src/utilities/texture_atlas.jl @@ -7,7 +7,7 @@ mutable struct TextureAtlas index::Int data::Matrix{Float16} # rectangles we rendered our glyphs into in normalized uv coordinates - uv_rectangles::Vector{Vec4f0} + uv_rectangles::Vector{Vec4f} end Base.size(atlas::TextureAtlas) = size(atlas.data) @@ -36,11 +36,11 @@ end function TextureAtlas(initial_size = TEXTURE_RESOLUTION[]) return TextureAtlas( - RectanglePacker(Rect2D(0, 0, initial_size...)), + RectanglePacker(Rect2(0, 0, initial_size...)), Dict{Tuple{Char, String}, Int}(), 1, zeros(Float16, initial_size...), - Vec4f0[], + Vec4f[], ) end @@ -194,7 +194,7 @@ function insert_glyph!(atlas::TextureAtlas, glyph::Char, font::NativeFont) downsample = 5 # render font 5x larger, and then downsample back to desired pixelsize pad = 8 # padd rendered font by 6 pixel in each direction uv_pixel = render(atlas, glyph, font, downsample, pad) - tex_size = Vec2f0(size(atlas.data) .- 1) # starts at 1 + tex_size = Vec2f(size(atlas.data) .- 1) # starts at 1 idx_left_bottom = minimum(uv_pixel)# 0 based!!! idx_right_top = maximum(uv_pixel) @@ -208,7 +208,7 @@ function insert_glyph!(atlas::TextureAtlas, glyph::Char, font::NativeFont) uv_left_bottom_pad = (left_bottom_pad) ./ tex_size uv_right_top_pad = (right_top_pad) ./ tex_size - uv_offset_rect = Vec4f0(uv_left_bottom_pad..., uv_right_top_pad...) + uv_offset_rect = Vec4f(uv_left_bottom_pad..., uv_right_top_pad...) i = atlas.index push!(atlas.uv_rectangles, uv_offset_rect) atlas.index = i + 1 @@ -268,7 +268,7 @@ function render(atlas::TextureAtlas, glyph::Char, font, downsample=5, pad=6) bitmap, extent = renderface(font, glyph, pixelsize * downsample) # Our downsampeld & padded distancefield sd = sdistancefield(bitmap, downsample, pad) - rect = Rect2D(0, 0, size(sd)...) + rect = Rect2(0, 0, size(sd)...) uv = push!(atlas.rectangle_packer, rect) # find out where to place the rectangle uv == nothing && error("texture atlas is too small. Resizing not implemented yet. Please file an issue at Makie if you encounter this") #TODO resize surface # write distancefield into texture diff --git a/src/utilities/utilities.jl b/src/utilities/utilities.jl index 228e8e84a18..a114bc4e141 100644 --- a/src/utilities/utilities.jl +++ b/src/utilities/utilities.jl @@ -68,7 +68,7 @@ function nan_extrema(array) mini = min(mini, elem) maxi = max(maxi, elem) end - Vec2f0(mini, maxi) + Vec2f(mini, maxi) end function extract_expr(extract_func, dictlike, args) @@ -316,9 +316,9 @@ function surface_normals(x, y, z) of = (ci(-1, -1), ci(1, -1), ci(-1, 1), ci(1, 1)) function offsets(off) s = size(z) - return Vec3f0(get_dim(x, off, 1, s), get_dim(y, off, 2, s), z[off]) + return Vec3f(get_dim(x, off, 1, s), get_dim(y, off, 2, s), z[off]) end - return normalize(mapreduce(offsets, +, init=Vec3f0(0), of)) + return normalize(mapreduce(offsets, +, init=Vec3f(0), of)) end return vec(map(normal, CartesianIndices(z))) end diff --git a/test/conversions.jl b/test/conversions.jl index 3fe535fac27..396607dcbb8 100644 --- a/test/conversions.jl +++ b/test/conversions.jl @@ -164,16 +164,16 @@ end Makie.convert_single_argument(v::MyNestedVector) = v.v Makie.convert_single_argument(v::MyVector) = v.v - @test convert_arguments(Lines, myvector, mynestedvector) == (Point2f0.(1:10, 11:20),) + @test convert_arguments(Lines, myvector, mynestedvector) == (Point2f.(1:10, 11:20),) @test isequal( convert_arguments(Lines, [1, missing, 2]), - (Point2f0[(1, 1), (2, NaN), (3, 2)],) + (Point2f[(1, 1), (2, NaN), (3, 2)],) ) @test isequal( convert_arguments(Lines, [Point(1, 2), missing, Point(3, 4)]), - (Point2f0[(1.0, 2.0), (NaN, NaN), (3.0, 4.0)],) + (Point2f[(1.0, 2.0), (NaN, NaN), (3.0, 4.0)],) ) end @@ -185,7 +185,7 @@ end end @testset "colors" begin - @test to_color(["red", "green"]) isa Vector{RGBAf0} + @test to_color(["red", "green"]) isa Vector{RGBAf} @test to_color(["red", "green"]) == [to_color("red"), to_color("green")] end diff --git a/test/events.jl b/test/events.jl index e9ce0bc1bd2..da96fee3136 100644 --- a/test/events.jl +++ b/test/events.jl @@ -69,31 +69,31 @@ end cc = cameracontrols(scene) # Verify initial camera state - @test cc.lookat[] == Vec3f0(0) - @test cc.eyeposition[] == Vec3f0(3) - @test cc.upvector[] == Vec3f0(0, 0, 1) + @test cc.lookat[] == Vec3f(0) + @test cc.eyeposition[] == Vec3f(3) + @test cc.upvector[] == Vec3f(0, 0, 1) # Rotation # 1) In scene, in drag e.mouseposition[] = (400, 250) e.mousebutton[] = MouseButtonEvent(Mouse.left, Mouse.press) e.mouseposition[] = (600, 250) - @test cc.lookat[] ≈ Vec3f0(0) - @test cc.eyeposition[] ≈ Vec3f0(4.14532, -0.9035063, 3.0) - @test cc.upvector[] ≈ Vec3f0(0, 0, 1) + @test cc.lookat[] ≈ Vec3f(0) + @test cc.eyeposition[] ≈ Vec3f(4.14532, -0.9035063, 3.0) + @test cc.upvector[] ≈ Vec3f(0, 0, 1) # 2) Outside scene, in drag e.mouseposition[] = (1000, 450) - @test cc.lookat[] ≈ Vec3f0(0) - @test cc.eyeposition[] ≈ Vec3f0(-2.8912058, -3.8524969, -1.9491522) - @test cc.upvector[] ≈ Vec3f0(-0.5050875, -0.6730229, 0.5403024) + @test cc.lookat[] ≈ Vec3f(0) + @test cc.eyeposition[] ≈ Vec3f(-2.8912058, -3.8524969, -1.9491522) + @test cc.upvector[] ≈ Vec3f(-0.5050875, -0.6730229, 0.5403024) # 3) not in drag e.mousebutton[] = MouseButtonEvent(Mouse.left, Mouse.release) e.mouseposition[] = (400, 250) - @test cc.lookat[] ≈ Vec3f0(0) - @test cc.eyeposition[] ≈ Vec3f0(-2.8912058, -3.8524969, -1.9491522) - @test cc.upvector[] ≈ Vec3f0(-0.5050875, -0.6730229, 0.5403024) + @test cc.lookat[] ≈ Vec3f(0) + @test cc.eyeposition[] ≈ Vec3f(-2.8912058, -3.8524969, -1.9491522) + @test cc.upvector[] ≈ Vec3f(-0.5050875, -0.6730229, 0.5403024) @@ -104,30 +104,30 @@ end cc = cameracontrols(scene) # Verify initial camera state - @test cc.lookat[] == Vec3f0(0) - @test cc.eyeposition[] == Vec3f0(3) - @test cc.upvector[] == Vec3f0(0, 0, 1) + @test cc.lookat[] == Vec3f(0) + @test cc.eyeposition[] == Vec3f(3) + @test cc.upvector[] == Vec3f(0, 0, 1) # translation # 1) In scene, in drag e.mousebutton[] = MouseButtonEvent(Mouse.right, Mouse.press) e.mouseposition[] = (600, 250) - @test cc.lookat[] ≈ Vec3f0(5.4697413, -3.3484206, -2.1213205) - @test cc.eyeposition[] ≈ Vec3f0(8.469742, -0.34842062, 0.8786795) - @test cc.upvector[] ≈ Vec3f0(0.0, 0.0, 1.0) + @test cc.lookat[] ≈ Vec3f(5.4697413, -3.3484206, -2.1213205) + @test cc.eyeposition[] ≈ Vec3f(8.469742, -0.34842062, 0.8786795) + @test cc.upvector[] ≈ Vec3f(0.0, 0.0, 1.0) # 2) Outside scene, in drag e.mouseposition[] = (1000, 450) - @test cc.lookat[] ≈ Vec3f0(9.257657, -5.4392805, -3.818377) - @test cc.eyeposition[] ≈ Vec3f0(12.257658, -2.4392805, -0.81837714) - @test cc.upvector[] ≈ Vec3f0(0.0, 0.0, 1.0) + @test cc.lookat[] ≈ Vec3f(9.257657, -5.4392805, -3.818377) + @test cc.eyeposition[] ≈ Vec3f(12.257658, -2.4392805, -0.81837714) + @test cc.upvector[] ≈ Vec3f(0.0, 0.0, 1.0) # 3) not in drag e.mousebutton[] = MouseButtonEvent(Mouse.right, Mouse.release) e.mouseposition[] = (400, 250) - @test cc.lookat[] ≈ Vec3f0(9.257657, -5.4392805, -3.818377) - @test cc.eyeposition[] ≈ Vec3f0(12.257658, -2.4392805, -0.81837714) - @test cc.upvector[] ≈ Vec3f0(0.0, 0.0, 1.0) + @test cc.lookat[] ≈ Vec3f(9.257657, -5.4392805, -3.818377) + @test cc.eyeposition[] ≈ Vec3f(12.257658, -2.4392805, -0.81837714) + @test cc.upvector[] ≈ Vec3f(0.0, 0.0, 1.0) @@ -138,31 +138,31 @@ end cc = cameracontrols(scene) # Verify initial camera state - @test cc.lookat[] == Vec3f0(0) - @test cc.eyeposition[] == Vec3f0(3) - @test cc.upvector[] == Vec3f0(0, 0, 1) + @test cc.lookat[] == Vec3f(0) + @test cc.eyeposition[] == Vec3f(3) + @test cc.upvector[] == Vec3f(0, 0, 1) @test cc.zoom_mult[] == 1f0 # Zoom e.scroll[] = (0.0, 4.0) - @test cc.lookat[] ≈ Vec3f0(0) - @test cc.eyeposition[] ≈ Vec3f0(3) - @test cc.upvector[] ≈ Vec3f0(0.0, 0.0, 1.0) + @test cc.lookat[] ≈ Vec3f(0) + @test cc.eyeposition[] ≈ Vec3f(3) + @test cc.upvector[] ≈ Vec3f(0.0, 0.0, 1.0) @test cc.zoom_mult[] ≈ 0.6830134f0 # should not work outside the scene e.mouseposition[] = (1000, 450) e.scroll[] = (0.0, 4.0) - @test cc.lookat[] ≈ Vec3f0(0) - @test cc.eyeposition[] ≈ Vec3f0(3) - @test cc.upvector[] ≈ Vec3f0(0.0, 0.0, 1.0) + @test cc.lookat[] ≈ Vec3f(0) + @test cc.eyeposition[] ≈ Vec3f(3) + @test cc.upvector[] ≈ Vec3f(0.0, 0.0, 1.0) @test cc.zoom_mult[] ≈ 0.6830134f0 end @testset "mouse state machine" begin scene = Scene(resolution=(800, 600)); e = events(scene) - bbox = Node(Rect2D(200, 200, 400, 300)) + bbox = Node(Rect2(200, 200, 400, 300)) msm = addmouseevents!(scene, bbox, priority=typemax(Int8)) eventlog = MouseEvent[] on(x -> begin push!(eventlog, x); false end, msm.obs) @@ -174,16 +174,16 @@ end e.mouseposition[] = (300, 200) @test length(eventlog) == 1 @test eventlog[1].type == MouseEventTypes.enter - @test eventlog[1].px == Point2f0(300, 200) - @test eventlog[1].prev_px == Point2f0(0, 200) + @test eventlog[1].px == Point2f(300, 200) + @test eventlog[1].prev_px == Point2f(0, 200) empty!(eventlog) # over e.mouseposition[] = (300, 300) @test length(eventlog) == 1 @test eventlog[1].type == MouseEventTypes.over - @test eventlog[1].px == Point2f0(300, 300) - @test eventlog[1].prev_px == Point2f0(300, 200) + @test eventlog[1].px == Point2f(300, 300) + @test eventlog[1].prev_px == Point2f(300, 200) empty!(eventlog) for button in (:left, :middle, :right) @@ -197,8 +197,8 @@ end getfield(MouseEventTypes, Symbol(button, :up)) )) @test eventlog[i].type == t - @test eventlog[i].px == Point2f0(300, 300) - @test eventlog[i].prev_px == Point2f0(300, 300) + @test eventlog[i].px == Point2f(300, 300) + @test eventlog[i].prev_px == Point2f(300, 300) end empty!(eventlog) @@ -212,8 +212,8 @@ end getfield(MouseEventTypes, Symbol(button, :up)) )) @test eventlog[i].type == t - @test eventlog[i].px == Point2f0(300, 300) - @test eventlog[i].prev_px == Point2f0(300, 300) + @test eventlog[i].px == Point2f(300, 300) + @test eventlog[i].prev_px == Point2f(300, 300) end empty!(eventlog) @@ -227,8 +227,8 @@ end getfield(MouseEventTypes, Symbol(button, :up)) )) @test eventlog[i].type == t - @test eventlog[i].px == Point2f0(300, 300) - @test eventlog[i].prev_px == Point2f0(300, 300) + @test eventlog[i].px == Point2f(300, 300) + @test eventlog[i].prev_px == Point2f(300, 300) end empty!(eventlog) @@ -238,8 +238,8 @@ end e.mouseposition[] = (700, 200) e.mousebutton[] = MouseButtonEvent(getfield(Mouse, button), Mouse.release) @test length(eventlog) == 6 - prev_px = Point2f0[(300, 300), (300, 300), (300, 300), (500, 300), (700, 200), (700, 200)] - px = Point2f0[(300, 300), (500, 300), (500, 300), (700, 200), (700, 200), (700, 200)] + prev_px = Point2f[(300, 300), (300, 300), (300, 300), (500, 300), (700, 200), (700, 200)] + px = Point2f[(300, 300), (500, 300), (500, 300), (700, 200), (700, 200), (700, 200)] for (i, t) in enumerate(( getfield(MouseEventTypes, Symbol(button, :down)), getfield(MouseEventTypes, Symbol(button, :dragstart)), @@ -299,13 +299,13 @@ end @test eventlog[5].type == MouseEventTypes.over @test eventlog[6].type == MouseEventTypes.leftdragstop @test eventlog[7].type == MouseEventTypes.leftup - @test eventlog[1].px == Point2f0(300, 300) - @test eventlog[2].px == Point2f0(350, 350) - @test eventlog[3].px == Point2f0(350, 350) - @test eventlog[4].px == Point2f0(350, 400) - @test eventlog[5].px == Point2f0(400, 400) - @test eventlog[6].px == Point2f0(400, 400) - @test eventlog[7].px == Point2f0(400, 400) + @test eventlog[1].px == Point2f(300, 300) + @test eventlog[2].px == Point2f(350, 350) + @test eventlog[3].px == Point2f(350, 350) + @test eventlog[4].px == Point2f(350, 400) + @test eventlog[5].px == Point2f(400, 400) + @test eventlog[6].px == Point2f(400, 400) + @test eventlog[7].px == Point2f(400, 400) empty!(eventlog) end end diff --git a/test/makielayout.jl b/test/makielayout.jl index 3f75ced1e2b..c57747fefa7 100644 --- a/test/makielayout.jl +++ b/test/makielayout.jl @@ -51,11 +51,11 @@ end ax.limits[] = (nothing, nothing) ax.xautolimitmargin = (0, 0) ax.yautolimitmargin = (0, 0) - scatter!(Point2f0[(0, 0), (1, 2)]) + scatter!(Point2f[(0, 0), (1, 2)]) @test ax.limits[] == (nothing, nothing) @test ax.targetlimits[] == BBox(0, 1, 0, 2) @test ax.finallimits[] == BBox(0, 1, 0, 2) - scatter!(Point2f0(3, 4)) + scatter!(Point2f(3, 4)) @test ax.limits[] == (nothing, nothing) @test ax.targetlimits[] == BBox(0, 3, 0, 4) @test ax.finallimits[] == BBox(0, 3, 0, 4) @@ -63,7 +63,7 @@ end @test ax.limits[] == ((-1, 1), (0, 2)) @test ax.targetlimits[] == BBox(-1, 1, 0, 2) @test ax.finallimits[] == BBox(-1, 1, 0, 2) - scatter!(Point2f0(5, 6)) + scatter!(Point2f(5, 6)) @test ax.limits[] == ((-1, 1), (0, 2)) @test ax.targetlimits[] == BBox(-1, 1, 0, 2) @test ax.finallimits[] == BBox(-1, 1, 0, 2) @@ -75,7 +75,7 @@ end @test ax.limits[] == ((-10, 10), nothing) @test ax.targetlimits[] == BBox(-10, 10, 0, 6) @test ax.finallimits[] == BBox(-10, 10, 0, 6) - scatter!(Point2f0(11, 12)) + scatter!(Point2f(11, 12)) @test ax.limits[] == ((-10, 10), nothing) @test ax.targetlimits[] == BBox(-10, 10, 0, 12) @test ax.finallimits[] == BBox(-10, 10, 0, 12) @@ -84,7 +84,7 @@ end @test ax.limits[] == (nothing, (5, 7)) @test ax.targetlimits[] == BBox(0, 11, 5, 7) @test ax.finallimits[] == BBox(0, 11, 5, 7) - scatter!(Point2f0(-5, -7)) + scatter!(Point2f(-5, -7)) @test ax.limits[] == (nothing, (5, 7)) @test ax.targetlimits[] == BBox(-5, 11, 5, 7) @test ax.finallimits[] == BBox(-5, 11, 5, 7) diff --git a/test/quaternions.jl b/test/quaternions.jl index beb20fe7f1f..ea0361b22bc 100644 --- a/test/quaternions.jl +++ b/test/quaternions.jl @@ -8,21 +8,21 @@ c = cos(theta); s = sin(theta) Rx = [1 0 0; 0 c -s; 0 s c] - @test Mat3f0(qx) ≈ Rx + @test Mat3f(qx) ≈ Rx theta = pi / 6 qy = qrotation(SVector(0.0, 1.0, 0.0), theta) c = cos(theta); s = sin(theta) Ry = [c 0 s; 0 1 0; -s 0 c] - @test Mat3f0(qy) ≈ Ry + @test Mat3f(qy) ≈ Ry theta = 4pi / 3 qz = qrotation(SVector(0.0, 0.0, 1.0), theta) c = cos(theta); s = sin(theta) Rz = [c -s 0; s c 0; 0 0 1] - @test Mat3f0(qz) ≈ Rz + @test Mat3f(qz) ≈ Rz - @test Mat3f0(qx * qy * qz) ≈ Rx * Ry * Rz - @test Mat3f0(qy * qx * qz) ≈ Ry * Rx * Rz - @test Mat3f0(qz * qx * qy) ≈ Rz * Rx * Ry + @test Mat3f(qx * qy * qz) ≈ Rx * Ry * Rz + @test Mat3f(qy * qx * qz) ≈ Ry * Rx * Rz + @test Mat3f(qz * qx * qy) ≈ Rz * Rx * Ry a, b = qrotation(SVector(0.0, 0.0, 1.0), deg2rad(0)), qrotation(SVector(0.0, 0.0, 1.0), deg2rad(180)) # @test slerp(a, b, 0.0) ≈ a diff --git a/test/statistical_tests.jl b/test/statistical_tests.jl index 7a7b26313c9..095d9e99fb3 100644 --- a/test/statistical_tests.jl +++ b/test/statistical_tests.jl @@ -4,7 +4,7 @@ import Distributions using KernelDensity using Random: seed! -using GeometryBasics: FRect2D +using GeometryBasics: Rect2f seed!(0) @@ -147,7 +147,7 @@ end fig, ax, p = crossbar(1, 3, 2, 4) @test p isa CrossBar @test p.plots[1] isa Poly - @test p.plots[1][1][] == [FRect2D(Float32[0.6, 2.0], Float32[0.8, 2.0]),] + @test p.plots[1][1][] == [Rect2f(Float32[0.6, 2.0], Float32[0.8, 2.0]),] @test p.plots[2] isa LineSegments @test p.plots[2][1][] == Point{2,Float32}[Float32[0.6, 3.0], Float32[1.4, 3.0]] @@ -157,7 +157,7 @@ end @test p.plots[1][1][][1] isa Makie.AbstractMesh poly = Point{2,Float32}[[0.6, 2.0], [1.4, 2.0], [1.4, 2.5], [1.2, 3.0], [1.4, 3.5], [1.4, 4.0], [0.6, 4.0], [0.6, 3.5], [0.8, 3.0], [0.6, 2.5]] - @test map(Point2f0, p.plots[1][1][][1].position) == poly + @test map(Point2f, p.plots[1][1][][1].position) == poly @test p.plots[2] isa LineSegments @test p.plots[2][1][] == Point{2,Float32}[Float32[0.8, 3.0], Float32[1.2, 3.0]] end @@ -197,11 +197,11 @@ end @test plts[3].plots[1] isa Poly poly = [ - FRect2D(Float32[0.6, 5.75], Float32[0.8, 9.5]), - FRect2D(Float32[1.6, 25.75], Float32[0.8, 9.5]), - FRect2D(Float32[2.6, 45.75], Float32[0.8, 9.5]), - FRect2D(Float32[3.6, 65.75], Float32[0.8, 9.5]), - FRect2D(Float32[4.6, 85.75], Float32[0.8, 9.5]), + Rect2f(Float32[0.6, 5.75], Float32[0.8, 9.5]), + Rect2f(Float32[1.6, 25.75], Float32[0.8, 9.5]), + Rect2f(Float32[2.6, 45.75], Float32[0.8, 9.5]), + Rect2f(Float32[3.6, 65.75], Float32[0.8, 9.5]), + Rect2f(Float32[4.6, 85.75], Float32[0.8, 9.5]), ] @test plts[3].plots[1][1][] == poly @@ -229,15 +229,15 @@ end @test plts[3] isa CrossBar @test plts[3].plots[1] isa Poly - notch_boxes = Vector{Point{2,Float32}}[map(Point2f0, [[0.6, 5.75], [1.4, 5.75], [1.4, 7.14366], [1.2, 10.5], [1.4, 13.8563], [1.4, 15.25], [0.6, 15.25], [0.6, 13.8563], [0.8, 10.5], [0.6, 7.14366]]), - map(Point2f0, [[1.6, 25.75], [2.4, 25.75], [2.4, 27.1437], [2.2, 30.5], [2.4, 33.8563], [2.4, 35.25], [1.6, 35.25], [1.6, 33.8563], [1.8, 30.5], [1.6, 27.1437]]), - map(Point2f0, [[2.6, 45.75], [3.4, 45.75], [3.4, 47.1437], [3.2, 50.5], [3.4, 53.8563], [3.4, 55.25], [2.6, 55.25], [2.6, 53.8563], [2.8, 50.5], [2.6, 47.1437]]), - map(Point2f0, [[3.6, 65.75], [4.4, 65.75], [4.4, 67.1437], [4.2, 70.5], [4.4, 73.8563], [4.4, 75.25], [3.6, 75.25], [3.6, 73.8563], [3.8, 70.5], [3.6, 67.1437]]), - map(Point2f0, [[4.6, 85.75], [5.4, 85.75], [5.4, 87.1437], [5.2, 90.5], [5.4, 93.8563], [5.4, 95.25], [4.6, 95.25], [4.6, 93.8563], [4.8, 90.5], [4.6, 87.1437]])] + notch_boxes = Vector{Point{2,Float32}}[map(Point2f, [[0.6, 5.75], [1.4, 5.75], [1.4, 7.14366], [1.2, 10.5], [1.4, 13.8563], [1.4, 15.25], [0.6, 15.25], [0.6, 13.8563], [0.8, 10.5], [0.6, 7.14366]]), + map(Point2f, [[1.6, 25.75], [2.4, 25.75], [2.4, 27.1437], [2.2, 30.5], [2.4, 33.8563], [2.4, 35.25], [1.6, 35.25], [1.6, 33.8563], [1.8, 30.5], [1.6, 27.1437]]), + map(Point2f, [[2.6, 45.75], [3.4, 45.75], [3.4, 47.1437], [3.2, 50.5], [3.4, 53.8563], [3.4, 55.25], [2.6, 55.25], [2.6, 53.8563], [2.8, 50.5], [2.6, 47.1437]]), + map(Point2f, [[3.6, 65.75], [4.4, 65.75], [4.4, 67.1437], [4.2, 70.5], [4.4, 73.8563], [4.4, 75.25], [3.6, 75.25], [3.6, 73.8563], [3.8, 70.5], [3.6, 67.1437]]), + map(Point2f, [[4.6, 85.75], [5.4, 85.75], [5.4, 87.1437], [5.2, 90.5], [5.4, 93.8563], [5.4, 95.25], [4.6, 95.25], [4.6, 93.8563], [4.8, 90.5], [4.6, 87.1437]])] meshes = plts[3].plots[1][1][] @testset for (i, mesh) in enumerate(meshes) @test mesh isa Makie.AbstractMesh - vertices = map(Point2f0, mesh.position) + vertices = map(Point2f, mesh.position) @test vertices ≈ notch_boxes[i] end end diff --git a/test/transformations.jl b/test/transformations.jl index 0b5b666305f..8fcea2377ac 100644 --- a/test/transformations.jl +++ b/test/transformations.jl @@ -2,25 +2,25 @@ using Makie: PointTrans, xyz_boundingbox, apply_transform @testset "Basic transforms" begin function fpoint2(x::Point2) - return Point2f0(x[1] + 10, x[2] - 77) + return Point2f(x[1] + 10, x[2] - 77) end function fpoint3(x::Point3) - return Point3f0(x[1] + 10, x[2] - 77, x[3] / 4) + return Point3f(x[1] + 10, x[2] - 77, x[3] / 4) end trans2 = PointTrans{2}(fpoint2) trans3 = PointTrans{3}(fpoint3) - points2 = [Point2f0(0, 0), Point2f0(0, 1)] + points2 = [Point2f(0, 0), Point2f(0, 1)] bb = xyz_boundingbox(trans2, points2) - @test bb == Rect(Vec3f0(10, -77, 0), Vec3f0(0, 1, 0)) + @test bb == Rect(Vec3f(10, -77, 0), Vec3f(0, 1, 0)) bb = xyz_boundingbox(trans3, points2) - @test bb == Rect(Vec3f0(10, -77, 0), Vec3f0(0, 1, 0)) + @test bb == Rect(Vec3f(10, -77, 0), Vec3f(0, 1, 0)) - points3 = [Point3f0(0, 0, 4), Point3f0(0, 1, -8)] + points3 = [Point3f(0, 0, 4), Point3f(0, 1, -8)] bb = xyz_boundingbox(trans2, points3) - @test bb == Rect(Vec3f0(10, -77, -8), Vec3f0(0, 1, 12)) + @test bb == Rect(Vec3f(10, -77, -8), Vec3f(0, 1, 12)) bb = xyz_boundingbox(trans3, points3) - @test bb == Rect(Vec3f0(10, -77, -2.0), Vec3f0(0, 1, 3.0)) + @test bb == Rect(Vec3f(10, -77, -2.0), Vec3f(0, 1, 3.0)) @test apply_transform(trans2, points2) == fpoint2.(points2) @test apply_transform(trans3, points3) == fpoint3.(points3) @@ -44,10 +44,10 @@ end @test apply_transform(t1, p2) == Point(sqrt(2.0), sqrt(5.0)) @test apply_transform(t1, p3) == Point(sqrt(2.0), sqrt(5.0), sqrt(4.0)) - @test apply_transform(t2, p2) == Point2f0(sqrt(2.0), log(5.0)) - @test apply_transform(t2, p3) == Point3f0(sqrt(2.0), log(5.0), 4.0) + @test apply_transform(t2, p2) == Point2f(sqrt(2.0), log(5.0)) + @test apply_transform(t2, p3) == Point3f(sqrt(2.0), log(5.0), 4.0) - @test apply_transform(t3, p3) == Point3f0(sqrt(2.0), log(5.0), log10(4.0)) + @test apply_transform(t3, p3) == Point3f(sqrt(2.0), log(5.0), log10(4.0)) i2 = (identity, identity) i3 = (identity, identity, identity) @@ -55,12 +55,12 @@ end @test apply_transform(i3, p3) == p3 # test that identity gives back exact same arrays without copying - p2s = Point2f0[(1, 2), (3, 4)] + p2s = Point2f[(1, 2), (3, 4)] @test apply_transform(identity, p2s) === p2s @test apply_transform(i2, p2s) === p2s @test apply_transform(i3, p2s) === p2s - p3s = Point3f0[(1, 2, 3), (3, 4, 5)] + p3s = Point3f[(1, 2, 3), (3, 4, 5)] @test apply_transform(identity, p3s) === p3s @test apply_transform(i2, p3s) === p3s @test apply_transform(i3, p3s) === p3s @@ -73,8 +73,8 @@ end @test apply_transform(i2, 1..2) == 1..2 @test apply_transform(i3, 1..2) == 1..2 - pa = Point2f0(1, 2) - pb = Point2f0(3, 4) - r2 = FRect2D(pa, pb .- pa) - @test apply_transform(t1, r2) == FRect2D(apply_transform(t1, pa), apply_transform(t1, pb) .- apply_transform(t1, pa) ) + pa = Point2f(1, 2) + pb = Point2f(3, 4) + r2 = Rect2f(pa, pb .- pa) + @test apply_transform(t1, r2) == Rect2f(apply_transform(t1, pa), apply_transform(t1, pb) .- apply_transform(t1, pa) ) end From c6259e1d2a37cc0ab48b8735fa2a83fac0701904 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 23 Aug 2021 17:26:59 +0200 Subject: [PATCH 2/4] Reexport deprecated names --- CairoMakie/src/CairoMakie.jl | 10 ++++++---- GLMakie/src/GLMakie.jl | 9 ++++++--- WGLMakie/src/WGLMakie.jl | 7 ++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CairoMakie/src/CairoMakie.jl b/CairoMakie/src/CairoMakie.jl index 35f42a85467..95cd23239f0 100644 --- a/CairoMakie/src/CairoMakie.jl +++ b/CairoMakie/src/CairoMakie.jl @@ -18,10 +18,12 @@ const OneOrVec{T} = Union{ NTuple{N2, T} where N2, } -# re-export Makie -for name in names(Makie) - @eval using Makie: $(name) - @eval export $(name) +# re-export Makie, including deprecated names +for name in names(Makie, all=true) + if Base.isexported(Makie, name) + @eval using Makie: $(name) + @eval export $(name) + end end export inline! diff --git a/GLMakie/src/GLMakie.jl b/GLMakie/src/GLMakie.jl index 5c094a3ffd7..b9be9d6b7d4 100644 --- a/GLMakie/src/GLMakie.jl +++ b/GLMakie/src/GLMakie.jl @@ -18,9 +18,12 @@ using Base.Iterators: repeated, drop using LinearAlgebra -for name in names(Makie) - @eval import Makie: $(name) - @eval export $(name) +# re-export Makie, including deprecated names +for name in names(Makie, all=true) + if Base.isexported(Makie, name) + @eval using Makie: $(name) + @eval export $(name) + end end export inline! diff --git a/WGLMakie/src/WGLMakie.jl b/WGLMakie/src/WGLMakie.jl index f2adeaff769..fba4f41a110 100644 --- a/WGLMakie/src/WGLMakie.jl +++ b/WGLMakie/src/WGLMakie.jl @@ -64,9 +64,10 @@ function __init__() end end -for name in names(Makie) - if name !== :Button && name !== :Slider - @eval import Makie: $(name) +# re-export Makie, including deprecated names +for name in names(Makie, all=true) + if Base.isexported(Makie, name) && name !== :Button && name !== :Slider + @eval using Makie: $(name) @eval export $(name) end end From d7307291e3f3cdc060dd729d5eb1c9bef57e5fb2 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 23 Aug 2021 18:02:10 +0200 Subject: [PATCH 3/4] Qualify extended methods --- GLMakie/src/drawing_primitives.jl | 4 +-- GLMakie/src/events.jl | 56 +++++++++++++++---------------- GLMakie/src/screen.jl | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/GLMakie/src/drawing_primitives.jl b/GLMakie/src/drawing_primitives.jl index 58488fb3c91..85c029bdee0 100644 --- a/GLMakie/src/drawing_primitives.jl +++ b/GLMakie/src/drawing_primitives.jl @@ -2,8 +2,8 @@ using Makie: get_texture_atlas, glyph_uv_width!, transform_func_obs, apply_trans using Makie: attribute_per_char, FastPixel, el32convert, Pixel using Makie: convert_arguments, preprojected_glyph_arrays -convert_attribute(s::ShaderAbstractions.Sampler{RGBAf}, k::key"color") = s -function convert_attribute(s::ShaderAbstractions.Sampler{T, N}, k::key"color") where {T, N} +Makie.convert_attribute(s::ShaderAbstractions.Sampler{RGBAf}, k::key"color") = s +function Makie.convert_attribute(s::ShaderAbstractions.Sampler{T, N}, k::key"color") where {T, N} ShaderAbstractions.Sampler( el32convert(s.data), minfilter = s.minfilter, magfilter = s.magfilter, x_repeat = s.repeat[1], y_repeat = s.repeat[min(2, N)], z_repeat = s.repeat[min(3, N)], diff --git a/GLMakie/src/events.jl b/GLMakie/src/events.jl index 4c317db4b03..b2cfd0b17cf 100644 --- a/GLMakie/src/events.jl +++ b/GLMakie/src/events.jl @@ -18,8 +18,8 @@ Returns a signal, which is true as long as the window is open. returns `Node{Bool}` [GLFW Docs](http://www.glfw.org/docs/latest/group__window.html#gaade9264e79fae52bdb78e2df11ee8d6a) """ -window_open(scene::Scene, screen) = window_open(scene, to_native(screen)) -function window_open(scene::Scene, window::GLFW.Window) +Makie.window_open(scene::Scene, screen) = window_open(scene, to_native(screen)) +function Makie.window_open(scene::Scene, window::GLFW.Window) event = scene.events.window_open function windowclose(win) @print_error begin @@ -31,7 +31,7 @@ function window_open(scene::Scene, window::GLFW.Window) GLFW.SetWindowCloseCallback(window, windowclose) end -function disconnect!(window::GLFW.Window, ::typeof(window_open)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(window_open)) GLFW.SetWindowCloseCallback(window, nothing) end @@ -40,7 +40,7 @@ function window_position(window::GLFW.Window) (xy.x, xy.y) end -function window_area(scene::Scene, screen::Screen) +function Makie.window_area(scene::Scene, screen::Screen) window = to_native(screen) event = scene.events.window_area dpievent = scene.events.window_dpi @@ -70,7 +70,7 @@ function window_area(scene::Scene, screen::Screen) return end -function disconnect!(window::GLFW.Window, ::typeof(window_area)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(window_area)) GLFW.SetWindowPosCallback(window, nothing) GLFW.SetFramebufferSizeCallback(window, nothing) end @@ -81,8 +81,8 @@ Registers a callback for the mouse buttons + modifiers returns `Node{NTuple{4, Int}}` [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#ga1e008c7a8751cea648c8f42cc91104cf) """ -mouse_buttons(scene::Scene, screen) = mouse_buttons(scene, to_native(screen)) -function mouse_buttons(scene::Scene, window::GLFW.Window) +Makie.mouse_buttons(scene::Scene, screen) = mouse_buttons(scene, to_native(screen)) +function Makie.mouse_buttons(scene::Scene, window::GLFW.Window) event = scene.events.mousebutton function mousebuttons(window, button, action, mods) @print_error begin @@ -92,11 +92,11 @@ function mouse_buttons(scene::Scene, window::GLFW.Window) disconnect!(window, mouse_buttons) GLFW.SetMouseButtonCallback(window, mousebuttons) end -function disconnect!(window::GLFW.Window, ::typeof(mouse_buttons)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(mouse_buttons)) GLFW.SetMouseButtonCallback(window, nothing) end -keyboard_buttons(scene::Scene, screen) = keyboard_buttons(scene, to_native(screen)) -function keyboard_buttons(scene::Scene, window::GLFW.Window) +Makie.keyboard_buttons(scene::Scene, screen) = keyboard_buttons(scene, to_native(screen)) +function Makie.keyboard_buttons(scene::Scene, window::GLFW.Window) event = scene.events.keyboardbutton function keyoardbuttons(window, button, scancode::Cint, action, mods::Cint) @print_error begin @@ -107,7 +107,7 @@ function keyboard_buttons(scene::Scene, window::GLFW.Window) GLFW.SetKeyCallback(window, keyoardbuttons) end -function disconnect!(window::GLFW.Window, ::typeof(keyboard_buttons)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(keyboard_buttons)) GLFW.SetKeyCallback(window, nothing) end @@ -116,8 +116,8 @@ Registers a callback for drag and drop of files. returns `Node{Vector{String}}`, which are absolute file paths [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#gacc95e259ad21d4f666faa6280d4018fd) """ -dropped_files(scene::Scene, screen) = dropped_files(scene, to_native(screen)) -function dropped_files(scene::Scene, window::GLFW.Window) +Makie.dropped_files(scene::Scene, screen) = dropped_files(scene, to_native(screen)) +function Makie.dropped_files(scene::Scene, window::GLFW.Window) event = scene.events.dropped_files function droppedfiles(window, files) @print_error begin @@ -128,7 +128,7 @@ function dropped_files(scene::Scene, window::GLFW.Window) event[] = String[] GLFW.SetDropCallback(window, droppedfiles) end -function disconnect!(window::GLFW.Window, ::typeof(dropped_files)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(dropped_files)) GLFW.SetDropCallback(window, nothing) end @@ -138,8 +138,8 @@ returns an `Node{Vector{Char}}`, containing the pressed char. Is empty, if no key is pressed. [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#ga1e008c7a8751cea648c8f42cc91104cf) """ -unicode_input(scene::Scene, screen) = unicode_input(scene, to_native(screen)) -function unicode_input(scene::Scene, window::GLFW.Window) +Makie.unicode_input(scene::Scene, screen) = unicode_input(scene, to_native(screen)) +function Makie.unicode_input(scene::Scene, window::GLFW.Window) event = scene.events.unicode_input function unicodeinput(window, c::Char) @print_error begin @@ -151,7 +151,7 @@ function unicode_input(scene::Scene, window::GLFW.Window) # event[] = x GLFW.SetCharCallback(window, unicodeinput) end -function disconnect!(window::GLFW.Window, ::typeof(unicode_input)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(unicode_input)) GLFW.SetCharCallback(window, nothing) end @@ -189,7 +189,7 @@ returns an `Node{Vec{2, Float64}}`, which is not in scene coordinates, with the upper left window corner being 0 [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#ga1e008c7a8751cea648c8f42cc91104cf) """ -function mouse_position(scene::Scene, screen::Screen) +function Makie.mouse_position(scene::Scene, screen::Screen) window = to_native(screen) e = events(scene) on(screen.render_tick) do _ @@ -217,7 +217,7 @@ function mouse_position(scene::Scene, screen::Screen) return end -function disconnect!(window::GLFW.Window, ::typeof(mouse_position)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(mouse_position)) GLFW.SetCursorPosCallback(window, nothing) nothing end @@ -228,8 +228,8 @@ returns an `Node{Vec{2, Float64}}`, which is an x and y offset. [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#gacc95e259ad21d4f666faa6280d4018fd) """ -scroll(scene::Scene, screen) = scroll(scene, to_native(screen)) -function scroll(scene::Scene, window::GLFW.Window) +Makie.scroll(scene::Scene, screen) = scroll(scene, to_native(screen)) +function Makie.scroll(scene::Scene, window::GLFW.Window) event = scene.events.scroll function scrollcb(window, w::Cdouble, h::Cdouble) @print_error begin @@ -239,7 +239,7 @@ function scroll(scene::Scene, window::GLFW.Window) disconnect!(window, scroll) GLFW.SetScrollCallback(window, scrollcb) end -function disconnect!(window::GLFW.Window, ::typeof(scroll)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(scroll)) GLFW.SetScrollCallback(window, nothing) end @@ -249,8 +249,8 @@ returns an `Node{Bool}`, which is true whenever the window has focus. [GLFW Docs](http://www.glfw.org/docs/latest/group__window.html#ga6b5f973531ea91663ad707ba4f2ac104) """ -hasfocus(scene::Scene, screen) = hasfocus(scene, to_native(screen)) -function hasfocus(scene::Scene, window::GLFW.Window) +Makie.hasfocus(scene::Scene, screen) = hasfocus(scene, to_native(screen)) +function Makie.hasfocus(scene::Scene, window::GLFW.Window) event = scene.events.hasfocus function hasfocuscb(window, focus::Bool) @print_error begin @@ -262,7 +262,7 @@ function hasfocus(scene::Scene, window::GLFW.Window) event[] = GLFW.GetWindowAttrib(window, GLFW.FOCUSED) nothing end -function disconnect!(window::GLFW.Window, ::typeof(hasfocus)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(hasfocus)) GLFW.SetWindowFocusCallback(window, nothing) end @@ -272,8 +272,8 @@ returns an `Node{Bool}`, which is true whenever the cursor enters the window. [GLFW Docs](http://www.glfw.org/docs/latest/group__input.html#ga762d898d9b0241d7e3e3b767c6cf318f) """ -entered_window(scene::Scene, screen) = entered_window(scene, to_native(screen)) -function entered_window(scene::Scene, window::GLFW.Window) +Makie.entered_window(scene::Scene, screen) = entered_window(scene, to_native(screen)) +function Makie.entered_window(scene::Scene, window::GLFW.Window) event = scene.events.entered_window function enteredwindowcb(window, entered::Bool) @print_error begin @@ -284,6 +284,6 @@ function entered_window(scene::Scene, window::GLFW.Window) GLFW.SetCursorEnterCallback(window, enteredwindowcb) end -function disconnect!(window::GLFW.Window, ::typeof(entered_window)) +function Makie.disconnect!(window::GLFW.Window, ::typeof(entered_window)) GLFW.SetCursorEnterCallback(window, nothing) end diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index 205cc1deea1..7d2fcfd7385 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -46,7 +46,7 @@ Base.wait(scene::Scene) = wait(Makie.getscreen(scene)) Base.show(io::IO, screen::Screen) = print(io, "GLMakie.Screen(...)") Base.size(x::Screen) = size(x.framebuffer) -function insertplots!(screen::GLScreen, scene::Scene) +function Makie.insertplots!(screen::GLScreen, scene::Scene) get!(screen.screen2scene, WeakRef(scene)) do id = length(screen.screens) + 1 push!(screen.screens, (id, scene)) From a6c63599ee89c4c44903076fce0fb27f51f49f4c Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 23 Aug 2021 21:10:37 +0200 Subject: [PATCH 4/4] Reexport deprecations in GeometryBasics --- src/deprecated.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/deprecated.jl b/src/deprecated.jl index 3d102b689b1..8d8ea7cb43a 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -1,3 +1,8 @@ +# defined in Makie Base.@deprecate_binding Quaternionf0 Quaternionf Base.@deprecate_binding RGBf0 RGBf Base.@deprecate_binding RGBAf0 RGBAf + +# defined in GeometryBasics and reexported by Makie +export FRect, FRect2D, IRect2D, FRect3D, IRect3D, Rect3D, IRect, FRect, Rect2D +export Vec4f0, Vec3f0, Vec2f0, Point4f0, Point3f0, Point2f0