use of org.robovm.apple.coregraphics.CGRect in project playn by threerings.
the class RoboGLContext method updateTexture.
void updateTexture(int tex, CGImage image) {
int width = (int) image.getWidth(), height = (int) image.getHeight();
if (width <= 0 || height <= 0) {
platform.log().warn("Ignoring texture update for empty image (" + width + "x" + height + ").");
return;
}
CGBitmapContext bctx = RoboGraphics.createCGBitmap(width, height);
CGRect rect = new CGRect(0, 0, width, height);
bctx.clearRect(rect);
bctx.drawImage(rect, image);
updateTexture(tex, width, height, bctx.getData());
bctx.dispose();
}
use of org.robovm.apple.coregraphics.CGRect in project playn by threerings.
the class RoboTextLayout method wrapLines.
private static CFArray wrapLines(NSAttributedString astring, float wrapWidth) {
CTFramesetter fs = CTFramesetter.create(astring);
try {
// iOS lays things out from max-y up to zero (inverted coordinate system); so we need to
// provide a large height for our rectangle to ensure that all lines "fit"
CGPath path = CGPath.createWithRect(new CGRect(0, 0, wrapWidth, Float.MAX_VALUE / 2), CGAffineTransform.Identity());
CTFrame frame = fs.createFrame(new CFRange(0, 0), path, null);
return frame.getLines();
} finally {
fs.dispose();
}
}
use of org.robovm.apple.coregraphics.CGRect in project playn by threerings.
the class TestsGameRoboVM method didFinishLaunching.
@Override
public boolean didFinishLaunching(UIApplication app, UIApplicationLaunchOptions launchOpts) {
// create a full-screen window
CGRect bounds = UIScreen.getMainScreen().getBounds();
UIWindow window = new UIWindow(bounds);
// configure and register the PlayN platform; start our game
RoboPlatform.Config config = new RoboPlatform.Config();
config.orients = UIInterfaceOrientationMask.All;
RoboPlatform pf = RoboPlatform.register(window, config);
pf.run(new TestsGame());
// make our main window visible
window.makeKeyAndVisible();
addStrongRef(window);
return true;
}
use of org.robovm.apple.coregraphics.CGRect in project playn by threerings.
the class RoboAbstractImage method draw.
@Override
public void draw(CGBitmapContext bctx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) {
// adjust our source rect to account for the scale factor
sx *= scale.factor;
sy *= scale.factor;
sw *= scale.factor;
sh *= scale.factor;
CGImage cgImage = cgImage();
float iw = cgImage.getWidth(), ih = cgImage.getHeight();
float scaleX = dw / sw, scaleY = dh / sh;
// pesky fiddling to cope with the fact that UIImages are flipped
bctx.saveGState();
bctx.translateCTM(dx, dy + dh);
bctx.scaleCTM(1, -1);
bctx.clipToRect(new CGRect(0, 0, dw, dh));
bctx.translateCTM(-sx * scaleX, -(ih - (sy + sh)) * scaleY);
bctx.drawImage(new CGRect(0, 0, iw * scaleX, ih * scaleY), cgImage);
bctx.restoreGState();
}
Aggregations