Skip to content

Commit

Permalink
fix: graphics info card precision issue
Browse files Browse the repository at this point in the history
  • Loading branch information
F-star committed Oct 28, 2024
1 parent 6b5a8de commit 273c00a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/graphics/graphics/graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,13 @@ export class SuikaGraphics<ATTRS extends GraphicsAttrs = GraphicsAttrs> {
this.setWorldTransform(newWoldTf);
}

getInfoPanelAttrs() {
getInfoPanelAttrs(): {
label: string;
key: string;
value: number;
uiType: string;
suffixValue?: string;
}[] {
const size = this.getTransformedSize();
const pos = this.getWorldPosition();
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface IAttr {
key: string;
value: number | string;
uiType: string;
precision?: number;
}

export const ElementsInfoCards: FC = () => {
Expand All @@ -42,6 +43,10 @@ export const ElementsInfoCards: FC = () => {
for (const el of items) {
const attrs = el.getInfoPanelAttrs();
for (const attr of attrs) {
if (attr.uiType === 'number') {
const precision = 2;
attr.value = remainDecimal(attr.value, precision);
}
const label = attr.label;
if (!map.has(label)) {
map.set(label, attr);
Expand Down

0 comments on commit 273c00a

Please sign in to comment.