Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
podem me dizer porque esta dando erro.
a imagem deve ser refletida
Desenhar(P1.getGraphics());
// TODO add your handling code here:
}
//desenho a ser refletido
private void Desenhar(Graphics g)
{ try {g.clearRect(0,0,400,280);
g.setColor(Color.BLUE);
// Polygon p=new Polygon();
int x1,y1,x2,y2,k=20; // k tamanho do desenho
double r=1+2*Math.cos(Math.toRadians(0));
x1=150+(int)(k*r*Math.cos(Math.toRadians(0)));
y1=80+(int)(k*r*Math.sin(Math.toRadians(0)));
for(int i=1;i<=360;i++)
{ r=1+2*Math.cos(Math.toRadians(8*i)); // equação polar r=1+2cos(2ang)
x2=150+(int)(k*r*Math.cos(Math.toRadians(i))); // coordenadas retangulares
y2=80+(int)(k*r*Math.sin(Math.toRadians(i)));
g.drawLine(x1,y1, x2, y2);
// g.drawPolygon(p);
x1=x2;
y1=y2;
}
//g.fillPolygon(p);
Thread.sleep(1000); // 50 milisegundos:
g.clearRect(0,0,400,280);
}
catch(InterruptedException e)
{ }
}
public class ReflectedImage
{
public Image create(Image image, int bgColor, int reflectionHeight)
{
int w = image.GetWidth[400];//erro
int h = image.GetHeight[280];//erro
Image reflectedImage = Image.createImage(400,280 + reflectionHeight);
Graphics g = reflectedImage.getGraphics();
g.setColor(Color.BLUE);
g.fillRect(0, 0, 400,280 + reflectionHeight);
g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);//erro
int[] rgba = new int[w];
int Y = -1;
for(int i = 0; i < reflectionHeight; i++)
{
int y = (h - 1) - (i * h / reflectionHeight);
if(y != Y)
image.getRGB(rgba, 0, w, 0, y, w, 1);//erro
int alpha = 0xff - (i * 0xff / reflectionHeight);
for(int j = 0; j < w; j++)
{
int origAlpha = (rgba[j] >> 24);
int newAlpha = (alpha & origAlpha) * alpha / 0xff;
rgba[j] = (rgba[j] & 0x00ffffff);
rgba[j] = (rgba[j] | (newAlpha << 24));
}
g.drawRGB(rgba, 0, w, 0, h + i, w, 1, true); //erro
}
return reflectedImage;
}
}Carregando comentários...