Skip to content

Commit

Permalink
prepare for version 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cormullion committed Jan 21, 2022
1 parent f787a87 commit 7c3d196
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 128 deletions.
26 changes: 16 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
# Changelog

## [v????] - forthcoming
## [v3.0.0] - forthcoming

### Added

- dependency on LatexStrings

- `Luxor.get_current_hue()` and `Luxor.get_current_color()`

### Changed

- changed return values of circle/ellipse/rect to boundingbox-able pts
(for @TheCedarPrince :))
- the shape-making functions such as
`circle`/`ellipse`/`rect` now return 'useful' values
instead of Booleans. These values can usually be used as
arguments to `BoundingBox()`. (for @TheCedarPrince :))

- switched to Graham Scan algorithm for `polyhull()`

- switched to Graham Scan algorithm for polyhull()
- allow user to change tolerance for `isapprox()`

- allow use to change tolerance for isapprox()
- export `determinant3()`

### Removed

### Deprecated

# ────────────────────────────────────────────────────────────────────────────────────

## [v2.19.0] - forthcoming
## [v2.19.0] - 2022-01-03

### Added

- LaTeX strings for text() - amazing work by @davibarreira, @Kolaru, and @TheCedarPrince - Thanks!
- LaTeX strings for `text()` - amazing work by @davibarreira, @Kolaru, and @TheCedarPrince - Thanks!

- leading option for textfit()
- leading option for `textfit()`

- BoundingBox for stored Path objects
- `BoundingBox()` for stored Path objects

- `textonpoly()` can put text the route of a polygon
- `textonpoly()` can put text on the route of a polygon

### Changed

Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Luxor"
uuid = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
authors = ["cormullion <[email protected]>"]
version = "2.20.0"
version = "3.0.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -20,11 +20,11 @@ LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Cairo = "0.7, 0.8, 1.0"
Colors = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 1.0"
FFMPEG = "0.4"
FileIO = "1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11"
FileIO = "1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12"
Juno = "0.7, 0.8"
Rsvg = "1.0"
Requires = "1"
LaTeXStrings = "1.1"
LaTeXStrings = "1.1, 1.2, 1.3"
julia = "1.3"

[extras]
Expand Down
2 changes: 2 additions & 0 deletions docs/src/example/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ end
If you have the right fonts installed, you can easily draw simple ``\LaTeX`` equations.

```julia
# using Luxor
# using MathTeXEngine
background("khaki")
f(t) = Point(4cos(t) + 2cos(5t), 4sin(t) + 2sin(5t))
setline(15)
Expand Down
7 changes: 3 additions & 4 deletions docs/src/explanation/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ state, but the graphics you've already drawn are unchanged.
Many of the drawing functions have an *action* argument,
supplied either as a symbol argument (eg `:fill`) or as a
keyword argument (eg `action=:fill`). This action determines
what happens to the current path. It can be `:none`,
`:fill`, `:stroke`, `:fillstroke`, `:fillpreserve`,
what happens to the current path. It can be `:fill`,
`:stroke`, `:fillstroke`, `:fillpreserve`,
`:strokepreserve`, `:clip`, or `:path`. The default is
`:none`, which is usually equivalent to `:path`, ie. add to
the current path but otherwise do nothing.
usually `:path`, ie. add the graphics to the current path.

The main Julia data types you'll encounter in Luxor are:

Expand Down
32 changes: 30 additions & 2 deletions docs/src/howto/geometrytools.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,35 @@ nothing # hide

![angle three points](../assets/figures/anglethreepoints.png)

Functions that help with geometry include [`distance`](@ref), [`getnearestpointonline`](@ref), [`pointlinedistance`](@ref), [`slope`](@ref), [`perpendicular`](@ref), [`dotproduct`](@ref), [`@polar`](@ref), [`polar`](@ref), [`ispointonline`](@ref),[`ispointonpoly`](@ref), [`isarcclockwise`](@ref), [`pointinverse`](@ref), and [`anglethreepoints`](@ref).
Functions that help with geometry include:

- [`distance`](@ref)

- [`getnearestpointonline`](@ref)

- [`pointlinedistance`](@ref)

- [`slope`](@ref)

- [`perpendicular`](@ref)

- [`dotproduct`](@ref)

- [`@polar`](@ref)

- [`polar`](@ref)

- [`ispointonline`](@ref)

- [`ispointonpoly`](@ref)

- [`isarcclockwise`](@ref)

- [`pointinverse`](@ref)

- [`anglethreepoints`](@ref)

- [`determinant3`](@ref)

## Triangle centers

Expand Down Expand Up @@ -485,7 +513,7 @@ Drawing(600, 400, "../assets/figures/bbox4.png") # hide
background("antiquewhite") # hide
Random.seed!(42) # hide
origin() # hide
bx = BoundingBox(box(O, 200, 200, :none))
bx = BoundingBox(box(O, 200, 200))
setline(1)
sethue("black") # hide
box(bx, :stroke)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/howto/polygons.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ Random.seed!(42) # hide
pts = [Point(x, rand(-100:100)) for x in -280:30:280]
setopacity(0.7)
sethue("red")
prettypoly(pts, :none, () -> circle(O, 5, :fill))
prettypoly(pts, () -> circle(O, 5, :fill))
sethue("darkmagenta")
poly(polyfit(pts, 200), :stroke)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/howto/simplegraphics.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ function marker(r, t) #hide
circle(Point(0, 0), r, :fill) #hide
sethue("white") #hide
fontsize(25) #hide
text(string(t), halign=:center, valign=:middle) #hide
text(string(t), halign=:center, valign=:middle) # hide
end #hide
end #hide
Expand All @@ -741,7 +741,7 @@ sethue("olivedrab")
arrow(pts[1:4]...,
decorate = () ->
ngon(Point(0, 0), 20, 4, 0, :fill),
decoration = 0.75, :none)
decoration = 0.75, :none) # default action is :stroke
finish() # hide
nothing # hide
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorial/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This short piece of code does the following things:

In case you're wondering, the units are *points* (as in font sizes), and there are 72 points in an inch, just over 3 per millimeter. The y-axis points down the page. If you want to be reminded of where the x and y axes are, uses the [`rulers`](@ref) function.

The `:fill` at the end of [`circle`](@ref) is one of a set of symbols that lets you use the shape in different ways. There's the `:stroke` action, which draws around the edges but doesn't fill the shape with color, and you might also meet the `:path`, `:fillstroke`, `:fillpreserve`, `:strokepreserve`, `:clip`, and `:none` actions. You can usually supply these either as an argument or using the keyword argument version, eg `action=:fill`.
The `:fill` at the end of [`circle`](@ref) is one of a set of symbols that lets you use the shape in different ways. There's the `:stroke` action, which draws around the edges but doesn't fill the shape with color, and you might also meet the `:fillstroke`, `:fillpreserve`, `:strokepreserve`, `:clip`, and `:path` actions. You can usually supply these either as an argument or using the keyword argument version, eg `action=:fill`.

## Circles in a spiral

Expand Down
30 changes: 18 additions & 12 deletions src/BoundingBox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,29 @@ The default `BoundingBox(;centered=true)` returns a
BoundingBox the same size and position as the current
drawing, and assumes the origin (0, 0) is at the center.
If the `centered` option is `false`, the function
assumes that the origin is at the top left of the drawing.
So this function doesn't really work if the current matrix
has been modified (by `translate()`, `scale()`, `rotate()`
etc.)
If the `centered` option is `false`, the function assumes
that the origin is at the top left of the drawing. So this
function doesn't really work if the current matrix has been
modified (by `translate()`, `scale()`, `rotate()` etc.)
An instance of the BoundingBox type holds two Points,
`corner1` and `corner2`.
BoundingBox(;centered = true) # the bounding box of the Drawing
BoundingBox(s::AbstractString) # the bounding box of a text string at the origin
BoundingBox(pt::Array) # the bounding box of a polygon
BoundingBox(circle(O, 100)) # the bounding box of a circle function
BoundingBox(circle(O, 100)) # the bounding box of a path added by circle()
BoundingBox(path::Path) # the bounding box of a Path
You can use `BoundingBox()` with the functions that add
graphic shapes to the current path (eg `box()`, `circle()`,
`star()`, `ngon()`). But note that eg `BoundingBox(box(O,
100, 100))` adds a shape to the current path as well as
returning a bounding box.
"""
function BoundingBox(; centered = true)
if currentdrawing() == false
Expand Down Expand Up @@ -291,14 +299,12 @@ end
Define a box using the bounds in `bbox`.
Use `vertices=true` to return an array of the four corner points: bottom left,
Use `vertices = true` to return an array of the four corner points: bottom left,
top left, top right, bottom right.
"""
function box(
bbox::BoundingBox;
function box(bbox::BoundingBox;
action = :none,
vertices = false,
)
vertices = false)
if vertices || action == :none
botleft = Point(bbox.corner1.x, bbox.corner2.y)
topleft = bbox.corner1
Expand Down
2 changes: 1 addition & 1 deletion src/Luxor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export Drawing,
between, slope, intersectionlines, pointlinedistance,
getnearestpointonline, isinside,
rotate_point_around_point, perpendicular, crossproduct,
dotproduct, distance, prettypoly, polysmooth, polysplit,
dotproduct, determinant3, distance, prettypoly, polysmooth, polysplit,
poly, simplify, polycentroid, polysortbyangle, polyhull,
polysortbydistance, offsetpoly, polyfit, currentpoint,
hascurrentpoint, getworldposition, anglethreepoints,
Expand Down
13 changes: 7 additions & 6 deletions src/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ end
do_action(action)
This is usually called by other graphics functions. Actions for graphics commands include
`:fill`, `:stroke`, `:clip`, `:fillstroke`, `:fillpreserve`, `:strokepreserve`, `:none`, and
`:path`.
`:fill`, `:stroke`, `:clip`, `:fillstroke`, `:fillpreserve`, and `:strokepreserve`.
The `:path` action adds the graphics to the current path.
"""
function do_action(action)
if action == :fill
Expand All @@ -221,8 +222,8 @@ function do_action(action)
fillpreserve()
elseif action == :strokepreserve
strokepreserve()
elseif action == :none
end
# ignore any other value for action
return true
end

Expand Down Expand Up @@ -371,13 +372,13 @@ line(x, y) = Cairo.line_to(get_current_cr(), x, y)
line(pt) = line(pt.x, pt.y)

"""
line(pt1::Point, pt2::Point; action=:none)
line(pt1::Point, pt2::Point, action=:none)
line(pt1::Point, pt2::Point; action=:path)
line(pt1::Point, pt2::Point, action=:path)
Make a line between two points, `pt1` and `pt2` and do an action.
"""
function line(pt1::Point, pt2::Point;
action=:none)
action=:path)
move(pt1)
line(pt2)
do_action(action)
Expand Down
23 changes: 23 additions & 0 deletions src/colors_styles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,26 @@ function mask(point::Point, focus::Point, width, height;
end
return ratio
end

"""
get_current_hue()
As set by eg `sethue()`. Return an RGB colorant.
"""
function get_current_hue()
return RGB(Luxor.get_current_redvalue(),
Luxor.get_current_greenvalue(),
Luxor.get_current_bluevalue())
end

"""
get_current_color()
As set by eg `setcolor()`. Return an RGBA colorant.
"""
function get_current_color()
return RGBA(Luxor.get_current_redvalue(),
Luxor.get_current_greenvalue(),
Luxor.get_current_bluevalue(),
Luxor.get_current_alpha())
end
Loading

0 comments on commit 7c3d196

Please sign in to comment.