Verified Commit 29cb0ca5 authored by Jordan Petridis's avatar Jordan Petridis 🌱

Normalize comments.

parent be147655
......@@ -10,7 +10,7 @@ newline_style = "Unix"
write_mode = "Overwrite"
condense_wildcard_suffixes = false
format_strings = true
# normalize_comments = true
normalize_comments = true
reorder_imports = true
reorder_imported_names = true
reorder_imports_in_group = true
......
......@@ -160,42 +160,24 @@ impl Default for AspectRatio {
fn parse_align_mode(s: &str) -> Option<Align> {
match s {
"none" => Some(Align::None),
"xMinYMin" => {
Some(Align::Aligned { align: AlignMode::XminYmin,
fit: FitMode::Meet, })
}
"xMidYMin" => {
Some(Align::Aligned { align: AlignMode::XmidYmin,
fit: FitMode::Meet, })
}
"xMaxYMin" => {
Some(Align::Aligned { align: AlignMode::XmaxYmin,
fit: FitMode::Meet, })
}
"xMinYMid" => {
Some(Align::Aligned { align: AlignMode::XminYmid,
fit: FitMode::Meet, })
}
"xMidYMid" => {
Some(Align::Aligned { align: AlignMode::XmidYmid,
fit: FitMode::Meet, })
}
"xMaxYMid" => {
Some(Align::Aligned { align: AlignMode::XmaxYmid,
fit: FitMode::Meet, })
}
"xMinYMax" => {
Some(Align::Aligned { align: AlignMode::XminYmax,
fit: FitMode::Meet, })
}
"xMidYMax" => {
Some(Align::Aligned { align: AlignMode::XmidYmax,
fit: FitMode::Meet, })
}
"xMaxYMax" => {
Some(Align::Aligned { align: AlignMode::XmaxYmax,
fit: FitMode::Meet, })
}
"xMinYMin" => Some(Align::Aligned { align: AlignMode::XminYmin,
fit: FitMode::Meet, }),
"xMidYMin" => Some(Align::Aligned { align: AlignMode::XmidYmin,
fit: FitMode::Meet, }),
"xMaxYMin" => Some(Align::Aligned { align: AlignMode::XmaxYmin,
fit: FitMode::Meet, }),
"xMinYMid" => Some(Align::Aligned { align: AlignMode::XminYmid,
fit: FitMode::Meet, }),
"xMidYMid" => Some(Align::Aligned { align: AlignMode::XmidYmid,
fit: FitMode::Meet, }),
"xMaxYMid" => Some(Align::Aligned { align: AlignMode::XmaxYmid,
fit: FitMode::Meet, }),
"xMinYMax" => Some(Align::Aligned { align: AlignMode::XminYmax,
fit: FitMode::Meet, }),
"xMidYMax" => Some(Align::Aligned { align: AlignMode::XmidYmax,
fit: FitMode::Meet, }),
"xMaxYMax" => Some(Align::Aligned { align: AlignMode::XmaxYmax,
fit: FitMode::Meet, }),
_ => None,
}
}
......@@ -281,10 +263,8 @@ impl Parse for AspectRatio {
Ok(AspectRatio { defer,
align: match align {
Align::None => Align::None,
Align::Aligned { align, .. } => {
Align::Aligned { align,
fit: fit_mode, }
}
Align::Aligned { align, .. } => Align::Aligned { align,
fit: fit_mode, },
}, })
}
}
......
......@@ -5,7 +5,7 @@ use cairo::MatrixTrait;
use glib::translate::*;
use util::*;
/* Keep this in sync with ../../rsvg-private.h:RsvgBbox */
// Keep this in sync with ../../rsvg-private.h:RsvgBbox
#[repr(C)]
#[derive(Copy, Clone)]
pub struct RsvgBbox {
......@@ -59,13 +59,12 @@ pub extern "C" fn rsvg_bbox_insert(raw_dst: *mut RsvgBbox, raw_src: *const RsvgB
affine.invert(); // this will panic!() if it's not invertible... should we check on our own?
affine = cairo::Matrix::multiply(&src.affine, &affine);
/* This is a trick. We want to transform each of the corners of
* the rectangle defined by src.rect with the affine
* transformation, and get the bounding box of all the four
* resulting points. The modulus and division accomplish this by
* running through all the combinations of adding or not adding
* the width/height to the first point src.rect.(x, y).
*/
// This is a trick. We want to transform each of the corners of
// the rectangle defined by src.rect with the affine
// transformation, and get the bounding box of all the four
// resulting points. The modulus and division accomplish this by
// running through all the combinations of adding or not adding
// the width/height to the first point src.rect.(x, y).
for i in 0..4 {
let rx: f64 = src.rect.x + src.rect.width * f64::from(i % 2);
let ry: f64 = src.rect.y + src.rect.height * f64::from(i / 2);
......@@ -123,7 +122,7 @@ pub extern "C" fn rsvg_bbox_clip(raw_dst: *mut RsvgBbox, raw_src: *const RsvgBbo
affine.invert();
affine = cairo::Matrix::multiply(&src.affine, &affine);
/* This is a trick. See rsvg_bbox_insert() for a description of how it works. */
// This is a trick. See rsvg_bbox_insert() for a description of how it works.
for i in 0..4 {
let rx: f64 = src.rect.x + src.rect.width * f64::from(i % 2);
let ry: f64 = src.rect.y + src.rect.height * f64::from(i / 2);
......
......@@ -136,27 +136,20 @@ impl From<u32> for Color {
impl From<Result<Color, AttributeError>> for ColorSpec {
fn from(result: Result<Color, AttributeError>) -> ColorSpec {
match result {
Ok(Color::Inherit) => {
ColorSpec { kind: ColorKind::Inherit,
argb: 0, }
}
Ok(Color::Inherit) => ColorSpec { kind: ColorKind::Inherit,
argb: 0, },
Ok(Color::CurrentColor) => {
ColorSpec { kind: ColorKind::CurrentColor,
argb: 0, }
}
Ok(Color::CurrentColor) => ColorSpec { kind: ColorKind::CurrentColor,
argb: 0, },
Ok(Color::RGBA(rgba)) => {
ColorSpec { kind: ColorKind::ARGB,
argb: (u32::from(rgba.alpha) << 24 | u32::from(rgba.red) << 16
| u32::from(rgba.green) << 8
| u32::from(rgba.blue)), }
}
Ok(Color::RGBA(rgba)) => ColorSpec { kind: ColorKind::ARGB,
argb: (u32::from(rgba.alpha) << 24
| u32::from(rgba.red) << 16
| u32::from(rgba.green) << 8
| u32::from(rgba.blue)), },
_ => {
ColorSpec { kind: ColorKind::ParseError,
argb: 0, }
}
_ => ColorSpec { kind: ColorKind::ParseError,
argb: 0, },
}
}
}
......
......@@ -21,10 +21,8 @@ impl Parse for CoordUnits {
match s {
"userSpaceOnUse" => Ok(CoordUnits::UserSpaceOnUse),
"objectBoundingBox" => Ok(CoordUnits::ObjectBoundingBox),
_ => {
Err(AttributeError::Parse(ParseError::new("expected 'userSpaceOnUse' or \
'objectBoundingBox'")))
}
_ => Err(AttributeError::Parse(ParseError::new("expected 'userSpaceOnUse' or \
'objectBoundingBox'"))),
}
}
}
......
......@@ -49,17 +49,13 @@ impl error::Error for NodeError {
impl fmt::Display for NodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.err {
AttributeError::Parse(ref n) => {
write!(f,
"error parsing value for attribute \"{}\": {}",
self.attr_name, n.display)
}
AttributeError::Parse(ref n) => write!(f,
"error parsing value for attribute \"{}\": {}",
self.attr_name, n.display),
AttributeError::Value(ref s) => {
write!(f,
"invalid value for attribute \"{}\": {}",
self.attr_name, s)
}
AttributeError::Value(ref s) => write!(f,
"invalid value for attribute \"{}\": {}",
self.attr_name, s),
}
}
}
......
......@@ -27,10 +27,9 @@ struct ColorStop {
coord_units!(GradientUnits, CoordUnits::ObjectBoundingBox);
/* Any of the attributes in gradient elements may be omitted. In turn, the missing
* ones can be inherited from the gradient referenced by its "fallback" IRI. We
* represent these possibly-missing attributes as Option<foo>.
*/
// Any of the attributes in gradient elements may be omitted. In turn, the missing
// ones can be inherited from the gradient referenced by its "fallback" IRI. We
// represent these possibly-missing attributes as Option<foo>.
#[derive(Clone)]
struct GradientCommon {
pub units: Option<GradientUnits>,
......@@ -208,8 +207,7 @@ impl GradientVariant {
}
fn resolve_from_defaults(&mut self) {
/* These are per the spec */
// These are per the spec
match *self {
GradientVariant::Linear { .. } => {
self.resolve_from_fallback(&GradientVariant::default_linear())
......@@ -455,10 +453,9 @@ fn set_linear_gradient_on_pattern(gradient: &Gradient,
true
}
/* SVG defines radial gradients as being inside a circle (cx, cy, radius). The
* gradient projects out from a focus point (fx, fy), which is assumed to be
* inside the circle, to the edge of the circle. */
//
// SVG defines radial gradients as being inside a circle (cx, cy, radius). The
// gradient projects out from a focus point (fx, fy), which is assumed to be
// inside the circle, to the edge of the circle.
// The description of https://www.w3.org/TR/SVG/pservers.html#RadialGradientElement
// states:
//
......@@ -468,40 +465,37 @@ fn set_linear_gradient_on_pattern(gradient: &Gradient,
// defined by ‘cx’, ‘cy’ and ‘r’.
//
// So, let's do that!
//
fn fix_focus_point(mut fx: f64, mut fy: f64, cx: f64, cy: f64, radius: f64) -> (f64, f64) {
/* Easy case first: the focus point is inside the circle */
// Easy case first: the focus point is inside the circle
if (fx - cx) * (fx - cx) + (fy - cy) * (fy - cy) <= radius * radius {
return (fx, fy);
}
/* Hard case: focus point is outside the circle. */
//
// Hard case: focus point is outside the circle.
// First, translate everything to the origin.
//
fx -= cx;
fy -= cy;
/* Find the vector from the origin to (fx, fy) */
// Find the vector from the origin to (fx, fy)
let mut vx = fx;
let mut vy = fy;
/* Find the vector's magnitude */
// Find the vector's magnitude
let mag = (vx * vx + vy * vy).sqrt();
/* Normalize the vector to have a magnitude equal to radius; (vx, vy) will now be on the
* edge of the circle */
// Normalize the vector to have a magnitude equal to radius; (vx, vy) will now be on the
// edge of the circle
let scale = mag / radius;
vx /= scale;
vy /= scale;
/* Translate back to (cx, cy) and we are done! */
// Translate back to (cx, cy) and we are done!
(vx + cx, vy + cy)
}
......
......@@ -44,18 +44,14 @@ impl NodeTrait for NodeImage {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal, None)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical, None)?),
Attribute::Width => {
self.w.set(parse("width",
value,
LengthDir::Horizontal,
Some(RsvgLength::check_nonnegative))?)
}
Attribute::Height => {
self.h.set(parse("height",
value,
LengthDir::Vertical,
Some(RsvgLength::check_nonnegative))?)
}
Attribute::Width => self.w.set(parse("width",
value,
LengthDir::Horizontal,
Some(RsvgLength::check_nonnegative))?),
Attribute::Height => self.h.set(parse("height",
value,
LengthDir::Vertical,
Some(RsvgLength::check_nonnegative))?),
Attribute::PreserveAspectRatio => {
self.aspect.set(parse("preserveAspectRatio", value, (), None)?)
......
......@@ -15,7 +15,7 @@ use parsers::Parse;
use parsers::ParseError;
use util::utf8_cstr;
/* Keep this in sync with ../../rsvg-private.h:LengthUnit */
// Keep this in sync with ../../rsvg-private.h:LengthUnit
#[repr(C)]
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum LengthUnit {
......@@ -28,7 +28,7 @@ pub enum LengthUnit {
RelativeSmaller,
}
/* Keep this in sync with ../../rsvg-private.h:LengthDir */
// Keep this in sync with ../../rsvg-private.h:LengthDir
#[repr(C)]
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum LengthDir {
......@@ -37,11 +37,11 @@ pub enum LengthDir {
Both,
}
/* This is *not* an opaque struct; it is actually visible to the C code. It is so
* that the remaining C code can create RsvgLength values as part of existing
* structures or objects, without allocations on the heap.
*/
/* Keep this in sync with ../../rsvg-private.h:RsvgLength */
// This is *not* an opaque struct; it is actually visible to the C code. It is so
// that the remaining C code can create RsvgLength values as part of existing
// structures or objects, without allocations on the heap.
//
// Keep this in sync with ../../rsvg-private.h:RsvgLength
#[repr(C)]
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct RsvgLength {
......@@ -104,9 +104,8 @@ pub extern "C" fn rsvg_length_parse(string: *const libc::c_char, dir: LengthDir)
RsvgLength::parse(my_string, dir).unwrap_or_else(|_| RsvgLength::default())
}
/* https://www.w3.org/TR/SVG/types.html#DataTypeLength
* https://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#length-units */
//
// https://www.w3.org/TR/SVG/types.html#DataTypeLength
// https://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#length-units
// Lengths have units. When they need to be need resolved to
// units in the user's coordinate system, some unit types
// need to know if they are horizontal/vertical/both. For example,
......@@ -114,7 +113,6 @@ pub extern "C" fn rsvg_length_parse(string: *const libc::c_char, dir: LengthDir)
// viewport's width. In this case, the @dir argument is used
// inside RsvgLength::normalize(), when it needs to know to what the
// length refers.
//
fn make_err() -> AttributeError {
AttributeError::Parse(ParseError::new("expected length: number(\"em\" | \"ex\" | \"px\" | \
......@@ -214,99 +212,72 @@ impl RsvgLength {
.map_err (|_| AttributeError::Parse (ParseError::new ("expected number and optional symbol, or number and percentage")))?;
match *token {
Token::Number { value, .. } => {
RsvgLength { length: f64::from(value),
unit: LengthUnit::Default,
dir, }
}
Token::Number { value, .. } => RsvgLength { length: f64::from(value),
unit: LengthUnit::Default,
dir, },
Token::Percentage { unit_value, .. } => {
RsvgLength { length: f64::from(unit_value),
unit: LengthUnit::Percent,
dir, }
}
Token::Percentage { unit_value, .. } => RsvgLength { length:
f64::from(unit_value),
unit: LengthUnit::Percent,
dir, },
Token::Dimension { value, ref unit, .. } => {
let value = f64::from(value);
match unit.as_ref() {
"em" => {
RsvgLength { length: value,
unit: LengthUnit::FontEm,
dir, }
}
"ex" => {
RsvgLength { length: value,
unit: LengthUnit::FontEx,
dir, }
}
"pt" => {
RsvgLength { length: value / POINTS_PER_INCH,
unit: LengthUnit::Inch,
dir, }
}
"in" => {
RsvgLength { length: value,
unit: LengthUnit::Inch,
dir, }
}
"cm" => {
RsvgLength { length: value / CM_PER_INCH,
unit: LengthUnit::Inch,
dir, }
}
"mm" => {
RsvgLength { length: value / MM_PER_INCH,
unit: LengthUnit::Inch,
dir, }
}
"pc" => {
RsvgLength { length: value / PICA_PER_INCH,
unit: LengthUnit::Inch,
dir, }
}
"px" => {
RsvgLength { length: value,
unit: LengthUnit::Default,
dir, }
}
"em" => RsvgLength { length: value,
unit: LengthUnit::FontEm,
dir, },
"ex" => RsvgLength { length: value,
unit: LengthUnit::FontEx,
dir, },
"pt" => RsvgLength { length: value / POINTS_PER_INCH,
unit: LengthUnit::Inch,
dir, },
"in" => RsvgLength { length: value,
unit: LengthUnit::Inch,
dir, },
"cm" => RsvgLength { length: value / CM_PER_INCH,
unit: LengthUnit::Inch,
dir, },
"mm" => RsvgLength { length: value / MM_PER_INCH,
unit: LengthUnit::Inch,
dir, },
"pc" => RsvgLength { length: value / PICA_PER_INCH,
unit: LengthUnit::Inch,
dir, },
"px" => RsvgLength { length: value,
unit: LengthUnit::Default,
dir, },
_ => return Err(make_err()),
}
}
// FIXME: why are the following in Length? They should be in FontSize
Token::Ident(ref cow) => {
match cow.as_ref() {
"larger" => {
RsvgLength { length: 0.0,
unit: LengthUnit::RelativeLarger,
dir, }
}
"smaller" => {
RsvgLength { length: 0.0,
unit: LengthUnit::RelativeSmaller,
dir, }
}
"xx-small" | "x-small" | "small" | "medium" | "large" | "x-large"
| "xx-large" => {
RsvgLength { length: compute_named_size(cow),
unit: LengthUnit::Inch,
dir, }
}
Token::Ident(ref cow) => match cow.as_ref() {
"larger" => RsvgLength { length: 0.0,
unit: LengthUnit::RelativeLarger,
dir, },
_ => return Err(make_err()),
}
}
"smaller" => RsvgLength { length: 0.0,
unit: LengthUnit::RelativeSmaller,
dir, },
"xx-small" | "x-small" | "small" | "medium" | "large" | "x-large"
| "xx-large" => RsvgLength { length: compute_named_size(cow),
unit: LengthUnit::Inch,
dir, },
_ => return Err(make_err()),
},
_ => return Err(make_err()),
}
......@@ -317,12 +288,10 @@ impl RsvgLength {
}
fn viewport_percentage(x: f64, y: f64) -> f64 {
/* https://www.w3.org/TR/SVG/coords.html#Units */
//
// https://www.w3.org/TR/SVG/coords.html#Units
// "For any other length value expressed as a percentage of the viewport, the
// percentage is calculated as the specified percentage of
// sqrt((actual-width)**2 + (actual-height)**2))/sqrt(2)."
//
(x * x + y * y).sqrt() / SQRT_2
}
......@@ -426,17 +395,14 @@ pub extern "C" fn rsvg_parse_stroke_dasharray(string: *const libc::c_char) -> Rs
let my_string = unsafe { &String::from_glib_none(string) };
match parse_stroke_dash_array(my_string) {
Ok(StrokeDasharray::None) => {
RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::None,
num_dashes: 0,
dashes: ptr::null_mut(), }
}
Ok(StrokeDasharray::None) => RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::None,
num_dashes: 0,
dashes: ptr::null_mut(), },
Ok(StrokeDasharray::Inherit) => {
RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::Inherit,
num_dashes: 0,
dashes: ptr::null_mut(), }
}
Ok(StrokeDasharray::Inherit) => RsvgStrokeDasharray { kind:
RsvgStrokeDasharrayKind::Inherit,
num_dashes: 0,
dashes: ptr::null_mut(), },
Ok(StrokeDasharray::Dasharray(ref v)) => {
RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::Dashes,
......@@ -444,11 +410,9 @@ pub extern "C" fn rsvg_parse_stroke_dasharray(string: *const libc::c_char) -> Rs
dashes: to_c_array(v), }
}
Err(_) => {
RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::Error,
num_dashes: 0,
dashes: ptr::null_mut(), }
}
Err(_) => RsvgStrokeDasharray { kind: RsvgStrokeDasharrayKind::Error,
num_dashes: 0,
dashes: ptr::null_mut(), },
}
}
......
......@@ -114,8 +114,7 @@ impl CairoTagging for cairo::Context {
}
}
/***** C Prototypes **** * * * * * * * * * * **/
// ****************** C Prototypes ******************
#[no_mangle]
pub extern "C" fn rsvg_node_link_new(_: *const libc::c_char,
raw_parent: *const RsvgNode)
......
......@@ -22,7 +22,6 @@ use util::*;
use viewbox::*;
// markerUnits attribute: https://www.w3.org/TR/SVG/painting.html#MarkerElement
#[derive(Debug, Copy, Clone, PartialEq)]
enum MarkerUnits {
UserSpaceOnUse,
......@@ -43,16 +42,13 @@ impl Parse for MarkerUnits {
match s {
"userSpaceOnUse" => Ok(MarkerUnits::UserSpaceOnUse),
"strokeWidth" => Ok(MarkerUnits::StrokeWidth),
_ => {
Err(AttributeError::Parse(ParseError::new("expected \"userSpaceOnUse\" or \
\"strokeWidth\"")))
}
_ => Err(AttributeError::Parse(ParseError::new("expected \"userSpaceOnUse\" or \
\"strokeWidth\""))),
}
}
}
// orient attribute: https://www.w3.org/TR/SVG/painting.html#MarkerElement
#[derive(Debug, Copy, Clone, PartialEq)]
enum MarkerOrient {
Auto,
......@@ -72,16 +68,13 @@ impl Parse for MarkerOrient {
fn parse(s: &str, _: ()) -> Result<MarkerOrient, AttributeError> {
match s {
"auto" => Ok(MarkerOrient::Auto),
_ => {
parsers::angle_degrees(s).map(MarkerOrient::Degrees)
.map_err(AttributeError::Parse)
}
_ => parsers::angle_degrees(s).map(MarkerOrient::Degrees)
.map_err(AttributeError::Parse),
}
}
}
// NodeMarker
struct NodeMarker {
units: Cell<MarkerUnits>,
ref_x: Cell<RsvgLength>,
......@@ -202,19 +195,15 @@ impl NodeTrait for NodeMarker {
Attribute::RefY => self.ref_y.set(parse("refY", value, LengthDir::Vertical, None)?),
Attribute::MarkerWidth => {
self.width.set(parse("markerWidth",
value,
LengthDir::Horizontal,
Some(RsvgLength::check_nonnegative))?)
}
Attribute::MarkerWidth => self.width.set(parse("markerWidth",
value,
LengthDir::Horizontal,
Some(RsvgLength::check_nonnegative))?),
Attribute::MarkerHeight => {
self.height.set(parse("markerHeight",
value,
LengthDir::Vertical,
Some(RsvgLength::check_nonnegative))?)
}
Attribute::MarkerHeight => self.height.set(parse("markerHeight",
value,
LengthDir::Vertical,
Some(RsvgLength::check_nonnegative))?),
Attribute::Orient => self.orient.set(parse("orient", value, (), None)?),
......@@ -248,7 +237,6 @@ pub extern "C" fn rsvg_node_marker_new(_: *const libc::c_char,
}
// Machinery to figure out marker orientations
#[derive(Debug, PartialEq)]
pub enum Segment {
Degenerate {
......@@ -276,8 +264,7 @@ enum SegmentState {
ClosedSubpath,
}
/* This converts a cairo_path_t into a list of curveto-like segments. Each segment can be: */
//
// This converts a cairo_path_t into a list of curveto-like segments. Each segment can be:
// 1. Segment::Degenerate => the segment is actually a single point (x, y)
//
// 2. Segment::LineOrCurve => either a lineto or a curveto (or the effective lineto that results
......@@ -292,8 +279,6 @@ enum SegmentState {
// The tangent at the end point is given by the vector (P4 - P3).
// The tangents also work if the segment refers to a lineto (they will both just point in the
// same direction).
//
fn make_degenerate(x: f64, y: f64) -> Segment {
Segment::Degenerate { x, y }
}
......@@ -345,33 +330,29 @@ pub fn path_builder_to_segments(builder: &RsvgPathBuilder) -> Vec<Segment> {
match state {
SegmentState::Initial | SegmentState::InSubpath => {
/* Ignore the very first moveto in a sequence (Initial state), or if we
* were already drawing within a subpath, start
* a new subpath.
*/
// Ignore the very first moveto in a sequence (Initial state), or if we
// were already drawing within a subpath, start
// a new subpath.
state = SegmentState::NewSubpath;
}
SegmentState::NewSubpath => {
/* We had just begun a new subpath (i.e. from a moveto) and we got
* another moveto? Output a stray point for the
* previous moveto.
*/
// We had just begun a new subpath (i.e. from a moveto) and we got
// another moveto? Output a stray point for the
// previous moveto.
segments.push(make_degenerate(last_x, last_y));
state = SegmentState::NewSubpath;
}
SegmentState::ClosedSubpath => {
/* Cairo outputs a moveto after every closepath, so that subsequent
* lineto/curveto commands will start at the closed vertex. */
//
// Cairo outputs a moveto after every closepath, so that subsequent
// lineto/curveto commands will start at the closed vertex.
// We don't want to actually emit a point (a degenerate segment) in that
// artificial-moveto case.
//
// We'll reset to the Initial state so that a subsequent "real" moveto will
// be handled as the beginning of a new subpath, or a degenerate point, as
// usual.
//
state = SegmentState::Initial;
}
}
......@@ -419,12 +400,11 @@ fn points_equal(x1: f64, y1: f64, x2: f64, y2: f64) -> bool {