TREE ANIMATION USING C++ GRAPHICS
TREE ANIMATION USING C++
GRAPHICS
VIDYAVARDHINI INSTITUTE OF TECHNOLOGY PAI
1
TREE ANIMATION USING C++ GRAPHICS
INTRODUCTION
In the realm of computer graphics and programming, the creation of visually engaging and
interactive animations is a fascinating endeavor. Our Tree Animation Microproject in C++
graphics is designed to introduce you to the exciting world of computer graphics while letting
you explore the beauty of nature through the creation of a dynamic and vibrant tree animation.
In this project, you will harness the power of C++ and its
graphics libraries to construct a digital tree that not only sways gently in the virtual breeze but
also allows for user interaction. You will delve into fundamental concepts such as rendering,
animation, and event handling to bring your tree to life on the screen.
Through this microproject, you will:
Learn the basics of C++ graphics programming.
Understand the principles of object-oriented programming for creating graphical
elements.
Explore the art of animation by manipulating visual elements like branches and leaves.
Implement user interactivity, enabling users to control aspects of the animation.
Gain valuable experience in project development, coding, and problem-solving.
By the end of this microproject, you will have not only enhanced your C++ programming
skills but also created a captivating tree animation that can serve as a foundation for more
complex graphics projects. So, let's embark on this creative journey to bring a digital tree
to life through the magic of C++ graphics!
VIDYAVARDHINI INSTITUTE OF TECHNOLOGY PAI
2
TREE ANIMATION USING C++ GRAPHICS
SOURCE CODE
#include<conio.h>
#include<iostream.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void tree(float x, float y, float len, float a, float b)
{
if (len<20)
{
delay(50);
setcolor(14);
circle(x,y,6);
return;
}
float x1, y1;
setcolor(14);
outtextxy(150,5);
setcolor(10);
x1=x+len*cos(3.1428*a/180);
y1=y-len*sin(3.1428*a/180);
tree(x1, y1, len*0.75,a-b,b);
tree(x1, y1, len*0.75,a-b, -b);
}
void main( )
{
int gd=0,gm,i,rd;
float x=320,y=550, t=140;
clrscr( );
initgraph(&gd,&gm,”c://turboc3//bgi”);
for(i=0; i<=3; i++)
{
tree(x+i, y,t, 90,30);
tree(x+i, y, t, 90, -30);
}
getch( );
closegraph( );
}
VIDYAVARDHINI INSTITUTE OF TECHNOLOGY PAI
3
TREE ANIMATION USING C++ GRAPHICS
output
VIDYAVARDHINI INSTITUTE OF TECHNOLOGY PAI
4
TREE ANIMATION USING C++ GRAPHICS
Conclucion:-
he project showcased the following key features:
1. Realistic tree growth animation, with branches dynamically extending and leaves
sprouting.
2. User interactivity for controlling the growth speed and resetting the animation.
3. A visually pleasing and intuitive interface, enhancing the user experience.
This microproject serves as a valuable learning experience for those
interested in computer graphics and C++ programming. It highlights the importance of algorithm
design, user interface development, and graphical rendering in the context of interactive
animations.
Moving forward, there is room for further enhancements, such as adding more
complex tree structures, optimizing performance, or integrating additional user features. This
project provides a strong foundation for anyone interested in expanding their skills in C++
graphics programming and creating more sophisticated animations.
VIDYAVARDHINI INSTITUTE OF TECHNOLOGY PAI