Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2010 The PlayN Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package playn.java;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.util.Deque;
import java.util.LinkedList;
import playn.core.*;
import pythagoras.f.FloatMath;
import pythagoras.f.MathUtil;
class JavaCanvas extends Canvas {
final Graphics2D g2d;
private Deque stateStack = new LinkedList();
private Ellipse2D.Float ellipse = new Ellipse2D.Float();
private Line2D.Float line = new Line2D.Float();
private Rectangle2D.Float rect = new Rectangle2D.Float();
private RoundRectangle2D.Float roundRect = new RoundRectangle2D.Float();
public JavaCanvas (Graphics gfx, JavaImage image) {
super(gfx, image);
g2d = image.bufferedImage().createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
float scale = image.scale().factor;
g2d.scale(scale, scale);
// push default state
stateStack.push(new JavaCanvasState());
// All clears go to rgba(0,0,0,0).
g2d.setBackground(new Color(0, true));
}
public float alpha() {
return currentState().alpha;
}
@Override
public Image snapshot() {
BufferedImage bmp = ((JavaImage)image).bufferedImage();
ColorModel cm = bmp.getColorModel();
boolean isAlphaPremultiplied = bmp.isAlphaPremultiplied();
WritableRaster raster = bmp.copyData(null);
BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
return new JavaImage(gfx, image.scale(), snap, "