Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
feat(setLegend): error if non-rectangular bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiasAurel committed Feb 2, 2024
1 parent 791ea6b commit a993dba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/shared/sprig_engine/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ exports.clearText = () => native.text_clear();

exports.setLegend = (...bitmaps) => {
native.legend_clear();

for (const [key, bitmap] of bitmaps) {
const rows = bitmap.trim().split("\n").map(x => x.trim())
const rowLengths = rows.map(x => x.length);
const isRect = rowLengths.every(val => val === rowLengths[0])
if (!isRect) throw new Error(`Bitmap with key ${key} is not rectangular.`)
}

for (const [charStr, bitmap] of bitmaps) {
native.legend_doodle_set(charStr, bitmap.trim());
}
Expand Down

0 comments on commit a993dba

Please sign in to comment.