Stay organized with collections
Save and categorize content based on your preferences.
Since version 2 as a style for Arc, version 3 as a style for Line
A stroke pattern with individual segments, which can take specified weights and
colors. Of particular use for rendering GOAL_PROGRESS, RANGED_VALUE
and WEIGHTED_ELEMENTS complications.
The WeightedStroke element has the following attributes:
Required attributes
The following attributes are required:
colors
The colors of each element of the weighted stroke, as a space-separated list
of hex values, for example: #FF0000 #00FF00 #0000FF.
When used to render GOAL_PROGRESS or RANGED_VALUE complication data that
supplies color data, or with WEIGHTED_ELEMENTS, colors can be populated
directly with
[COMPLICATION.GOAL_PROGRESS_COLORS], [COMPLICATION.RANGED_VALUE_COLORS], or
[COMPLICATION.WEIGHTED_ELEMENTS_COLORS].
A space-separated list of values, which determine the proportion of the arc or
line taken up by each weight, for example 1.0 2.0 3.0, where the third element
takes up 3 times the angle or length of the first element.
When used to represent data from WEIGHTED_ELEMENTS complication, the
[COMPLICATION.WEIGHTED_ELEMENTS_WEIGHTS] can be passed in directly.
discreteGap
When used on an arc, the angle between each element. When used on a line, the
length between each element. Defaults to 0.0.
interpolate
When set to true, each element N from the weights list has a color
gradient from color N to color N+1 of the colors list, as opposed to a
solid color.
When used to represent data from GOAL_PROGRESS or RANGED_VALUE
complications, you can pass in values for the
[COMPLICATION.GOAL_PROGRESS_COLORS_INTERPOLATE] or
[COMPLICATION.RANGED_VALUE_COLORS_INTERPOLATE] fields directly. When used in
representing WEIGHTED_ELEMENTS complication data, set interpolate to
false.
Defaults to false.
cap
Determine the shape of the edge of the stroke. Supported values are:
BUTT causes the stroke to end with the path, and not project beyond it.
ROUNDcauses the stroke to project out as a semicircle, with the center at
the end of the path.
SQUARE causes the stroke to project out as a square, with the center at
the end of the path.
Inner elements
The WeightedStroke element can contain the following elements:
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-20 UTC.
[null,null,["Last updated 2025-05-20 UTC."],[],[],null,["# WeightedStroke\n\nWatch Face Format version Version 4 Version 3 Version 2 Version 1\n\n*** ** * ** ***\n\n*Since version 2 as a style for `Arc`, version 3 as a style for `Line`*\n\nA stroke pattern with individual segments, which can take specified weights and\ncolors. Of particular use for rendering [GOAL_PROGRESS](/training/wearables/wff/common/transform/transform), [RANGED_VALUE](/training/wearables/wff/common/transform/transform)\nand [WEIGHTED_ELEMENTS](/training/wearables/wff/common/transform/transform) complications.\n\nSyntax\n------\n\n```xml\n\u003cWeightedStroke colors=\"argb-color-list\" thickness=\"float\"\n weights=\"weight-list\" discreteGap=\"float\" interpolate=\"boolean\"\n cap=\"BUTT | ROUND | SQUARE\" /\u003e\n```\n\nAttributes\n----------\n\nThe `WeightedStroke` element has the following attributes:\n\n### Required attributes\n\nThe following attributes are required:\n\n`colors`\n\n: The colors of each element of the weighted stroke, as a space-separated list\n of hex values, for example: `#FF0000 #00FF00 #0000FF`.\n\n: When used to render `GOAL_PROGRESS` or `RANGED_VALUE` complication data that\n supplies color data, or with `WEIGHTED_ELEMENTS`, `colors` can be populated\n directly with\n `[COMPLICATION.GOAL_PROGRESS_COLORS]`, `[COMPLICATION.RANGED_VALUE_COLORS]`, or\n `[COMPLICATION.WEIGHTED_ELEMENTS_COLORS]`.\n\n`thickness`\n\n: The thickness of the stroke expressed as a [float dimension](/training/wearables/wff/common/attributes/dimension-type).\n\n This attribute is [transformable](/training/wearables/wff/common/transform/transform).\n\n### Optional attributes\n\nThe following attributes are optional:\n\n`weights`\n\n: A space-separated list of values, which determine the proportion of the arc or\n line taken up by each weight, for example `1.0 2.0 3.0`, where the third element\n takes up 3 times the angle or length of the first element.\n\n: When used to represent data from `WEIGHTED_ELEMENTS` complication, the\n `[COMPLICATION.WEIGHTED_ELEMENTS_WEIGHTS]` can be passed in directly.\n\n`discreteGap`\n\n: When used on an arc, the angle between each element. When used on a line, the\n length between each element. Defaults to `0.0`.\n\n`interpolate`\n\n: When set to `true`, each element *N* from the `weights` list has a color\n gradient from color *N* to color *N+1* of the `colors` list, as opposed to a\n solid color.\n\n: When used to represent data from `GOAL_PROGRESS` or `RANGED_VALUE`\n complications, you can pass in values for the\n `[COMPLICATION.GOAL_PROGRESS_COLORS_INTERPOLATE]` or\n `[COMPLICATION.RANGED_VALUE_COLORS_INTERPOLATE]` fields directly. When used in\n representing `WEIGHTED_ELEMENTS` complication data, set `interpolate` to\n `false`.\n\n: Defaults to `false`.\n\n`cap`\n\n: Determine the shape of the edge of the stroke. Supported values are:\n\n - `BUTT` causes the stroke to end with the path, and not project beyond it.\n - `ROUND`causes the stroke to project out as a semicircle, with the center at the end of the path.\n - `SQUARE` causes the stroke to project out as a square, with the center at the end of the path.\n\nInner elements\n--------------\n\nThe `WeightedStroke` element can contain the following elements:\n\n- [`Transform`](/training/wearables/wff/common/transform/transform)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [WeightedStroke](/training/wearables/wff/v2/group/part/draw/style/weighted-stroke)\n- [Complication](/training/wearables/wff/complication/complication)\n- [Stroke](/training/wearables/wff/v2/group/part/draw/style/stroke)"]]