@@ -4646,23 +4646,32 @@ base class Shader extends NativeFieldWrapperClass1 {
4646
4646
}
4647
4647
}
4648
4648
4649
- /// Defines what happens at the edge of a gradient or the sampling of a source image
4650
- /// in an [ImageFilter] .
4649
+ /// Defines how to handle areas outside the defined bounds of a gradient or image filter.
4651
4650
///
4652
- /// A gradient is defined along a finite inner area. In the case of a linear
4653
- /// gradient, it's between the parallel lines that are orthogonal to the line
4654
- /// drawn between two points. In the case of radial gradients, it's the disc
4655
- /// that covers the circle centered on a particular point up to a given radius.
4651
+ /// ## For Gradients
4656
4652
///
4657
- /// An image filter reads source samples from a source image and performs operations
4658
- /// on those samples to produce a result image. An image defines color samples only
4659
- /// for pixels within the bounds of the image but some filter operations, such as a blur
4660
- /// filter, read samples over a wide area to compute the output for a given pixel. Such
4661
- /// a filter would need to combine samples from inside the image with hypothetical
4662
- /// color values from outside the image.
4653
+ /// Gradients are defined with some specific bounds creating an inner area and an outer area, and `TileMode` controls how colors
4654
+ /// are determined for areas outside these bounds:
4663
4655
///
4664
- /// This enum is used to define how the gradient or image filter should treat the regions
4665
- /// outside that defined inner area.
4656
+ /// - **Linear gradients**: The inner area is the area between two points
4657
+ /// (typically referred to as `start` and `end` in the gradient API), or more precisely,
4658
+ /// it's the area between the parallel lines that are orthogonal to the line drawn between the two points.
4659
+ /// Colors outside this area are determined by the `TileMode` .
4660
+ ///
4661
+ /// - **Radial gradients**: The inner area is the disc defined by a center and radius.
4662
+ /// Colors outside this disc are determined by the `TileMode` .
4663
+ ///
4664
+ /// - **Sweep gradients**: The inner area is the angular sector between `startAngle`
4665
+ /// and `endAngle` . Colors outside this sector are determined by the `TileMode` .
4666
+ ///
4667
+ /// ## For Image Filters
4668
+ ///
4669
+ /// When applying filters (like blur) that sample colors from outside an image's bounds,
4670
+ /// `TileMode` defines how those out-of-bounds samples are determined:
4671
+ ///
4672
+ /// - It controls what color values are used when the filter needs to sample
4673
+ /// from areas outside the original image.
4674
+ /// - This is particularly important for effects like blurring near image edges.
4666
4675
///
4667
4676
/// See also:
4668
4677
///
@@ -4680,8 +4689,12 @@ base class Shader extends NativeFieldWrapperClass1 {
4680
4689
enum TileMode {
4681
4690
/// Samples beyond the edge are clamped to the nearest color in the defined inner area.
4682
4691
///
4683
- /// A gradient will paint all the regions outside the inner area with the
4684
- /// color at the end of the color stop list closest to that region.
4692
+ /// For gradients, this means the region outside the inner area is painted with
4693
+ /// the color at the end of the color stop list closest to that region.
4694
+ ///
4695
+ /// For sweep gradients specifically, the entire area outside the angular sector
4696
+ /// defined by [startAngle] and [endAngle] will be painted with the color at the
4697
+ /// end of the color stop list closest to that region.
4685
4698
///
4686
4699
/// An image filter will substitute the nearest edge pixel for any samples taken from
4687
4700
/// outside its source image.
@@ -4697,6 +4710,9 @@ enum TileMode {
4697
4710
/// repeated from 1.0 to 2.0, 2.0 to 3.0, and so forth (and for linear gradients, similarly
4698
4711
/// from -1.0 to 0.0, -2.0 to -1.0, etc).
4699
4712
///
4713
+ /// For sweep gradients, the gradient pattern is repeated in the same direction
4714
+ /// (clockwise) for angles beyond [endAngle] and before [startAngle] .
4715
+ ///
4700
4716
/// An image filter will treat its source image as if it were tiled across the enlarged
4701
4717
/// sample space from which it reads, each tile in the same orientation as the base image.
4702
4718
///
@@ -4712,6 +4728,9 @@ enum TileMode {
4712
4728
/// again from 4.0 to 3.0, and so forth (and for linear gradients, similarly in the
4713
4729
/// negative direction).
4714
4730
///
4731
+ /// For sweep gradients, the gradient pattern is mirrored back and forth as the angle
4732
+ /// increases beyond [endAngle] or decreases below [startAngle] .
4733
+ ///
4715
4734
/// An image filter will treat its source image as tiled in an alternating forwards and
4716
4735
/// backwards or upwards and downwards direction across the sample space from which
4717
4736
/// it is reading.
@@ -4724,8 +4743,11 @@ enum TileMode {
4724
4743
/// Samples beyond the edge are treated as transparent black.
4725
4744
///
4726
4745
/// A gradient will render transparency over any region that is outside the circle of a
4727
- /// radial gradient or outside the parallel lines that define the inner area of a linear
4728
- /// gradient.
4746
+ /// radial gradient, outside the parallel lines that define the inner area of a linear
4747
+ /// gradient, or outside the angular sector of a sweep gradient.
4748
+ ///
4749
+ /// For sweep gradients, only the sector between [startAngle] and [endAngle] will be
4750
+ /// painted; all other areas will be transparent.
4729
4751
///
4730
4752
/// An image filter will substitute transparent black for any sample it must read from
4731
4753
/// outside its source image.
@@ -4933,17 +4955,39 @@ base class Gradient extends Shader {
4933
4955
/// positive angles going clockwise around the `center` .
4934
4956
///
4935
4957
/// If `colorStops` is provided, `colorStops[i]` is a number from 0.0 to 1.0
4936
- /// that specifies where `color[i]` begins in the gradient. If `colorStops` is
4937
- /// not provided, then only two stops, at 0.0 and 1.0, are implied (and
4938
- /// `color` must therefore only have two entries). Stop values less than 0.0
4939
- /// will be rounded up to 0.0 and stop values greater than 1.0 will be rounded
4940
- /// down to 1.0. Each stop value must be greater than or equal to the previous
4941
- /// stop value. Stop values that do not meet this criteria will be rounded up
4942
- /// to the previous stop value.
4958
+ /// that specifies where `colors[i]` begins in the gradient. If `colorStops` is
4959
+ /// not provided, then only two stops, at 0.0 and 1.0, are implied
4960
+ /// (and `colors` must therefore only have two entries). Stop values less than
4961
+ /// 0.0 will be rounded up to 0.0 and stop values greater than 1.0 will be
4962
+ /// rounded down to 1.0. Each stop value must be greater than or equal to the
4963
+ /// previous stop value. Stop values that do not meet this criteria will be
4964
+ /// rounded up to the previous stop value.
4965
+ ///
4966
+ /// The `startAngle` and `endAngle` parameters define the angular sector to be
4967
+ /// painted. Angles are measured in radians clockwise from the positive x-axis.
4968
+ /// Values outside the range `[0, 2π]` are normalized to this range using modulo
4969
+ /// arithmetic. The gradient is only painted in the sector between `startAngle`
4970
+ /// and `endAngle` . The `tileMode` determines how the gradient behaves outside
4971
+ /// this sector.
4972
+ ///
4973
+ /// The `tileMode` argument specifies how the gradient should handle areas
4974
+ /// outside the angular sector defined by `startAngle` and `endAngle` :
4943
4975
///
4944
4976
/// The behavior before `startAngle` and after `endAngle` is described by the
4945
4977
/// `tileMode` argument. For details, see the [TileMode] enum.
4946
4978
///
4979
+ /// * [TileMode.clamp] : The edge colors are extended to infinity.
4980
+ /// * [TileMode.mirror] : The gradient is repeated, alternating direction each time.
4981
+ /// * [TileMode.repeated] : The gradient is repeated in the same direction.
4982
+ /// * [TileMode.decal] : Only the colors within the gradient's angular sector are
4983
+ /// drawn, with transparent black elsewhere.
4984
+ ///
4985
+ /// The [colorStops] argument must have the same number of values as [colors] ,
4986
+ /// if specified. It specifies the position of each color stop between 0.0 and
4987
+ /// 1.0. If it is null, a uniform distribution is assumed. The stop values must
4988
+ /// be in ascending order. A stop value of 0.0 corresponds to [startAngle] , and
4989
+ /// a stop value of 1.0 corresponds to [endAngle] .
4990
+ ///
4947
4991
/// ![] (https://flutter.github.io/assets-for-api-docs/assets/dart-ui/tile_mode_clamp_sweep.png)
4948
4992
/// ![] (https://flutter.github.io/assets-for-api-docs/assets/dart-ui/tile_mode_decal_sweep.png)
4949
4993
/// ![] (https://flutter.github.io/assets-for-api-docs/assets/dart-ui/tile_mode_mirror_sweep.png)
0 commit comments