Search in sources :

Example 11 with CGRect

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();
}
Also used : CGBitmapContext(org.robovm.apple.coregraphics.CGBitmapContext) CGRect(org.robovm.apple.coregraphics.CGRect)

Example 12 with CGRect

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();
    }
}
Also used : CGPath(org.robovm.apple.coregraphics.CGPath) CGRect(org.robovm.apple.coregraphics.CGRect) CFRange(org.robovm.apple.corefoundation.CFRange)

Example 13 with CGRect

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;
}
Also used : TestsGame(playn.tests.core.TestsGame) CGRect(org.robovm.apple.coregraphics.CGRect) RoboPlatform(playn.robovm.RoboPlatform) UIWindow(org.robovm.apple.uikit.UIWindow)

Example 14 with CGRect

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();
}
Also used : CGImage(org.robovm.apple.coregraphics.CGImage) CGRect(org.robovm.apple.coregraphics.CGRect)

Aggregations

CGRect (org.robovm.apple.coregraphics.CGRect)14 CGBitmapContext (org.robovm.apple.coregraphics.CGBitmapContext)2 CFRange (org.robovm.apple.corefoundation.CFRange)1 CGImage (org.robovm.apple.coregraphics.CGImage)1 CGMutablePath (org.robovm.apple.coregraphics.CGMutablePath)1 CGPath (org.robovm.apple.coregraphics.CGPath)1 CGPoint (org.robovm.apple.coregraphics.CGPoint)1 UIInterfaceOrientation (org.robovm.apple.uikit.UIInterfaceOrientation)1 UITextField (org.robovm.apple.uikit.UITextField)1 UITouch (org.robovm.apple.uikit.UITouch)1 UITouchPhase (org.robovm.apple.uikit.UITouchPhase)1 UIWindow (org.robovm.apple.uikit.UIWindow)1 RoboPlatform (playn.robovm.RoboPlatform)1 TestsGame (playn.tests.core.TestsGame)1