Skip to content

Commit a8088be

Browse files
committed
text rotations fix?
1 parent ed58dad commit a8088be

File tree

7 files changed

+24
-25
lines changed

7 files changed

+24
-25
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Thebes"
22
uuid = "8b424ff8-82f5-59a4-86a6-de3761897198"
33
authors = ["cormullion <[email protected]>"]
4-
version = "0.3.0"
4+
version = "0.4.0"
55

66
[deps]
77
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Luxor.jl is built on [Cairo.jl](https://github.com/JuliaGraphics/Cairo.jl), and
3333
[pkg-0.7-img]: http://pkg.julialang.org/badges/Thebes_0.7.svg
3434
[pkg-0.7-url]: http://pkg.julialang.org/?pkg=Thebes&ver=0.7
3535

36-
[travis-img]: https://travis-ci.org/cormullion/Thebes.jl.svg?branch=master
37-
[travis-url]: https://travis-ci.org/cormullion/Thebes.jl
36+
[travis-img]: https://travis-ci.com/cormullion/Thebes.jl.svg?branch=master
37+
[travis-url]: https://travis-ci.com/cormullion/Thebes.jl
3838

3939
[appvey-img]: https://ci.appveyor.com/api/projects/status/jfa9e54lv92rqd3m?svg=true
4040
[appvey-url]: https://ci.appveyor.com/project/cormullion/thebes-jl/branch/master

REQUIRE

-2
This file was deleted.
Loading

docs/src/text.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fontsize(40)
2828
fontface("Georgia-Italic")
2929
3030
text3D("the x-axis", Point3D(50, 0, 0))
31-
text3D("the y-axis", Point3D(0, 50, 0), rotation=(0, 0, π/2))
31+
text3D("the y-axis", Point3D(0, 50, 0), center=Point3D(0, 50, 0), rotation=(π/2, 0, π/2))
3232
text3D("the z-axis", Point3D(0, 0, 0), rotation=(0, π/2, 0), halign=:right)
3333
3434
finish() # hide
@@ -41,7 +41,7 @@ You can also use some of Luxor's text functions, such as `textextents()`, which
4141

4242
```@example
4343
using Thebes, Luxor, Colors # hide
44-
Drawing(600, 500, "assets/figures/text2.svg") # hide
44+
Drawing(800, 600, "assets/figures/text2.svg") # hide
4545
background("black") # hide
4646
origin() # hide
4747
eyepoint(Point3D(250, 250, 550))
@@ -52,11 +52,11 @@ fontsize(50)
5252
te = textextents("Julia")
5353
5454
for y in -1200:te[3]:1200
55-
for x in -1200:te[4]:1200
56-
sethue(HSB(mod(x*y, 360), .8, .8))
57-
text3D("Julia", Point3D(x, y, 0), rotation=(0, 0, π/2))
55+
for x in -1200:te[4]:1200
56+
sethue(HSB(mod(x*y, 360), .6, .9))
57+
text3D("Julia", Point3D(x, y, 0), center=Point3D(x, y, 0), rotation=(0,0,π/2))
58+
end
5859
end
59-
end
6060
finish() # hide
6161
nothing # hide
6262
```

examples/text-rotation.jl

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Thebes, Luxor, Colors
22

3-
4-
53
function frame(scene, fn)
64
background("black")
75
eased_n = scene.easingfunction(fn, 0, 1, scene.framerange.stop)

src/text.jl

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
"""
22
text3D(str, pt::Point3D;
3-
halign=:left,
4-
valign=:baseline,
5-
rotation = (0, 0, 0)))
3+
halign = :left,
4+
valign = :baseline,
5+
center = Point3D(0, 0, 0),
6+
rotation = (0, 0, 0))
67
78
Draw text at point `pt`, lying in the plane of the x axis.
8-
Angles in `rotation` can rotate the text away from the x
9-
plane around the x, y, and z axes.
9+
Angles in `rotation` rotate the text. The `center` of rotation defaults
10+
to `Point3D(0, 0, 0)`.
1011
1112
Uses current `fontface()` and `fontsize()` settings.
13+
14+
TODO Make sense of it all.
1215
"""
13-
function text3D(str, origin::Point3D;
16+
function text3D(str, anchor::Point3D;
1417
halign=:left,
1518
valign=:baseline,
19+
center=Point3D(0, 0, 0),
1620
rotation = (0, 0, 0))
1721

1822
textoutlines(str, O, :path,
@@ -22,16 +26,15 @@ function text3D(str, origin::Point3D;
2226

2327
o = getpathflat()
2428
newpath() # otherwise the path would be drawn twice
25-
z = origin.z
26-
for e in o
29+
for e in o
2730
if e.element_type == 0
2831
(x, y) = e.points
29-
pt3 = rotateby(origin + Point3D(x, -y, z), origin, rotation...)
30-
pin(pt3, gfunction = (p3, p2) -> move(p2))
32+
newpt = rotateby(Point3D(anchor.x + x, anchor.y -y, anchor.z), center, rotation...)
33+
pin(newpt, gfunction = (p3, p2) -> move(p2))
3134
elseif e.element_type == 1
3235
(x, y) = e.points
33-
pt3 = rotateby(origin + Point3D(x, -y, z), origin, rotation...)
34-
pin(pt3, gfunction = (p3, p2) -> line(p2))
36+
newpt = rotateby(Point3D(anchor.x + x, anchor.y -y, anchor.z), center, rotation...)
37+
pin(newpt, gfunction = (p3, p2) -> line(p2))
3538
elseif e.element_type == 3
3639
closepath()
3740
else

0 commit comments

Comments
 (0)