simplify logic
This commit is contained in:
parent
14765ef2e9
commit
b74d1ff276
@ -672,45 +672,44 @@ end
|
||||
function gr_set_tickfont(sp, letter)
|
||||
axis = sp[Symbol(letter, :axis)]
|
||||
|
||||
rot = axis[:rotation] % 360
|
||||
if letter === :x || (RecipesPipeline.is3d(sp) && letter === :y)
|
||||
mirror = (
|
||||
vcenter = :vcenter,
|
||||
hcenter = :hcenter,
|
||||
left = :right,
|
||||
right = :left,
|
||||
bottom = :top,
|
||||
top = :bottom,
|
||||
)
|
||||
|
||||
hv_align(rot) = begin
|
||||
halign = if 0 < rot < 180 || -360 < rot < -180
|
||||
:right
|
||||
elseif 180 < rot < 360 || -180 < rot < 0
|
||||
:left
|
||||
else
|
||||
:hcenter
|
||||
end
|
||||
valign = if -90 < rot < 90 || rot < -270 || rot > 270
|
||||
axis[:mirror] ? :bottom : :top
|
||||
elseif abs(rot) % 90 == 0 # -270, -90, 90, 270
|
||||
:vcenter
|
||||
:top
|
||||
elseif 90 < rot < 270 || -270 < rot < -90
|
||||
:bottom
|
||||
else
|
||||
axis[:mirror] ? :top : :bottom
|
||||
:vcenter
|
||||
end
|
||||
halign, valign
|
||||
end
|
||||
|
||||
halign = if abs(rot) % 180 == 0 # -180, 0, 180
|
||||
:hcenter
|
||||
elseif 0 < rot < 180 || -360 < rot < -180
|
||||
axis[:mirror] ? :left : :right
|
||||
else # 180 < rot < 360 || -180 < rot < 0
|
||||
axis[:mirror] ? :right : :left
|
||||
end
|
||||
if letter === :x || (RecipesPipeline.is3d(sp) && letter === :y)
|
||||
halign, valign = hv_align(axis[:rotation] % 360)
|
||||
else
|
||||
valign = if rot % 180 == 0
|
||||
:vcenter
|
||||
elseif 0 < rot < 180 || -360 < rot < -180
|
||||
axis[:mirror] ? :top : :bottom
|
||||
else # rot < 0
|
||||
axis[:mirror] ? :bottom : :top
|
||||
halign, valign = hv_align((axis[:rotation] + 90) % 360) # y := x + 90°
|
||||
end
|
||||
|
||||
halign = if -90 < rot < 90 || rot < -270 || rot > 270
|
||||
axis[:mirror] ? :left : :right
|
||||
elseif abs(rot) == 90 || abs(rot) == 270
|
||||
:hcenter
|
||||
else # 90 < rot < 270; -270 < rot < -90
|
||||
axis[:mirror] ? :right : :left
|
||||
end
|
||||
end
|
||||
gr_set_font(
|
||||
tickfont(axis),
|
||||
sp,
|
||||
halign = halign,
|
||||
valign = valign,
|
||||
halign = axis[:mirror] ? mirror[halign] : halign,
|
||||
valign = axis[:mirror] ? mirror[valign] : valign,
|
||||
rotation = axis[:rotation],
|
||||
color = axis[:tickfontcolor],
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user