Applying Paint Attributes
Paint attributes can be applied in three ways:- As properties on drawing components or groups
- As children of drawing components or groups
- Via Paint component reference for manual assignment
Property-Based Attributes
These attributes can be set directly as props:Child-Based Attributes
These attributes are applied as children:Fills and Strokes
In Skia, paint has astyle property indicating whether it’s a fill or stroke. You can apply multiple paints to a single shape:
- One light blue fill
- Two different stroke paints with different colors and widths
Inheritance
Descendants inherit paint attributes from their ancestors:- The first circle inherits the
lightbluecolor as a fill - The second circle inherits both the color and the stroke styling
Complex Paint Attributes
Shaders and filters are passed as children:Inherited Complex Attributes
Complex attributes also inherit:Manual Paint Assignment
For advanced use cases, create paint instances manually:Common Patterns
Multiple Fills with Opacity
Stroke Over Fill
Gradient with Stroke
Multiple Strokes
Paint Priority
When multiple paint attributes are specified:- Direct props on the component have highest priority
- Paint children are applied in order
- Inherited attributes from parent groups apply if not overridden
Performance Tips
- Reuse paint instances when possible
- Use groups to apply common attributes to multiple shapes
- Avoid creating new paint objects every render
- Cache color values that don’t change
- Use simple blend modes for better performance
See Also
- Paint Properties - Detailed property reference
- Blend Modes - Color blending modes
- Shaders - Gradient and pattern fills
- Group Component - Grouping and inheritance