public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) { if ( transform != null ) { // dispose of previous to prevent leaking of handles transform.dispose(); } transform = new Transform( gc.getDevice() ); transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification ); transform.scale( magnification, magnification ); gc.setTransform( transform ); currentMagnification = magnification; }
public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) { if ( transform != null ) { // dispose of previous to prevent leaking of handles transform.dispose(); } transform = new Transform( gc.getDevice() ); transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification ); transform.scale( magnification, magnification ); gc.setTransform( transform ); currentMagnification = magnification; }
@Override protected Image renderRotated( Device device, int width, int height, double angleRadians ) { Image result = new Image( device, width * 2, height * 2 ); GC gc = new GC( result ); int bw = bitmap.getBounds().width; int bh = bitmap.getBounds().height; Transform affineTransform = new Transform( device ); affineTransform.translate( width, height ); affineTransform.rotate( (float) Math.toDegrees( angleRadians ) ); affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh ); gc.setTransform( affineTransform ); gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh ); gc.dispose(); return result; } }
public Image getIcon(Icon id) { Image image = icons.get(id); if (image == null) { String vectorResName = "/icons/ic_" + id.name().toLowerCase() + (dark ? "_white_24dp.xml" : "_black_24dp.xml"); InputStream is = getClass().getResourceAsStream(vectorResName); int expectedSize = Math.round(24 * pixelPerDp); AndroidVectorDrawable avd = AndroidVectorDrawable.read(display, is, pixelPerDp); image = new Image(display, expectedSize, expectedSize); GC gc = new GC(image); if (expectedSize != 24) { Transform transform = new Transform(display); gc.getTransform(transform); transform.scale(expectedSize/24f, expectedSize/24f); gc.setTransform(transform); transform.dispose(); } avd.draw(gc); icons.put(id, image); } return image; }
/** * Applies a scale transform. * * @param scaleX the scale factor along the x-axis. * @param scaleY the scale factor along the y-axis. */ @Override public void scale(double scaleX, double scaleY) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.scale((float) scaleX, (float) scaleY); this.gc.setTransform(swtTransform); swtTransform.dispose(); }
transform.scale(scaleWidth, scaleWidth); transform.scale(scaleWidth, scaleWidth); gc.setTransform(transform); transform.dispose(); transform.scale(heartScale, 0.5f*scale); gc.setTransform(transform); transform.dispose(); transform.scale(0.5f*scale, spadeScale); gc.setTransform(transform); transform.dispose();
transform.scale(scaleSpinnerX.getSelection()/100f, scaleSpinnerY.getSelection()/100f);
@ActionParams(names="canvas,gc,shape") public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) { Thing thing = shape.getThing(); Path path = (Path) shape.getData(PATH); if(path != null && !path.isDisposed()) { float bounds[] = new float[4]; path.getBounds(bounds); //System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]); Transform oldTransform = new Transform(gc.getDevice()); gc.getTransform(oldTransform); Transform transform = new Transform(gc.getDevice()); transform.translate(shape.getX(), shape.getY()); transform.scale(shape.getWidth() / (bounds[0] + bounds[2]), shape.getHeight() / (bounds[1] + bounds[3])); //transform.multiply(oldTransform); gc.setTransform(transform); if(thing.getBoolean("fill")) { gc.fillPath(path); }else { gc.drawPath(path); } gc.setTransform(oldTransform); transform.dispose(); oldTransform.dispose(); } }
transform.translate((width - (bounds.width * scaleX + 10) * 4) / 2, 25 + bounds.height + size.y + (height - (25 + bounds.height + size.y + bounds.height*scaleY)) / 2); transform.scale(scaleX, scaleY);