Tabnine Logo
Scale.scaledCeil
Code IndexAdd Tabnine to your IDE (free)

How to use
scaledCeil
method
in
playn.core.gl.Scale

Best Java code snippets using playn.core.gl.Scale.scaledCeil (Showing top 18 results out of 315)

origin: threerings/playn

public SurfaceGL(GLContext ctx, float width, float height) {
 super(ctx);
 this.width = width;
 this.height = height;
 this.texWidth = ctx.scale.scaledCeil(width);
 this.texHeight = ctx.scale.scaledCeil(height);
 createTexture();
 scale(ctx.scale.factor, ctx.scale.factor);
}
origin: com.googlecode.playn/playn-android

AndroidCanvasImage(AndroidGraphics gfx, float width, float height, Scale scale) {
 super(gfx.ctx, Bitmap.createBitmap(scale.scaledCeil(width), scale.scaledCeil(height),
                   gfx.preferredBitmapConfig), scale);
 this.canvas = new AndroidCanvas(bitmap, width, height);
 this.canvas.scale(scale.factor, scale.factor);
}
origin: threerings/playn

AndroidCanvasImage(AndroidGraphics gfx, float width, float height, Scale scale) {
 super(gfx.ctx, Bitmap.createBitmap(scale.scaledCeil(width), scale.scaledCeil(height),
                   gfx.preferredBitmapConfig), scale);
 this.canvas = new AndroidCanvas(bitmap, width, height);
 this.canvas.scale(scale.factor, scale.factor);
}
origin: threerings/playn

public static HtmlCanvas create(Scale scale, float width, float height) {
 float sw = scale.scaledCeil(width), sh = scale.scaledCeil(height);
 HtmlCanvas canvas = new HtmlCanvas(sw, sh);
 canvas.scale(scale.factor, scale.factor);
 return canvas;
}
origin: com.googlecode.playn/playn-java

JavaCanvasImage(GLContext ctx, float width, float height) {
 super(ctx, new BufferedImage(ctx.scale.scaledCeil(width), ctx.scale.scaledCeil(height),
                BufferedImage.TYPE_INT_ARGB_PRE), ctx.scale);
 Graphics2D gfx = img.createGraphics();
 gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 gfx.scale(ctx.scale.factor, ctx.scale.factor);
 canvas = new JavaCanvas(gfx, width(), height());
}
origin: threerings/playn

JavaCanvasImage(GLContext ctx, float width, float height) {
 super(ctx, new BufferedImage(ctx.scale.scaledCeil(width), ctx.scale.scaledCeil(height),
                BufferedImage.TYPE_INT_ARGB_PRE), ctx.scale);
 Graphics2D gfx = img.createGraphics();
 gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 gfx.scale(ctx.scale.factor, ctx.scale.factor);
 canvas = new JavaCanvas(gfx, width(), height());
}
origin: threerings/playn

@Override
public void setSize(int width, int height, boolean fullscreen) {
 int rawWidth = ctx.scale.scaledCeil(width), rawHeight = ctx.scale.scaledCeil(height);
 platform.comp.setSize(rawWidth, rawHeight);
 platform.shell.setFullScreen(fullscreen);
 platform.shell.pack();
}
origin: threerings/playn

@Override
public void setSize(int width, int height) {
 int swidth = scale.scaledCeil(width), sheight = scale.scaledCeil(height);
 super.setSize(swidth, sheight);
 elem.setWidth(swidth);
 elem.setHeight(sheight);
 rootWidth = swidth;
 rootHeight = sheight;
}
origin: com.googlecode.playn/playn-swt-java

@Override
public void setSize(int width, int height, boolean fullscreen) {
 int rawWidth = ctx.scale.scaledCeil(width), rawHeight = ctx.scale.scaledCeil(height);
 platform.comp.setSize(rawWidth, rawHeight);
 platform.shell.setFullScreen(fullscreen);
 platform.shell.pack();
}
origin: com.googlecode.playn/playn-java

public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) {
 this.platform = platform;
 // if we're being run in headless mode, create a stub GL context which does not trigger the
 // initialization of LWJGL; this allows tests to run against non-graphics services without
 // needing to configure LWJGL native libraries
 this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) :
  new JavaGLContext(platform, config.scaleFactor);
 this.rootLayer = new GroupLayerGL(ctx);
 // set up the dummy font contexts
 Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
 aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 aaFontContext = aaGfx.getFontRenderContext();
 Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
 aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
 aFontContext = aGfx.getFontRenderContext();
 if (!config.headless) {
  setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height),
          config.fullscreen);
 }
}
origin: threerings/playn

public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) {
 this.platform = platform;
 // if we're being run in headless mode, create a stub GL context which does not trigger the
 // initialization of LWJGL; this allows tests to run against non-graphics services without
 // needing to configure LWJGL native libraries
 this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) :
  new JavaGLContext(platform, config.scaleFactor);
 this.rootLayer = new GroupLayerGL(ctx);
 // set up the dummy font contexts
 Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
 aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 aaFontContext = aaGfx.getFontRenderContext();
 Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
 aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
 aFontContext = aGfx.getFontRenderContext();
 if (!config.headless) {
  setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height),
          config.fullscreen);
 }
}
origin: threerings/playn

@Override
protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY,
                float x, float y, float width, float height) {
 assert isReady() : "Cannot generate a pattern from unready image.";
 // we have to account for the scale factor when extracting our subimage
 BufferedImage subImage = img.getSubimage(
  scale.scaledFloor(x), scale.scaledFloor(y),
  scale.scaledCeil(width), scale.scaledCeil(height));
 Rectangle2D rect = new Rectangle2D.Float(0, 0, width, height);
 return new JavaPattern(image, repeatX, repeatY, new TexturePaint(subImage, rect));
}
origin: com.googlecode.playn/playn-java

@Override
protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY,
                float x, float y, float width, float height) {
 assert isReady() : "Cannot generate a pattern from unready image.";
 // we have to account for the scale factor when extracting our subimage
 BufferedImage subImage = img.getSubimage(
  scale.scaledFloor(x), scale.scaledFloor(y),
  scale.scaledCeil(width), scale.scaledCeil(height));
 Rectangle2D rect = new Rectangle2D.Float(0, 0, width, height);
 return new JavaPattern(image, repeatX, repeatY, new TexturePaint(subImage, rect));
}
origin: threerings/playn

public RoboCanvas(RoboGLContext ctx, float width, float height, boolean interpolate) {
 super(width, height);
 // if our size is invalid, we'll fail below at CGBitmapContext, so fail here more usefully
 if (width <= 0 || height <= 0) throw new IllegalArgumentException(
  "Invalid size " + width + "x" + height);
 states.addFirst(new RoboCanvasState());
 this.ctx = ctx;
 // create our raw image data
 texWidth = ctx.scale.scaledCeil(width);
 texHeight = ctx.scale.scaledCeil(height);
 // create the bitmap context via which we'll render into it
 bctx = RoboGraphics.createCGBitmap(texWidth, texHeight);
 if (!interpolate) {
  bctx.setInterpolationQuality(CGInterpolationQuality.None);
 }
 // clear the canvas before we scale our bitmap context to avoid artifacts
 bctx.clearRect(new CGRect(0, 0, texWidth, texHeight));
 // CG coordinate system is OpenGL-style (0,0 in lower left); so we flip it
 bctx.translateCTM(0, ctx.scale.scaled(height));
 bctx.scaleCTM(ctx.scale.factor, -ctx.scale.factor);
}
origin: com.googlecode.playn/playn-swt-java

public SWTGraphics (SWTPlatform platform, JavaPlatform.Config config, final Composite comp) {
 super(platform, config);
 this.platform = platform;
 // create our GLCanvas
 GLData data = new GLData ();
 data.doubleBuffer = true;
 canvas = new GLCanvas(comp, SWT.NONE, data);
 makeCurrent();
 comp.addListener(SWT.Resize, new Listener() {
  public void handleEvent(Event event) {
   // resize our GLCanvas to fill the window; we do manual layout so that other SWT widgets
   // can be overlaid on top of our GLCanvas
   Rectangle bounds = comp.getBounds();
   comp.setBounds(bounds);
   canvas.setBounds(bounds);
   makeCurrent();
   // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height);
   ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height));
  }
 });
 // platform.log().info("Setting size " + config.width + "x" + config.height);
 platform.comp.setSize(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height));
 platform.shell.pack();
}
origin: threerings/playn

public SWTGraphics (SWTPlatform platform, JavaPlatform.Config config, final Composite comp) {
 super(platform, config);
 this.platform = platform;
 // create our GLCanvas
 GLData data = new GLData ();
 data.doubleBuffer = true;
 canvas = new GLCanvas(comp, SWT.NONE, data);
 makeCurrent();
 comp.addListener(SWT.Resize, new Listener() {
  public void handleEvent(Event event) {
   // resize our GLCanvas to fill the window; we do manual layout so that other SWT widgets
   // can be overlaid on top of our GLCanvas
   Rectangle bounds = comp.getBounds();
   comp.setBounds(bounds);
   canvas.setBounds(bounds);
   makeCurrent();
   // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height);
   ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height));
  }
 });
 // platform.log().info("Setting size " + config.width + "x" + config.height);
 platform.comp.setSize(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height));
 platform.shell.pack();
}
origin: threerings/playn

private int scaleTexture() {
 int scaledWidth = scale.scaledCeil(width());
 int scaledHeight = scale.scaledCeil(height());
 // GL requires pow2 on axes that repeat
 int width = GLUtil.nextPowerOfTwo(scaledWidth), height = GLUtil.nextPowerOfTwo(scaledHeight);
 // TODO: if width/height > platform_max_size, repeatedly scale by 0.5 until within bounds
 // platform_max_size = 1024 for iOS, GL10.GL_MAX_TEXTURE_SIZE on android, etc.
 // no need to scale if our source data is already a power of two
 if ((width == 0) && (height == 0)) {
  int reptex = createPow2RepTex(scaledWidth, scaledHeight, repeatX, repeatY, mipmapped);
  if (mipmapped) ctx.generateMipmap(reptex);
  return reptex;
 }
 // otherwise we need to scale our non-repeated texture, so load that normally
 int tex = createMainTex();
 // width/height == 0 => already a power of two.
 if (width == 0)
  width = scaledWidth;
 if (height == 0)
  height = scaledHeight;
 // create our texture and point a new framebuffer at it
 try {
  return convertToRepTex(ctx, tex, width, height, repeatX, repeatY, mipmapped);
 } finally {
  // delete the non-repeated texture
  ctx.destroyTexture(tex);
 }
}
origin: threerings/playn

private int scaleTexture() {
 int scaledWidth = scale().scaledCeil(this.width);
 int scaledHeight = scale().scaledCeil(this.height);
playn.core.glScalescaledCeil

Javadoc

Returns the supplied length scaled by our scale factor and rounded up.

Popular methods of Scale

  • invScaled
  • <init>
  • getScaledResources
  • invScaledFloor
  • scaled
    Returns the supplied length scaled by our scale factor.
  • computePath
  • scaledFloor

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now