You are on page 1of 24

Computer Engineering Project Topic Name

A Report On
“MICRO PROJECT”

“TWINKLING STAR"

Submitted from the

“DIPLOMA IN COMPUTER ENGINEERING”

MSBTE, PUNE

Department of Computer Engineering


Abhaysinhraje Bhonsle Institute of Technology
(Polytechnic), Shendre, Satara.

Academic Year – 2023-2024

Page 1 of 24
Computer Engineering Project Topic Name

Vidyavardhini Charitable trust


Abhaysinhraje Bhonsle Institute of Technology
Shahunagar -Shendre, Satara.

CERTIFICATE
This is to certify that:

Name and roll no’s of group members

22:PIYUSH AMOL PATIL


23:VARSHA MANIK PATIL
24:PRERNA HIRALAL PAWAR

GUIDE H.O.D. PRINCIPAL

Page 2 of 24
Computer Engineering Project Topic Name

TABLE OF CONTENTS

Sr. Index Page No.


No.
1. Abstract 4

2. Action plan 5

3. Introduction 6

4. Project Objective 7

5. Algorithm 8-9

6. Flowchart 10

7. Program 11-15

8. Output 16-19

9 Implementation of microproject 20-21

1. Conclusion 22

2. Reference 23

Page 3 of 24
Computer Engineering Project Topic Name

ABSTRACT

The "Animated Twinkle Star Using C Graphics" mini-project is a computer


graphics program that aims to create a visually appealing and dynamic
twinkle star animation using the C programming language. This project
leverages the graphics library in C to draw and manipulate geometric shapes
to simulate the twinkling effect of a star.

The main objectives of this mini-project are as follows:

Graphics Rendering: Utilize C graphics functions to create a graphical


environment where we can draw and animate objects.

Star Creation: Implement algorithms to draw a star-like shape with multiple


points. This will serve as the central element of the animation.

Twinkling Effect: Develop a twinkle effect by varying the brightness of the


star points over time. This can be achieved by modifying the color and
intensity of the star points.

Animation Control: Implement timing and control mechanisms to regulate


the twinkling effect and overall animation. Users should be able to start,
pause, or reset the animation.

User Interaction: Enhance the project by allowing user interaction, such as


adjusting the animation speed or the number of points in the star.

Page 4 of 24
Computer Engineering Project Topic Name

ACTION PLAN

Sr. Details of Activity Start Finish Responsible


No. Date Date Team Member

1. Selected the topic for Micro 3-8-2023 6-8-2023 Prerna


project Varsha
2. Organized things required 11-8-2023 15-8-2023 Piyush
for Micro project
3. Browsed for information of 18-8-2023 24-8-2023 Varsha
raw data Prerna

4. Attended extra lecture for 3-9-2023 17-9-2023 Prerna


project Piyush

5. Prepared notes accordingly 21-9-2023 29-9-2023 Prerna

6. Created Word document 2-10-2023 15-10-2023 Prerna


with our teacher’s help Varsha
Piyush

7. Made required corrections 17-10-2023 20-10-2023 Varsha


after discussion
8. Also created a PDF 24-10-2023 29-10-2023 Prerna
document to make a hard Varsha
copy of the report

Page 5 of 24
Computer Engineering Project Topic Name

INTRODUCTION

In the world of computer programming, few endeavors are as enchanting and


visually captivating as creating animations. The "Animated Twinkle Star
Using C Graphics" mini-project is a delightful exploration of graphics
programming in the C language, designed to introduce you to the exciting
realm of computer graphics through the creation of a charming and dynamic
twinkling star animation.

Computer graphics programming allows us to bring imagination to life on the


screen, blending artistry and logic to craft captivating visual experiences.
With this project, we embark on a journey that combines the elegance of C
with the creative canvas of graphics to simulate the mesmerizing twinkle of a
star in a night sky.

PROJECT OBJECTIVE
Page 6 of 24
Computer Engineering Project Topic Name

The primary goals of this mini-project are as follows:

1) Graphics Programming Proficiency: Develop a solid foundation in


graphics programming using the C language. Learn how to set up a
graphical environment, draw geometric shapes, and control animations.

2) Realistic Animation: Explore the principles of animation to create a lifelike


twinkling effect for the star. Emulate the subtle changes in brightness that
make a star twinkle in the night sky.

3) User Interaction: Enable user interaction with the animation, allowing


users to adjust parameters such as animation speed, number of points in
the star, or even add additional elements to the scene.

4) Creative Expression: Encourage creativity by allowing customization of


the star's appearance and behavior. Experiment with colors, sizes, and
patterns to make your twinkling star unique.

5) Problem-Solving Skills: Enhance your problem-solving abilities by tackling


challenges related to graphics rendering, animation timing, and user
interface design.

6) Educational Value: Provide an educational platform for beginners in


programming and graphics, enabling them to gain practical experience
and insights into these exciting fields.

Page 7 of 24
Computer Engineering Project Topic Name

ALGORITHM -
1) Initialize Graphics: Set up the graphics environment using the appropriate
C graphics library (e.g., SDL, OpenGL, or a library specific to your
development environment). Create a window or canvas for rendering.

2) Define Star Shape: Decide on the number of points for your star shape. A
typical choice might be a five-pointed star (pentagram). You can choose to
create a star shape using basic geometric principles, such as triangles and
lines, or use predefined shapes if available in your graphics library.

3) Animation Loop: Implement an animation loop that continually refreshes


the screen. This loop is responsible for drawing and updating the star's
appearance.

4) Star Positioning: Determine the position of the star on the canvas. You may
want to place it in the center of the screen or at a random position.

5) Twinkling Effect: To create the twinkling effect, randomly modify the


brightness or color of the star points at regular intervals. You can achieve
this by adjusting the RGB values of the star's color. For example, you
might increase and decrease the intensity of the star's color to simulate
twinkling.

6) User Interaction: Allow user interaction by implementing controls to


adjust animation speed or change the number of points in the star. Listen
for user input (e.g., key presses or mouse clicks) and respond accordingly.

7) Animation Timing: To control the speed of the animation, use timing


mechanisms like sleep or timer callbacks. Adjust the time delay between
frames to achieve the desired animation speed.

Page 8 of 24
Computer Engineering Project Topic Name

8) Clear and Redraw: In each iteration of the animation loop, clear the
previous frame to erase the previous state of the star, then redraw the star
in its new state.

9) Repeat: Continue looping through steps 5-8 to create a continuous and


twinkling animation. This loop runs until the user decides to exit the
program.

10) Exit Handling: Implement a mechanism to gracefully exit the program


when the user decides to close the window or press a specific key.

11) Cleanup: Properly release any allocated resources (e.g., memory) and
close the graphics window when the program exits.

12) Documentation: Finally, document your code, providing comments and


explanations for each major function and section to make it
understandable and maintainable.

FLOW CHART -

Page 9 of 24
Computer Engineering Project Topic Name

Start

Initialize graphic mode and graphic driver

if (err I)= grOk


if (i‘== DARKGRAY Declare line function

Declare variables line function

End

PROGRAM –
#include<stdio.h>
Page 10 of 24
Computer Engineering Project Topic Name

#include<conio.h>
#include<graphics.h>
#include<dos.h>
int main() {

/* request auto detection */


int gdriver = DETECT, gmode, err;
int i, midx, midy;

/* initialize graphic mode */


initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
err = graphresult();

if (err != grOk) {
/* error occurred */
printf("Graphics Error: %s\n",
grapherrormsg(err));
return 0;
}

/* center position of the star */


midx = getmaxx() / 2;
midy = getmaxy() / 2;

/*
* draw a star and fill with different
* colors to get twinkling effect
Page 11 of 24
Computer Engineering Project Topic Name

*/
for (i = 1; i <= 15; i++) {
if (i == DARKGRAY)
continue;

setcolor(i);
setfillstyle(SOLID_FILL, i);

/* top portion of star */


line(midx, midy - 100, midx + 30, midy);
line(midx, midy - 100, midx, midy + 30);
line(midx + 30, midy, midx, midy + 30);
floodfill(midx + 1, midy + 1, i);

setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
line(midx + 30, midy, midx + 140, midy);
line(midx + 30, midy, midx, midy + 30);
line(midx + 140, midy, midx, midy + 30);
floodfill(midx + 31, midy + 1, DARKGRAY);

/* right portion of star */


setcolor(i);
setfillstyle(SOLID_FILL, i);
line(midx + 140, midy, midx, midy + 30);
line(midx + 140, midy, midx + 40, midy + 50);
line(midx + 40, midy + 50, midx, midy + 30);
Page 12 of 24
Computer Engineering Project Topic Name

floodfill(midx + 40, midy + 48, i);

setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
line(midx + 40, midy + 50, midx, midy + 30);
line(midx + 40, midy + 50, midx + 110, midy + 160);
line(midx + 110, midy + 160, midx, midy + 30);
floodfill(midx + 40, midy + 51, DARKGRAY);

/* bottom right portion of star */


setcolor(i);
setfillstyle(SOLID_FILL, i);
line(midx + 110, midy + 160, midx, midy + 30);
line(midx + 110, midy + 160, midx, midy + 90);
line(midx, midy + 90, midx, midy + 30);
floodfill(midx + 1, midy + 90, i);
setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
line(midx, midy + 90, midx, midy + 30);
line(midx, midy + 30, midx - 110, midy + 160);
line(midx - 110, midy + 160, midx, midy + 90);
floodfill(midx - 1, midy + 90, DARKGRAY);

/* bottom left portion of star */


setcolor(i);
setfillstyle(SOLID_FILL, i);
line(midx, midy + 30, midx - 110, midy + 160);
Page 13 of 24
Computer Engineering Project Topic Name

line(midx - 40, midy + 50, midx - 110, midy + 160);


line(midx - 40, midy + 50, midx, midy + 30);
floodfill(midx - 38, midy + 50, i);

setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
line(midx - 40, midy + 50, midx, midy + 30);
line(midx - 140, midy, midx - 40, midy + 50);
line(midx - 140, midy, midx, midy + 30);
floodfill(midx - 40, midy + 48, DARKGRAY);

/* left portion of star */


setcolor(i);
setfillstyle(SOLID_FILL, i);
line(midx - 30, midy, midx - 140, midy);
line(midx - 140, midy, midx, midy + 30);
line(midx - 30, midy, midx, midy + 30);
floodfill(midx - 30, midy + 1, i);

setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
line(midx - 30, midy, midx, midy + 30);
line(midx, midy - 100, midx - 30, midy);
line(midx, midy - 100, midx, midy + 30);
floodfill(midx - 28, midy, DARKGRAY);
/* sleep for 2 seconds */
sleep(2);
Page 14 of 24
Computer Engineering Project Topic Name

}
getch();
/* deallocate memory allocated for graphic screen */
closegraph();
return 0;
}

Page 15 of 24
Computer Engineering Project Topic Name

OUTPUT:

Page 16 of 24
Computer Engineering Project Topic Name

Page 17 of 24
Computer Engineering Project Topic Name

Page 18 of 24
Computer Engineering Project Topic Name

Page 19 of 24
Computer Engineering Project Topic Name

IMPLEMENTATION OF
“Project Topic Name”
1..Setup Graphics Environment:
● Initialize the graphics library (e.g., using TurboC, SDL, or OpenGL).

● Create a window or canvas for rendering.

2.. Define Star Shape:


● Decide on the number of points for your star shape (e.g., a five-pointed star).

● Define star coordinates, size, and initial appearance.

3.. Animation Loop:


● Create a loop that continues until a user exit command is given.

● Inside the loop, repeatedly:

● Clear the screen to erase the previous frame.

● Update the star's appearance to simulate the twinkling effect.

● Handle user interaction (e.g., adjust animation speed, exit command).

4.. Twinkling Effect:


● Randomly modify the brightness or color of the star points.

● Redraw the star with the updated appearance.

5.. User Interaction:


● Implement controls to:

Page 20 of 24
Computer Engineering Project Topic Name

● Adjust animation speed (e.g., using keyboard input).

● Change the number of points in the star (if desired).

● Exit the program gracefully.

6..Timing and Delays:


● Use timing mechanisms (e.g., delay or timers) to control animation speed.

7..Cleanup and Exit:


● Release allocated resources (e.g., memory) and close the graphics window
when the program exits.

8.. Documentation and Comments:


● Add comments and documentation to your code to make it understandable
and maintainable.

9..Testing and Debugging:


● Test your program, check for errors, and debug as needed.

Page 21 of 24
Computer Engineering Project Topic Name

CONCLUSION

❖ In conclusion, the "Animated Twinkle Star Using C Graphics" mini-


project has provided a practical introduction to graphics programming
in C. By creating a dynamic twinkling star animation, you've learned
the basics of graphics rendering, animation control, and user
interaction. This project serves as a foundation for further exploration
of computer graphics and animation, offering a blend of creativity and
coding skills.

Page 22 of 24
Computer Engineering Project Topic Name

REFERENCE

Website Name:
● "Computer Graphics with Open GL" by Donald Hearn and
M. Pauline Baker: This is a classic textbook for learning
computer graphics with OpenGL.
Page 23 of 24
Computer Engineering Project Topic Name

● "Beginning OpenGL Game Programming" by Dave Astle and


Kevin Hawkins: It's a good book for those who want to get into
game programming with OpenGL.

Reference Books Name:


● LearnOpenGL: LearnOpenGL is a fantastic online resource
for learning modern OpenGL. It provides tutorials with
explanations and code examples.
● SDL Game Development: If you prefer using SDL, you can
find tutorials and examples on the official SDL website. Also,
there are community-contributed tutorials and resources.

Page 24 of 24

You might also like