From 3482848ad1dab03693d94f640b8ed0e3f6b58f44 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 28 Oct 2023 17:14:48 +0900 Subject: [PATCH 1/2] update around Juno --- Project.toml | 2 -- docs/src/explanation/basics.md | 2 +- src/Luxor.jl | 1 - src/drawings.jl | 4 ++-- test/interactive-tests.jl | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index a618e850..15e8c984 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,6 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" MathTeXEngine = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53" PolygonAlgorithms = "32a0d02f-32d9-4438-b5ed-3a2932b48f96" @@ -32,7 +31,6 @@ Colors = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 1.0" DataStructures = "0.18" FFMPEG = "0.4" FileIO = "1" -Juno = "0.7, 0.8" LaTeXStrings = "1.1, 1.2, 1.3" MathTeXEngine = "0.5" PolygonAlgorithms = "0.1" diff --git a/docs/src/explanation/basics.md b/docs/src/explanation/basics.md index db9e7b22..e92b7dce 100644 --- a/docs/src/explanation/basics.md +++ b/docs/src/explanation/basics.md @@ -262,7 +262,7 @@ In some situations you'll want to explicitly return the current drawing to the c # Working in IDEs and notebooks -You can use an environment such as a Jupyter or Pluto notebook or the Juno or VS Code IDEs, and load Luxor at the start of a session. The first drawing will take a few seconds, because the Cairo graphics engine needs to warm up. Subsequent drawings are then much quicker. (This is true of much graphics and plotting work. Julia compiles each function when it first encounters it, and then calls the compiled versions for the rest of the session.) +You can use an environment such as a Jupyter or Pluto notebook or VS Code IDEs, and load Luxor at the start of a session. The first drawing will take a few seconds, because the Cairo graphics engine needs to warm up. Subsequent drawings are then much quicker. (This is true of much graphics and plotting work. Julia compiles each function when it first encounters it, and then calls the compiled versions for the rest of the session.) ## Working in Jupyter diff --git a/src/Luxor.jl b/src/Luxor.jl index b6f1d47c..b1f09892 100644 --- a/src/Luxor.jl +++ b/src/Luxor.jl @@ -16,7 +16,6 @@ using Cairo using Colors using Dates using FFMPEG -using Juno using Rsvg import PolygonAlgorithms as PA diff --git a/src/drawings.jl b/src/drawings.jl index 919bbe65..c48b0068 100644 --- a/src/drawings.jl +++ b/src/drawings.jl @@ -428,10 +428,10 @@ function Base.show(io::IO, ::MIME"text/plain", d::Drawing) @debug "show MIME:text/plain" returnvalue = d.filename - # IJulia and Juno call the `show` function twice: once for + # IJulia call the `show` function twice: once for # the image MIME and a second time for the text/plain MIME. # We check if this is such a 'second call': - if (get(io, :jupyter, false) || Juno.isactive()) && + if get(io, :jupyter, false) && (d.surfacetype == :svg || d.surfacetype == :png) return d.filename end diff --git a/test/interactive-tests.jl b/test/interactive-tests.jl index 2fea9a52..c5f675eb 100644 --- a/test/interactive-tests.jl +++ b/test/interactive-tests.jl @@ -2,7 +2,7 @@ # this test isn't run by Pkg.test -# it can be run to test Juno/Jupyter integration... +# it can be run to test Jupyter integration... using Luxor From a2f55ced25dd2c22b18643a38091a53bffd3dff7 Mon Sep 17 00:00:00 2001 From: GiggleLiu Date: Mon, 30 Oct 2023 02:27:35 +0800 Subject: [PATCH 2/2] closed smooth path --- src/polygons.jl | 19 ++++++++++++------- test/polysmooth-tests.jl | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/polygons.jl b/src/polygons.jl index 2b3c2d91..a9c61cf1 100644 --- a/src/polygons.jl +++ b/src/polygons.jl @@ -359,8 +359,8 @@ function drawroundedcorner(cornerpoint::Point, p1::Point, p2::Point, radius, pat end """ - polysmooth(points, radius, action=:action; debug=false) - polysmooth(points, radius; action=:none, debug=false) + polysmooth(points, radius, action=:action; debug=false, close=true) + polysmooth(points, radius; action=:none, debug=false, close=true) Make a closed path from the `points` and round the corners by making them arcs with the given radius. Execute the action when finished. @@ -373,14 +373,14 @@ The `debug` option also draws the construction circles at each corner. TODO Return something more useful than a Boolean. """ -function polysmooth(points::Array{Point,1}, radius, action::Symbol; debug = false) +function polysmooth(points::Array{Point,1}, radius, action::Symbol; debug = false, close = true) temppath = Tuple[] l = length(points) if l < 3 # there are less than three points to smooth return nothing else - @inbounds for i in 1:l + @inbounds for i in 1:(close ? l : l-2) p1 = points[mod1(i, l)] p2 = points[mod1(i + 1, l)] p3 = points[mod1(i + 2, l)] @@ -391,7 +391,12 @@ function polysmooth(points::Array{Point,1}, radius, action::Symbol; debug = fals end end # need to close by joining to first point - push!(temppath, temppath[1]) + if close + push!(temppath, temppath[1]) + else + pushfirst!(temppath, (:line, points[1])) + push!(temppath, (:line, points[end])) + end # draw the path for (c, p) in temppath if c == :line @@ -405,8 +410,8 @@ function polysmooth(points::Array{Point,1}, radius, action::Symbol; debug = fals do_action(action) end -polysmooth(points::Array{Point,1}, radius; action = :none, debug = false) = - polysmooth(points, radius, action; debug = debug) +polysmooth(points::Array{Point,1}, radius; action = :none, debug = false, close = true) = + polysmooth(points, radius, action; debug = debug, close = close) """ offsetpoly(plist::Array{Point, 1}, d) where T<:Number diff --git a/test/polysmooth-tests.jl b/test/polysmooth-tests.jl index fcd0f270..13b9f63e 100644 --- a/test/polysmooth-tests.jl +++ b/test/polysmooth-tests.jl @@ -23,6 +23,7 @@ function star_test(fname) p = star(pos, tiles.tilewidth/2 - 10, randomsides, randomratio, 0, vertices=true) prettypoly(p, close=true, :stroke) polysmooth(p, randomsmoothing, :fill, debug=true) + polysmooth(p, randomsmoothing, :fill, debug=true, close=false) end @test finish() == true println("...finished test: output in $(fname)")