How to use the paper.Color function in paper

To help you get started, we’ve selected a few paper examples, based on popular ways it is used in public projects.

github alexjlockwood / ShapeShifter / src / app / scripts / paper / item / Util.ts View on Github external
const { trimPathStart, trimPathEnd, trimPathOffset } = layer;
    // TODO: make sure this works with compound paths as well (Android behavior is different)
    const pathLength = layer.pathData ? layer.pathData.getPathLength() : 0;
    const dashArray = pathLength
      ? LayerUtil.toStrokeDashArray(trimPathStart, trimPathEnd, trimPathOffset, pathLength)
      : undefined;
    const dashOffset = pathLength
      ? LayerUtil.toStrokeDashOffset(trimPathStart, trimPathEnd, trimPathOffset, pathLength)
      : undefined;
    const f = ColorUtil.parseAndroidColor(fillColor);
    const s = ColorUtil.parseAndroidColor(strokeColor);
    // TODO: import a compound path instead
    return new paper.Path({
      data: { id: layer.id },
      pathData: layer.pathData ? layer.pathData.getPathString() : '',
      fillColor: f ? new paper.Color(f.r, f.g, f.b, f.a * fillAlpha) : undefined,
      strokeColor: s ? new paper.Color(s.r, s.g, s.b, s.a * strokeAlpha) : undefined,
      strokeWidth: layer.strokeWidth,
      miterLimit: layer.strokeMiterLimit,
      strokeJoin: layer.strokeLinejoin,
      strokeCap: layer.strokeLinecap,
      fillRule: layer.fillType === 'evenOdd' ? 'evenodd' : 'nonzero',
      dashArray,
      dashOffset,
    });
  }
github emfmesquita / beyondhelp / src / services / PaperMapService.js View on Github external
const applyColor = (path: Path, color: string) => {
    path.strokeColor = new Color(color);
    const fill = new Color(color);
    fill.alpha = 0.2;
    path.fillColor = fill;
};
github alexjlockwood / ShapeShifter / src / app / modules / editor / scripts / paper / item / PaperLayer.ts View on Github external
function parseAndroidColor(androidColor: string, alpha = 1) {
  const color = ColorUtil.parseAndroidColor(androidColor);
  return color
    ? new paper.Color(color.r / 255, color.g / 255, color.b / 255, (color.a / 255) * alpha)
    : undefined;
}
github CIDARLAB / 3DuF / src / app / view / tools / selectTool.js View on Github external
rectSelect(point1, point2) {
        let rect = new paper.Path.Rectangle(point1, point2);
        rect.fillColor = new paper.Color(0, .3, 1, .4);
        rect.strokeColor = new paper.Color(0, 0, 0);
        rect.strokeWidth = 2;
        rect.selected = true;
        return rect;
    }
}
github mydraft-cc / ui / src / core / utils / paper-helper.ts View on Github external
export function toColor(value: string | number | Color): paper.Color {
        if (value === 'transparent') {
            return new paper.Color(1, 1, 1, 0.0001);
        } else {
            const color = Color.fromValue(value);

            return new paper.Color(color.r, color.g, color.b);
        }
    }
}
github emfmesquita / beyondhelp / src / services / PaperMapService.js View on Github external
const applyColor = (path: Path, color: string) => {
    path.strokeColor = new Color(color);
    const fill = new Color(color);
    fill.alpha = 0.2;
    path.fillColor = fill;
};
github CIDARLAB / 3DuF / src / app / view / tools / mouseSelectTool.js View on Github external
rectSelect(point1, point2) {
        let rect = new paper.Path.Rectangle(point1, point2);
        rect.fillColor = new paper.Color(0, .3, 1, .4);
        rect.strokeColor = new paper.Color(0, 0, 0);
        rect.strokeWidth = 2;
        rect.selected = true;
        return rect;
    }
}
github fponticelli / tempo / demo / paper / src / path_simplification / sample.ts View on Github external
}
          }
        },
        path(
          {
            segments: state => state.current,
            selected: true
          }
        ),
        iterate(
          { getArray: (state: State) => state.paths },
          path<[Segment[], State, number], Action>(
            {
              segments: ([segments]) => segments,
              strokeWidth: 2,
              strokeColor: new Color(0.75, 0.75, 0.75),
              selected: ([_, state, index]) => state.paths.length - 1 === index
            }
          )
        )
      )
    )
  )