forked from firka/flutter
Add diagram links for StrokeJoin and StrokeCap (flutter/engine#5456)
This updates the documentation for StrokeJoin and StrokeCap to contain animated diagrams that describe their function. The actual diagrams reside in the assets-for-api-docs repo.
This commit is contained in:
@@ -824,37 +824,101 @@ enum FilterQuality {
|
||||
|
||||
/// Styles to use for line endings.
|
||||
///
|
||||
/// See [Paint.strokeCap].
|
||||
/// See also:
|
||||
///
|
||||
/// * [Paint.strokeCap] for how this value is used.
|
||||
/// * [StrokeJoin] for the different kinds of line segment joins.
|
||||
// These enum values must be kept in sync with SkPaint::Cap.
|
||||
enum StrokeCap {
|
||||
/// Begin and end contours with a flat edge and no extension.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// Compare to the [square] cap, which has the same shape, but extends past
|
||||
/// the end of the line by half a stroke width.
|
||||
butt,
|
||||
|
||||
/// Begin and end contours with a semi-circle extension.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// The cap is colored in the diagram above to highlight it: in normal use it
|
||||
/// is the same color as the line.
|
||||
round,
|
||||
|
||||
/// Begin and end contours with a half square extension. This is
|
||||
/// similar to extending each contour by half the stroke width (as
|
||||
/// given by [Paint.strokeWidth]).
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// The cap is colored in the diagram above to highlight it: in normal use it
|
||||
/// is the same color as the line.
|
||||
///
|
||||
/// Compare to the [butt] cap, which has the same shape, but doesn't extend
|
||||
/// past the end of the line.
|
||||
square,
|
||||
}
|
||||
|
||||
/// Styles to use for line joins.
|
||||
/// Styles to use for line segment joins.
|
||||
///
|
||||
/// This only affects line joins for polygons drawn by [Canvas.drawPath] and
|
||||
/// rectangles, not points drawn as lines with [Canvas.drawPoints].
|
||||
///
|
||||
/// See [Paint.strokeJoin].
|
||||
/// See also:
|
||||
///
|
||||
/// * [Paint.strokeJoin] and [Paint.strokeMiterLimit] for how this value is
|
||||
/// used.
|
||||
/// * [StrokeCap] for the different kinds of line endings.
|
||||
// These enum values must be kept in sync with SkPaint::Join.
|
||||
enum StrokeJoin {
|
||||
/// Joins between line segments form sharp corners.
|
||||
///
|
||||
/// {@animation joinMiter 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/miter_4_join.mp4}
|
||||
///
|
||||
/// The center of the line segment is colored in the diagram above to
|
||||
/// highlight the join, but in normal usage the join is the same color as the
|
||||
/// line.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Paint.strokeJoin], used to set the line segment join style to this
|
||||
/// value.
|
||||
/// * [Paint.strokeMiterLimit], used to define when a miter is drawn instead
|
||||
/// of a bevel when the join is set to this value.
|
||||
miter,
|
||||
|
||||
/// Joins between line segments are semi-circular.
|
||||
///
|
||||
/// {@animation joinRound 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/round_join.mp4}
|
||||
///
|
||||
/// The center of the line segment is colored in the diagram above to
|
||||
/// highlight the join, but in normal usage the join is the same color as the
|
||||
/// line.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Paint.strokeJoin], used to set the line segment join style to this
|
||||
/// value.
|
||||
round,
|
||||
|
||||
/// Joins between line segments connect the corners of the butt ends of the
|
||||
/// line segments to give a beveled appearance.
|
||||
///
|
||||
/// {@animation joinBevel 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/bevel_join.mp4}
|
||||
///
|
||||
/// The center of the line segment is colored in the diagram above to
|
||||
/// highlight the join, but in normal usage the join is the same color as the
|
||||
/// line.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Paint.strokeJoin], used to set the line segment join style to this
|
||||
/// value.
|
||||
bevel,
|
||||
}
|
||||
|
||||
@@ -1055,8 +1119,26 @@ class Paint {
|
||||
/// This applies to paths drawn when [style] is set to [PaintingStyle.stroke],
|
||||
/// It does not apply to points drawn as lines with [Canvas.drawPoints].
|
||||
///
|
||||
/// Defaults to [StrokeJoin.miter], i.e. sharp corners. See also
|
||||
/// [strokeMiterLimit] to control when miters are replaced by bevels.
|
||||
/// Defaults to [StrokeJoin.miter], i.e. sharp corners.
|
||||
///
|
||||
/// Some examples of joins:
|
||||
///
|
||||
/// {@animation joinMiter 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/miter_4_join.mp4}
|
||||
///
|
||||
/// {@animation joinRound 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/round_join.mp4}
|
||||
///
|
||||
/// {@animation joinBevel 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/bevel_join.mp4}
|
||||
///
|
||||
/// The centers of the line segments are colored in the diagrams above to
|
||||
/// highlight the joins, but in normal usage the join is the same color as the
|
||||
/// line.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [strokeMiterLimit] to control when miters are replaced by bevels when
|
||||
/// this is set to [StrokeJoin.miter].
|
||||
/// * [strokeCap] to control what is drawn at the ends of the stroke.
|
||||
/// * [StrokeJoin] for the definitive list of stroke joins.
|
||||
StrokeJoin get strokeJoin {
|
||||
return StrokeJoin.values[_data.getInt32(_kStrokeJoinOffset, _kFakeHostEndian)];
|
||||
}
|
||||
@@ -1073,12 +1155,28 @@ class Paint {
|
||||
/// [StrokeJoin.miter] and the [style] is set to [PaintingStyle.stroke]. If
|
||||
/// this limit is exceeded, then a [StrokeJoin.bevel] join will be drawn
|
||||
/// instead. This may cause some 'popping' of the corners of a path if the
|
||||
/// angle between line segments is animated.
|
||||
/// angle between line segments is animated, as seen in the diagrams below.
|
||||
///
|
||||
/// This limit is expressed as a limit on the length of the miter.
|
||||
///
|
||||
/// Defaults to 4.0. Using zero as a limit will cause a [StrokeJoin.bevel]
|
||||
/// join to be used all the time.
|
||||
///
|
||||
/// {@animation joinMiter 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/miter_0_join.mp4}
|
||||
///
|
||||
/// {@animation joinMiter 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/miter_4_join.mp4}
|
||||
///
|
||||
/// {@animation joinMiter 300 300 https://flutter.github.io/assets-for-api-docs/assets/dart-ui/miter_6_join.mp4}
|
||||
///
|
||||
/// The centers of the line segments are colored in the diagrams above to
|
||||
/// highlight the joins, but in normal usage the join is the same color as the
|
||||
/// line.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [strokeJoin] to control the kind of finish to place on the joins
|
||||
/// between segments.
|
||||
/// * [strokeCap] to control what is drawn at the ends of the stroke.
|
||||
double get strokeMiterLimit {
|
||||
return _data.getFloat32(_kStrokeMiterLimitOffset, _kFakeHostEndian);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user