0% found this document useful (0 votes)
11 views18 pages

CGR Microproject

Uploaded by

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

CGR Microproject

Uploaded by

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

INSTITUTE OF ENGINEERING & TECHNOLOGY, KANNAD

DEPARTMENT OF COMPUTER ENGINEERING

SUBJECT: Computer Graphics


TOPIC: Program to create Screen Saver of Balloons

ACADEMIC YEAR: 2024-2025

MICRO PROJECT
DIPLOMA IN COMPUTER ENGINEERING

 GOYANKA DEVESH
 RATHOD GOPAL
 PALE ISHWARI
 RAUT AVINASH

 GUIDED BY: Prof. P.A. Wagh


ABSTRACT
Screen savers are graphical applications designed to activate after a period of
user inactivity, originally developed to prevent CRT monitor burn-in but now
used for aesthetic and security purposes. This paper focuses on the
implementation of a screen saver using principles of computer graphics,
exploring the creation of dynamic and visually appealing animations. The
program leverages key computer graphics concepts such as geometric
transformations, animation, and rendering pipelines to create customizable
screen savers.

The core of the program utilizes graphics libraries such as OpenGL, DirectX, or
higher-level frameworks like Pygame (Python) or Java's AWT and Swing to
render 2D and 3D objects on the screen. The implementation involves applying
fundamental geometric transformations—translation, rotation, and scaling—to
create motion and interaction between graphical elements. Keyframe animation
techniques and interpolation methods are used to produce smooth transitions and
object movement across the screen.

The screen saver’s visual complexity is enhanced through the use of shaders,
lighting models, and texture mapping, enabling the creation of realistic or
abstract graphical patterns. Particle systems are employed to simulate natural
phenomena such as fireworks, snowfall, or flowing water, adding a dynamic
aspect to the visual display. Additionally, procedural graphics techniques, such
as fractals and noise functions, are used to generate intricate patterns and
animations that evolve over time.

User interaction is monitored by capturing system events such as keyboard and


mouse activity, ensuring the screen saver is deactivated upon user input. The
screen saver supports customizable themes, allowing users to select different
animation types, color schemes, object behavior, and animation speed. These
options are configured via graphical user interfaces (GUIs) or external
configuration files, making the program adaptable to individual preferences.

The paper also explores optimization techniques to enhance rendering


performance, including double buffering and frame rate control, ensuring smooth
visual output without taxing system resources. The use of spatial data structures,
such as quadtrees or bounding boxes, is incorporated to efficiently manage the
rendering of multiple objects and their interactions.
Furthermore, the screen saver can integrate optional security features, requiring
user authentication or password entry to exit the screen saver, thus adding a layer
of protection to the system during idle states.

In conclusion, this paper demonstrates how computer graphics techniques can be


effectively used to create visually engaging and customizable screen savers. By
leveraging geometric transformations, animation, procedural generation, and
optimization techniques, the screen saver not only provides a visually pleasing
idle-state application but also serves functional and security-related purposes in
modern computer systems.
INTRODUCTION
In the domain of computer graphics (CGR), creating a screen saver is a
comprehensive project that brings together several fundamental concepts,
including rendering, animation, user interaction, and real-time system response.
While early screen savers were designed to prevent phosphor burn-in on CRT
monitors by keeping the display active with dynamic content, their purpose in
modern systems has shifted toward aesthetic and entertainment values, with
additional roles in enhancing security through system lock mechanisms. This
project aims to implement a customizable and visually rich screen saver using
the principles of CGR, combining creativity and technical problem-solving.

The creation of a screen saver program touches on multiple areas of computer


graphics:

1. Rendering Techniques: The project will make use of 2D and 3D rendering


techniques to display graphical objects such as shapes, patterns, and
animated figures. By using graphics libraries like OpenGL, DirectX, or
other high-level frameworks (e.g., Pygame or Java's AWT/Swing), the
program can leverage shaders, lighting models, and texture mapping to
create realistic and visually appealing effects. In a 3D context, techniques
such as perspective projection, depth buffering, and normal vectors can
be utilized to simulate realistic motion and spatial relationships.
2. Geometric Transformations and Animation: At the core of the screen
saver is the ability to animate objects smoothly across the screen. This is
accomplished through geometric transformations—translation, rotation,
and scaling—allowing objects to move, rotate, or change size in a
continuous and visually smooth manner. Keyframe animation and
interpolation techniques are used to define motion over time, ensuring that
the screen saver transitions seamlessly between various states and
movements.
3. Procedural Generation and Particle Systems: Procedural generation
techniques are applied to create dynamically evolving visual content.
Using algorithms such as fractals, Perlin noise, or L-systems, the screen
saver can generate complex and organic-looking patterns that change
unpredictably over time, adding an element of uniqueness to the display.
Similarly, particle systems are employed to simulate phenomena such as
fire, rain, snow, or swirling fog, enhancing the visual complexity and
artistic appeal of the screen saver.
4. System Inactivity Detection: A critical component of the screen saver
program is the detection of system inactivity. The program monitors the
system for periods of user inactivity—when no keyboard or mouse events
are detected—and initiates the screen saver after a predefined time.
Implementing this functionality requires an understanding of event-driven
programming, as the program must continuously track user inputs and
respond accordingly.
5. Customizability and User Interaction: An important feature of modern
screen savers is user customization. The program will provide options for
users to adjust the visual style, animation speed, color schemes, and
themes. These options may be accessed via graphical user interfaces
(GUIs) or external configuration files, allowing for a personalized user
experience. Additionally, the screen saver can be designed to respond to
certain types of user interaction, such as allowing users to interact with
the animations (e.g., moving objects with the mouse) before deactivating
the screen saver entirely.
6. Performance Optimization: Efficient use of system resources is critical in
screen saver programs, especially since they are intended to run
continuously during idle periods without overburdening the CPU or GPU.
Techniques such as double buffering, frame rate control, and efficient
memory management will be implemented to ensure that the screen saver
runs smoothly across various hardware configurations. Spatial data
structures like quadtrees or bounding volumes can be used to optimize
object rendering, ensuring that only visible objects are processed in each
frame.
7. Security Considerations: Beyond providing visual effects, the screen saver
can serve a functional role in securing the system. By integrating a
password-protected exit, the screen saver can effectively lock the system
when active, requiring user authentication to resume normal operation.
This feature is particularly useful in multi-user or public computing
environments, where unauthorized access during idle times could pose a
security risk.
8. Cross-Platform Compatibility: An additional consideration is designing
the screen saver to be cross-platform, allowing it to run on different
operating systems such as Windows, macOS, and Linux. This requires
careful handling of platform-specific system calls for detecting inactivity
and managing screen rendering, as well as choosing the appropriate
graphics library or framework to ensure compatibility.

By leveraging these core components of computer graphics, the screen saver


program will serve as a showcase for both aesthetic design and technical
proficiency. The combination of dynamic visual effects, smooth animations, and
interactive elements demonstrates how computer graphics can be applied to
create engaging and user-friendly applications that run efficiently during system
idle states.
In conclusion, this project presents an opportunity to explore the intersection of
artistic creativity and technical expertise in computer graphics. By creating a
screen saver, we apply key CGR concepts in rendering, animation, and system
optimization to develop a functional program that balances visual appeal with
performance. As screen savers continue to evolve in purpose—from preventing
screen burn-in to serving as aesthetic and security tools—this project
underscores the ongoing relevance and potential of computer graphics in modern
software development.
THEORY
In an extended exploration of creating a screen saver with floating balloons
using principles from computer graphics (CGR), we delve deeper into the
technical aspects, optimization strategies, and advanced features that can be
implemented to create a robust and visually captivating application. The screen
saver aims to simulate an aesthetically pleasing and dynamic scene where
balloons rise and drift in a fluid motion across the screen during system idle time.
Let’s explore more theoretical aspects to further enrich the project.

1. Advanced Rendering Techniques

In addition to basic rendering concepts, advanced lighting, shading, and anti-


aliasing techniques can be incorporated to enhance the visual quality of the
balloons and their environment.

 Phong Shading: This shading model can be used to provide realistic


lighting on 3D balloon surfaces. It calculates light reflections based on the
normal vectors of each surface point, giving the balloons a glossy, three-
dimensional look. This would require:
o Diffuse lighting to simulate the scattering of light across the
balloon's surface.
o Specular highlights to add a shiny reflection, which is
characteristic of real latex balloons.
 Texture Mapping: If the balloon bodies are not plain solid colors, texture
mapping can be employed to add patterns or images to the balloons. For
example, textures like stars, stripes, or cloud-like patterns can be wrapped
around each balloon to add variety and visual complexity.
 Anti-Aliasing: To avoid jagged edges (aliasing) in 2D balloons or the
balloon strings, anti-aliasing algorithms such as MSAA (Multisample
Anti-Aliasing) can be applied. This technique smooths out the edges of the
objects by blending the pixels at the borders, making the scene look more
polished.

2. Complex Geometric Transformations

While basic transformations like translation (moving balloons upwards) and


scaling (shrinking balloons as they rise) are fundamental, more complex
geometric transformations can introduce a greater degree of realism and
interactivity:

 Rotation: Balloons can be made to rotate slowly as they float. In 3D, this
would involve applying a rotational matrix to the balloon around its own
axis or around a world axis (for example, rotating slightly as if swaying in
the wind).
 Shearing: In 2D animations, a slight shearing transformation could be
applied to simulate wind effects, causing the balloons to tilt sideways as
they drift upward. This adds a more dynamic and natural movement to the
scene.

Incorporating these transformations enhances the realism of the balloons'


movement, as real-world balloons often rotate, tilt, and deform slightly as they
rise and interact with air currents.

3. Particle Systems for Balloon Motion

A particle system can be employed to simulate the motion of multiple balloons as


independent entities that follow specific behaviors. Each balloon can be treated
as a particle with properties such as position, velocity, acceleration, and lifetime.

 Forces: By simulating natural forces like gravity, drag, and wind, the
motion of the balloons can be modeled more realistically. Though the
balloons float upwards, a subtle drag force can slow their ascent, while
wind forces can push them laterally. This can be achieved by applying
Newtonian physics equations to each balloon's movement:
o Velocity update: v = v + a * dt
o Position update: p = p + v * dt
 Wind Simulation: Using a random or sinusoidal function, wind can be
simulated to blow the balloons left and right. The wind’s strength can vary
over time, creating unpredictable movements in the balloons' paths. This
can be combined with procedural generation to make each balloon’s
movement unique.

4. Real-Time Shadows and Lighting

For a more sophisticated visual effect, real-time shadows can be introduced. In


a 3D environment, the balloons can cast shadows on a ground plane or other
objects, which adds to the depth perception of the scene. To implement shadows:

 Shadow Mapping: This technique can be used to calculate the position of


the balloon relative to the light source and project its shadow onto the
appropriate surfaces.
 Soft Shadows: To avoid sharp, unrealistic shadows, soft shadows can be
implemented by using a blur filter on the shadow map or through more
complex algorithms such as percentage-closer filtering (PCF).
Additionally, dynamic lighting can be added to simulate different light sources.
For instance, a glowing light in the background (like a sunset) can create a soft
lighting effect on the balloons, making the scene more visually appealing.

5. Physics-Based Interactions

In a more advanced version of the balloon screen saver, physics-based


interactions can be introduced. This includes having the balloons collide with
one another or with the boundaries of the screen:

 Collision Detection: In 2D, simple circle-based or bounding-box collision


detection can be used. In 3D, more complex bounding volume hierarchies
(BVH) or sphere collision detection can be applied.
 Elastic Collisions: When balloons collide, they can bounce off each other
using simple elastic collision physics. This involves swapping the velocities
of two balloons upon collision, adjusted by their masses (if different).

Incorporating such physics interactions makes the screen saver more dynamic,
allowing balloons to interact with one another in a realistic manner.

6. Memory Management and Optimization

To keep the screen saver efficient, several optimization strategies must be


employed:

 Efficient Memory Use: Given that the screen saver runs continuously, it
is essential to minimize memory leaks. Garbage collection and object
pooling techniques can ensure that balloons are efficiently reused or
deleted when no longer visible.
 LOD (Level of Detail): For 3D implementations, using a Level of Detail
system can reduce the complexity of balloon models when they are far
away. Farther balloons can use lower-resolution meshes, improving
performance by reducing the number of polygons rendered.
 Multithreading: If the system allows, rendering and updating balloon
positions can be handled in separate threads, improving performance and
responsiveness by dividing the workload between the CPU and GPU.

7. Procedural Generation for Endless Variety

To ensure that the screen saver never looks exactly the same, procedural
generation techniques are used to introduce endless variations in balloon size,
color, movement, and positioning:
 Random Seed: A random seed can be applied each time the screen saver
is launched, generating a unique combination of balloon attributes and
motion patterns.
 Perlin Noise: Using Perlin noise or other coherent noise functions can
create more organic and smooth balloon drift patterns. This can be used
for both horizontal movement (simulating gentle wind) and vertical speed
variation.

8. User Customization and Configuration

Incorporating a user interface (UI) or configuration settings allows users to


personalize the screen saver. Users could customize parameters such as:

 Number of Balloons: Adjust the maximum number of balloons visible at


once.
 Balloon Color Schemes: Choose from predefined color palettes or create
custom colors.
 Motion Speed: Allow the user to control the overall speed of the animation.
 Background Themes: Users can select different backgrounds or even set
a custom image to serve as the backdrop for the screen saver.

This user interaction makes the screen saver more engaging and adaptable to
user preferences.

9. Interactive Features and Gamification

To increase interactivity, the screen saver can introduce interactive elements or


even basic gamification:

 Popping Balloons: Users can "pop" balloons by clicking on them, which


would trigger a sound effect and an animation showing the balloon
bursting. The popped balloon would then disappear and be replaced by a
new balloon.
 Scoring System: A simple scoring system could be implemented,
rewarding the user points for popping balloons. This can also introduce
an element of gamification, where users compete for high scores, making
the screen saver more engaging.

10. Cross-Platform Compatibility

For broader usability, the screen saver can be made cross-platform, allowing it
to run on Windows, macOS, and Linux systems. This requires:
 Cross-Platform Graphics Libraries: Choosing a cross-platform graphics
library like OpenGL, Vulkan, or a higher-level library such as SDL or
Pygame ensures compatibility across multiple operating systems.
 Handling Platform-Specific APIs: Detecting system inactivity or
managing windowed fullscreen mode requires platform-specific API calls.
Wrapping these system calls in platform-agnostic code allows the screen
saver to be portable.
CODE

#include <graphics.h>
#include <conio.h>
#include <dos.h>

x
void drawBalloon(int x, int y) {
// Balloon string
line(x, y + 50, x, y + 100);

// Balloon body
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
ellipse(x, y, 0, 360, 30, 50);
floodfill(x, y, RED);
}

int main() {
int gd = DETECT, gm;
int x = 200, y = 350;
int direction = -1; // Initially moving upwards

initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");

while (!kbhit()) {
cleardevice(); // Clear the screen
drawBalloon(x, y); // Draw the balloon at the current position

delay(50); // Small delay for smooth animation

// Move the balloon


y += direction * 5;

// Change direction when balloon reaches the screen's top or bottom


if (y < 50) {
direction = 1; // Move down
} else if (y > 350) {
direction = -1; // Move up
}
}

closegraph(); // Close the graphics window


return 0;
}
OUTPUT
CONCLUSION
The balloon screen saver program, implemented using libraries like
graphics.h, SDL2, or SFML, serves as a fundamental example of applying
computer graphics concepts in C/C++ programming. By creating a visually
engaging animation of balloons floating across the screen, the program
demonstrates essential graphics techniques such as:

1. Rendering Shapes: The balloons are rendered using circles, which are a
basic geometric shape. The program teaches how to draw shapes and fill
them with color.
2. Animation: The upward movement of balloons illustrates the concept of
frame-based animation, where each frame updates the position of the
objects (balloons) and then redraws them. This method is central to
creating any animated screen saver or graphical simulation.
3. Randomization: Randomizing properties such as balloon size, color,
speed, and starting position adds variety to the animation, making it look
more dynamic and realistic.
4. Basic Physics Simulation: The balloon movement gives an elementary
introduction to simulating physical behavior (in this case, simulating
floating by moving balloons upwards at various speeds).
5. Event-Driven Programming: In some versions (such as SDL2 or SFML),
the program responds to user input events, like detecting when the user
closes the program or presses a key, making it interactive and adaptable.

Learning Outcomes:

 Graphics Rendering: The program helps understand how to render


basic graphics using a chosen library (like graphics.h, SDL2, or
SFML), which can later be extended to more complex visual projects.
 Animation Techniques: It demonstrates how continuous loops, frame
updates, and timed delays can be used to create smooth animations.
 Introduction to Game Development: This project provides a
foundation for further work in 2D game development, screen savers, or
visual simulations.
 Customization: The program can be expanded to include various effects
such as user interaction (mouse or keyboard), collision detection, and
more sophisticated physics for more engaging visuals.

Overall, this screen saver project offers a simple yet effective way to learn key
concepts of computer graphics and animation, and serves as an excellent starting
point for more complex graphical projects in C/C++.
REFERENCE

WEB 1 : https://www.geeksforgeeks.org/computer-graphics-2/

WEB 2: https://www.javatpoint.com/computer-graphics-tutorial

WEB 3:
https://www.tutorialspoint.com/computer_graphics/index.htm

You might also like