@shopify/react-native-skia
Version:
High-performance React Native Graphics using Skia
26 lines (21 loc) • 785 B
text/typescript
import type { InputRRect, SkRRect } from "../../../skia/types";
import type { DrawingContext, RoundedRectProps } from "../../types";
import { NodeType } from "../../types";
import { processRRect } from "../datatypes";
import { JsiDrawingNode } from "../DrawingNode";
import type { NodeContext } from "../Node";
export class RRectNode extends JsiDrawingNode<RoundedRectProps, InputRRect> {
rect?: SkRRect;
constructor(ctx: NodeContext, props: RoundedRectProps) {
super(ctx, NodeType.RRect, props);
}
protected deriveProps() {
return processRRect(this.Skia, this.props);
}
draw({ canvas, paint }: DrawingContext) {
if (this.derived === undefined) {
throw new Error("RRectNode: rect is undefined");
}
canvas.drawRRect(this.derived, paint);
}
}