Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

CurveConverter



The CurveConverter class converts a list of CubicCurve and QuadCurve to a list of simple Shapes:
  • Lines
  • Arcs
  • Ellipse2D
Note that this class correctly takes into account disconnected paths in the Shape.

Conversion of full-circle arcs will be made to Ellipse2D only if CurveConverter.allowCircles(boolean) is set with the true argument.

Algorithm

The class will try to approximate each CubicCurve and QuadCurve to:
  • A line if the curve is flat
  • The closest Arc if the curve is not flat

Consecutive CubicCurve or QuadCurve can form an unique Arc if their center and computed "radius" are close enough.

Limitations

The algorithm will not try to subdivide the curves to get the best possible approximation:

For example, if you have this GeneralPath constructed with a series of moveTo, lineTo, and curveTo:
shapenormalizer3
After conversion, we have the following result (in red superposed to the original shape):
shapenormalizer4

See also


Categories: geom | packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences