-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graphics: Adjust image alignment when rotating images to avoid croppi…
…ng (fix #2535)
- Loading branch information
1 parent
9cc9268
commit ff487e0
Showing
5 changed files
with
164 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
var g = Graphics.createArrayBuffer(16,16,8); | ||
g.dump = _=>{ | ||
var s = ""; | ||
var b = new Uint8Array(g.buffer); | ||
var n = 0; | ||
for (var y=0;y<g.getHeight();y++) { | ||
s+="\n"; | ||
for (var x=0;x<g.getWidth();x++) | ||
s+=".-+#"[b[n++]&3]; | ||
} | ||
return s; | ||
} | ||
g.print = _=>{ | ||
print("`"+g.dump()+"`"); | ||
} | ||
var ok = true; | ||
function SHOULD_BE(a) { | ||
var b = g.dump(); | ||
if (a!=b) { | ||
console.log("GOT :"+b+"\nSHOULD BE:"+a+"\n================"); | ||
ok = false; | ||
} | ||
} | ||
|
||
var img = { | ||
width : 8, height : 8, bpp : 8, | ||
buffer : new Uint8Array([ | ||
3,3,3,3,3,3,3,3, | ||
3,3,3,3,3,3,3,3, | ||
3,1,1,1,1,1,1,3, | ||
3,1,1,1,1,1,1,3, | ||
3,1,1,1,1,1,1,3, | ||
3,1,1,1,1,1,1,3, | ||
3,1,1,1,1,1,1,3, | ||
3,3,3,3,3,3,3,3, | ||
]).buffer | ||
}; | ||
|
||
g.clear().drawImage(img,4,4,{rotate:-0.000000001}); | ||
SHOULD_BE(` | ||
########........ | ||
########........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
########........ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................`); | ||
|
||
g.clear().drawImage(img,4,4,{rotate:Math.PI/2}); | ||
SHOULD_BE(` | ||
########........ | ||
#-----##........ | ||
#-----##........ | ||
#-----##........ | ||
#-----##........ | ||
#-----##........ | ||
#-----##........ | ||
########........ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................`); | ||
|
||
|
||
g.clear().drawImage(img,4,4,{rotate:Math.PI}); | ||
SHOULD_BE(` | ||
########........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
#------#........ | ||
########........ | ||
########........ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................`); | ||
|
||
|
||
g.clear().drawImage(img,4,4,{rotate:Math.PI*3/2}); | ||
SHOULD_BE(` | ||
########........ | ||
##-----#........ | ||
##-----#........ | ||
##-----#........ | ||
##-----#........ | ||
##-----#........ | ||
##-----#........ | ||
########........ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................`); | ||
|
||
result = ok; |