Skip to content

Commit

Permalink
update src with broadcasting etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium committed Feb 17, 2024
1 parent 1b3a776 commit 47a30f5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/BoundingBox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ end
# basics
# adding a number to a box makes the box larger all round
+(z::Number, bb1::BoundingBox) =
BoundingBox(bb1.corner1 - z, bb1.corner2 + z)
BoundingBox(bb1.corner1 .- z, bb1.corner2 .+ z)
+(bb1::BoundingBox, z::Number) =
BoundingBox(bb1.corner1 - z, bb1.corner2 + z)
BoundingBox(bb1.corner1 .- z, bb1.corner2 .+ z)

# subtracting a number makes the box smaller all round
-(z::Number, bb1::BoundingBox) =
BoundingBox(bb1.corner1 + z, bb1.corner2 - z)
BoundingBox(bb1.corner1 .+ z, bb1.corner2 .- z)
-(bb1::BoundingBox, z::Number) =
BoundingBox(bb1.corner1 + z, bb1.corner2 - z)
BoundingBox(bb1.corner1 .+ z, bb1.corner2 .- z)

function (*)(bb::BoundingBox, s::Real)
c = midpoint(bb...)
Expand Down
2 changes: 1 addition & 1 deletion src/Path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ determine the accuracy.
"""
function get_bezier_points(bps::BezierPathSegment;
steps = 10)
return bezier.(range(0.0, 1.0, length = steps), bps...)
return bezier.(range(0.0, 1.0, length = steps), Ref.(tuple(bps...))...)
end

"""
Expand Down
8 changes: 4 additions & 4 deletions src/arrows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,13 @@ function tickline(startpos, finishpos;
# 1 major/minor division means 3 ticks (beginning, middle, end)

if log == true
majorticklocations = between.(O, newfinishpos, log10.(range(1, 10, length=(major+2))))
majorticklocations = between.(Ref(O), Ref(newfinishpos), log10.(range(1, 10, length=(major+2))))
n_minorticks = ((major + 1) * (minor + 1)) + 1
minorticklocations = between.(O, newfinishpos, log10.(range(1, 10, length=n_minorticks)))
minorticklocations = between.(Ref(O), Ref(newfinishpos), log10.(range(1, 10, length=n_minorticks)))
else
majorticklocations = between.(O, newfinishpos, range(0, 1, length=(major+2)))
majorticklocations = between.(Ref(O), Ref(newfinishpos), range(0, 1, length=(major+2)))
n_minorticks = ((major + 1) * (minor + 1)) + 1
minorticklocations = between.(O, newfinishpos, range(0, 1, length=n_minorticks))
minorticklocations = between.(Ref(O), Ref(newfinishpos), range(0, 1, length=n_minorticks))
end
if vertices == true
else
Expand Down
4 changes: 2 additions & 2 deletions src/bars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function barchart(values;
maxbarrange = maxvalue + abs(maxvalue)
basepoint = boundingbox - (0, margin)
hpositions = between.(
boxbottomleft(basepoint),
boxbottomright(basepoint),
Ref(boxbottomleft(basepoint)),
Ref(boxbottomright(basepoint)),
# skip first and last, then take every other one, which is at halfway
range(0.0, stop=1.0, length=2length(values) + 1))[2:2:end-1]
@layer begin
Expand Down
2 changes: 1 addition & 1 deletion src/curves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ Find the area of intersection between two circles, the first centered at `pt1` w
If one circle is entirely within another, that circle's area is returned.
"""
function intersection2circles(pt1, rad1, pt2, rad2)
function intersection2circles(pt1::Point, rad1::Real, pt2::Point, rad2::Real)
# via casey and jùlio on slack
# squared radii
rr1, rr2 = rad1 * rad1, rad2 * rad2
Expand Down
7 changes: 3 additions & 4 deletions src/polygons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ Move (permanently) a polygon from `frompoint` to `topoint`.
"""
function polymove!(pgon, frompoint::Point, topoint::Point)
d = topoint - frompoint
return pgon .+= d
return pgon .+= Ref(d)
end

"""
Expand All @@ -1190,9 +1190,8 @@ end
Scale (permanently) a polygon by `s`, relative to `center`.
"""
function polyscale!(pgon, s;
center = O)
return pgon .= between.(center, pgon, s)
function polyscale!(pgon, s; center::Point = O)
return pgon .= between.(Ref(center), pgon, s)
end

"""
Expand Down

0 comments on commit 47a30f5

Please sign in to comment.