Muhammad Ridhan Maulana. N - Pertemuan 9
Muhammad Ridhan Maulana. N - Pertemuan 9
Muhammad Ridhan Maulana. N - Pertemuan 9
N
Nim : 181011401397
Kelas : 06TPLP013
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import javax.imageio.*;
import java.io.*;
public cliping() {
this.setBackground(Color.WHITE);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
@Override
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
try
"Z:\\po.jpg"
));
//clip
g2.clip(lingkaran);
g2.setClip(null);
//image asli
g2.setColor(Color.BLACK);
catch(IOException e)
}
Source Code:
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public GrafikCanvas () {
//menambahkan Canvas
this.setBackground(Color.WHITE);
@Override
super.paintComponent (g);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.RED);
g2.setColor(Color.RED);
g2.setColor(Color.BLACK);
drawComposite(g2, 0.5f);
int[] alphaComp = {
AlphaComposite.SRC, AlphaComposite.DST_IN,
AlphaComposite.DST_OUT, AlphaComposite.DST_OVER,
AlphaComposite.SRC_IN, AlphaComposite.SRC_OVER,
AlphaComposite.SRC_OUT, AlphaComposite.CLEAR
};
"SRC_IN","SRC_OVER", "SRC_OUT","CLEAR" };
int x, y;
x = y = 40;
AlphaComposite ac;
ac = AlphaComposite.getInstance(alphaComp[j], alpha);
BufferedImage buffImg =
gbi.setColor(Color.BLUE);
gbi.setColor(Color.RED);
gbi.setComposite(ac);
g2.drawImage(buffImg,null, x, y);
g2.drawString(caption[j], x, y+70);
x += 80;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// tambahkan canvas
frame.getContentPane().add(canvas);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);