Skip to content

Commit

Permalink
docs and tests for release 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cormullion committed Jun 1, 2022
1 parent dd28f45 commit a6a1300
Show file tree
Hide file tree
Showing 10 changed files with 1,189 additions and 160 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Changelog

## [v3.3.0] - forthcoming
## [v3.3.0] - 2022-06-01 11:28:44

### Added

### Changed

- `textfit()` algorithm revisited; it's quicker, at least....
- `polymorph()` keywords changed
- `polymorph()` can now morph between open polygons
- `polymorph()` can now also morph between open polygons
- minimum Julia version is now 1.6
- there are still bugs/edgecases in `polyhull()` which I can't find/fix
- docs now built on Linux (for LaTeX purposes)

### Removed

Expand Down
Binary file modified docs/src/assets/figures/pro-text-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/figures/pro-text-placement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,065 changes: 1,065 additions & 0 deletions docs/src/assets/figures/texttrack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 40 additions & 30 deletions docs/src/example/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ graphics without you having to provide the usual set-up and
finish instructions:

```julia
# using Luxor
using Luxor

@png begin
fontsize(50)
Expand All @@ -54,26 +54,36 @@ finish instructions:

![background](../assets/figures/hello-world-macro.png)

```julia
@svg begin
```@example
using Luxor
@drawsvg begin
background("black")
sethue("red")
randpoint = Point(rand(-200:200), rand(-200:200))
circle(randpoint, 2, :fill)
sethue("black")
randpoint = Point(rand(-300:300), rand(-300:300))
circle(randpoint, 5, :fill)
sethue("white")
foreach(f -> arrow(f, between(f, randpoint, .1), arrowheadlength=6),
first.(collect(Table(fill(20, 15), fill(20, 15)))))
first.(collect(Table(fill(30, 20), fill(30, 20)))))
end
```
![background](../assets/figures/circle-dots.png)

The `@draw` and `drawsvg` macros are useful if you work in
Juno/VS Code IDEs or a notebook environment such as Jupyter
or Pluto and don't need to always save your work in files.
They create a PNG or SVG format drawing in memory, rather
than saved in a file. It's displayed in the plot pane or in
an adjacent cell.
than saved in a file.

In this document, which was generated by Documenter.jl, the result
of executing the code is included and displayed as a
graphic.

For Juno and VS Code, the graphic is usually displayed in
the plot pane. In Pluto, it appears above the cell.

```julia
using Luxor

@draw begin
setopacity(0.85)
steps = 20
Expand Down Expand Up @@ -137,10 +147,10 @@ Here's a version of the Sierpinski recursive triangle, clipped to a circle.
![Sierpinski](../assets/figures/sierpinski.png)

```julia
# using Luxor, Colors
# Drawing()
# background("white")
# origin()
using Luxor, Colors
Drawing()
background("white")
origin()

function triangle(points, degree)
sethue(cols[degree])
Expand Down Expand Up @@ -170,8 +180,8 @@ depth = 8 # 12 is ok, 20 is right out (on my computer, at least)
cols = distinguishable_colors(depth) # from Colors.jl
draw(depth)

# finish()
# preview()
finish()
preview()
```

The Point type is an immutable composite type containing `x` and `y` fields that specify a 2D point.
Expand All @@ -181,7 +191,7 @@ The Point type is an immutable composite type containing `x` and `y` fields that
[`tickline()`](@ref) is useful for generating spaced points along a line:

```@example
using Luxor # hide
using Luxor
@drawsvg begin
background("black")
fontsize(12)
Expand All @@ -196,7 +206,7 @@ end 800 150
The [`arrow`](@ref) functions let you add decoration to the arrow shafts, so it's possible to use this function to create more complicated spacings. Here's how a curved number line could be made:

```@example
using Luxor # hide
using Luxor
@drawsvg begin
background("antiquewhite")
_counter() = (a = -1; () -> a += 1)
Expand Down Expand Up @@ -268,10 +278,10 @@ If you have the right fonts installed, you can easily draw simple ``\LaTeX`` equ

```@example
# drawing with 800×300 canvas
using Luxor # hide
using Luxor
using MathTeXEngine
d = Drawing(800, 300, :svg) # hide
origin() # hide
d = Drawing(800, 300, :svg)
origin()
background("khaki")
f(t) = Point(4cos(t) + 2cos(5t), 4sin(t) + 2sin(5t))
setline(15)
Expand All @@ -283,8 +293,8 @@ fontsize(35)
end
sethue("grey5")
text(L"f(t) = [4\cos(t) + 2\cos(5t), 4\sin(t) + 2\sin(5t)]", halign=:center)
finish() # hide
d # hide
finish()
d
```

## Triangulations
Expand All @@ -294,12 +304,12 @@ random points can be used to derive a set of Voronoi cells.

```@example
# Inspired by @TheCedarPrince!
using Luxor, Colors, Random # hide
Random.seed!(42) # hide
using Luxor, Colors, Random
Random.seed!(42)
d = @drawsvg begin # hide
background("black") # hide
setlinejoin("bevel") # hide
d = @drawsvg begin
background("black")
setlinejoin("bevel")
verts = randompointarray(BoundingBox(), 40)
triangles = polytriangulate(verts) # create Delaunay
Expand Down Expand Up @@ -340,6 +350,6 @@ for v in verts
strokepath()
end
end
end 800 500 # hide
d # hide
end 800 500
d
```
10 changes: 10 additions & 0 deletions docs/src/howto/polygons.md
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,16 @@ nothing # hide

![polysampling 2](../assets/figures/polysample2.png)

!!! note

In Luxor, you'll meet `close` and `closed` options.
`close` is an instruction to path-drawing functions,
that says "join the most recent point to the first
point". Whereas, `closed` is an indication that the
polygons or paths should be treated as being closed
rather than open, ie whether that last segment joining
the end point to the first is used for calculations.

### Polygon side lengths

`polydistances` returns an array of the accumulated side lengths of a polygon.
Expand Down
Loading

0 comments on commit a6a1300

Please sign in to comment.