Upload
khondokar-fida-hasan
View
216
Download
0
Embed Size (px)
Citation preview
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 1/22
Department of Information and CommunicationTechnology
Comilla University
Term PaperOn
Painting Software Project
“PaintIT”Submitted to:Khondokar Fida Hasan
Email: [email protected]
LecturerDept. of Information and Communication Technology (ICT)Comilla University (CoU), Comilla-3503Bangladesh
Submitted by:
Group - B
Name ID Position Email
Md. Mynoddin 0909024 Group Leader [email protected]
Rokeya Begum Jothi 0909017 Group Member [email protected]
Afsana Jahan Shuki 0909025 Group Member [email protected]
Zeni Chakma 0909029 Group Member [email protected]
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 2/22
Date of Submission : 14th April, 2012
P a g e | 2
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 3/22
ACKNOWLEDGEMENT
First of all we all like to express our greatfullness to our Creator for giving us chance to prepare
this term and successfully complete our project on painting software “PaintIT”. The satisfaction
that accompanies that the successful completion of any task would be incomplete without
the mention of people whose ceaseless cooperation made it possible, whose constant
guidance and encouragement crown all efforts with success. We are grateful to our project
guide Mr. Khondakar Fida Hasan for the guidance, inspiration and constructive
suggestions that helpful us in the preparation of this project. We also thank our respectful
teacher and students who has helped in successful completion of the project.
P a g e | 3
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 4/22
Table of Contents
1 Introduction ………………………………………………………………………….. 4
2 Overview of Painting Software Project …………………………………………….. 5
2.1 Purpose ……………………………………………………………………….. 5
2.2 Scope …………………………………………………………………………. 5
2.3 Technology used ……………………………………………………………….. 5
2.4 Assumptions …………………………………………………………………… 5
3 Methodology ………………………………………………………………………… 6
3.1 Paint algorithm ………………………………………………………………… 6
3.2 Tools used in the painting projects …………………………………………….. 63.2.1 Bar drawing function …………………………………………………….. 7
3.2.2 Ellipse drawing function …………………………………………………. 7
3.2.3 Line drawing function …………………………………………………….. 8
3.2.4 Rectangle drawing function ………………………………………………. 8
3.3 Source code ……………………………………………………………………… 9
4 Results ………………………………………………………………………………… 17
5 Discussion ……………………………………………………………………………... 18
5.1 Future Scope of application ……………………………………………………... 18
5.2 Software scope ………………………………………………………………….... 18
5.2.1 Extensibility ………………………………………………………………... 18
5.2.2 Reusability …………………………………………………………………. 18
5.2.3 Understandability …………………………………………………………... 18
5.2.4 Cost-effectiveness…………………………………………………………... 18
6 Conclusion …………………………………………………………………………….. 19
Bibliography ……………………………………………………………………………... 20
Appendix ………………………………………………………………………………… 21
P a g e | 4
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 5/22
Introduction
Painting is the practice of applying paint, pigment, color or other medium to a surface the
medium is commonly applied to the base with a brush but other objects can be used. In art, the
term painting describes both the act and the result of the action. However, painting is also used
outside of art as a common trade among craftsmen and builders. Paintings may have for their
support such surfaces as walls, paper, canvas, wood, glass, lacquer, clay, leaf, copper or
concrete, and may incorporate multiple other materials including sand, clay, paper, gold leaf as
well as objects. Painting is a mode of creative expression, and the forms are numerous. This
term paper is about painting software project PaintIT to automation this painting with digital
media. Painting software is computerized software that helps a painter to paint just like he/she
can paint with his/her paper and pencil, brush, color etc. Moreover, virtual painter is smoother
than real painting, because it automates such tools that allow erasing choosing different color,
eraser that is expensive, sometime impossible to erase in real painting. Painting is a
spontaneous and expressive form of art. Every brush stroke in a painting conveys meaning to
the viewer. To preserve these aspects of real painting, it’s needed to develop a special user interface that guarantees interactivity, a software model for simulating the brush, the ink as
well as the strokes. This section explains an expressive painting software projects PaintIT and
its tool which allows an artist or a newcomer in field of painting to create 2D painting. The
overall user interface design goal is to make it very simple and straight-forward to use. The
experience of using this tool should be very similar to the actual painting experience.
P a g e | 5
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 6/22
Overview of Painting Software Project
“ PaintIT”
Painting software project PaintIT is related to painting which allows to any users to
paint. This project named PaintIT , is a C/C++ console based 2d painting software; instead of
manipulating ploys or curves, access to select a tool and literally paint the best way to play
with it. The following summery describes the painting project PaintIT console base painting
software:
Purpose:
The purpose of this application is the automation of painting. It provides following
facilities to a user to:
• use familiar and useful painting tools to paint.
• choose different color and shape to paint.
• totally freehand painting.
Scope:
The different areas where we can use this application are:
• Any education institute can make use of it for newcomer to familiarizing with easy
painting tools and freehand computer painting.
• It can be used in home and kid’s class for introduce basic painting
Technology Used:
• Language: C++ (Object Oriented Programming Approach)
• Environment: Console 2D graphics environment
• Compiler: Turbo C++ 3.0 IDE
Assumptions
• This application is used to convert the manual painting to the virtual painting
• User has the allowances to use virtual color and shape instead of real paper and pencil.
P a g e | 6
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 7/22
Methodology
For painting (front end- users) we use simple algorithm that we first have to take painting
space select color and select painting tools and continue paint as we like and then we exit.
Paint Algorithm
1. start
2. set a blank space to paint
3. select color
4. select painting tools
5. draw
6. exit
In order to using set (beck end – developers) painting space and provide color and shape tools
with freehand painting with mouse functionality for C and C++ console environment first it’s
essential for using Turbo C++ graphics routine that activate graphics driver and use graphics.h
header file functions.
Tools used in the painting projects:
1. Bar
2. Line
3. Pixel
4. Eclipse
5. Freehand Drawing
6. Rectangle
Generally after activating graphics driver mode and mouse operation in console window we
define access freehand drawing thus the following function should be initialize define that
specific tool operation.
P a g e | 7
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 8/22
Bar drawing function:
In this project bar drawing tools has been created using a function bar() , which draws a
filled-in, rectangular, two-dimensional bar.
The general syntax of the bar() is:
void far bar( int left, int top, int right, int bottom);
where left, top, right, and bottom are user defined integer variables. The left and top are the
rectangle’s upper left corner. The right and bottom are the rectangle’s lower right corner. The
coordinates are in pixels. Here, all the vales of coordinate are taken from the mouse position
value.
Ellipse drawing function:
The ellipse() is a method that is used to draw an elliptical arc using the current color.
The general syntax of the ellipse() is :
void far ellipse(int x, int y, int stangle, int endangle, int xradious, int y radious);
Argument Meaning
(x,y) center of ellipse
xradiuos Horizontal axis
yradious Vertical axis
stangle Starting angle
endangle Ending angle
The ellipse or sector travels from stangle to endangle = 360, the call to ellipse draws a complete
ellipse.
Angle for ellipse, fillellipse, and sector (counter-clockwise).
90 degrees
180 0 degrees
degrees 360 degress
270 degrees
P a g e | 8
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 9/22
Line drawing function:
Given that the two endpoints of the line segment are specified at positions (x1,y1) and
(x2,y2). we can determine values for the slope m and y intercept b with the following
calculations, m=(y2-y1)/(x2-x1) so, b=y1-m.x1
Algorithm:
dx = x2 - x1
dy = y2 - y1
for x from x1 to x2
{
y = y1 + (dy) * (x - x1)/(dx)
plot(x, y)
}
The general syntax of the line method() is:
void far line(int x1, int y1, int x2, int y2);
Rectangle drawing function:
The rectangle() method use draw a rectangle, using the current line style, thickness
and drawing color.
The general syntax of the rectangle() is:
void far rectangle (int left, int top, int right, int bottom);
where (left, top) defines the upper left corner of the rectangle and (right, bottom) defines the
lower right corner. The condition that is used to draw rectangle is given below:
0<= left <=right <= getmaxx and
0<= top <=bottom <= getmaxy.
P a g e | 9
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 10/22
Source Code:
/***********************************************************************
ICT Painting Software Project : PaintIT
Language : C++ (Object Oreinted Approach)
Compiler : Turbo C++ 3.0 IDE
(c) ICT Painting Software Project Group
Md. Mynoddin - [email protected]
Rokeya Begum Jothi
Afsana Jahan Shuki
Zeni Chakma
**************************************************************************/
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
union REGS i, o;
int leftcolor[15];
class paint
{
int left, top, c, color;
public:
int get_key();
void draw_color_panel();
void draw_shape_panel();
void change_color(int x, int y);
P a g e | 10
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 11/22
char change_shape(int x, int y);
void showmouseptr();
void hidemouseptr();
void restrictmouseptr( int x1, int y1, int x2, int y2);
void getmousepos(int *button,int *x,int *y);
};
int paint::get_key()
{
union REGS i,o;
i.h.ah = 0;
int86(22,&i,&o);
return ( o.h.ah );
}
void paint::draw_color_panel()
{
left = 100;
top = 436;
color = getcolor();
setcolor(GREEN);
rectangle(4,431,635,457);
setcolor(WHITE);
settextstyle(TRIPLEX_FONT,0,2);
outtextxy(10,431,"Colors : ");
for( c = 1 ; c <= 15 ; c++ )
{
setfillstyle(SOLID_FILL, c);
bar(left, top, left+16, top+16);
leftcolor[c-1] = left;
P a g e | 11
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 12/22
left += 26;
}
setcolor(color);
}
void paint::draw_shape_panel()
{
left = 529;
top = 45;
color = getcolor();
setcolor(GREEN);
rectangle(525,40,633,255);
for( c = 1 ; c <= 7 ; c++ )
{
rectangle(left, top, left+100, top+25);
top += 30;
}
setcolor(WHITE);
outtextxy(530,45,"Bar");
outtextxy(530,75,"Line");
outtextxy(530,105,"Pixel");
outtextxy(530,135,"Ellipse");
outtextxy(530,165,"Freehand");
outtextxy(530,195,"Rectangle");
outtextxy(530,225,"Clear");
setcolor(color);
}
void paint::change_color(int x, int y)
{
for( c = 0 ; c <= 13 ; c++ )
{
if( x > leftcolor[c] && x < leftcolor[c+1] && y > 437 && y < 453 )
setcolor(c+1);
P a g e | 12
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 13/22
if( x > leftcolor[14] && x < 505 && y > 437 && y < 453 )
setcolor(WHITE);
}
}
char paint::change_shape(int x, int y)
{
if ( x > 529 && x < 625 && y > 45 && y < 70 )
return 'b';
else if ( x > 529 && x < 625 && y > 75 && y < 100 )
return 'l';
else if ( x > 529 && x < 625 && y > 105 && y < 130 )
return 'p';
else if ( x > 529 && x < 625 && y > 135 && y < 160 )
return 'e';
else if ( x > 529 && x < 625 && y > 165 && y < 190 )
return 'f';
else if ( x > 529 && x < 625 && y > 195 && y < 220 )
return 'r';
else if ( x > 529 && x < 625 && y > 225 && y < 250 )
return 'c';
return 0;
}
void paint::showmouseptr()
{
i.x.ax = 1;
int86(0x33,&i,&o);
}
void paint::hidemouseptr()
{
i.x.ax = 2;
P a g e | 13
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 14/22
int86(0x33,&i,&o);
}
void paint::restrictmouseptr( int x1, int y1, int x2, int y2)
{
i.x.ax = 7;
i.x.cx = x1;
i.x.dx = x2;
int86(0x33,&i,&o);
i.x.ax = 8;
i.x.cx = y1;
i.x.dx = y2;
int86(0x33,&i,&o);
}
void paint::getmousepos(int *button,int *x,int *y)
{
i.x.ax = 3;
int86(0x33,&i,&o);
*button = o.x.bx;
*x = o.x.cx;
*y = o.x.dx;
}
int main()
{
paint p;
int gd = DETECT,gm;
int maxx,maxy,x,y,button,prevx,prevy,temp1,temp2,key,color;
char ch = 'f' ; // default free-hand drawing
P a g e | 14
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 15/22
initgraph(&gd,&gm,"C:\\TC\\BGI");
maxx = getmaxx();
maxy = getmaxy();
// setbkcolor(7);
setcolor(BLUE);
rectangle(0,0,maxx,maxy);
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(maxx/2-300,maxy-28," Painting Software Project PaintIT by ICT_Group-B");
//Md. mynoddin, Rokeya Begum Jothi, Afsana Jahan Shuki, Zeni Chakma
p.draw_color_panel();
p.draw_shape_panel();
setviewport(1,1,maxx-1,maxy-1,1);
p.restrictmouseptr(1,1,maxx-1,maxy-1);
p.showmouseptr();
rectangle(2,2,518,427);
setviewport(1,1,519,428,1);
while(1)
{
if(kbhit())
{
key = p.get_key();
if( key == 1 )
{
closegraph();
P a g e | 15
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 16/22
exit(0);
}
}
p.getmousepos(&button,&x,&y);
if( button == 1 )
{
if( x > 4 && x < 635 && y > 431 && y < 457 )
p.change_color( x, y );
else if ( x > 529 && x < 625 && y > 40 && y < 250 )
ch = p.change_shape( x, y );
temp1 = x ;
temp2 = y ;
if ( ch == 'f' )
{
p.hidemouseptr();
while( button == 1 )
{
line(temp1,temp2,x,y);
temp1 = x;
temp2 = y;
p.getmousepos(&button,&x,&y);
}
p.showmouseptr();
}
while( button == 1)
p.getmousepos(&button,&x,&y);
/* to avoid interference of mouse while drawing */
p.hidemouseptr();
P a g e | 16
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 17/22
if( ch == 'p')
putpixel(x,y,getcolor());
else if ( ch == 'b' )
{
setfillstyle(SOLID_FILL,getcolor());
bar(temp1,temp2,x,y);
}
else if ( ch == 'l')
line(temp1,temp2,x,y);
else if ( ch == 'e')
ellipse(temp1,temp2,0,360,abs(x-temp1),abs(y-temp2));
else if ( ch == 'r' )
rectangle(temp1,temp2,x,y);
else if ( ch == 'c' )
{
ch = 'f'; // setting to freehand drawing
clearviewport();
color = getcolor();
setcolor(WHITE);
rectangle(2,2,518,427);
setcolor(color);
}
p.showmouseptr();
}
}
// getch();
// return 0;
}
P a g e | 17
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 18/22
Results:
The result of this project outputs a window for painting interface. After painting we got
the following screenshot:
P a g e | 18
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 19/22
Discussion
We have build this software for working in console window that doesn’t have the facility to
menu system and have no feature of GUI interface. For build this project and implement the
functionality of different algorithm for painting tools like ellipse drawing we have used
Borland Graphics Interface library graphics.h header file’s function. So, we have some
limitation and we are promising to improve it’s functionality feature scope.
Future Scope of Application:
This application can be easily implemented under various situations. We can add new
features as and when we require. Reusability is Possible as and when require in this
application. There is flexibility in all the modules.
Software Scope:
• Extensibility: This software is extendable in ways that its original developers may not
expect. The following principles enhances extensibility like hide data structure, avoid
traversing multiple links or methods, avoid case statements on object type and
distinguish public and private operations.
• Reusability: Reusability is possible as and when require in this application. We can
update it next version. Reusable software reduces design, coding and testing cost by
amortizing effort over several designs. Reducing the amount of code also
simplifies understanding, which increases the likelihood that the code is correct.
We follow up both types of reusability: Sharing of newly written code within a
project and reuse of previously written code on new projects.
• Understandability: A method is understandable if someone other than the creator
of the method can understand the code (as well as the creator after a time
lapse). We use the method, which small and coherent helps to accomplish this.
• Cost-effectiveness: Its cost is under the budget and make within given time period.
It is desirable to aim for a system with a minimum cost subject to the condition
that it must satisfy the entire requirement.
P a g e | 19
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 20/22
Scope of this document is to put down the requirements, clearly identifying the
information needed by the user, the source of the information and outputs expected from
the system.
Conclusion
The main goal of this project is to bring painting to the digital realm, while preserving the
tradition and essence of the original art form. We have successfully 2D expressive painting
software that enables a general user to create simple painting spontaneously. This console
based software is easy to use and has an interface similar to the simple painting interface. This
tool was developed using an object-oriented approach. Future changes to this tool can be easily
done by modifying each individual object. Although this tool was designed to create simple
painting, creative artists can use it to generate any simple art they want. It is possible to make
sketches and gesture drawings because of the responsiveness of the brush and the simple user
interface. More features can be added to the 2D expressive paint tool, for example, simulating
the interaction between ink and paper, as well as different effects when an artist tilts the brush.
It is our goal to introduce the more easily and simple painting to more people, from
professional animators to the general public and push the traditional art of painting to a
different level.
P a g e | 20
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 21/22
Bibliography
Books:
1. Herbert Schildt, C++: The Complete reference, Fourth Edition
2. D Ravichandran, Programming with C++
3. Zhigang Xiang, Roy Plastok, Computer Graphics, Second edition
4. James D. Foley, Andries Van Dam, Steven K. Feiner, John F. Hughes, Computer
Graphics Principles & Practice, 2 ed
5. Davis Chapman, SAMS Teach Yourself Visual C++ 6 in 21 days
Web Sites:
http://www.programmingsimplified.com/
http://en.wikipedia.org/wiki/Painter%27s_algorithm
http://en.wikipedia.org/wiki/Painting
http://www.qt-project.org
http://doc.qt.nokia.com/4.7/paintsystem.html
P a g e | 21
8/2/2019 Term Paper on Painting Project
http://slidepdf.com/reader/full/term-paper-on-painting-project 22/22
Appendix
Assumptions, 5
Bar Drawing Function, 7
Cost-effectiveness, 18
Ellipse Drawing Function, 7
Extensibility, 18
Future Scope of Application, 18
Line Drawing Function, 7
Methodology, 6
Overview of painting software
project , 5
Paint Algorithm, 6
Purpose, 5
Rectangle Drawing Function, 7
Reusability, 18
Scope, 5
Software Scope, 18
Source Code, 9
Technology Used, 5
Understandability, 18
P a g e | 22