From fa4db319cfaabc629ee8cf1fafe331f40ef634f4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 31 Jan 2020 23:25:27 +0100 Subject: [PATCH] add lens! shorthand --- src/recipes.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 550f99cc..992c0398 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -901,6 +901,8 @@ end # --------------------------------------------------------------------------- # lens! - magnify a region of a plot +lens!(args...;kwargs...) = plot!(args...; seriestype=:lens, kwargs...) +export lens! @recipe function f(::Type{Val{:lens}}, plt::AbstractPlot) # TODO: validate input sp_index, inset_bbox = plotattributes[:inset_subplots] @@ -955,28 +957,23 @@ end function intersection_point(xA, yA, xB, yB, h, w) s = (yA - yB) / (xA - xB) - @show s, xA, yA, xB, yB, h, w hh = h / 2 hw = w / 2 # left or right? if -hh <= s * hw <= hh if xA > xB # right - println("right") return xB + hw, yB + s * hw else # left - println("left") return xB - hw, yB - s * hw end # top or bot? elseif -hw <= hh/s <= hw if yA > yB # top - println("top") return xB + hh/s, yB + hh else # bottom - println("bottom") return xB - hh/s, yB - hh end end