From bba8e24ec6fb7fcb2544dd8d74f0a2721d85e7ea Mon Sep 17 00:00:00 2001 From: GiggleLiu Date: Thu, 9 Nov 2023 02:13:51 +0800 Subject: [PATCH] fix intersect lines and polysmooth function --- src/point.jl | 4 ++-- src/polygons.jl | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/point.jl b/src/point.jl index d9057be7..1b7a62a1 100644 --- a/src/point.jl +++ b/src/point.jl @@ -327,9 +327,9 @@ function ispointonline(pt::Point, pt1::Point, pt2::Point; # point on the line if (abs(dxl) >= abs(dyl)) - return dxl > 0 ? pt1.x <= pt.x && pt.x <= pt2.x : pt2.x <= pt.x && pt.x <= pt1.x + return dxl > 0 ? pt1.x <= pt.x+atol && pt.x <= pt2.x+atol : pt2.x <= pt.x+atol && pt.x <= pt1.x+atol else - return dyl > 0 ? pt1.y <= pt.y && pt.y <= pt2.y : pt2.y <= pt.y && pt.y <= pt1.y + return dyl > 0 ? pt1.y <= pt.y+atol && pt.y <= pt2.y+atol : pt2.y <= pt.y+atol && pt.y <= pt1.y+atol end end diff --git a/src/polygons.jl b/src/polygons.jl index f708d5db..1252f88b 100644 --- a/src/polygons.jl +++ b/src/polygons.jl @@ -393,13 +393,16 @@ function polysmooth(points::Array{Point,1}, radius, action::Symbol; debug = fals # need to close by joining to first point if close push!(temppath, temppath[1]) + temppath[1] = (:move, temppath[1][2]) else - pushfirst!(temppath, (:line, points[1])) + pushfirst!(temppath, (:move, points[1])) push!(temppath, (:line, points[end])) end # draw the path for (c, p) in temppath - if c == :line + if c == :move + move(p) + elseif c == :line line(p) # add line segment elseif c == :arc arc(p...) # add clockwise arc segment