Anda di halaman 1dari 4

Texture

Buat variabel
Buatvariabel
TexturePainttcabai;
BufferedImagecabai;
BufferedImage cabai;

publicTexture(){
try{
y{
cabai=
ImageIO.read(this.getClass().getResource("cabai.bmp"));
}
catch(IOExceptione){
(
p
){
e.printStackTrace();
}
}
initComponents();
}

publicvoidpaint(Graphicsg){
super.paint(g);
i ( )
Graphics2Dg2d=(Graphics2D)g;
tcabai =newTexturePaint(cabai,newRectangle(0,0,25,25));
tcabai
new TexturePaint(cabai, new Rectangle(0, 0, 25, 25));
GeneralPathcb=newGeneralPath(GeneralPath.WIND_NON_ZERO);
g2d.setColor(Color.red);
cb.moveTo( 100.0f,25.0f);
cb.lineTo(+100.0f,25.0f);
cb.lineTo(
b li T ( 50.0f,+100.0f);
50 0f 100 0f)
cb.lineTo( 0.0f,100.0f);
cb.lineTo(+ 50.0f, + 100.0f);
cb.lineTo(+50.0f,+100.0f);
cb.closePath();
g2d.translate(250.0f,100.0f);
g2d.draw(cb);
g2d.setPaint(tcabai);
g2d.fill(cb);
2d fill( b)
}

Anda mungkin juga menyukai