Commit 52324758 authored by Viktor Lidholt's avatar Viktor Lidholt

Merge pull request #567 from vlidholt/master

Adds API docs to sprite ColorSequence and Layer
parents e053b35c db8bdbe6
part of sprites; 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 { class ColorSequence {
/// List of colors.
List<Color> colors; List<Color> colors;
/// List of color stops, normalized values (0.0 to 1.0) and ordered.
List<double> colorStops; List<double> colorStops;
/// Creates a new color sequence from a list of [colors] and a list of
/// [colorStops].
ColorSequence(this.colors, this.colorStops) { ColorSequence(this.colors, this.colorStops) {
assert(colors != null); assert(colors != null);
assert(colorStops != null); assert(colorStops != null);
assert(colors.length == colorStops.length); assert(colors.length == colorStops.length);
} }
/// Creates a new color sequence from a start and an end color.
ColorSequence.fromStartAndEndColor(Color start, Color end) { ColorSequence.fromStartAndEndColor(Color start, Color end) {
colors = [start, end]; colors = [start, end];
colorStops = [0.0, 1.0]; colorStops = [0.0, 1.0];
} }
/// Creates a new color sequence by copying an existing sequence.
ColorSequence.copy(ColorSequence sequence) { ColorSequence.copy(ColorSequence sequence) {
colors = new List<Color>.from(sequence.colors); colors = new List<Color>.from(sequence.colors);
colorStops = new List<double>.from(sequence.colorStops); 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) { Color colorAtPosition(double pos) {
assert(pos >= 0.0 && pos <= 1.0); assert(pos >= 0.0 && pos <= 1.0);
......
part of sprites; 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 { 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; 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]); Layer([Rect this.layerRect = null]);
Paint _cachedPaint = new Paint() Paint _cachedPaint = new Paint()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment