mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-26 20:40:39 +02:00
Fix for invalid restore from keithp. Began adding notes on arc support.
This commit is contained in:
parent
1154ac5b59
commit
9c5be2cf31
3 changed files with 55 additions and 5 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2003-09-15 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* src/cairo.c (cairo_restore): Fix to catch invalid restore rather
|
||||
than just catching the second invalid restore. Fix from Keith
|
||||
Packard <keithp@keithp.com>.
|
||||
|
||||
2003-09-12 Carl Worth <cworth@east.isi.edu>
|
||||
|
||||
* src/cairo_surface.c (cairo_surface_create_similar_solid): Don't
|
||||
|
|
|
|||
46
TODO
46
TODO
|
|
@ -10,3 +10,49 @@
|
|||
compiled conditionally.
|
||||
|
||||
* Verification, profiling, optimization.
|
||||
|
||||
|
||||
Some notes on arc support
|
||||
-------------------------
|
||||
|
||||
"Approximation of circular arcs by cubic poynomials", Michael Goldapp,
|
||||
Computer Aided Geometric Design 8 (1991) 227-238.
|
||||
|
||||
To draw a unit arc from 0 to A with 0 < A < pi/2:
|
||||
|
||||
Y
|
||||
|
||||
| .
|
||||
| / .
|
||||
| / .
|
||||
|/A .
|
||||
+------.-- X
|
||||
0 1
|
||||
|
||||
The deviation in radius is given by:
|
||||
|
||||
rho(t) = sqrt ( x^2(t) + y^2(t) ) - 1
|
||||
|
||||
A simpler error function to work with is:
|
||||
|
||||
e(t) = x^2(t) + y^2(t) - 1
|
||||
|
||||
And from Dokken[cite]: e(t) ~ 2 abs( rho(t) )
|
||||
|
||||
A single cubic Bezier spline approximation must have the 4 control points:
|
||||
|
||||
(1, 0)
|
||||
(1, h)
|
||||
(cos(A) + h * sin(A), sin(A) - h * cos(A))
|
||||
(cos(A), sin(A))
|
||||
|
||||
Various approximations can be determined by selecting the value of
|
||||
h. A convenient value, (though not optimal in terms of error), is:
|
||||
|
||||
h = 4/3 * tan(A/4)
|
||||
|
||||
From which we can determine the maximum error:
|
||||
|
||||
abs( max(e(t)) ) = 4/27 * (sin^6 (A/4)) / (cos^2 (A/4))
|
||||
t in [0,1]
|
||||
|
||||
|
|
|
|||
|
|
@ -110,15 +110,13 @@ cairo_restore (cairo_t *cr)
|
|||
if (cr->status)
|
||||
return;
|
||||
|
||||
if (cr->gstate == NULL) {
|
||||
cr->status = CAIRO_STATUS_INVALID_RESTORE;
|
||||
return;
|
||||
}
|
||||
|
||||
top = cr->gstate;
|
||||
cr->gstate = top->next;
|
||||
|
||||
_cairo_gstate_destroy (top);
|
||||
|
||||
if (cr->gstate == NULL)
|
||||
cr->status = CAIRO_STATUS_INVALID_RESTORE;
|
||||
}
|
||||
slim_hidden_def(cairo_restore);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue