iOS porting: Main screen and compositor

This commit is contained in:
James Babcock committed 2026-09-05 22:59:37 -07:00
1 parent 61b3bf8b7c
commit 99793a37a7
24 files changed
+1124 -70

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { ImageSource } from '@nativescript/core'
import { GrayImage } from '../graphics/image'
declare const FaceclawGraphics: any
export function previewPixels(pixels: Uint8Array, width: number, height: number, green = false): ImageSource {
// NSData copies the buffer; the UIImage owns its pixels after this call.
const copy = new Uint8Array(pixels)
const data = NSData.dataWithBytesLength(interop.handleof(copy.buffer), copy.byteLength)
const native = FaceclawGraphics.previewWidthHeightGreen(data, width, height, green)
if (!native) throw new Error('Could not create preview image')
return new ImageSource(native)
}
export function rasterizeSvg(svg: string, size: number): GrayImage | null {
const data = FaceclawGraphics.renderSVGSize(svg, size)
if (!data) return null
const image = new GrayImage(size, size, 0)
image.pixels.set(new Uint8Array(interop.bufferFromData(data)))
return image
}