Skip to content

Commit

Permalink
update texture atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Jul 20, 2023
1 parent 0e291f4 commit 77cc78d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utilities/texture_atlas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Base.show(io::IO, atlas::TextureAtlas)
println(io, " font_render_callback: ", length(atlas.font_render_callback))
end

const SERIALIZATION_FORMAT_VERSION = "v2"
const SERIALIZATION_FORMAT_VERSION = "v3"

# basically a singleton for the textureatlas
function get_cache_path(resolution::Int, pix_per_glyph::Int)
Expand Down Expand Up @@ -489,7 +489,7 @@ end

function marker_scale_factor(atlas::TextureAtlas, path::BezierPath)
# See offset_bezierpath
return bezierpath_pad_scale_factor(atlas, path) * maximum(widths(bbox(path)))
return bezierpath_pad_scale_factor(atlas, path) * maximum(widths(bbox(path)))
end

function rescale_marker(atlas::TextureAtlas, pathmarker::BezierPath, font, markersize)
Expand All @@ -514,13 +514,13 @@ end

function offset_bezierpath(atlas::TextureAtlas, bp::BezierPath, markersize::Vec2, markeroffset::Vec2)
# - wh = widths(bbox(bp)) is the untouched size of the given bezierpath
# - full_pixel_size_in_atlas is the size of the signed distance field in the
# - full_pixel_size_in_atlas is the size of the signed distance field in the
# texture atlas. This includes glyph padding
# - px_size is the size of signed distance field without padding
# To correct scaling on glow, stroke and AA widths in GLMakie we need to
# keep the aspect ratio of the aspect ratio (somewhat) correct when
# generating the sdf. This results in direct proportionality only for the
# longer dimension of wh and px_size. The shorter side becomes inaccurate
# To correct scaling on glow, stroke and AA widths in GLMakie we need to
# keep the aspect ratio of the aspect ratio (somewhat) correct when
# generating the sdf. This results in direct proportionality only for the
# longer dimension of wh and px_size. The shorter side becomes inaccurate
# due to integer rounding issues.
# 1. To calculate the width we can use the ratio of the proportional sides
# scale = maximum(wh) / maximum(px_size)
Expand All @@ -530,9 +530,9 @@ function offset_bezierpath(atlas::TextureAtlas, bp::BezierPath, markersize::Vec2
# 2. To calculate the offset we can simple move to the center of the bezier
# path and consider that the center of the final marker. (From the center
# scaling should be equal in ±x and ±y direction respectively.)

bb = bbox(bp)
scaled_size = bezierpath_pad_scale_factor(atlas, bp) * maximum(widths(bb))
scaled_size = bezierpath_pad_scale_factor(atlas, bp) * maximum(widths(bb))
return markersize * (origin(bb) .+ 0.5f0 * widths(bb) .- 0.5f0 .* scaled_size)

end
Expand Down

0 comments on commit 77cc78d

Please sign in to comment.