export const updatePen = (pen: any, prop: string, render = true) => {
  const v: any = { id: pen.id };
  const rect: any = meta2d.getPenRect(pen);

  v[prop] = pen[prop];
  if (prop === 'x') {
    v.x = rect.x;
  } else if (prop === 'y') {
    v.y = rect.y;
  } else if (prop === 'width') {
    v.height = (rect.width / pen.width) * pen.height;
  } else if (prop === 'height') {
    v.width = (rect.height / pen.height) * pen.width;
  } else if (prop === 'shadow') {
    if (v[prop]) {
      !v.shadowOffsetX && (v.shadowOffsetX = 0);
      !v.shadowOffsetY && (v.shadowOffsetY = 0);
      !v.shadowBlur && (v.shadowBlur = 0);
    } else {
      v.shadowColor = '';
    }
  } else if (prop === 'lineGradientColors') {
    //@ts-ignore
    if (meta2d.store.active[0].name === 'line') {
      //@ts-ignore
      meta2d.store.active[0].calculative.gradientColorStop = null;
    } else {
      //@ts-ignore
      meta2d.store.active[0].calculative.lineGradient = null;
    }
    //不同模式切换不同的系统配色
  } else if (prop === 'titleFnJs') {
    v.titleFn = null;
  } else if (prop === 'dash') {
    v.lineDash = lineDashObj[v[prop]];
  }
  meta2d.setValue(v, { render });
};

export const lineDashObj = [
  undefined,
  [5, 5],
  [10, 10],
  [10, 10, 2, 10],
  [1, 16],
];
