Follow Me

Drawing a face using Java Graphics



By  Ajith KP     9:18 PM    Labels: 
          I hope you have all used MS-PAINT, GIMP, etc to draw pictures in your childhood. Here I would like to share how to draw a face using Java programming. In this program I have used JFrame, JPanel, Color and Graphics library to draw the face.


          Video Tutorial

          The source code

import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;

/*

    Coded By Ajith Kp [ ajithkp560 ]
    (C) » GPU SMACKERS ™ (C)

*/
public class FaceDrawApp extends JPanel{
    public void paintComponent(Graphics g)
    {
        //Draw Face
        g.setColor(Color.BLUE);
        g.drawOval(100, 100, 300, 400);
        
        //Draw EyeBrow
        g.setColor(Color.GREEN);
        g.drawRect(170, 190, 70, 5);
        g.drawRect(270, 190, 70, 5);
        
        //Draw Eyes
        g.setColor(Color.CYAN);
        g.drawOval(175, 200, 60, 40);
        g.drawOval(195, 210, 20, 20);
        g.drawOval(275, 200, 60, 40);
        g.drawOval(295, 210, 20, 20);
        
        //Draw Nose
        g.setColor(Color.RED);
        g.drawOval(240, 255, 40, 70);
        
        //Draw Lips
        g.setColor(Color.PINK);
        g.drawOval(180, 350, 150, 30);
        g.drawLine(180, 365, 330, 365);
        
        //Draw Ears
        g.setColor(Color.ORANGE);
        g.drawOval(75, 250, 25, 100);
        g.drawOval(400, 250, 25, 100);
        
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        JFrame fda = new JFrame("FaceDrawApp by Ajith Kp [ ajithkp560 ]");
        fda.setBackground(Color.BLACK);
        fda.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fda.setVisible(true);
        fda.setSize(500, 700);
        fda.add(new FaceDrawApp());
    }
    
}

About Ajith KP

I'm Ajith Kp (ajithkp560). I'm very interested in Graphics and its programming. Also I'm a good gamer. This blog is all about Graphics programming and games. Hope you will interested and share it with your friends. Thanks for visit...

1 comment:

  1. Casino Del Sol - Mapyro
    Welcome to Casino Del Sol, the 대구광역 출장샵 perfect place to relax, play and meet new players in 강릉 출장샵 San Diego County. Casino Del 광명 출장샵 Sol. 1 동두천 출장샵 block from Fremont 남원 출장안마 Street. Rating: 2.9 · ‎14 reviews

    ReplyDelete


Contact Form

Name

Email *

Message *

Translate