public Image rotate(double radians) {
		if(radians == 0) return new Image(pixels, width, height);
		int x, y, fromX, fromY, toX, toY, transparent = 0x7f007f;
		
		double cosAngle = Math.cos(radians);
		double sinAngle = Math.sin(radians);
		
		int[] rotatedPixels = new int[width * height];
		
		for (y = 0; y < height; y++) {
			for (x = 0; x < width; x++) {
				toX = (width / 2) - x;
				toY = (height / 2) - y;
				fromX = (int)((toX * cosAngle) - (toY * sinAngle));
				fromY = (int)((toX * sinAngle) + (toY * cosAngle));
				fromX += width / 2;
				fromY += height / 2;
				
				if (fromX < 0 || fromX >= width || fromY < 0 || fromY >= height) {
					rotatedPixels[x + y * width] = transparent;
				} else {
					rotatedPixels[x + y * width] = pixels[fromX + fromY * width];
				}
			}
		}
		
		Image rotatedImage = new Image(rotatedPixels, width, height);
		return rotatedImage;
	}