提交 5054ec3d 编写于 作者: V Viktor Lidholt

Adds API docs to sprite ColorSequence and Layer

上级 4b48c8cf
part of sprites;
/// A sequence of colors representing a gradient or a color transition over
/// time. The sequence is represented by a list of [colors] and a list of
/// [colorStops], the stops are normalized values (0.0 to 1.0) and ordered in
/// the list. Both lists have the same number of elements.
class ColorSequence {
/// List of colors.
List<Color> colors;
/// List of color stops, normalized values (0.0 to 1.0) and ordered.
List<double> colorStops;
/// Creates a new color sequence from a list of [colors] and a list of
/// [colorStops].
ColorSequence(this.colors, this.colorStops) {
assert(colors != null);
assert(colorStops != null);
assert(colors.length == colorStops.length);
}
/// Creates a new color sequence from a start and an end color.
ColorSequence.fromStartAndEndColor(Color start, Color end) {
colors = [start, end];
colorStops = [0.0, 1.0];
}
/// Creates a new color sequence by copying an existing sequence.
ColorSequence.copy(ColorSequence sequence) {
colors = new List<Color>.from(sequence.colors);
colorStops = new List<double>.from(sequence.colorStops);
}
/// Returns the color at a normalized (0.0 to 1.0) position in the color
/// sequence. If a color stop isn't hit, the returned color will be an
/// interpolation of a color between two color stops.
Color colorAtPosition(double pos) {
assert(pos >= 0.0 && pos <= 1.0);
......
part of sprites;
/// A [Node] that provides an intermediate rendering surface in the sprite
/// rendering tree. A [Layer] can be used to change the opacity, color, or to
/// apply an effect to a set of nodes. All nodes that are children to the
/// [Layer] will be rendered into the surface. If the area that is needed for
/// the children to be drawn is know, the [layerRect] property should be set as
/// this can enhance performance.
class Layer extends Node with SpritePaint {
/// The area that the children of the [Layer] will occupy. This value is
/// treated as a hint to the rendering system and may in some cases be
/// ignored. If the area isn't known, the layerRect can be set to [null].
///
/// myLayer.layerRect = new Rect.fromLTRB(0.0, 0.0, 200.0, 100.0);
Rect layerRect;
/// Creates a new layer. The layerRect can optionally be passed as an argument
/// if it is known.
///
/// var myLayer = new Layer();
Layer([Rect this.layerRect = null]);
Paint _cachedPaint = new Paint()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册