зеркало из https://github.com/mozilla/pluotsorbet.git
fix translate in gfx
This commit is contained in:
Родитель
1f60bb7145
Коммит
1930bdcaa8
27
midp/gfx.js
27
midp/gfx.js
|
@ -299,32 +299,21 @@
|
|||
cb(c);
|
||||
}
|
||||
|
||||
function withTranslate(g, c, cb) {
|
||||
var transX = g.class.getField("transX", "I").get(g),
|
||||
transY = g.class.getField("transY", "I").get(g),
|
||||
translate = transX || transY;
|
||||
if (translate) {
|
||||
c.save();
|
||||
c.translate(transX, transY);
|
||||
cb();
|
||||
c.restore();
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
function withClip(g, c, x, y, cb) {
|
||||
var clipX1 = g.class.getField("clipX1", "S").get(g),
|
||||
clipY1 = g.class.getField("clipY1", "S").get(g),
|
||||
clipX2 = g.class.getField("clipX2", "S").get(g),
|
||||
clipY2 = g.class.getField("clipY2", "S").get(g),
|
||||
clipped = g.class.getField("clipped", "Z").get(g);
|
||||
clipped = g.class.getField("clipped", "Z").get(g),
|
||||
transX = g.class.getField("transX", "I").get(g),
|
||||
transY = g.class.getField("transY", "I").get(g);
|
||||
c.save();
|
||||
if (clipped) {
|
||||
c.beginPath();
|
||||
c.rect(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1);
|
||||
c.clip();
|
||||
}
|
||||
c.translate(transX, transY);
|
||||
cb(x, y);
|
||||
c.restore();
|
||||
}
|
||||
|
@ -397,11 +386,9 @@
|
|||
texture = imgData.class.getField("nativeImageData", "I").get(imgData);
|
||||
withGraphics(_this, function(c) {
|
||||
withAnchor(_this, c, anchor, x, y, texture.width, texture.height, function(x, y) {
|
||||
withTranslate(_this, c, function() {
|
||||
c.drawImage(texture, x, y);
|
||||
});
|
||||
});
|
||||
});
|
||||
stack.push(1);
|
||||
}
|
||||
|
||||
|
@ -410,12 +397,10 @@
|
|||
withGraphics(_this, function(c) {
|
||||
withTextAnchor(_this, c, anchor, x, y, str, function(x, y) {
|
||||
withPixel(_this, c, function() {
|
||||
withTranslate(_this, c, function() {
|
||||
c.fillText(str, x, y);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Native["javax/microedition/lcdui/Graphics.drawChars.([CIIIII)V"] = function(ctx, stack) {
|
||||
|
@ -425,12 +410,10 @@
|
|||
withGraphics(_this, function(c) {
|
||||
withTextAnchor(_this, c, anchor, x, y, str, function(x, y) {
|
||||
withPixel(_this, c, function() {
|
||||
withTranslate(_this, c, function() {
|
||||
c.fillText(str, x, y);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Native["javax/microedition/lcdui/Graphics.drawChar.(CIII)V"] = function(ctx, stack) {
|
||||
|
@ -438,12 +421,10 @@
|
|||
withGraphics(_this, function(c) {
|
||||
withTextAnchor(_this, c, anchor, x, y, chr, function(x, y) {
|
||||
withPixel(_this, c, function() {
|
||||
withTranslate(_this, c, function() {
|
||||
c.fillText(chr, x, y);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Native["javax/microedition/lcdui/Graphics.fillTriangle.(IIIIII)V"] = function(ctx, stack) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче