Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deps, e.g. Setfield #3546

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
ShaderAbstractions = "65257c39-d410-5151-9873-9b3e5be5013e"
Showoff = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
SignedDistanceFields = "73760f76-fbc4-59ce-8f25-708e95d2df96"
Expand Down Expand Up @@ -103,7 +102,6 @@ REPL = "1.0, 1.6"
Random = "1.0, 1.6"
RelocatableFolders = "0.1, 0.2, 0.3, 1.0"
Scratch = "1"
Setfield = "1"
ShaderAbstractions = "0.4"
Showoff = "0.3, 1.0.2"
SignedDistanceFields = "0.4"
Expand Down
3 changes: 1 addition & 2 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ using StructArrays
# Text related packages
using FreeType
using FreeTypeAbstraction
using UnicodeFun
using LinearAlgebra
using Statistics
using MakieCore
using OffsetArrays
using Downloads
using ShaderAbstractions

import UnicodeFun
import RelocatableFolders
import StatsBase
import Distributions
Expand All @@ -59,7 +59,6 @@ import FileIO
import SparseArrays
import TriplotBase
import DelaunayTriangulation as DelTri
import Setfield
import REPL
import MacroTools

Expand Down
2 changes: 1 addition & 1 deletion src/basic_recipes/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function draw_axis3d(textbuffer, linebuffer, scale, limits, ranges_labels, fonts
end / scale[j]
pos = labelposition(ranges, i, tickdir, titlegap[i] + tick_widths, origin) .+ offset2
push!(
textbuffer, to_latex(axisnames[i]), pos,
textbuffer, UnicodeFun.to_latex(axisnames[i]), pos;
fontsize = axisnames_size[i], color = axisnames_color[i],
rotation = axisrotation[i], align = axisalign[i], font = axisnames_font[i]
)
Expand Down
39 changes: 12 additions & 27 deletions src/basic_recipes/convenience_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,25 @@ If you change the offsets or the font size, you may need to change the resolutio
"""
function showgradients(
cgrads::AbstractVector{Symbol};
h = 0.0,
offset = 0.4,
fontsize = 0.7,
size = (800, length(cgrads) * 84),
monospace = true
)::Scene
)

scene = Scene(size = resolution)
f = Figure(; size=size)
ax = Axis(f[1, 1])

map(collect(cgrads)) do cmap
labels = map(enumerate(cgrads)) do (i, cmap)
c = to_colormap(cmap)

cbar = image!(
scene,
range(0, stop = 10, length = length(c)),
range(0, stop = 1, length = length(c)),
image!(
ax,
0..10,
i..(i+1),
reshape(c, (length(c),1))
)[end]

cmapstr = monospace ? UnicodeFun.to_latex("\\mono{$cmap}") : string(cmap, ":")

text!(
scene,
cmapstr,
position = Point2f(-0.1, 0.5 + h),
align = (:right, :center),
fontsize = fontsize
)

translate!(cbar, 0, h, 0)

h -= (1 + offset)
cmapstr = string(cmap)
return ((i + (i + 1))/2, cmapstr)
end

scene

ax.yticks = (first.(labels), last.(labels))
return f
end
31 changes: 29 additions & 2 deletions src/basic_recipes/text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,30 @@ struct GlyphInfo
strokewidth::Float32
end

# Copy constructor, to overwrite a field
function GlyphInfo(gi::GlyphInfo;
glyph=gi.glyph,
font=gi.font,
origin=gi.origin,
extent=gi.extent,
size=gi.size,
rotation=gi.rotation,
color=gi.color,
strokecolor=gi.strokecolor,
strokewidth=gi.strokewidth)

return GlyphInfo(glyph,
font,
origin,
extent,
size,
rotation,
color,
strokecolor,
strokewidth)
end


function GlyphCollection(v::Vector{GlyphInfo})
GlyphCollection(
[i.glyph for i in v],
Expand Down Expand Up @@ -359,7 +383,9 @@ function apply_lineheight!(lines, lh)
for (i, line) in enumerate(lines)
for j in eachindex(line)
l = line[j]
l = Setfield.@set l.origin[2] -= (i-1) * 20 # TODO: Lineheight
ox, oy = l.origin
jkrumbiegel marked this conversation as resolved.
Show resolved Hide resolved
# TODO: Lineheight
l = GlyphInfo(l; origin=Point2f(ox, oy - (i - 1) * 20))
line[j] = l
end
end
Expand Down Expand Up @@ -401,7 +427,8 @@ function apply_alignment_and_justification!(lines, ju, al)
ju_offset = fju * (max_x - max_xs[i])
for j in eachindex(line)
l = line[j]
l = Setfield.@set l.origin -= Point2f(al_offset_x - ju_offset, al_offset_y)
o = l.origin
l = GlyphInfo(l; origin = o .- Point2f(al_offset_x - ju_offset, al_offset_y))
line[j] = l
end
end
Expand Down
21 changes: 0 additions & 21 deletions src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,27 +618,6 @@ end
logit_10(x) = Makie.logit(x) / log(10)
expit_10(x) = Makie.logistic(log(10) * x)

# function get_ticks(l::LogitTicks, scale::typeof(Makie.logit), ::Automatic, vmin, vmax)

# ticks_scaled = get_tickvalues(l.linear_ticks, identity, logit_10(vmin), logit_10(vmax))

# ticks = expit_10.(ticks_scaled)

# base_labels = get_ticklabels(automatic, ticks_scaled)

# labels = map(ticks_scaled, base_labels) do t, bl
# if t == 0
# "¹/₂"
# elseif t < 0
# "10" * Makie.UnicodeFun.to_superscript(bl)
# else
# "1-10" * Makie.UnicodeFun.to_superscript("-" * bl)
# end
# end

# (ticks, labels)
# end

"""
get_tickvalues(lt::LinearTicks, vmin, vmax)

Expand Down