applyVMobjectStroke method

void applyVMobjectStroke(
  1. Path2D path,
  2. VMobject vmob, {
  3. required bool background,
})

Implementation

void applyVMobjectStroke(Path2D path, VMobject vmob,
    {required bool background}) {
  var strokeWidth = vmob.getStrokeWidth(background: background);

  if (strokeWidth == 0) {
    return;
  }

  var strokeColors = vmob.getStrokeColors(background: background);
  var screenSizeFactor = display.camera.getFrameWidth() / FRAME_WIDTH;
  ctx.lineWidth = strokeWidth * lineWidthMultiple * screenSizeFactor;

  var isTransparent = strokeColors.every((color) => color.a == 0);

  if (strokeColors.isEmpty || isTransparent) {
    return;
  }

  if (strokeColors.length > 1) {
    ctx.strokeStyle = createVMobjectGradient(vmob, strokeColors);
  } else {
    var color = display.applyColorTransformation(
        vmob.getStrokeColor(background: background));
    ctx.strokeStyle = color.toRGBAString();
  }

  ctx.stroke(path);
}