Skip to content

Commit 3c25161

Browse files
authored
Clarify sweep gradient angle rotation and unit (#130)
See linebender/vello#1205 and [#vello > Sweep Gradient Convention @ 💬](https://xi.zulipchat.com/#narrow/channel/197075-vello/topic/Sweep.20Gradient.20Convention/near/538611201). This lifts some wording from [`kurbo::Affine::rotate`](https://docs.rs/kurbo/0.12.0/kurbo/struct.Affine.html#method.rotate).
1 parent 1d8181c commit 3c25161

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ This release has an [MSRV] of 1.82.
2626

2727
- Breaking change: `Image` has been renamed to `ImageBrush`, which now consists of an `ImageData` and an `ImageSampler`. ([#117][], [#123][] by [@nicoburns][], [@DJMcNab][])
2828
- Breaking change: `Font` has been renamed to `FontData` to match `ImageData`. ([#126][] by [@nicoburns][])
29+
- Breaking change: the angle directions of `SweepGradientPosition` are now described to be clockwise in a Y-down coordinate system, as is common in computer graphics.
30+
This is reversed from the most likely reading of the previous wording.
31+
More generally, the angle directions are now described numerically to be unambiguous across coordinate systems.
32+
The angle unit is now specified to be in radians. ([#130][] by [@tomcur][])
2933
- Update to `color` 0.3.2. ([#115][] by [@sagudev][])
3034

3135
### Raw Resource Changes
@@ -154,13 +158,16 @@ This release has an [MSRV] of 1.70.
154158
[#120]: https://github.com/linebender/peniko/pull/120
155159
[#121]: https://github.com/linebender/peniko/pull/121
156160
[#123]: https://github.com/linebender/peniko/pull/123
161+
[#126]: https://github.com/linebender/peniko/pull/126
162+
[#130]: https://github.com/linebender/peniko/pull/130
157163

158164
[@dfrg]: https://github.com/dfrg
159165
[@DJMcNab]: https://github.com/DJMcNab
160166
[@liferooter]: https://github.com/liferooter
161167
[@nicoburns]: https://github.com/nicoburns
162168
[@ratmice]: https://github.com/ratmice
163169
[@sagudev]: https://github.com/sagudev
170+
[@tomcur]: https://github.com/tomcur
164171
[@waywardmonkeys]: https://github.com/waywardmonkeys
165172

166173
[Unreleased]: https://github.com/linebender/peniko/compare/v0.4.0...HEAD

src/gradient.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,22 @@ impl RadialGradientPosition {
198198
}
199199

200200
/// Parameters that define the position of a sweep gradient.
201+
///
202+
/// Conventionally, a positive increase in one of the sweep angles is a clockwise rotation in a
203+
/// Y-down, X-right coordinate system (as is common for graphics). More generally, the convention
204+
/// for rotations is that a positive angle rotates a positive X direction into positive Y.
201205
#[derive(Copy, Clone, PartialEq, Debug)]
202206
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
203207
pub struct SweepGradientPosition {
204208
/// Center point.
205209
center: Point,
206-
/// Start angle of the sweep, counter-clockwise of the x-axis.
210+
/// Start angle of the sweep in radians, measuring from the positive X-axis.
211+
///
212+
/// Clockwise in a Y-down coordinate system.
207213
start_angle: f32,
208-
/// End angle of the sweep, counter-clockwise of the x-axis.
214+
/// End angle of the sweep in radians, measuring from the positive X-axis.
215+
///
216+
/// Clockwise in a Y-down coordinate system.
209217
end_angle: f32,
210218
}
211219
impl SweepGradientPosition {

0 commit comments

Comments
 (0)