@shopify/react-native-skia
Version:
High-performance React Native Graphics using Skia
81 lines (71 loc) • 1.48 kB
JavaScript
import { HostObject } from "./Host";
export class JsiSkParagraph extends HostObject {
constructor(CanvasKit, ref) {
super(CanvasKit, ref, "Paragraph");
}
layout(width) {
this.ref.layout(width);
}
paint(canvas, x, y) {
canvas.ref.drawParagraph(this.ref, x, y);
}
getHeight() {
return this.ref.getHeight();
}
getMaxWidth() {
return this.ref.getMaxWidth();
}
getGlyphPositionAtCoordinate(x, y) {
return this.ref.getGlyphPositionAtCoordinate(x, y).pos;
}
getRectsForPlaceholders() {
return this.ref.getRectsForPlaceholders().map(_ref => {
let {
rect,
dir
} = _ref;
return {
rect: {
x: rect.at(0),
y: rect.at(1),
width: rect.at(2),
height: rect.at(3)
},
direction: dir.value
};
});
}
getRectsForRange(start, end) {
return this.ref.getRectsForRange(start, end, {
value: 0
}
/** kTight */
, {
value: 0
}
/** kTight */
).map(_ref2 => {
let {
rect
} = _ref2;
return {
x: rect[0],
y: rect[1],
width: rect[2],
height: rect[3]
};
});
}
getLineMetrics() {
return this.ref.getLineMetrics().map((r, index) => ({
x: r.left,
y: index * r.height,
width: r.width,
height: r.height
}));
}
dispose() {
this.ref.delete();
}
}
//# sourceMappingURL=JsiSkParagraph.js.map