|
|
|
|
|
|
|
|
|
|
public class LinearGradient : Gradient, IEquatable<LinearGradient> { |
|
|
|
public LinearGradient( |
|
|
|
Alignment begin = null, |
|
|
|
Alignment end = null, |
|
|
|
AlignmentGeometry begin = null, |
|
|
|
AlignmentGeometry end = null, |
|
|
|
List<Color> colors = null, |
|
|
|
List<float> stops = null, |
|
|
|
TileMode tileMode = TileMode.clamp, |
|
|
|
|
|
|
this.tileMode = tileMode; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly Alignment begin; |
|
|
|
public readonly AlignmentGeometry begin; |
|
|
|
public readonly Alignment end; |
|
|
|
public readonly AlignmentGeometry end; |
|
|
|
begin.withinRect(rect), |
|
|
|
end.withinRect(rect), |
|
|
|
begin.resolve(textDirection).withinRect(rect), |
|
|
|
end.resolve(textDirection).withinRect(rect), |
|
|
|
colors, _impliedStops(), |
|
|
|
tileMode, _resolveTransform(rect, textDirection) |
|
|
|
); |
|
|
|
|
|
|
b._impliedStops(), |
|
|
|
t); |
|
|
|
return new LinearGradient( |
|
|
|
begin: Alignment.lerp(a.begin, b.begin, t), |
|
|
|
end: Alignment.lerp(a.end, b.end, t), |
|
|
|
begin: AlignmentGeometry.lerp(a.begin, b.begin, t), |
|
|
|
end: AlignmentGeometry.lerp(a.end, b.end, t), |
|
|
|
colors: interpolated.colors, |
|
|
|
stops: interpolated.stops, |
|
|
|
tileMode: t < 0.5 ? a.tileMode : b.tileMode |
|
|
|
|
|
|
|
|
|
|
public class RadialGradient : Gradient, IEquatable<RadialGradient> { |
|
|
|
public RadialGradient( |
|
|
|
Alignment center = null, |
|
|
|
AlignmentGeometry center = null, |
|
|
|
AlignmentGeometry focal = null, |
|
|
|
float focalRadius = 0.0f, |
|
|
|
this.focal = focal; |
|
|
|
this.focalRadius = focalRadius; |
|
|
|
public readonly Alignment center; |
|
|
|
public readonly AlignmentGeometry center; |
|
|
|
|
|
|
|
public readonly float radius; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Shader createShader(Rect rect, TextDirection? textDirection = null) { |
|
|
|
return ui.Gradient.radial( |
|
|
|
center.withinRect(rect), |
|
|
|
center.resolve(textDirection).withinRect(rect), |
|
|
|
radius * rect.shortestSide, |
|
|
|
colors, _impliedStops(), |
|
|
|
tileMode, |
|
|
|
|
|
|
b._impliedStops(), |
|
|
|
t); |
|
|
|
return new RadialGradient( |
|
|
|
center: Alignment.lerp(a.center, b.center, t), |
|
|
|
center: AlignmentGeometry.lerp(a.center, b.center, t), |
|
|
|
tileMode: t < 0.5 ? a.tileMode : b.tileMode |
|
|
|
tileMode: t < 0.5 ? a.tileMode : b.tileMode, |
|
|
|
focal: AlignmentGeometry.lerp(a.focal, b.focal, t), |
|
|
|
focalRadius: Mathf.Max(0.0f, Mathf.Lerp(a.focalRadius, b.focalRadius, t)) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SweepGradient : Gradient, IEquatable<SweepGradient> { |
|
|
|
public SweepGradient( |
|
|
|
Alignment center = null, |
|
|
|
AlignmentGeometry center = null, |
|
|
|
float startAngle = 0.0f, |
|
|
|
float endAngle = Mathf.PI * 2, |
|
|
|
List<Color> colors = null, |
|
|
|
|
|
|
this.tileMode = tileMode; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly Alignment center; |
|
|
|
public readonly AlignmentGeometry center; |
|
|
|
|
|
|
|
public readonly float startAngle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Shader createShader(Rect rect, TextDirection? textDirection = null) { |
|
|
|
return ui.Gradient.sweep( |
|
|
|
center.withinRect(rect), |
|
|
|
center.resolve(textDirection).withinRect(rect), |
|
|
|
colors, _impliedStops(), |
|
|
|
tileMode, |
|
|
|
startAngle, endAngle, _resolveTransform(rect, textDirection) |
|
|
|