You are on page 1of 16

A

Micro-Project Report
On

Moving Boat

Submitted for the partial fulfillment of Third Semester subject “Computer Graphics” Code
: 22318

Sumbitted By:-
Name of Student Enrollment No

1. Tirth patel 1. 2105300269

2. Abhishek londhe 2. 2105300271

3. Soham more 3. 2105300283


Under the Guidance of
Prof: Gauri A. Sonawane

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, Mumbai

Mahavir Polytechnic, Nashik.(0530)


DEPARTMENT OF COMPUTER ENGINEERING
MAHAVIR POLYTECHNIC, NASHIK.

DEPARTMENT OF COMPUTER ENGINEERING

Certificate
This is to certify that the Micro Project Report on “ Moving Boat” is
satisfactorily completed and submitted in the partial fulfillment of the
requirement for Subject "Computer Graphics ” in Second Year Computer
Engineering in Semester Third of Academic Year 2022-2023

Tirth patel 2105300269

Abhishek londhe 2105300271

Soham more 2105300283

Prof. Gauri A. Sonawane Prof. Anup Sonawane Prof. S.V sagare

Subject Teacher Head of the Department Principa


INDEX

SR.NO. CONTENT PAGE NO.

1
INTRODUCTION

2
MODEL/CHART/DIAGRAM

3
PROCEDURE/WORKING OF MODEL

4
CALCULATION/EXPLAINATION

5
RESOURCES
PROJECT ABSTRACT

• Brief Description:-
• As we all know that computer graphics is mainly used to design animations using
codes and for this purpose we need to have knowledge of computer graphics.
Computer graphics is responsible for displaying art and image data effectively and
meaningfully. It is also used for processing image data received for the physical
world, such as photo and video content.in this micro project we are going to draw a
moving boat using all the basic techniques that we have learnt.

• Aim of Micro-project
a) To draw a moving boat.
b) To understand the concepts practically that we have learnt theoretically.
c) Learning how to develop codes of these images using c programming.
d) By the help of codes we understand the concepts clearly.

• Course Outcomes
a) Manipulate visual and geometrical information of images.
b) Implement standard algorithms to draw various graphics objects using C program.
c) Develop programs for 2-D and 3-D transformation.
d) Use projections to visualize objects on a view plane.
e) Implement various clipping algorithms.
f) Develop programs to create curves using algorithms.

• Procedure
The finalization of the topic is done, I as group member and also proceeded by the
preparation and submission of the abstract to our project guide Mrs. Shivani Shinde.
I review the literature of the project and collect the data related to this project.After
compilation of report and presentation and the final submission was done.
• Functions used in code: -
a) getmaxx(): The graphics.h header file includes the getmaxx() function, which
returns the maximum X coordinate for the current graphics mode and driver.

b) setcolor(N): The setcolor() function in the header file graphics.h is used to change
the current drawing color to the new color.

c) setlinestyle(linestyle, upattern, thickness): The setlinestyle() function in the


header file graphics.h sets the style for all lines drawn by using functions like line,
lineto, rectangle, drawpoly, and so on.

d) rectangle(X1, Y1, X2, Y2): It is employed in the creation of a rectangle. The


rectangle must be drawn using the coordinates of the left top and right bottom
corners. The X-coordinate and Y-coordinate of the top left corner
are X1 and Y1 and the X-coordinate and Y-coordinate of the bottom right corner
are X2 and Y2 respectively.

e) floodfill(pattern, color): The function is used to fill a confined space. To fill the
area, the current fill pattern and color are used.

• Steps to generate the moving boat:-


a) Pass three arguments to the initgraph() function to initialize the graphics driver
and graphics mode.
b) Initialize the boat’s position by considering two variables X and Y.
c) Create a river/sea on which the boat will move by drawing a rectangle and fill it
with light blue paint to make it look like a river/sea.
d) Choose the coordinates so that the boat is just above the river/sea.
e) Change the boat’s position using a loop continuously so that it appears to be moving
in the river.
• Code to draw moving boat: -

// C program to draw the moving boat

// using c graphics

#include <conio.h>

#include <dos.h>

#include <graphics.h>

#include <stdio.h>

// Driver Code int

main()

// Initialize graphic driver

int gdriver = DETECT, gmode, err;

int i = 0, j, x, y, x1, y1, x2, y2;

// Start graphics mode by passing

// three arguments to initgraph()

// &gdriver is the address of the

// gdriver variable.

// &gmode is the address of gmode

// "C:Turboc3BGI" is the directory


// path where BGI files are stored

initgraph(&gdriver, &gmode, "C:\\

Turboc3\\BGI");

err = graphresult(); if

(err != grOk) {

printf("Graphics Error: %s\n",

grapherrormsg(err));

return 0;

j = 0;

// Initialize position for boat

x = 50, y = getmaxy() / 2 + 140;

while (x + 60 < getmaxx()

&& (!kbhit())) {

// Set the positions for rain

x1 = 10, i = y1 = 0; x2 = 0,

y2 = 50; // Clears graphic

screen cleardevice();
// Set the color of river/sea

setcolor(LIGHTBLUE); setlinestyle(SOLID_LINE, 1,

1); setfillstyle(SOLID_FILL, LIGHTBLUE);

// Draw the river/sea

rectangle(0, getmaxy() / 2 + 150,

getmaxx(), getmaxy());

floodfill(getmaxx() - 10,

getmaxy() - 10,

LIGHTBLUE);

// Rain drops

setlinestyle(DASHED_LINE, 1, 2);

while (i < 700) {

line(x1, y1, x2, y2); x1 = x1

+ 20; y2 = y2 + 50;

i++;

// Drawing the boat

setlinestyle(SOLID_LINE, 1, 2);

setcolor(BROWN);
setfillstyle(SOLID_FILL, BROWN);

sector(x, y, 180, 360, 50, 10);

setcolor(DARKGRAY);

setlinestyle(SOLID_LINE,

1, 3); // Leg and body of stick

man line(x + 40, y - 15, x + 40, y -

40);

line(x + 40, y - 15, x + 45, y - 10);

line(x + 45, y - 10, x + 45, y);

line(x + 40, y - 15, x + 37, y);

// Head and hand of stick man

circle(x + 40, y - 45, 5); line(x +

40, y - 35, x + 50, y - 30); line(x + 40, y

- 35, x + 35, y - 32); line(x + 35, y

- 32, x + 45, y - 25); line(x + 60, y

- 45, x + 27, y + 10);

// Moving the position of

// boat and stick man

x++;

setcolor(LIGHTBLUE);

delay(250);
// Clears the graphic device

cleardevice(); // Drawing sea/river

setlinestyle(SOLID_LINE, 1, 1);

setfillstyle(SOLID_FILL, LIGHTBLUE);

rectangle(0, getmaxy() / 2 + 150,

getmaxx(), getmaxy());

floodfill(getmaxx() - 10,

getmaxy() - 10, LIGHTBLUE);

// Rain drops

setlinestyle(DASHED_LINE, 1, 2);

x1 = 10, i = y1 = 0;

x2 = 0, y2 = 70;

while (i < 700) {

line(x1, y1, x2, y2);

x1 = x1 + 30; y2 =

y2 + 60;

i++;

// Drawing the boat

setlinestyle(SOLID_LINE, 1, 1);

setcolor(BROWN);
setfillstyle(SOLID_FILL, BROWN);

sector(x, y, 180, 360, 50, 10);

// Body and leg of stick man

setcolor(DARKGRAY);

setlinestyle(SOLID_LINE, 1, 3);

line(x + 40, y - 15, x + 40, y - 40);

line(x + 40, y - 15, x + 45, y - 10);

line(x + 45, y - 10, x + 45, y);

line(x + 40, y - 15, x + 37, y); //

Head hands of stick man

circle(x + 40, y - 45, 5); line(x +

40, y - 35, x + 52, y - 30);

line(x + 40, y - 35, x + 37, y - 32);

line(x + 37, y - 32, x + 49, y - 25);

line(x + 60, y - 45, x + 27, y + 10);

// Forwarding the position of

// the boat

x++;

// Sleep for 250 milliseconds

delay(250);

// Clears the graphic device


cleardevice();

j++;

getch();

// Deallocate memory allocated

// for graphic screen

closegraph(); return

0;

}
• Output: -
➢ RESOURCES
S. No. Name of Specifications Quantity
Resource/material
1. Books Computer Graphics

Author: Dr. Chopra 1


Rajiv

2. Internet (Website) MS Word,


--
Turbo C++

3. Material for making model Paint application for


measurements --
ACKNOWLEDGEMENT

It is my Proud privilege to express a deep sense of gratitude and regard to


my guide Prof Gauri A. Sonawane ,Academic Co-ordinator of Mahavir
polytechnic nashik. He Initiative and Keep interest in every step provided a
constant source of inspiration to our group of intensive in this work.

I wish to place on record my sincere thanks to Prof. Anup Sonawane


H.O.D. of Computer Engineering Department, Mahavir polytechnic nashik who
provided the Valuable guidance and constant encouragement to complete this
dissertation.

There were also some turning point where for a moment , I found myself
little depressed and at these very critical junctures, I am proud to confess our
teacher staff, which always appeared as a lamp post of live inspiration.

So my Sincere thanks to all Professors, Department teaching, Non-Teaching


Staff & my group Members , all my friends who directly or indirectly helped me
in the development & evolution of my thoughts in completing this work.

TIRTH PATEL
Enrollment No. 2105300269

ABHISHEK LONDHE
Enrollment No. 2105300271

Soham More
Enrollment No. 2105300283

You might also like