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