package exercicio3_6; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.Ellipse2D; import javax.swing.JApplet; import javax.swing.JFrame; import javax.swing.JPanel; public class Exercicio3_6 extends JApplet { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Exercicio3_6"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new Exercicio3_6(); applet.init(); frame.getContentPane().add(applet); frame.pack(); frame.setVisible(true); } public void init() { JPanel panel = new Exercicio3_6Panel(); getContentPane().add(panel); } } class Exercicio3_6Panel extends JPanel { public Exercicio3_6Panel() { setPreferredSize(new Dimension(400, 400)); setBackground(Color.BLUE); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; Font font = new Font("Serif", Font.PLAIN, 250); g2.setColor(Color.yellow); FontRenderContext fontrc = g2.getFontRenderContext(); GlyphVector vect = font.createGlyphVector(fontrc, "M"); Shape shape = vect.getOutline(100, 300); g2.setClip(shape); g2.setColor(Color.BLACK); g2.fill(shape); g2.setColor(Color.red); for (int i = 0; i < 1000; i++) { Shape shape2 = new Ellipse2D.Double(Math.random() * 500, Math.random() * 400, 30, 20); g2.draw(shape2); } FontRenderContext fontrc1 = g2.getFontRenderContext(); GlyphVector vect1 = font.createGlyphVector(fontrc1, "L"); Shape shape1 = vect1.getOutline(100, 300); g2.translate(5, 80); g2.rotate(-Math.PI / 6); g2.setClip(shape1); g2.setColor(Color.red); g2.fill(shape1); g2.setColor(Color.BLACK); for (int a = 0; a < 1000; a++) { Shape shape3 = new Ellipse2D.Double(Math.random() * 500, Math.random() * 400, 30, 20); g2.draw(shape3); } } }