Skip to content

Commit

Permalink
#2 remove sdf from non-sdf icons
Browse files Browse the repository at this point in the history
  • Loading branch information
smellman committed Dec 10, 2023
1 parent dac8908 commit 36b4be8
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
15 changes: 12 additions & 3 deletions src/lib/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,22 @@ export class Image {
}

to_obj(): SpriteImage {
if (this.sdf) {
return {
height: this.buffer_height(),
width: this.buffer_width(),
x: this.x,
y: this.y,
pixelRatio: this.ratio,
sdf: this.sdf,
}
}
return {
height: this.sdf ? this.buffer_height() : this.real_height(),
width: this.sdf ? this.buffer_width() : this.real_width(),
height: this.real_height(),
width: this.real_width(),
x: this.x,
y: this.y,
pixelRatio: this.ratio,
sdf: this.sdf,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/test1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1,"sdf":false},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1,"sdf":false},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1,"sdf":false}}
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1}}
2 changes: 1 addition & 1 deletion tests/fixtures/test2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"airport":{"height":30,"width":30,"x":0,"y":86,"pixelRatio":2,"sdf":false},"airport_xl":{"height":86,"width":86,"x":0,"y":0,"pixelRatio":2,"sdf":false},"my_bbq":{"height":64,"width":64,"x":86,"y":0,"pixelRatio":2,"sdf":false}}
{"airport":{"height":30,"width":30,"x":0,"y":86,"pixelRatio":2},"airport_xl":{"height":86,"width":86,"x":0,"y":0,"pixelRatio":2},"my_bbq":{"height":64,"width":64,"x":86,"y":0,"pixelRatio":2}}
2 changes: 1 addition & 1 deletion tests/fixtures/test3.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1,"sdf":false},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1,"sdf":false},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1,"sdf":false}}
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1}}
2 changes: 1 addition & 1 deletion tests/fixtures/test3@2x.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"airport":{"height":30,"width":30,"x":0,"y":86,"pixelRatio":2,"sdf":false},"airport_xl":{"height":86,"width":86,"x":0,"y":0,"pixelRatio":2,"sdf":false},"my_bbq":{"height":64,"width":64,"x":86,"y":0,"pixelRatio":2,"sdf":false}}
{"airport":{"height":30,"width":30,"x":0,"y":86,"pixelRatio":2},"airport_xl":{"height":86,"width":86,"x":0,"y":0,"pixelRatio":2},"my_bbq":{"height":64,"width":64,"x":86,"y":0,"pixelRatio":2}}
2 changes: 1 addition & 1 deletion tests/fixtures/test4.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1,"sdf":false},"arrow":{"height":15,"width":15,"x":15,"y":43,"pixelRatio":1,"sdf":false},"circle":{"height":15,"width":15,"x":30,"y":43,"pixelRatio":1,"sdf":false},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1,"sdf":false},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1,"sdf":false}}
{"airport":{"height":15,"width":15,"x":0,"y":43,"pixelRatio":1},"arrow":{"height":15,"width":15,"x":15,"y":43,"pixelRatio":1},"circle":{"height":15,"width":15,"x":30,"y":43,"pixelRatio":1},"my_bbq":{"height":32,"width":32,"x":43,"y":0,"pixelRatio":1},"airport_xl":{"height":43,"width":43,"x":0,"y":0,"pixelRatio":1}}
2 changes: 1 addition & 1 deletion tests/fixtures/test5.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/fixtures/test5@2x.json

Large diffs are not rendered by default.

0 comments on commit 36b4be8

Please sign in to comment.