copyWith method

Sp3dMaterial copyWith({
  1. Color? bg,
  2. bool? isFill,
  3. double? strokeWidth,
  4. Color? strokeColor,
  5. int? imageIndex,
  6. List<Offset>? textureCoordinates,
  7. String? name,
  8. Map<String, dynamic>? option,
})

Creates a copy with only the specified values rewritten.

  • bg : Background color
  • isFill : If true, fill by bg color.
  • strokeWidth : Stroke width.
  • strokeColor : Stroke color.
  • imageIndex : Invalid if null. When fill is enabled and there are 4 vertex, fill with image with the clockwise order as the vertices from the upper left.
  • textureCoordinates : You can specify the part of the image that you want to cut out and use. Use by specifying the coordinate information for the image. Specify the coordinates counterclockwise with a triangle(3 vertices) or rectangle(There are two triangles. 6 vertices).
  • name : The material name.
  • option : Optional attributes that may be added for each app.

Implementation

Sp3dMaterial copyWith(
    {Color? bg,
    bool? isFill,
    double? strokeWidth,
    Color? strokeColor,
    int? imageIndex,
    List<Offset>? textureCoordinates,
    String? name,
    Map<String, dynamic>? option}) {
  List<Offset>? tCoord;
  if (textureCoordinates == null) {
    if (this.textureCoordinates != null) {
      tCoord = [];
      for (Offset o in this.textureCoordinates!) {
        tCoord.add(Offset(o.dx, o.dy));
      }
    }
  }
  return Sp3dMaterial(
      bg ??
          Color.fromARGB(
              this.bg.alpha, this.bg.red, this.bg.green, this.bg.blue),
      isFill ?? this.isFill,
      strokeWidth ?? this.strokeWidth,
      strokeColor ??
          Color.fromARGB(this.strokeColor.alpha, this.strokeColor.red,
              this.strokeColor.green, this.strokeColor.blue),
      imageIndex: imageIndex ?? this.imageIndex,
      textureCoordinates: textureCoordinates ?? tCoord,
      name: name ?? this.name,
      option: option ?? (option != null ? {...option} : null));
}