@shopify/react-native-skia
Version:
High-performance React Native Graphics using Skia
56 lines (55 loc) • 1.35 kB
JavaScript
import { enumKey, processColor } from "../../../dom/nodes";
import { BlendMode, PaintStyle, StrokeCap, StrokeJoin } from "../../../skia/types";
export const setPaintProperties = (Skia, ctx, {
opacity,
color,
blendMode,
strokeWidth,
style,
strokeJoin,
strokeCap,
strokeMiter,
antiAlias,
dither
}, standalone) => {
"worklet";
const {
paint
} = ctx;
if (opacity !== undefined) {
if (standalone) {
paint.setAlphaf(paint.getAlphaf() * opacity);
} else {
ctx.setOpacity(ctx.getOpacity() * opacity);
}
}
if (color !== undefined) {
paint.setShader(null);
paint.setColor(processColor(Skia, color));
}
if (blendMode !== undefined) {
paint.setBlendMode(BlendMode[enumKey(blendMode)]);
}
if (strokeWidth !== undefined) {
paint.setStrokeWidth(strokeWidth);
}
if (style !== undefined) {
paint.setStyle(PaintStyle[enumKey(style)]);
}
if (strokeJoin !== undefined) {
paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);
}
if (strokeCap !== undefined) {
paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);
}
if (strokeMiter !== undefined) {
paint.setStrokeMiter(strokeMiter);
}
if (antiAlias !== undefined) {
paint.setAntiAlias(antiAlias);
}
if (dither !== undefined) {
paint.setDither(dither);
}
};
//# sourceMappingURL=Paint.js.map