HELLO WORLD Animation

Hey there coders!  This is a new way to write “HELLO WORLD” in java. Whenever we start to learn any language it is a convention to first print “HELLO WORLD” using that language. Thereby, this word is special for us all coders and developers.So here I  have made a little animation on this beloved phrase.

It is basically similar to the way we would write it with a pen on a sheet in capitals. Alternate colours have been used in this animation to make it more appealing. It is a very simple animation and useful for beginners to try.

This animation is making use of applet package and Abstract Window Toolkit package for graphics.

Following is a part of animation along with the source code.

Hello World animation

Running Program

 

The code for the animation :

import java.applet.*;
import java.awt.*;

public class hello extends Applet {
  
  public void init()
  {
    resize(500,500);
    setBackground(Color.white);
  }
  
  public void paint(Graphics g)
  {
    g.setColor(Color.red);
    try{//HELLO
      //H
    for(int i=100;i<151;i++)
    {
      g.fillOval(50, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=50;i<76;i++)
    {
      g.fillOval(i, 125, 5, 5);
      Thread.sleep(10);
    }
    g.setColor(Color.red);
    for(int i=100;i<151;i++)
    {
      g.fillOval(75, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    //E
    for(int i=100;i<151;i++)
    {
      g.fillOval(100, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=100;i<126;i++)
    {
      g.fillOval(i, 100, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=100;i<126;i++)
    {
      g.fillOval(i, 125, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=100;i<126;i++)
    {
      g.fillOval(i, 150, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    //L
    for(int i=100;i<151;i++)
    {
      g.fillOval(150, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    
    for(int i=150;i<176;i++)
    {
      g.fillOval(i, 150, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    //L
    for(int i=100;i<151;i++)
    {
      g.fillOval(200, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=200;i<226;i++)
    {
      g.fillOval(i, 150, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    //O
    for(int i=100;i<151;i++)
    {
      g.fillOval(250, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=250;i<276;i++)
    {
      g.fillOval(i, 150, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=150;i>99;i--)
    {
      g.fillOval(275, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=275;i>249;i--)
    {
      g.fillOval(i, 100, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    
    //WORLD
    
      //W
    for(int i=200;i<251;i++)
    {
      g.fillOval(50, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=50;i<63;i++)
    {
      g.fillOval(i, 250, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=250;i>226;i--)
    {
      g.fillOval(62, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=62;i<76;i++)
    {
      g.fillOval(i, 250, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=250;i>199;i--)
    {
      g.fillOval(75,i , 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    //O
    for(int i=200;i<251;i++)
    {
      g.fillOval(100, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=100;i<126;i++)
    {
      g.fillOval(i, 250, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=250;i>199;i--)
    {
      g.fillOval(125, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=125;i>99;i--)
    {
      g.fillOval(i, 200, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    //R
    for(int i=200;i<251;i++)
    {
      g.fillOval(150, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=150;i<176;i++)
    {
      g.fillOval(i, 200, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    for(int i=200;i<226;i++)
    {
      g.fillOval(175, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    for(int i=175;i>149;i--)
    {
      g.fillOval(i,225,5,5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    int x=150,y=225;
    while(x<176)
    {
      g.fillOval(x, y, 5, 5);
      x++;y++;
      Thread.sleep(10);
    }g.setColor(Color.blue);
    //L
    for(int i=200;i<251;i++)
    {
      g.fillOval(200, i, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.red);
    
    for(int i=200;i<226;i++)
    {
      g.fillOval(i, 250, 5, 5);
      Thread.sleep(10);
    }g.setColor(Color.blue);
    
    //D
    
    for(int i=200;i<251;i++)
    {
      g.fillOval(250, i, 5, 5);
      Thread.sleep(10);
    }
    x=250;y=200;g.setColor(Color.red);
    while(x<276)
    {
      g.fillOval(x,y,5,5);
      x++;y++;
      Thread.sleep(10);
    }g.setColor(Color.blue);
    x=275;y=225;
    while(x>249)
    {
      g.fillOval(x, y, 5, 5);
      x--;y++;
      Thread.sleep(10);
    }
    }
    catch(Exception e)
    {}
      
  }

}

Code for each letter is mentioned above.Sleep time included here is ten. It can be increased or decreased according to desire. The words are also being written in the alternate colour that is red and blue, you improvise this animation with different words and colours.

You can also try different animations on this.

 

So try it for yourselves.

The following two tabs change content below.
Vijay Kashyap

Vijay Kashyap

Animation Programmer and Designer
Enthusiastic coder. Love to play games and make animations. Has a taste for designing and modelling. 🙂
Vijay Kashyap

Latest posts by Vijay Kashyap (see all)

You may also like...