0% found this document useful (0 votes)
249 views23 pages

CG Microproject 3RD Sem

The document describes an animated twinkling star project created using C graphics. The objectives are to learn graphics programming, create a realistic twinkling animation, allow user interaction, and encourage creativity. The algorithm initializes graphics, defines a star shape, implements an animation loop to redraw the twinkling star, and allows user control of parameters like animation speed and number of points. The goal is to simulate the subtle brightness changes that make stars twinkle in the night sky.

Uploaded by

Prajakta Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
249 views23 pages

CG Microproject 3RD Sem

The document describes an animated twinkling star project created using C graphics. The objectives are to learn graphics programming, create a realistic twinkling animation, allow user interaction, and encourage creativity. The algorithm initializes graphics, defines a star shape, implements an animation loop to redraw the twinkling star, and allows user control of parameters like animation speed and number of points. The goal is to simulate the subtle brightness changes that make stars twinkle in the night sky.

Uploaded by

Prajakta Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

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 23
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

Mr.Sarate S.R Mrs.NikamR.A Mr.Dhumal S.U


(computer department) (computer department)

GUIDE H.O.D. PRINCIPAL

Page 2 of 23
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

10. Conclusion 22

20. Reference 23

ABSTRACT

Page 3 of 23
Computer Engineering Project Topic Name

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.

ACTION PLAN

Page 4 of 23
Computer Engineering Project Topic Name

Sr. Details of Activity Start Date Finish Responsible


No. 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

INTRODUCTION

Page 5 of 23
Computer Engineering Project Topic Name

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
The primary goals of this mini-project are as follows:

Page 6 of 23
Computer Engineering Project Topic Name

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.

ALGORITHM -

Page 7 of 23
Computer Engineering Project Topic Name

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.
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.

Page 8 of 23
Computer Engineering Project Topic Name

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 -

Start

Page 9 of 23
Computer Engineering Project Topic Name

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>
#include<conio.h>
#include<graphics.h>

Page 10 of 23
Computer Engineering Project Topic Name

#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
*/
for (i = 1; i <= 15; i++) {
Page 11 of 23
Computer Engineering Project Topic Name

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);
floodfill(midx + 40, midy + 48, i);

Page 12 of 23
Computer Engineering Project Topic Name

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);
line(midx - 40, midy + 50, midx - 110, midy + 160);
line(midx - 40, midy + 50, midx, midy + 30);
Page 13 of 23
Computer Engineering Project Topic Name

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);
}
getch();
Page 14 of 23
Computer Engineering Project Topic Name

/* deallocate memory allocated for graphic screen */


closegraph();
return 0;
}

Page 15 of 23
Computer Engineering Project Topic Name

OUTPUT:

Page 16 of 23
Computer Engineering Project Topic Name

Page 17 of 23
Computer Engineering Project Topic Name

Page 18 of 23
Computer Engineering Project Topic Name

Page 19 of 23
Computer Engineering Project Topic Name

IMPLEMENTATION OF
“TWINKLING STAR”
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:
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.

Page 20 of 23
Computer Engineering Project Topic Name

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 23
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 23
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.
 "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:


 Learn OpenGL: 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 23 of 23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy