Skip to content

Commit

Permalink
Merge pull request #14 from ffreyer/update
Browse files Browse the repository at this point in the history
update to Makie 0.13
  • Loading branch information
SimonDanisch authored May 21, 2021
2 parents 4e5265f + 55ffcda commit c93c3e0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
authors = ["Anshul Singhvi"]
name = "MakieTeX"
uuid = "6d554a22-29e7-47bd-aee5-0c5f06619414"
version = "0.0.2"
version = "0.0.3"

[deps]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Rsvg = "c4c386cf-5103-5370-be45-f3a111cca3b8"

[compat]
AbstractPlotting = "0.15, 0.16, 0.17, 0.18"
Makie = "0.13"
Cairo = "1.0.4"
CairoMakie = "0.3, 0.4"
CairoMakie = "0.5"
Colors = "0.9, 0.10, 0.11, 0.12"
LaTeXStrings = "1.2"
Rsvg = "1"
julia = "1.3"
julia = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
6 changes: 3 additions & 3 deletions src/MakieTeX.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module MakieTeX
using AbstractPlotting, CairoMakie, AbstractPlotting.MakieLayout
using Makie, CairoMakie, Makie.MakieLayout
using Rsvg, Cairo
using Colors, LaTeXStrings

using AbstractPlotting.GeometryBasics: origin, widths
using AbstractPlotting.Observables
using Makie.GeometryBasics: origin, widths
using Makie.Observables

include("types.jl")
include("rendering.jl")
Expand Down
14 changes: 7 additions & 7 deletions src/layoutable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ function MakieLayout.layoutable(::Type{LTeX}, fig_or_scene; bbox = nothing, kwar
# rotation is applied via a model matrix which isn't used in the bbox calculation
# so we need to deal with it here
bb = boundingbox(t)
R = AbstractPlotting.Mat3f0(
R = Makie.Mat3f0(
cos(rotation), sin(rotation), 0,
-sin(rotation), cos(rotation), 0,
0, 0, 1
)
points = map(p -> R * p, unique(AbstractPlotting.coordinates(bb)))
new_bb = AbstractPlotting.xyz_boundingbox(identity, points)
points = map(p -> R * p, unique(Makie.coordinates(bb)))
new_bb = Makie.xyz_boundingbox(identity, points)
textbb[] = FRect2D(new_bb)
# textbb[] = FRect2D(boundingbox(t))
autowidth = AbstractPlotting.width(textbb[]) + padding[1] + padding[2]
autoheight = AbstractPlotting.height(textbb[]) + padding[3] + padding[4]
autowidth = Makie.width(textbb[]) + padding[1] + padding[2]
autoheight = Makie.height(textbb[]) + padding[3] + padding[4]
layoutobservables.autosize[] = (autowidth, autoheight)
end

onany(layoutobservables.computedbbox, padding) do bbox, padding
tw = AbstractPlotting.width(textbb[])
th = AbstractPlotting.height(textbb[])
tw = Makie.width(textbb[])
th = Makie.height(textbb[])

box = bbox.origin[1]
boy = bbox.origin[2]
Expand Down
18 changes: 9 additions & 9 deletions src/recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
merge(
default_theme(scene),
Attributes(
color = AbstractPlotting.automatic,
color = Makie.automatic,
implant = true,
dpi = 72.0,
align = (:left, :center),
Expand All @@ -14,23 +14,23 @@
)
end

function AbstractPlotting.convert_arguments(::Type{<: TeXImg}, x::AbstractString)
function Makie.convert_arguments(::Type{<: TeXImg}, x::AbstractString)
return (CachedTeX(implant_math(x)),)
end

function AbstractPlotting.convert_arguments(::Type{<: TeXImg}, x::LaTeXString)
function Makie.convert_arguments(::Type{<: TeXImg}, x::LaTeXString)
if first(x) == "\$" && last(x) == "\$"
return (CachedTeX(implant_math(x)),)
else
return (CachedTeX(implant_text(x)),)
end
end

function AbstractPlotting.convert_arguments(::Type{<: TeXImg}, doc::TeXDocument)
function Makie.convert_arguments(::Type{<: TeXImg}, doc::TeXDocument)
return (CachedTeX(doc),)
end

function AbstractPlotting.plot!(plot::T) where T <: TeXImg
function Makie.plot!(plot::T) where T <: TeXImg
# image to draw
# We always want to draw this at a 1:1 ratio, so increasing textsize or
# changing dpi should rerender
Expand Down Expand Up @@ -73,9 +73,9 @@ function AbstractPlotting.plot!(plot::T) where T <: TeXImg
x0 = xr.left; x1 = xr.right
y0 = yr.left; y1 = yr.right
model *
AbstractPlotting.translationmatrix(Vec3f0(0.5(x1+x0), 0.5(y1+y0), 0)) *
AbstractPlotting.rotationmatrix_z(angle) *
AbstractPlotting.translationmatrix(- Vec3f0(0.5(x1+x0), 0.5(y1+y0), 0))
Makie.translationmatrix(Vec3f0(0.5(x1+x0), 0.5(y1+y0), 0)) *
Makie.rotationmatrix_z(angle) *
Makie.translationmatrix(- Vec3f0(0.5(x1+x0), 0.5(y1+y0), 0))
end

image!(plot, xr, yr, img, model=model)
Expand All @@ -96,7 +96,7 @@ end

function CairoMakie.draw_plot(scene::Scene, screen::CairoMakie.CairoScreen, img::T) where T <: MakieTeX.TeXImg

bbox = AbstractPlotting.boundingbox(img)
bbox = Makie.boundingbox(img)

ctx = screen.context
tex = img[1][]
Expand Down

2 comments on commit c93c3e0

@SimonDanisch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/37215

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.0.3 -m "<description of version>" c93c3e0528a3926c00eee66047ebd38fe04cff00
git push origin v0.0.3

Please sign in to comment.