本文整理了Java中playn.core.Graphics.scale()
方法的一些代码示例,展示了Graphics.scale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.scale()
方法的具体详情如下:
包路径:playn.core.Graphics
类名称:Graphics
方法名:scale
[英]Returns the display scale factor. This will be Scale#ONE except on HiDPI devices that have been configured to use HiDPI mode.
[中]返回显示比例因子。除已配置为使用HiDPI模式的HiDPI设备外,这将是缩放一。
代码示例来源:origin: stackoverflow.com
@Override
public void paintComponent(Graphics g)
{
g.scale(zoomFactor, zoomFactor);
// Change the size of the panel
setSize(origWidth * zoomFactor, origHeight * zoomFactor);
// Re-Layout the panel
validate();
super.paintComponent(g);
}
代码示例来源:origin: threerings/tripleplay
/** Creates a canvas large enough to accommodate this styled text, and renders it therein. The
* canvas will include a one pixel border beyond the size of the styled text which is needed
* to accommodate antialiasing. */
public Canvas toCanvas () {
float pad = 1/_gfx.scale().factor;
Canvas canvas = _gfx.createCanvas(width()+2*pad, height()+2*pad);
render(canvas, pad, pad);
return canvas;
}
代码示例来源:origin: io.playn/playn-core
/**
* Creates a canvas image large enough to accommodate this text block and renders the lines into
* it. The image will include padding around the edge to ensure that antialiasing has a bit of
* extra space to do its work.
*/
public Canvas toCanvas(Graphics gfx, Align align, int fillColor) {
float pad = 1/gfx.scale().factor;
Canvas canvas = gfx.createCanvas(bounds.width()+2*pad, bounds.height()+2*pad);
canvas.setFillColor(fillColor);
fill(canvas, align, pad, pad);
return canvas;
}
}
代码示例来源:origin: playn/playn
/**
* Creates a canvas image large enough to accommodate this text block and renders the lines into
* it. The image will include padding around the edge to ensure that antialiasing has a bit of
* extra space to do its work.
*/
public Canvas toCanvas(Graphics gfx, Align align, int fillColor) {
float pad = 1/gfx.scale().factor;
Canvas canvas = gfx.createCanvas(bounds.width()+2*pad, bounds.height()+2*pad);
canvas.setFillColor(fillColor);
fill(canvas, align, pad, pad);
return canvas;
}
}
代码示例来源:origin: threerings/tripleplay
@Override public void setPosition (float x, float y) {
Root root = root();
if (root != null) {
Scale scale = root.iface.plat.graphics().scale();
if (hrange.active()) x = scale.roundToNearestPixel(x);
if (vrange.active()) y = scale.roundToNearestPixel(y);
}
Scroller.this.content.layer.setTranslation(x, y);
}
};
代码示例来源:origin: playn/playn
scale(game.graphics.scale().factor, game.graphics.scale().factor).
translate(160, (ygap + 150));
代码示例来源:origin: threerings/tripleplay
/**
* Does whatever this element needs to validate itself. This may involve recomputing
* visualizations, or laying out children, or anything else.
*/
protected void validate () {
if (!isSet(Flag.VALID)) {
// prior to laying ourselves out, ensure that our visual boundaries fall on physical
// pixels; this avoids rendering artifacts on devices where the scale factor between
// virtual and physical pixels is non-integral
Root root = root();
if (root != null) {
Scale scale = root.iface.plat.graphics().scale();
float x = layer.tx(), y = layer.ty();
float rx = scale.roundToNearestPixel(x), ry = scale.roundToNearestPixel(y);
float rr = scale.roundToNearestPixel(x + _size.width);
float rb = scale.roundToNearestPixel(y + _size.height);
layer.setTranslation(rx, ry);
_size.setSize(rr-rx, rb-ry);
}
// now that our boundaries are adjusted, we can layout our children (if any)
layout();
set(Flag.VALID, true);
wasValidated();
}
}
代码示例来源:origin: playn/playn
protected Texture makeTextImage() {
TextFormat format = new TextFormat(new Font(font.value(), style.value(), 24));
float wrapWidth = wrap.value() == 0 ?
Float.MAX_VALUE : game.graphics.viewSize.width()*wrap.value()/100;
TextBlock block = new TextBlock(
game.graphics.layoutText(sample, format, new TextWrap(wrapWidth)));
float awidth = adjustWidth(block.bounds.width()), aheight = adjustHeight(block.bounds.height());
float pad = 1/game.graphics.scale().factor;
Canvas canvas = game.graphics.createCanvas(awidth+2*pad, aheight+2*pad);
canvas.translate(pad, pad);
canvas.setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, awidth, aheight);
render(canvas, block, align.value(), lineBounds.value());
return canvas.toTexture();
}
内容来源于网络,如有侵权,请联系作者删除!