PrimitiveElement constructor
PrimitiveElement({
- required PaintStyle style,
- double? rotation,
- Offset? rotationAxis,
- String? tag,
Creates a primitive element.
Implementation
PrimitiveElement({
required PaintStyle style,
double? rotation,
Offset? rotationAxis,
String? tag,
}) : super(
style: style,
rotation: rotation,
rotationAxis: rotationAxis,
tag: tag,
) {
drawPath(path);
if (style.fillColor != null ||
style.fillGradient != null ||
style.fillShader != null) {
_fillPaint = Paint();
if (style.fillShader != null) {
_fillPaint!.shader = style.fillShader;
} else if (style.fillGradient != null) {
_fillPaint!.shader = style.fillGradient!
.createShader(style.gradientBounds ?? path.getBounds());
} else {
_fillPaint!.color = style.fillColor!;
}
if (style.blendMode != null) {
_fillPaint!.blendMode = style.blendMode!;
}
}
if (style.strokeColor != null || style.strokeGradient != null) {
_strokePaint = Paint();
_strokePaint!.style = PaintingStyle.stroke;
if (style.strokeShader != null) {
_strokePaint!.shader = style.strokeShader;
} else if (style.strokeGradient != null) {
_strokePaint!.shader = style.strokeGradient!
.createShader(style.gradientBounds ?? path.getBounds());
} else {
_strokePaint!.color = style.strokeColor!;
}
if (style.blendMode != null) {
_strokePaint!.blendMode = style.blendMode!;
}
if (style.strokeWidth != null) {
_strokePaint!.strokeWidth = style.strokeWidth!;
}
if (style.strokeCap != null) {
_strokePaint!.strokeCap = style.strokeCap!;
}
if (style.strokeJoin != null) {
_strokePaint!.strokeJoin = style.strokeJoin!;
}
if (style.strokeMiterLimit != null) {
_strokePaint!.strokeMiterLimit = style.strokeMiterLimit!;
}
}
if (style.dash != null) {
_dashPath = dashPath(path,
dashArray: CircularIntervalList(style.dash!),
dashOffset: style.dashOffset);
}
}