setStroke method

void setStroke({
  1. Color? color,
  2. List<Color>? colors,
  3. double? width,
  4. bool background = false,
  5. bool family = true,
})

Implementation

void setStroke(
    {Color? color,
    List<Color>? colors,
    double? width,
    bool background = false,
    bool family = true}) {
  // if both color and colors are set, append color to colors list
  colors = [if (colors != null) ...colors, if (color != null) color];

  if (family) {
    for (var mob in getVectorizedFamily()) {
      mob.setStroke(
          colors: colors,
          width: width,
          background: background,
          family: false);
    }
  }

  if (colors.isNotEmpty) {
    if (background) {
      backgroundStrokeColors ??= colors;

      if (backgroundStrokeColors!.length < colors.length) {
        backgroundStrokeColors =
            stretchListToLength(backgroundStrokeColors!, colors.length);
      } else if (colors.length < backgroundStrokeColors!.length) {
        backgroundStrokeColors =
            stretchListToLength(colors, backgroundStrokeColors!.length);
      }

      strokeColors = [
        for (var i in range(end: strokeColors!.length)) colors[i]
      ];
    } else {
      strokeColors ??= colors;

      if (strokeColors!.length < colors.length) {
        strokeColors = stretchListToLength(strokeColors!, colors.length);
      } else if (colors.length < strokeColors!.length) {
        strokeColors = stretchListToLength(colors, strokeColors!.length);
      }

      strokeColors = [
        for (var i in range(end: strokeColors!.length)) colors[i]
      ];
    }
  }

  if (width != null) {
    if (background) {
      backgroundStrokeWidth = width;
    } else {
      strokeWidth = width;
    }
  }
}