UNPKG

@shopify/react-native-skia

Version:

High-performance React Native Graphics using Skia

47 lines (37 loc) 1.46 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { BaseHostObject } from "./Host"; import { JsiSkRect } from "./JsiSkRect"; export class JsiSkRRect extends BaseHostObject { static fromValue(CanvasKit, rect) { if (rect instanceof JsiSkRect) { return rect.ref; } return CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect.rect), rect.rx, rect.ry); } constructor(CanvasKit, rect, rx, ry) { // based on https://github.com/google/skia/blob/main/src/core/SkRRect.cpp#L51 if (rx === Infinity || ry === Infinity) { rx = ry = 0; } if (rect.width < rx + rx || rect.height < ry + ry) { // At most one of these two divides will be by zero, and neither numerator is zero. const scale = Math.min(rect.width / (rx + rx), rect.height / (ry + ry)); rx *= scale; ry *= scale; } const ref = CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry); super(CanvasKit, ref, "RRect"); _defineProperty(this, "dispose", () => {// Float32Array }); } get rx() { return this.ref[4]; } get ry() { return this.ref[5]; } get rect() { return new JsiSkRect(this.CanvasKit, Float32Array.of(this.ref[0], this.ref[1], this.ref[2], this.ref[3])); } } //# sourceMappingURL=JsiSkRRect.js.map