Results 1 to 2 of 2
Thread: Rotating image with an Applet
- 03-11-2012, 03:49 AM #1
Rotating image with an Applet
I'm trying to rotate an image with Applet, but I'm having some problems.
Java Code:package Cell; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.awt.image.BufferedImage; public class Shiznit_2 extends Applet implements Runnable { private Image ship; int width = 300; int height = 300; int x = width/2; int y = height/2; int dx; int dy; double angle= 0.0; AffineTransform turn; BufferedImage bi; Graphics2D bs; Thread t; public void start(){ Thread gameThread = new Thread(this); gameThread.start(); } public void init() { setSize(300, 300); ship = getImage(getCodeBase(),"Cell/mito_0.gif"); dx=ship.getWidth(this); dy=ship.getHeight(this); turn = new AffineTransform(); bi = (BufferedImage)createImage(WIDTH, HEIGHT); bs = bi.createGraphics(); } public void run(){ while(true) { angle-=1; turn.translate(x, y); turn.rotate(Math.toRadians(angle), (50), (50) ); repaint(); } } public void paint(Graphics g) { update(g); } public void update(Graphics g) { Graphics2D g2 = (Graphics2D)g; bs.clearRect(0, 0, WIDTH, HEIGHT); bs.drawImage(ship, turn, this); g2.drawImage(bi, 0, 0, this); } }
Its supposed to spin the image using AffineTransform, but when I run it I just get a blank white screen.
Some help or tutorials links would be nice!
- 03-11-2012, 06:22 AM #2
Similar Threads
-
Help with Image Rotating?
By Leospaceman in forum Java 2DReplies: 2Last Post: 05-31-2011, 03:48 PM -
Problem in rotating an image
By newtoapplets in forum Java AppletsReplies: 0Last Post: 02-28-2011, 07:12 AM -
Rotating Buffered Image distorts image
By VortexSpin in forum Java 2DReplies: 1Last Post: 02-13-2011, 06:54 AM -
Rotating an image
By lackofcolor in forum Java 2DReplies: 3Last Post: 02-28-2009, 12:54 AM -
Rotating Image?
By sciguy77 in forum Java AppletsReplies: 9Last Post: 02-17-2009, 02:47 AM
Bookmarks