brilliantsole 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/brilliantsole.cjs +213 -0
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +244 -0
- package/build/brilliantsole.ls.js.map +1 -1
- package/build/brilliantsole.min.js.map +1 -1
- package/build/brilliantsole.module.d.ts +22 -22
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +22 -22
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +53 -23
- package/build/brilliantsole.node.module.js +205 -1
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS.d.ts +0 -2
- package/build/index.node.d.ts +31 -1
- package/examples/display-workout/script.js +0 -6
- package/package.json +1 -1
- package/src/BS.ts +0 -2
- package/examples/display-workout/uMyoBLE.js +0 -133
|
@@ -1450,24 +1450,24 @@ declare class Device {
|
|
|
1450
1450
|
get bluetoothId(): string | undefined;
|
|
1451
1451
|
get isAvailable(): boolean | undefined;
|
|
1452
1452
|
constructor();
|
|
1453
|
-
get addEventListener(): <T extends "
|
|
1453
|
+
get addEventListener(): <T extends "pressure" | "getFileTypes" | "maxFileLength" | "getFileType" | "setFileType" | "getFileLength" | "setFileLength" | "getFileChecksum" | "setFileChecksum" | "setFileTransferCommand" | "fileTransferStatus" | "getFileBlock" | "setFileBlock" | "fileBytesTransferred" | "fileTransferProgress" | "fileTransferComplete" | "fileReceived" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "tapDetector" | "barometer" | "camera" | "cameraStatus" | "cameraCommand" | "getCameraConfiguration" | "setCameraConfiguration" | "cameraData" | "cameraImageProgress" | "cameraImage" | "microphone" | "microphoneStatus" | "microphoneCommand" | "getMicrophoneConfiguration" | "setMicrophoneConfiguration" | "microphoneData" | "isRecordingMicrophone" | "microphoneRecording" | "getPressurePositions" | "getSensorScalars" | "sensorData" | "getSensorConfiguration" | "setSensorConfiguration" | "getTfliteName" | "setTfliteName" | "getTfliteTask" | "setTfliteTask" | "getTfliteSampleRate" | "setTfliteSampleRate" | "getTfliteSensorTypes" | "setTfliteSensorTypes" | "tfliteIsReady" | "getTfliteCaptureDelay" | "setTfliteCaptureDelay" | "getTfliteThreshold" | "setTfliteThreshold" | "getTfliteInferencingEnabled" | "setTfliteInferencingEnabled" | "tfliteInference" | "manufacturerName" | "modelNumber" | "hardwareRevision" | "firmwareRevision" | "softwareRevision" | "pnpId" | "serialNumber" | "deviceInformation" | "isCharging" | "getBatteryCurrent" | "getMtu" | "getId" | "getName" | "setName" | "getType" | "setType" | "getCurrentTime" | "setCurrentTime" | "getVibrationLocations" | "triggerVibration" | "isWifiAvailable" | "getWifiSSID" | "setWifiSSID" | "getWifiPassword" | "setWifiPassword" | "getWifiConnectionEnabled" | "setWifiConnectionEnabled" | "isWifiConnected" | "ipAddress" | "isWifiSecure" | "spriteSheetIndex" | "isConnected" | "connectionMessage" | "notConnected" | "connecting" | "connected" | "disconnecting" | "connectionStatus" | "rx" | "tx" | "batteryLevel" | "isDisplayAvailable" | "displayStatus" | "displayInformation" | "displayCommand" | "getDisplayBrightness" | "setDisplayBrightness" | "displayContextCommands" | "displayReady" | "getSpriteSheetName" | "setSpriteSheetName" | "displayContextState" | "displayColor" | "displayColorOpacity" | "displayOpacity" | "displaySpriteSheetUploadStart" | "displaySpriteSheetUploadProgress" | "displaySpriteSheetUploadComplete" | "smp" | "firmwareImages" | "firmwareUploadProgress" | "firmwareStatus" | "firmwareUploadComplete">(type: T, listener: (event: {
|
|
1454
1454
|
type: T;
|
|
1455
1455
|
target: Device;
|
|
1456
1456
|
message: DeviceEventMessages[T];
|
|
1457
1457
|
}) => void, options?: {
|
|
1458
1458
|
once?: boolean;
|
|
1459
1459
|
}) => void;
|
|
1460
|
-
get removeEventListener(): <T extends "
|
|
1460
|
+
get removeEventListener(): <T extends "pressure" | "getFileTypes" | "maxFileLength" | "getFileType" | "setFileType" | "getFileLength" | "setFileLength" | "getFileChecksum" | "setFileChecksum" | "setFileTransferCommand" | "fileTransferStatus" | "getFileBlock" | "setFileBlock" | "fileBytesTransferred" | "fileTransferProgress" | "fileTransferComplete" | "fileReceived" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "tapDetector" | "barometer" | "camera" | "cameraStatus" | "cameraCommand" | "getCameraConfiguration" | "setCameraConfiguration" | "cameraData" | "cameraImageProgress" | "cameraImage" | "microphone" | "microphoneStatus" | "microphoneCommand" | "getMicrophoneConfiguration" | "setMicrophoneConfiguration" | "microphoneData" | "isRecordingMicrophone" | "microphoneRecording" | "getPressurePositions" | "getSensorScalars" | "sensorData" | "getSensorConfiguration" | "setSensorConfiguration" | "getTfliteName" | "setTfliteName" | "getTfliteTask" | "setTfliteTask" | "getTfliteSampleRate" | "setTfliteSampleRate" | "getTfliteSensorTypes" | "setTfliteSensorTypes" | "tfliteIsReady" | "getTfliteCaptureDelay" | "setTfliteCaptureDelay" | "getTfliteThreshold" | "setTfliteThreshold" | "getTfliteInferencingEnabled" | "setTfliteInferencingEnabled" | "tfliteInference" | "manufacturerName" | "modelNumber" | "hardwareRevision" | "firmwareRevision" | "softwareRevision" | "pnpId" | "serialNumber" | "deviceInformation" | "isCharging" | "getBatteryCurrent" | "getMtu" | "getId" | "getName" | "setName" | "getType" | "setType" | "getCurrentTime" | "setCurrentTime" | "getVibrationLocations" | "triggerVibration" | "isWifiAvailable" | "getWifiSSID" | "setWifiSSID" | "getWifiPassword" | "setWifiPassword" | "getWifiConnectionEnabled" | "setWifiConnectionEnabled" | "isWifiConnected" | "ipAddress" | "isWifiSecure" | "spriteSheetIndex" | "isConnected" | "connectionMessage" | "notConnected" | "connecting" | "connected" | "disconnecting" | "connectionStatus" | "rx" | "tx" | "batteryLevel" | "isDisplayAvailable" | "displayStatus" | "displayInformation" | "displayCommand" | "getDisplayBrightness" | "setDisplayBrightness" | "displayContextCommands" | "displayReady" | "getSpriteSheetName" | "setSpriteSheetName" | "displayContextState" | "displayColor" | "displayColorOpacity" | "displayOpacity" | "displaySpriteSheetUploadStart" | "displaySpriteSheetUploadProgress" | "displaySpriteSheetUploadComplete" | "smp" | "firmwareImages" | "firmwareUploadProgress" | "firmwareStatus" | "firmwareUploadComplete">(type: T, listener: (event: {
|
|
1461
1461
|
type: T;
|
|
1462
1462
|
target: Device;
|
|
1463
1463
|
message: DeviceEventMessages[T];
|
|
1464
1464
|
}) => void) => void;
|
|
1465
|
-
get waitForEvent(): <T extends "
|
|
1465
|
+
get waitForEvent(): <T extends "pressure" | "getFileTypes" | "maxFileLength" | "getFileType" | "setFileType" | "getFileLength" | "setFileLength" | "getFileChecksum" | "setFileChecksum" | "setFileTransferCommand" | "fileTransferStatus" | "getFileBlock" | "setFileBlock" | "fileBytesTransferred" | "fileTransferProgress" | "fileTransferComplete" | "fileReceived" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "tapDetector" | "barometer" | "camera" | "cameraStatus" | "cameraCommand" | "getCameraConfiguration" | "setCameraConfiguration" | "cameraData" | "cameraImageProgress" | "cameraImage" | "microphone" | "microphoneStatus" | "microphoneCommand" | "getMicrophoneConfiguration" | "setMicrophoneConfiguration" | "microphoneData" | "isRecordingMicrophone" | "microphoneRecording" | "getPressurePositions" | "getSensorScalars" | "sensorData" | "getSensorConfiguration" | "setSensorConfiguration" | "getTfliteName" | "setTfliteName" | "getTfliteTask" | "setTfliteTask" | "getTfliteSampleRate" | "setTfliteSampleRate" | "getTfliteSensorTypes" | "setTfliteSensorTypes" | "tfliteIsReady" | "getTfliteCaptureDelay" | "setTfliteCaptureDelay" | "getTfliteThreshold" | "setTfliteThreshold" | "getTfliteInferencingEnabled" | "setTfliteInferencingEnabled" | "tfliteInference" | "manufacturerName" | "modelNumber" | "hardwareRevision" | "firmwareRevision" | "softwareRevision" | "pnpId" | "serialNumber" | "deviceInformation" | "isCharging" | "getBatteryCurrent" | "getMtu" | "getId" | "getName" | "setName" | "getType" | "setType" | "getCurrentTime" | "setCurrentTime" | "getVibrationLocations" | "triggerVibration" | "isWifiAvailable" | "getWifiSSID" | "setWifiSSID" | "getWifiPassword" | "setWifiPassword" | "getWifiConnectionEnabled" | "setWifiConnectionEnabled" | "isWifiConnected" | "ipAddress" | "isWifiSecure" | "spriteSheetIndex" | "isConnected" | "connectionMessage" | "notConnected" | "connecting" | "connected" | "disconnecting" | "connectionStatus" | "rx" | "tx" | "batteryLevel" | "isDisplayAvailable" | "displayStatus" | "displayInformation" | "displayCommand" | "getDisplayBrightness" | "setDisplayBrightness" | "displayContextCommands" | "displayReady" | "getSpriteSheetName" | "setSpriteSheetName" | "displayContextState" | "displayColor" | "displayColorOpacity" | "displayOpacity" | "displaySpriteSheetUploadStart" | "displaySpriteSheetUploadProgress" | "displaySpriteSheetUploadComplete" | "smp" | "firmwareImages" | "firmwareUploadProgress" | "firmwareStatus" | "firmwareUploadComplete">(type: T) => Promise<{
|
|
1466
1466
|
type: T;
|
|
1467
1467
|
target: Device;
|
|
1468
1468
|
message: DeviceEventMessages[T];
|
|
1469
1469
|
}>;
|
|
1470
|
-
get removeEventListeners(): <T extends "
|
|
1470
|
+
get removeEventListeners(): <T extends "pressure" | "getFileTypes" | "maxFileLength" | "getFileType" | "setFileType" | "getFileLength" | "setFileLength" | "getFileChecksum" | "setFileChecksum" | "setFileTransferCommand" | "fileTransferStatus" | "getFileBlock" | "setFileBlock" | "fileBytesTransferred" | "fileTransferProgress" | "fileTransferComplete" | "fileReceived" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "tapDetector" | "barometer" | "camera" | "cameraStatus" | "cameraCommand" | "getCameraConfiguration" | "setCameraConfiguration" | "cameraData" | "cameraImageProgress" | "cameraImage" | "microphone" | "microphoneStatus" | "microphoneCommand" | "getMicrophoneConfiguration" | "setMicrophoneConfiguration" | "microphoneData" | "isRecordingMicrophone" | "microphoneRecording" | "getPressurePositions" | "getSensorScalars" | "sensorData" | "getSensorConfiguration" | "setSensorConfiguration" | "getTfliteName" | "setTfliteName" | "getTfliteTask" | "setTfliteTask" | "getTfliteSampleRate" | "setTfliteSampleRate" | "getTfliteSensorTypes" | "setTfliteSensorTypes" | "tfliteIsReady" | "getTfliteCaptureDelay" | "setTfliteCaptureDelay" | "getTfliteThreshold" | "setTfliteThreshold" | "getTfliteInferencingEnabled" | "setTfliteInferencingEnabled" | "tfliteInference" | "manufacturerName" | "modelNumber" | "hardwareRevision" | "firmwareRevision" | "softwareRevision" | "pnpId" | "serialNumber" | "deviceInformation" | "isCharging" | "getBatteryCurrent" | "getMtu" | "getId" | "getName" | "setName" | "getType" | "setType" | "getCurrentTime" | "setCurrentTime" | "getVibrationLocations" | "triggerVibration" | "isWifiAvailable" | "getWifiSSID" | "setWifiSSID" | "getWifiPassword" | "setWifiPassword" | "getWifiConnectionEnabled" | "setWifiConnectionEnabled" | "isWifiConnected" | "ipAddress" | "isWifiSecure" | "spriteSheetIndex" | "isConnected" | "connectionMessage" | "notConnected" | "connecting" | "connected" | "disconnecting" | "connectionStatus" | "rx" | "tx" | "batteryLevel" | "isDisplayAvailable" | "displayStatus" | "displayInformation" | "displayCommand" | "getDisplayBrightness" | "setDisplayBrightness" | "displayContextCommands" | "displayReady" | "getSpriteSheetName" | "setSpriteSheetName" | "displayContextState" | "displayColor" | "displayColorOpacity" | "displayOpacity" | "displaySpriteSheetUploadStart" | "displaySpriteSheetUploadProgress" | "displaySpriteSheetUploadComplete" | "smp" | "firmwareImages" | "firmwareUploadProgress" | "firmwareStatus" | "firmwareUploadComplete">(type: T) => void;
|
|
1471
1471
|
get removeAllEventListeners(): () => void;
|
|
1472
1472
|
get connectionManager(): BaseConnectionManager | undefined;
|
|
1473
1473
|
set connectionManager(newConnectionManager: BaseConnectionManager | undefined);
|
|
@@ -1481,7 +1481,7 @@ declare class Device {
|
|
|
1481
1481
|
static set ReconnectOnDisconnection(newReconnectOnDisconnection: boolean);
|
|
1482
1482
|
get reconnectOnDisconnection(): boolean;
|
|
1483
1483
|
set reconnectOnDisconnection(newReconnectOnDisconnection: boolean);
|
|
1484
|
-
get connectionType(): "
|
|
1484
|
+
get connectionType(): "webBluetooth" | "noble" | "client" | "webSocket" | "udp" | undefined;
|
|
1485
1485
|
disconnect(): Promise<void>;
|
|
1486
1486
|
toggleConnection(): void;
|
|
1487
1487
|
get connectionStatus(): ConnectionStatus;
|
|
@@ -1501,10 +1501,10 @@ declare class Device {
|
|
|
1501
1501
|
get setType(): (newType: DeviceType) => Promise<void>;
|
|
1502
1502
|
get isInsole(): boolean;
|
|
1503
1503
|
get isGlove(): boolean;
|
|
1504
|
-
get side(): "
|
|
1504
|
+
get side(): "left" | "right";
|
|
1505
1505
|
get mtu(): number;
|
|
1506
1506
|
get sensorTypes(): SensorType[];
|
|
1507
|
-
get continuousSensorTypes(): ("
|
|
1507
|
+
get continuousSensorTypes(): ("pressure" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "barometer")[];
|
|
1508
1508
|
get sensorConfiguration(): SensorConfiguration;
|
|
1509
1509
|
get setSensorConfiguration(): (newSensorConfiguration: SensorConfiguration, clearRest?: boolean, sendImmediately?: boolean) => Promise<void>;
|
|
1510
1510
|
clearSensorConfiguration(): Promise<void>;
|
|
@@ -1516,9 +1516,9 @@ declare class Device {
|
|
|
1516
1516
|
resetPressureRange(): void;
|
|
1517
1517
|
get vibrationLocations(): ("front" | "rear")[];
|
|
1518
1518
|
triggerVibration(vibrationConfigurations: VibrationConfiguration[], sendImmediately?: boolean): Promise<void>;
|
|
1519
|
-
get fileTypes(): ("
|
|
1519
|
+
get fileTypes(): ("tflite" | "wifiServerCert" | "wifiServerKey" | "spriteSheet")[];
|
|
1520
1520
|
get maxFileLength(): number;
|
|
1521
|
-
get validFileTypes(): ("
|
|
1521
|
+
get validFileTypes(): ("tflite" | "wifiServerCert" | "wifiServerKey" | "spriteSheet")[];
|
|
1522
1522
|
sendFile(fileType: FileType, file: FileLike): Promise<void>;
|
|
1523
1523
|
receiveFile(fileType: FileType): Promise<void>;
|
|
1524
1524
|
get fileTransferStatus(): "idle" | "sending" | "receiving";
|
|
@@ -1531,7 +1531,7 @@ declare class Device {
|
|
|
1531
1531
|
get tfliteSampleRate(): number;
|
|
1532
1532
|
get setTfliteSampleRate(): (newSampleRate: number, sendImmediately?: boolean) => Promise<void>;
|
|
1533
1533
|
get tfliteSensorTypes(): ("pressure" | "linearAcceleration" | "gyroscope" | "magnetometer")[];
|
|
1534
|
-
get allowedTfliteSensorTypes(): ("
|
|
1534
|
+
get allowedTfliteSensorTypes(): ("pressure" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "tapDetector" | "barometer" | "camera" | "microphone")[];
|
|
1535
1535
|
get setTfliteSensorTypes(): (newSensorTypes: SensorType[], sendImmediately?: boolean) => Promise<void>;
|
|
1536
1536
|
get tfliteIsReady(): boolean;
|
|
1537
1537
|
get tfliteInferencingEnabled(): boolean;
|
|
@@ -1584,7 +1584,7 @@ declare class Device {
|
|
|
1584
1584
|
get cameraConfigurationRanges(): CameraConfigurationRanges;
|
|
1585
1585
|
get setCameraConfiguration(): (newCameraConfiguration: CameraConfiguration) => Promise<void>;
|
|
1586
1586
|
get hasMicrophone(): boolean;
|
|
1587
|
-
get microphoneStatus(): "idle" | "
|
|
1587
|
+
get microphoneStatus(): "idle" | "vad" | "streaming";
|
|
1588
1588
|
startMicrophone(sensorRate?: number): Promise<void>;
|
|
1589
1589
|
stopMicrophone(): Promise<void>;
|
|
1590
1590
|
enableMicrophoneVad(): Promise<void>;
|
|
@@ -1764,19 +1764,19 @@ declare class DeviceManager {
|
|
|
1764
1764
|
* _only available on web-bluetooth enabled browsers_
|
|
1765
1765
|
*/
|
|
1766
1766
|
GetDevices(): Promise<Device[] | undefined>;
|
|
1767
|
-
get AddEventListener(): <T extends "deviceIsConnected" | "deviceConnected" | "
|
|
1767
|
+
get AddEventListener(): <T extends "deviceIsConnected" | "deviceConnected" | "deviceDisconnected" | "availableDevices" | "connectedDevices">(type: T, listener: (event: {
|
|
1768
1768
|
type: T;
|
|
1769
1769
|
target: DeviceManager;
|
|
1770
1770
|
message: DeviceManagerEventMessages[T];
|
|
1771
1771
|
}) => void, options?: {
|
|
1772
1772
|
once?: boolean;
|
|
1773
1773
|
}) => void;
|
|
1774
|
-
get RemoveEventListener(): <T extends "deviceIsConnected" | "deviceConnected" | "
|
|
1774
|
+
get RemoveEventListener(): <T extends "deviceIsConnected" | "deviceConnected" | "deviceDisconnected" | "availableDevices" | "connectedDevices">(type: T, listener: (event: {
|
|
1775
1775
|
type: T;
|
|
1776
1776
|
target: DeviceManager;
|
|
1777
1777
|
message: DeviceManagerEventMessages[T];
|
|
1778
1778
|
}) => void) => void;
|
|
1779
|
-
get RemoveEventListeners(): <T extends "deviceIsConnected" | "deviceConnected" | "
|
|
1779
|
+
get RemoveEventListeners(): <T extends "deviceIsConnected" | "deviceConnected" | "deviceDisconnected" | "availableDevices" | "connectedDevices">(type: T) => void;
|
|
1780
1780
|
get RemoveAllEventListeners(): () => void;
|
|
1781
1781
|
_CheckDeviceAvailability(device: Device): void;
|
|
1782
1782
|
}
|
|
@@ -1800,6 +1800,36 @@ declare function simplifyCurves(curves: DisplayBezierCurve[], epsilon?: number):
|
|
|
1800
1800
|
declare function simplifyPoints(points: Vector2[], tolerance?: number): Vector2[];
|
|
1801
1801
|
declare function simplifyPointsAsCubicCurveControlPoints(points: Vector2[], error?: number): Vector2[];
|
|
1802
1802
|
|
|
1803
|
+
declare function quantizeImage(image: HTMLImageElement, width: number, height: number, numberOfColors: number, colors?: string[], canvas?: HTMLCanvasElement): Promise<{
|
|
1804
|
+
blob: Blob;
|
|
1805
|
+
colors: string[];
|
|
1806
|
+
colorIndices: number[];
|
|
1807
|
+
}>;
|
|
1808
|
+
declare function resizeImage(image: CanvasImageSource, width: number, height: number, canvas?: HTMLCanvasElement): HTMLCanvasElement;
|
|
1809
|
+
declare function resizeAndQuantizeImage(image: CanvasImageSource, width: number, height: number, numberOfColors: number, colors?: string[], canvas?: HTMLCanvasElement): Promise<{
|
|
1810
|
+
blob: Blob;
|
|
1811
|
+
colors: string[];
|
|
1812
|
+
colorIndices: number[];
|
|
1813
|
+
}>;
|
|
1814
|
+
declare function canvasToBitmaps(canvas: HTMLCanvasElement, numberOfColors: number, mtu: number): Promise<{
|
|
1815
|
+
bitmapRows: DisplayBitmap[][];
|
|
1816
|
+
colors: string[];
|
|
1817
|
+
}>;
|
|
1818
|
+
declare function imageToBitmaps(image: HTMLImageElement, width: number, height: number, numberOfColors: number, mtu: number): Promise<{
|
|
1819
|
+
bitmapRows: DisplayBitmap[][];
|
|
1820
|
+
colors: string[];
|
|
1821
|
+
}>;
|
|
1822
|
+
declare function canvasToSprite(canvas: HTMLCanvasElement, spriteName: string, numberOfColors: number, paletteName: string, overridePalette: boolean, spriteSheet: DisplaySpriteSheet, paletteOffset?: number): Promise<{
|
|
1823
|
+
sprite: DisplaySprite;
|
|
1824
|
+
blob: Blob;
|
|
1825
|
+
}>;
|
|
1826
|
+
declare function imageToSprite(image: HTMLImageElement, spriteName: string, width: number, height: number, numberOfColors: number, paletteName: string, overridePalette: boolean, spriteSheet: DisplaySpriteSheet, paletteOffset?: number): Promise<{
|
|
1827
|
+
sprite: DisplaySprite;
|
|
1828
|
+
blob: Blob;
|
|
1829
|
+
}>;
|
|
1830
|
+
declare function canvasToSpriteSheet(canvas: HTMLCanvasElement, spriteSheetName: string, numberOfColors: number, paletteName: string, maxFileLength?: number): Promise<DisplaySpriteSheet>;
|
|
1831
|
+
declare function imageToSpriteSheet(image: HTMLImageElement, spriteSheetName: string, width: number, height: number, numberOfColors: number, paletteName: string, maxFileLength?: number): Promise<DisplaySpriteSheet>;
|
|
1832
|
+
|
|
1803
1833
|
declare function hexToRGB(hex: string): DisplayColorRGB;
|
|
1804
1834
|
declare function rgbToHex({ r, g, b }: DisplayColorRGB): string;
|
|
1805
1835
|
|
|
@@ -1855,24 +1885,24 @@ declare class DevicePair {
|
|
|
1855
1885
|
constructor(type: DevicePairType);
|
|
1856
1886
|
get sides(): readonly ["left", "right"];
|
|
1857
1887
|
get type(): "insoles" | "gloves";
|
|
1858
|
-
get addEventListener(): <T extends "
|
|
1888
|
+
get addEventListener(): <T extends "pressure" | "deviceOrientation" | "sensorData" | "deviceIsConnected" | "deviceConnected" | "deviceNotConnected" | "isConnected" | "devicePressure" | "deviceGetFileTypes" | "deviceMaxFileLength" | "deviceGetFileType" | "deviceGetFileLength" | "deviceGetFileChecksum" | "deviceFileTransferStatus" | "deviceGetFileBlock" | "deviceFileTransferProgress" | "deviceFileTransferComplete" | "deviceFileReceived" | "deviceAcceleration" | "deviceGravity" | "deviceLinearAcceleration" | "deviceGyroscope" | "deviceMagnetometer" | "deviceGameRotation" | "deviceRotation" | "deviceActivity" | "deviceStepCounter" | "deviceStepDetector" | "deviceDeviceOrientation" | "deviceTapDetector" | "deviceBarometer" | "deviceCameraStatus" | "deviceGetCameraConfiguration" | "deviceCameraImageProgress" | "deviceCameraImage" | "deviceMicrophoneStatus" | "deviceGetMicrophoneConfiguration" | "deviceMicrophoneData" | "deviceIsRecordingMicrophone" | "deviceMicrophoneRecording" | "deviceSensorData" | "deviceGetSensorConfiguration" | "deviceGetTfliteName" | "deviceGetTfliteTask" | "deviceGetTfliteSampleRate" | "deviceGetTfliteSensorTypes" | "deviceTfliteIsReady" | "deviceGetTfliteCaptureDelay" | "deviceGetTfliteThreshold" | "deviceGetTfliteInferencingEnabled" | "deviceTfliteInference" | "deviceManufacturerName" | "deviceModelNumber" | "deviceHardwareRevision" | "deviceFirmwareRevision" | "deviceSoftwareRevision" | "devicePnpId" | "deviceSerialNumber" | "deviceDeviceInformation" | "deviceIsCharging" | "deviceGetBatteryCurrent" | "deviceGetMtu" | "deviceGetId" | "deviceGetName" | "deviceGetType" | "deviceGetCurrentTime" | "deviceIsWifiAvailable" | "deviceGetWifiSSID" | "deviceGetWifiPassword" | "deviceIsWifiConnected" | "deviceIpAddress" | "deviceConnectionMessage" | "deviceConnecting" | "deviceDisconnecting" | "deviceConnectionStatus" | "deviceBatteryLevel" | "deviceIsDisplayAvailable" | "deviceDisplayStatus" | "deviceDisplayInformation" | "deviceGetDisplayBrightness" | "deviceDisplayContextCommands" | "deviceDisplayReady" | "deviceGetSpriteSheetName" | "deviceDisplayContextState" | "deviceDisplayColor" | "deviceDisplayColorOpacity" | "deviceDisplayOpacity" | "deviceDisplaySpriteSheetUploadStart" | "deviceDisplaySpriteSheetUploadProgress" | "deviceDisplaySpriteSheetUploadComplete" | "deviceSmp" | "deviceFirmwareImages" | "deviceFirmwareUploadProgress" | "deviceFirmwareStatus" | "deviceGetEnableWifiConnection">(type: T, listener: (event: {
|
|
1859
1889
|
type: T;
|
|
1860
1890
|
target: DevicePair;
|
|
1861
1891
|
message: DevicePairEventMessages[T];
|
|
1862
1892
|
}) => void, options?: {
|
|
1863
1893
|
once?: boolean;
|
|
1864
1894
|
}) => void;
|
|
1865
|
-
get removeEventListener(): <T extends "
|
|
1895
|
+
get removeEventListener(): <T extends "pressure" | "deviceOrientation" | "sensorData" | "deviceIsConnected" | "deviceConnected" | "deviceNotConnected" | "isConnected" | "devicePressure" | "deviceGetFileTypes" | "deviceMaxFileLength" | "deviceGetFileType" | "deviceGetFileLength" | "deviceGetFileChecksum" | "deviceFileTransferStatus" | "deviceGetFileBlock" | "deviceFileTransferProgress" | "deviceFileTransferComplete" | "deviceFileReceived" | "deviceAcceleration" | "deviceGravity" | "deviceLinearAcceleration" | "deviceGyroscope" | "deviceMagnetometer" | "deviceGameRotation" | "deviceRotation" | "deviceActivity" | "deviceStepCounter" | "deviceStepDetector" | "deviceDeviceOrientation" | "deviceTapDetector" | "deviceBarometer" | "deviceCameraStatus" | "deviceGetCameraConfiguration" | "deviceCameraImageProgress" | "deviceCameraImage" | "deviceMicrophoneStatus" | "deviceGetMicrophoneConfiguration" | "deviceMicrophoneData" | "deviceIsRecordingMicrophone" | "deviceMicrophoneRecording" | "deviceSensorData" | "deviceGetSensorConfiguration" | "deviceGetTfliteName" | "deviceGetTfliteTask" | "deviceGetTfliteSampleRate" | "deviceGetTfliteSensorTypes" | "deviceTfliteIsReady" | "deviceGetTfliteCaptureDelay" | "deviceGetTfliteThreshold" | "deviceGetTfliteInferencingEnabled" | "deviceTfliteInference" | "deviceManufacturerName" | "deviceModelNumber" | "deviceHardwareRevision" | "deviceFirmwareRevision" | "deviceSoftwareRevision" | "devicePnpId" | "deviceSerialNumber" | "deviceDeviceInformation" | "deviceIsCharging" | "deviceGetBatteryCurrent" | "deviceGetMtu" | "deviceGetId" | "deviceGetName" | "deviceGetType" | "deviceGetCurrentTime" | "deviceIsWifiAvailable" | "deviceGetWifiSSID" | "deviceGetWifiPassword" | "deviceIsWifiConnected" | "deviceIpAddress" | "deviceConnectionMessage" | "deviceConnecting" | "deviceDisconnecting" | "deviceConnectionStatus" | "deviceBatteryLevel" | "deviceIsDisplayAvailable" | "deviceDisplayStatus" | "deviceDisplayInformation" | "deviceGetDisplayBrightness" | "deviceDisplayContextCommands" | "deviceDisplayReady" | "deviceGetSpriteSheetName" | "deviceDisplayContextState" | "deviceDisplayColor" | "deviceDisplayColorOpacity" | "deviceDisplayOpacity" | "deviceDisplaySpriteSheetUploadStart" | "deviceDisplaySpriteSheetUploadProgress" | "deviceDisplaySpriteSheetUploadComplete" | "deviceSmp" | "deviceFirmwareImages" | "deviceFirmwareUploadProgress" | "deviceFirmwareStatus" | "deviceGetEnableWifiConnection">(type: T, listener: (event: {
|
|
1866
1896
|
type: T;
|
|
1867
1897
|
target: DevicePair;
|
|
1868
1898
|
message: DevicePairEventMessages[T];
|
|
1869
1899
|
}) => void) => void;
|
|
1870
|
-
get waitForEvent(): <T extends "
|
|
1900
|
+
get waitForEvent(): <T extends "pressure" | "deviceOrientation" | "sensorData" | "deviceIsConnected" | "deviceConnected" | "deviceNotConnected" | "isConnected" | "devicePressure" | "deviceGetFileTypes" | "deviceMaxFileLength" | "deviceGetFileType" | "deviceGetFileLength" | "deviceGetFileChecksum" | "deviceFileTransferStatus" | "deviceGetFileBlock" | "deviceFileTransferProgress" | "deviceFileTransferComplete" | "deviceFileReceived" | "deviceAcceleration" | "deviceGravity" | "deviceLinearAcceleration" | "deviceGyroscope" | "deviceMagnetometer" | "deviceGameRotation" | "deviceRotation" | "deviceActivity" | "deviceStepCounter" | "deviceStepDetector" | "deviceDeviceOrientation" | "deviceTapDetector" | "deviceBarometer" | "deviceCameraStatus" | "deviceGetCameraConfiguration" | "deviceCameraImageProgress" | "deviceCameraImage" | "deviceMicrophoneStatus" | "deviceGetMicrophoneConfiguration" | "deviceMicrophoneData" | "deviceIsRecordingMicrophone" | "deviceMicrophoneRecording" | "deviceSensorData" | "deviceGetSensorConfiguration" | "deviceGetTfliteName" | "deviceGetTfliteTask" | "deviceGetTfliteSampleRate" | "deviceGetTfliteSensorTypes" | "deviceTfliteIsReady" | "deviceGetTfliteCaptureDelay" | "deviceGetTfliteThreshold" | "deviceGetTfliteInferencingEnabled" | "deviceTfliteInference" | "deviceManufacturerName" | "deviceModelNumber" | "deviceHardwareRevision" | "deviceFirmwareRevision" | "deviceSoftwareRevision" | "devicePnpId" | "deviceSerialNumber" | "deviceDeviceInformation" | "deviceIsCharging" | "deviceGetBatteryCurrent" | "deviceGetMtu" | "deviceGetId" | "deviceGetName" | "deviceGetType" | "deviceGetCurrentTime" | "deviceIsWifiAvailable" | "deviceGetWifiSSID" | "deviceGetWifiPassword" | "deviceIsWifiConnected" | "deviceIpAddress" | "deviceConnectionMessage" | "deviceConnecting" | "deviceDisconnecting" | "deviceConnectionStatus" | "deviceBatteryLevel" | "deviceIsDisplayAvailable" | "deviceDisplayStatus" | "deviceDisplayInformation" | "deviceGetDisplayBrightness" | "deviceDisplayContextCommands" | "deviceDisplayReady" | "deviceGetSpriteSheetName" | "deviceDisplayContextState" | "deviceDisplayColor" | "deviceDisplayColorOpacity" | "deviceDisplayOpacity" | "deviceDisplaySpriteSheetUploadStart" | "deviceDisplaySpriteSheetUploadProgress" | "deviceDisplaySpriteSheetUploadComplete" | "deviceSmp" | "deviceFirmwareImages" | "deviceFirmwareUploadProgress" | "deviceFirmwareStatus" | "deviceGetEnableWifiConnection">(type: T) => Promise<{
|
|
1871
1901
|
type: T;
|
|
1872
1902
|
target: DevicePair;
|
|
1873
1903
|
message: DevicePairEventMessages[T];
|
|
1874
1904
|
}>;
|
|
1875
|
-
get removeEventListeners(): <T extends "
|
|
1905
|
+
get removeEventListeners(): <T extends "pressure" | "deviceOrientation" | "sensorData" | "deviceIsConnected" | "deviceConnected" | "deviceNotConnected" | "isConnected" | "devicePressure" | "deviceGetFileTypes" | "deviceMaxFileLength" | "deviceGetFileType" | "deviceGetFileLength" | "deviceGetFileChecksum" | "deviceFileTransferStatus" | "deviceGetFileBlock" | "deviceFileTransferProgress" | "deviceFileTransferComplete" | "deviceFileReceived" | "deviceAcceleration" | "deviceGravity" | "deviceLinearAcceleration" | "deviceGyroscope" | "deviceMagnetometer" | "deviceGameRotation" | "deviceRotation" | "deviceActivity" | "deviceStepCounter" | "deviceStepDetector" | "deviceDeviceOrientation" | "deviceTapDetector" | "deviceBarometer" | "deviceCameraStatus" | "deviceGetCameraConfiguration" | "deviceCameraImageProgress" | "deviceCameraImage" | "deviceMicrophoneStatus" | "deviceGetMicrophoneConfiguration" | "deviceMicrophoneData" | "deviceIsRecordingMicrophone" | "deviceMicrophoneRecording" | "deviceSensorData" | "deviceGetSensorConfiguration" | "deviceGetTfliteName" | "deviceGetTfliteTask" | "deviceGetTfliteSampleRate" | "deviceGetTfliteSensorTypes" | "deviceTfliteIsReady" | "deviceGetTfliteCaptureDelay" | "deviceGetTfliteThreshold" | "deviceGetTfliteInferencingEnabled" | "deviceTfliteInference" | "deviceManufacturerName" | "deviceModelNumber" | "deviceHardwareRevision" | "deviceFirmwareRevision" | "deviceSoftwareRevision" | "devicePnpId" | "deviceSerialNumber" | "deviceDeviceInformation" | "deviceIsCharging" | "deviceGetBatteryCurrent" | "deviceGetMtu" | "deviceGetId" | "deviceGetName" | "deviceGetType" | "deviceGetCurrentTime" | "deviceIsWifiAvailable" | "deviceGetWifiSSID" | "deviceGetWifiPassword" | "deviceIsWifiConnected" | "deviceIpAddress" | "deviceConnectionMessage" | "deviceConnecting" | "deviceDisconnecting" | "deviceConnectionStatus" | "deviceBatteryLevel" | "deviceIsDisplayAvailable" | "deviceDisplayStatus" | "deviceDisplayInformation" | "deviceGetDisplayBrightness" | "deviceDisplayContextCommands" | "deviceDisplayReady" | "deviceGetSpriteSheetName" | "deviceDisplayContextState" | "deviceDisplayColor" | "deviceDisplayColorOpacity" | "deviceDisplayOpacity" | "deviceDisplaySpriteSheetUploadStart" | "deviceDisplaySpriteSheetUploadProgress" | "deviceDisplaySpriteSheetUploadComplete" | "deviceSmp" | "deviceFirmwareImages" | "deviceFirmwareUploadProgress" | "deviceFirmwareStatus" | "deviceGetEnableWifiConnection">(type: T) => void;
|
|
1876
1906
|
get removeAllEventListeners(): () => void;
|
|
1877
1907
|
get left(): Device | undefined;
|
|
1878
1908
|
get right(): Device | undefined;
|
|
@@ -1930,20 +1960,20 @@ declare abstract class BaseScanner {
|
|
|
1930
1960
|
static get isSupported(): boolean;
|
|
1931
1961
|
get isSupported(): boolean;
|
|
1932
1962
|
constructor();
|
|
1933
|
-
get addEventListener(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "
|
|
1963
|
+
get addEventListener(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "scanningAvailable" | "scanningNotAvailable" | "scanning" | "notScanning">(type: T, listener: (event: {
|
|
1934
1964
|
type: T;
|
|
1935
1965
|
target: BaseScanner;
|
|
1936
1966
|
message: ScannerEventMessages[T];
|
|
1937
1967
|
}) => void, options?: {
|
|
1938
1968
|
once?: boolean;
|
|
1939
1969
|
}) => void;
|
|
1940
|
-
protected get dispatchEvent(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "
|
|
1941
|
-
get removeEventListener(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "
|
|
1970
|
+
protected get dispatchEvent(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "scanningAvailable" | "scanningNotAvailable" | "scanning" | "notScanning">(type: T, message: ScannerEventMessages[T]) => void;
|
|
1971
|
+
get removeEventListener(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "scanningAvailable" | "scanningNotAvailable" | "scanning" | "notScanning">(type: T, listener: (event: {
|
|
1942
1972
|
type: T;
|
|
1943
1973
|
target: BaseScanner;
|
|
1944
1974
|
message: ScannerEventMessages[T];
|
|
1945
1975
|
}) => void) => void;
|
|
1946
|
-
get waitForEvent(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "
|
|
1976
|
+
get waitForEvent(): <T extends "isScanningAvailable" | "isScanning" | "discoveredDevice" | "expiredDiscoveredDevice" | "scanningAvailable" | "scanningNotAvailable" | "scanning" | "notScanning">(type: T) => Promise<{
|
|
1947
1977
|
type: T;
|
|
1948
1978
|
target: BaseScanner;
|
|
1949
1979
|
message: ScannerEventMessages[T];
|
|
@@ -2033,5 +2063,5 @@ declare const ThrottleUtils: {
|
|
|
2033
2063
|
debounce: typeof debounce;
|
|
2034
2064
|
};
|
|
2035
2065
|
|
|
2036
|
-
export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, _default as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment_d as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
|
|
2066
|
+
export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, _default as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment_d as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, canvasToBitmaps, canvasToSprite, canvasToSpriteSheet, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, imageToBitmaps, imageToSprite, imageToSpriteSheet, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, quantizeImage, resizeAndQuantizeImage, resizeImage, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
|
|
2037
2067
|
export type { BoundDeviceEventListeners, BoundDeviceManagerEventListeners, BoundDevicePairEventListeners, CameraCommand, CameraConfiguration, CameraConfigurationType, CenterOfPressure, ContinuousSensorType, DeviceEvent, DeviceEventListenerMap, DeviceEventMap, DeviceInformation, DeviceManagerEvent, DeviceManagerEventListenerMap, DeviceManagerEventMap, DevicePairEvent, DevicePairEventListenerMap, DevicePairEventMap, DevicePairType, DeviceType, DiscoveredDevice, DisplayAlignment, DisplayBezierCurveType, DisplayBitmap, DisplayBitmapColorPair, DisplayBrightness, DisplayColorRGB, DisplayContextCommand, DisplayContextCommandType, DisplayDirection, DisplaySegmentCap, DisplaySize, DisplaySprite, DisplaySpriteColorPair, DisplaySpriteContextCommandType, DisplaySpriteLine, DisplaySpriteLines, DisplaySpritePaletteSwap, DisplaySpriteSheet, DisplaySpriteSheetPalette, DisplaySpriteSubLine, DisplayWireframe, DisplayWireframeEdge, Euler, FileTransferDirection, FileType, FontToSpriteSheetOptions, MicrophoneCommand, MicrophoneConfiguration, MicrophoneConfigurationType, PressureData, Quaternion, Range, SensorConfiguration, SensorType, Side, TfliteFileConfiguration, TfliteSensorType, TfliteTask, Vector2, Vector3, VibrationConfiguration, VibrationLocation, VibrationType, VibrationWaveformEffect };
|
|
@@ -5587,6 +5587,9 @@ function removeSubstrings(string, substrings) {
|
|
|
5587
5587
|
|
|
5588
5588
|
const _console$r = createConsole("DisplaySpriteSheetUtils", { log: false });
|
|
5589
5589
|
const spriteHeaderLength = 3 * 2;
|
|
5590
|
+
function calculateSpriteSheetHeaderLength(numberOfSprites) {
|
|
5591
|
+
return 2 + numberOfSprites * 2 + numberOfSprites * spriteHeaderLength;
|
|
5592
|
+
}
|
|
5590
5593
|
function getCurvesPoints(curves) {
|
|
5591
5594
|
const curvePoints = [];
|
|
5592
5595
|
curves.forEach((curve, index) => {
|
|
@@ -6366,6 +6369,15 @@ function resizeImage(image, width, height, canvas) {
|
|
|
6366
6369
|
ctx.drawImage(image, 0, 0, width, height);
|
|
6367
6370
|
return canvas;
|
|
6368
6371
|
}
|
|
6372
|
+
function cropCanvas(canvas, x, y, width, height, targetCanvas) {
|
|
6373
|
+
targetCanvas = targetCanvas || document.createElement("canvas");
|
|
6374
|
+
const ctx = targetCanvas.getContext("2d", { willReadFrequently: true });
|
|
6375
|
+
targetCanvas.width = width;
|
|
6376
|
+
targetCanvas.height = height;
|
|
6377
|
+
ctx.imageSmoothingEnabled = false;
|
|
6378
|
+
ctx.drawImage(canvas, x, y, width, height, 0, 0, width, height);
|
|
6379
|
+
return targetCanvas;
|
|
6380
|
+
}
|
|
6369
6381
|
function removeAlphaFromCanvas(canvas) {
|
|
6370
6382
|
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
6371
6383
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
@@ -6404,6 +6416,77 @@ async function imageToBitmap(image, width, height, colors, bitmapColorIndices, n
|
|
|
6404
6416
|
};
|
|
6405
6417
|
return { blob, bitmap };
|
|
6406
6418
|
}
|
|
6419
|
+
const drawSpriteBitmapCommandHeaderLength = 1 + 2 + 2 + 2 + 2 + 1 + 2;
|
|
6420
|
+
async function canvasToBitmaps(canvas, numberOfColors, mtu) {
|
|
6421
|
+
const { blob, colors, colorIndices } = await quantizeCanvas(canvas, numberOfColors);
|
|
6422
|
+
const bitmapRows = [];
|
|
6423
|
+
const { width, height } = canvas;
|
|
6424
|
+
const numberOfPixels = width * height;
|
|
6425
|
+
const pixelDepth = DisplayPixelDepths.find((pixelDepth) => pixelDepthToNumberOfColors(pixelDepth) >= numberOfColors);
|
|
6426
|
+
_console$q.assertWithError(pixelDepth, `no pixelDepth found that covers ${numberOfColors} colors`);
|
|
6427
|
+
const pixelsPerByte = pixelDepthToPixelsPerByte(pixelDepth);
|
|
6428
|
+
const numberOfBytes = Math.ceil(numberOfPixels / pixelsPerByte);
|
|
6429
|
+
_console$q.log({
|
|
6430
|
+
width,
|
|
6431
|
+
height,
|
|
6432
|
+
numberOfPixels,
|
|
6433
|
+
pixelDepth,
|
|
6434
|
+
pixelsPerByte,
|
|
6435
|
+
numberOfBytes,
|
|
6436
|
+
mtu,
|
|
6437
|
+
});
|
|
6438
|
+
const maxPixelDataLength = mtu - (drawSpriteBitmapCommandHeaderLength + 5);
|
|
6439
|
+
const maxPixels = Math.floor(maxPixelDataLength / pixelsPerByte);
|
|
6440
|
+
const maxBitmapWidth = Math.min(maxPixels, width);
|
|
6441
|
+
let maxBitmapHeight = 1;
|
|
6442
|
+
if (maxBitmapWidth == width) {
|
|
6443
|
+
const bitmapRowPixelDataLength = Math.ceil(width / pixelsPerByte);
|
|
6444
|
+
maxBitmapHeight = Math.floor(maxPixelDataLength / bitmapRowPixelDataLength);
|
|
6445
|
+
}
|
|
6446
|
+
_console$q.log({
|
|
6447
|
+
maxPixelDataLength,
|
|
6448
|
+
maxPixels,
|
|
6449
|
+
maxBitmapHeight,
|
|
6450
|
+
maxBitmapWidth,
|
|
6451
|
+
});
|
|
6452
|
+
if (maxBitmapHeight >= height) {
|
|
6453
|
+
_console$q.log("image is small enough for a single bitmap");
|
|
6454
|
+
const bitmap = {
|
|
6455
|
+
numberOfColors,
|
|
6456
|
+
pixels: colorIndices,
|
|
6457
|
+
width,
|
|
6458
|
+
height,
|
|
6459
|
+
};
|
|
6460
|
+
bitmapRows.push([bitmap]);
|
|
6461
|
+
}
|
|
6462
|
+
else {
|
|
6463
|
+
let offsetX = 0;
|
|
6464
|
+
let offsetY = 0;
|
|
6465
|
+
const bitmapCanvas = document.createElement("canvas");
|
|
6466
|
+
const bitmapColorIndices = new Array(numberOfColors)
|
|
6467
|
+
.fill(0)
|
|
6468
|
+
.map((_, i) => i);
|
|
6469
|
+
while (offsetY < height) {
|
|
6470
|
+
const bitmapHeight = Math.min(maxBitmapHeight, height - offsetY);
|
|
6471
|
+
offsetX = 0;
|
|
6472
|
+
const bitmapRow = [];
|
|
6473
|
+
bitmapRows.push(bitmapRow);
|
|
6474
|
+
while (offsetX < width) {
|
|
6475
|
+
const bitmapWidth = Math.min(maxBitmapWidth, width - offsetX);
|
|
6476
|
+
cropCanvas(canvas, offsetX, offsetY, bitmapWidth, bitmapHeight, bitmapCanvas);
|
|
6477
|
+
const { bitmap } = await imageToBitmap(bitmapCanvas, bitmapWidth, bitmapHeight, colors, bitmapColorIndices, numberOfColors);
|
|
6478
|
+
bitmapRow.push(bitmap);
|
|
6479
|
+
offsetX += bitmapWidth;
|
|
6480
|
+
}
|
|
6481
|
+
offsetY += bitmapHeight;
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
return { bitmapRows, colors };
|
|
6485
|
+
}
|
|
6486
|
+
async function imageToBitmaps(image, width, height, numberOfColors, mtu) {
|
|
6487
|
+
const canvas = resizeImage(image, width, height);
|
|
6488
|
+
return canvasToBitmaps(canvas, numberOfColors, mtu);
|
|
6489
|
+
}
|
|
6407
6490
|
function getBitmapNumberOfBytes(bitmap) {
|
|
6408
6491
|
const pixelDepth = numberOfColorsToPixelDepth(bitmap.numberOfColors);
|
|
6409
6492
|
const pixelsPerByte = pixelDepthToPixelsPerByte(pixelDepth);
|
|
@@ -6423,6 +6506,127 @@ function assertValidBitmapPixels(bitmap) {
|
|
|
6423
6506
|
_console$q.assertRangeWithError(`bitmap.pixels[${index}]`, pixel, 0, bitmap.numberOfColors - 1);
|
|
6424
6507
|
});
|
|
6425
6508
|
}
|
|
6509
|
+
async function canvasToSprite(canvas, spriteName, numberOfColors, paletteName, overridePalette, spriteSheet, paletteOffset = 0) {
|
|
6510
|
+
const { width, height } = canvas;
|
|
6511
|
+
let palette = spriteSheet.palettes?.find((palette) => palette.name == paletteName);
|
|
6512
|
+
if (!palette) {
|
|
6513
|
+
palette = {
|
|
6514
|
+
name: paletteName,
|
|
6515
|
+
numberOfColors,
|
|
6516
|
+
colors: new Array(numberOfColors).fill("#000000"),
|
|
6517
|
+
};
|
|
6518
|
+
spriteSheet.palettes = spriteSheet.palettes || [];
|
|
6519
|
+
spriteSheet.palettes?.push(palette);
|
|
6520
|
+
}
|
|
6521
|
+
_console$q.log("pallete", palette);
|
|
6522
|
+
const sprite = {
|
|
6523
|
+
name: spriteName,
|
|
6524
|
+
width,
|
|
6525
|
+
height,
|
|
6526
|
+
paletteSwaps: [],
|
|
6527
|
+
commands: [],
|
|
6528
|
+
};
|
|
6529
|
+
const results = await quantizeCanvas(canvas, numberOfColors, !overridePalette ? palette.colors : undefined);
|
|
6530
|
+
const blob = results.blob;
|
|
6531
|
+
const colorIndices = results.colorIndices;
|
|
6532
|
+
if (overridePalette) {
|
|
6533
|
+
results.colors.forEach((color, index) => {
|
|
6534
|
+
palette.colors[index + paletteOffset] = color;
|
|
6535
|
+
});
|
|
6536
|
+
}
|
|
6537
|
+
sprite.commands.push({
|
|
6538
|
+
type: "selectBitmapColors",
|
|
6539
|
+
bitmapColorPairs: new Array(numberOfColors).fill(0).map((_, index) => ({
|
|
6540
|
+
bitmapColorIndex: index,
|
|
6541
|
+
colorIndex: index + paletteOffset,
|
|
6542
|
+
})),
|
|
6543
|
+
});
|
|
6544
|
+
const bitmap = {
|
|
6545
|
+
numberOfColors,
|
|
6546
|
+
pixels: colorIndices,
|
|
6547
|
+
width,
|
|
6548
|
+
height,
|
|
6549
|
+
};
|
|
6550
|
+
sprite.commands.push({ type: "drawBitmap", offsetX: 0, offsetY: 0, bitmap });
|
|
6551
|
+
const spriteIndex = spriteSheet.sprites.findIndex((sprite) => sprite.name == spriteName);
|
|
6552
|
+
if (spriteIndex == -1) {
|
|
6553
|
+
spriteSheet.sprites.push(sprite);
|
|
6554
|
+
}
|
|
6555
|
+
else {
|
|
6556
|
+
_console$q.log(`overwriting spriteIndex ${spriteIndex}`);
|
|
6557
|
+
spriteSheet.sprites[spriteIndex] = sprite;
|
|
6558
|
+
}
|
|
6559
|
+
return { sprite, blob };
|
|
6560
|
+
}
|
|
6561
|
+
async function imageToSprite(image, spriteName, width, height, numberOfColors, paletteName, overridePalette, spriteSheet, paletteOffset = 0) {
|
|
6562
|
+
const canvas = resizeImage(image, width, height);
|
|
6563
|
+
return canvasToSprite(canvas, spriteName, numberOfColors, paletteName, overridePalette, spriteSheet, paletteOffset);
|
|
6564
|
+
}
|
|
6565
|
+
const spriteSheetWithSingleBitmapCommandLength = calculateSpriteSheetHeaderLength(1) + drawSpriteBitmapCommandHeaderLength;
|
|
6566
|
+
function spriteSheetWithBitmapCommandAndSelectBitmapColorsLength(numberOfColors) {
|
|
6567
|
+
return (spriteSheetWithSingleBitmapCommandLength + (1 + 1 + numberOfColors * 2));
|
|
6568
|
+
}
|
|
6569
|
+
async function canvasToSpriteSheet(canvas, spriteSheetName, numberOfColors, paletteName, maxFileLength) {
|
|
6570
|
+
const spriteSheet = {
|
|
6571
|
+
name: spriteSheetName,
|
|
6572
|
+
palettes: [],
|
|
6573
|
+
paletteSwaps: [],
|
|
6574
|
+
sprites: [],
|
|
6575
|
+
};
|
|
6576
|
+
if (maxFileLength == undefined) {
|
|
6577
|
+
await canvasToSprite(canvas, "image", numberOfColors, paletteName, true, spriteSheet);
|
|
6578
|
+
}
|
|
6579
|
+
else {
|
|
6580
|
+
const { width, height } = canvas;
|
|
6581
|
+
const numberOfPixels = width * height;
|
|
6582
|
+
const pixelDepth = DisplayPixelDepths.find((pixelDepth) => pixelDepthToNumberOfColors(pixelDepth) >= numberOfColors);
|
|
6583
|
+
_console$q.assertWithError(pixelDepth, `no pixelDepth found that covers ${numberOfColors} colors`);
|
|
6584
|
+
const pixelsPerByte = pixelDepthToPixelsPerByte(pixelDepth);
|
|
6585
|
+
const numberOfBytes = Math.ceil(numberOfPixels / pixelsPerByte);
|
|
6586
|
+
_console$q.log({
|
|
6587
|
+
width,
|
|
6588
|
+
height,
|
|
6589
|
+
numberOfPixels,
|
|
6590
|
+
pixelDepth,
|
|
6591
|
+
pixelsPerByte,
|
|
6592
|
+
numberOfBytes,
|
|
6593
|
+
maxFileLength,
|
|
6594
|
+
});
|
|
6595
|
+
const maxPixelDataLength = maxFileLength -
|
|
6596
|
+
(spriteSheetWithBitmapCommandAndSelectBitmapColorsLength(numberOfColors) +
|
|
6597
|
+
5);
|
|
6598
|
+
const imageRowPixelDataLength = Math.ceil(width / pixelsPerByte);
|
|
6599
|
+
const maxSpriteHeight = Math.floor(maxPixelDataLength / imageRowPixelDataLength);
|
|
6600
|
+
if (maxSpriteHeight >= height) {
|
|
6601
|
+
_console$q.log("image is small enough for a single sprite");
|
|
6602
|
+
await canvasToSprite(canvas, "image", numberOfColors, paletteName, true, spriteSheet);
|
|
6603
|
+
}
|
|
6604
|
+
else {
|
|
6605
|
+
const { colors } = await quantizeCanvas(canvas, numberOfColors);
|
|
6606
|
+
spriteSheet.palettes?.push({ name: paletteName, numberOfColors, colors });
|
|
6607
|
+
let offsetY = 0;
|
|
6608
|
+
let imageIndex = 0;
|
|
6609
|
+
const spriteCanvas = document.createElement("canvas");
|
|
6610
|
+
while (offsetY < height) {
|
|
6611
|
+
const spriteHeight = Math.min(maxSpriteHeight, height - offsetY);
|
|
6612
|
+
cropCanvas(canvas, 0, offsetY, width, spriteHeight, spriteCanvas);
|
|
6613
|
+
offsetY += spriteHeight;
|
|
6614
|
+
_console$q.log(`cropping sprite ${imageIndex}`, {
|
|
6615
|
+
offsetY,
|
|
6616
|
+
width,
|
|
6617
|
+
spriteHeight,
|
|
6618
|
+
});
|
|
6619
|
+
await canvasToSprite(spriteCanvas, `image${imageIndex}`, numberOfColors, paletteName, false, spriteSheet);
|
|
6620
|
+
imageIndex++;
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
return spriteSheet;
|
|
6625
|
+
}
|
|
6626
|
+
async function imageToSpriteSheet(image, spriteSheetName, width, height, numberOfColors, paletteName, maxFileLength) {
|
|
6627
|
+
const canvas = resizeImage(image, width, height);
|
|
6628
|
+
return canvasToSpriteSheet(canvas, spriteSheetName, numberOfColors, paletteName, maxFileLength);
|
|
6629
|
+
}
|
|
6426
6630
|
|
|
6427
6631
|
const _console$p = createConsole("DisplayManagerInterface", { log: false });
|
|
6428
6632
|
async function runDisplayContextCommand(displayManager, command, sendImmediately) {
|
|
@@ -14388,5 +14592,5 @@ const ThrottleUtils = {
|
|
|
14388
14592
|
debounce,
|
|
14389
14593
|
};
|
|
14390
14594
|
|
|
14391
|
-
export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, DeviceManager$1 as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner$1 as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
|
|
14595
|
+
export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, DeviceManager$1 as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner$1 as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, canvasToBitmaps, canvasToSprite, canvasToSpriteSheet, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, imageToBitmaps, imageToSprite, imageToSpriteSheet, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, quantizeImage, resizeAndQuantizeImage, resizeImage, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
|
|
14392
14596
|
//# sourceMappingURL=brilliantsole.node.module.js.map
|