From db8bdbe61958148f66f0aa24a6db8acdfef387a2 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Tue, 11 Aug 2015 14:13:57 -0700 Subject: [PATCH] Adds API docs to sprite ColorSequence and Layer --- examples/game/lib/color_secuence.dart | 14 ++++++++++++++ examples/game/lib/layer.dart | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/examples/game/lib/color_secuence.dart b/examples/game/lib/color_secuence.dart index f53f3423ce..9ba85eefca 100644 --- a/examples/game/lib/color_secuence.dart +++ b/examples/game/lib/color_secuence.dart @@ -1,25 +1,39 @@ 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 colors; + + /// List of color stops, normalized values (0.0 to 1.0) and ordered. List 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.from(sequence.colors); colorStops = new List.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); diff --git a/examples/game/lib/layer.dart b/examples/game/lib/layer.dart index 90a31f6d1d..4f8fc1c438 100644 --- a/examples/game/lib/layer.dart +++ b/examples/game/lib/layer.dart @@ -1,8 +1,24 @@ 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()