www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS602 Assignment No 01 Spring 2020 Solution & Discussion Due Date: 02-06-2020

CS602 Assignment No 01 Spring 2020 Solution & Discussion Due Date: 02-06-2020

Views: 1703

### Replies to This Discussion

#include<stdio.h>
#include<conio.h>
#include<graphics.h> //how to add graphics library in dev c++
#include<math.h>
#include<iostream>
using namespace std;
// defining function of flood fill
void flood(int x, int y, int new_color, int old_color)
{
// check current pixel is old_color or not
if (getpixel(x, y) == old_color) {
// put new pixel with new color
putpixel(x, y, new_color);
// recursive call for bottom pixel fill
flood(x + 1, y, new_color, old_color);
// recursive call for top pixel fill
flood(x - 1, y, new_color, old_color);
// recursive call for right pixel fill
flood(x, y + 1, new_color, old_color);
// recursive call for left pixel fill
flood(x, y - 1, new_color, old_color);
}
}
// defining function of drawline
void drawline(int x0, int y0, int x1, int y1,int color)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
int col=color;
while(x<x1)
{
if(p>=0)
{
putpixel(x,y,col);
y=y+1;
p=p+2*dy-2*dx;
}
else
{
putpixel(x,y,col);
p=p+2*dy;
}
x=x+1;
}
}
//driver
int main(){
int gd, gm=DETECT, radius, x, y, font, font_dir, font_charsize;
initgraph(&gd, &gm, "");
//id display
//declaring parameters for printing id in program
font=8;
font_dir=0;
font_charsize=1;
//call function of printing text in graphic library
settextstyle(font,font_dir,font_charsize);
//call function for printing
x=10;
y=10;
outtextxy(x,y,"BC170000000");
//draw first circle
//initiating values to first circle
x=270;
y=330;
//call circle function to draw first circle
//call to fill circle and for giving color
flood(271,331,RED,0);
//draw second circle
//initiating values to second circle
x=320;
y=390;
//call circle function to draw second circle
//call to fill circle and for giving color
flood(321,391,GREEN,0);
//call draw line function
drawline(180,300,350,459, GREEN);
drawline(180,340,305,459, RED);
drawline(180,380,265,459, BLUE);
//draw rectangle
//initiating values to rectangle coordinates
int left, top, right, bottom;
left=180;
top=10;
right=440;
bottom=460;
//call rectangle function to draw rectangle
rectangle(left, top, right, bottom);
flood(260,260,WHITE,BLACK);
getch();
closegraph();
return 0;
}

CS602 Compter Graphics Assignment No. 1 Correct Solution by VU ACADEMY

Dear Students I have uploaded the correction solution of CS602 with Solution file.
All students must watch this video to get correct solution. This solution is 100 % according to assignment requirements. All previous shared solutions not fulfill the requirements of assignment

Regards

#CS602
#CS602Assignment
#CS602AssignmentSolution
#CS602Assignment2020
#CS602CorrectSolution
#CS602AssignmentSolution
#CS602AssignmentCorrectSolution
#CS602AssignmentNo12020
#CS602AssignmentSolved
#CS602AssignmentSolution
#CS602SolutionFile
#CS602AssignmentSolution
#CS602SolutionCode
#CS602SolvedAssignment
#CS602AssignmentSolution

sary solution same hen or sab me same error

kindly koi correct solution upload kr den aj extended day hai

no sb solution same ni hen. ap video dekhen output dekhen apko idea ho jay ga,

or error solution me ni ap k run krny k method me hai. ap just code copy kr k run kr rhy, library files or header files ni add kr rhy parameter b add krny project me. ap complete video ko follow kren thn error ni ay ga

Semester: Spring 2020
CS602: Computer Graphics
Total Marks: 20

Due Date: 1st June 2020

Objective
The objective of this assignment is to;
 Learn and practice basic concepts of computer graphics like pixels, lines, circles and rectangles, texts etc using Dev-C++. (You can download Dev-C++ setup from LMS)
 Learn to draw shapes and patterns by using graphics library functions.
Instructions:
You have to do the following steps first in order to perform the task.

1. Install Dev-C++ from your LMS.
2. Read out the file “Add graphics in Dev cpp” thoroughly and follow the instructions in the file properly provided to you on your LMS.
3. You should consult the recommended books, PowerPoint slides , Handouts and video lectures to clarify your concepts.
4. You can take any help from your provided labs.
5. It should be clear that your assignment will not get any credit if:
• The assignment is submitted after due date.
• The assignment is copied from Internet or from any other student.
• The submitted assignment does not open or file is corrupt.
Submission
You are required to submit your solution through LMS in zip format containing following files.
 Your Project in zipped form containing both .cpp and .exe file.

The word document (.doc/docx) or any other file format containing code will not be considered.
If the code files are missing in zip folder, your assignment will be awarded as zero.
Note: No assignment will be accepted after the due date through email in any case (load shedding, server down, internet malfunctioning etc.).
It is recommended to upload solution file at least two days before its closing date.

For any query about the assignment, contact at cs602@vu.edu.pk
Marks=20
ABC is a well-known graphic designing industry famous for greeting card designs, logos and visiting card designs. The company needs your services to write a code for following design for its client:

Write a code in C++ for generating the above design. Your actual Student-ID should be displayed at the top left corner of the screen.

Solution.cpp

 #include // driver code int main() { // gm is Graphics mode which is a computer display // mode that generates image using pixels. // DETECT is a macro defined in "graphics.h" header file int gd = DETECT, gm; int left = 200, top = 20; int right = 430, bottom = 460; // initgraph initializes the graphics system // by loading a graphics driver from disk initgraph(&gd, &gm, ""); setcolor(WHITE); settextstyle(DEFAULT_FONT, HORIZ_DIR, 2); outtextxy(10, 20, (char*)"BC123456789"); setcolor(WHITE); setfillstyle(SOLID_FILL,WHITE); rectangle(left, top, right, bottom); bar(200,20,430,460); setcolor(LIGHTRED); setfillstyle(SOLID_FILL,LIGHTRED); circle(left+100,top+280,50); floodfill(left+100,top+280,LIGHTRED); setcolor(LIGHTGREEN); setfillstyle(SOLID_FILL,LIGHTGREEN); circle(left+160,top+340,30); floodfill(left+160,top+340,LIGHTGREEN); setcolor(LIGHTBLUE); line(left,top+280,right,bottom-20); setcolor(LIGHTGREEN); line(left,top+300,right,bottom); setcolor(LIGHTRED); line(left,top+320,right-30,bottom); getch(); // closegraph function closes the graphics // mode and deallocates all memory allocated // by graphics system . closegraph(); }

Solution.cpp

 #include // driver code int main() { // gm is Graphics mode which is a computer display // mode that generates image using pixels. // DETECT is a macro defined in "graphics.h" header file int gd = DETECT, gm; int left = 200, top = 20; int right = 430, bottom = 460; // initgraph initializes the graphics system // by loading a graphics driver from disk initgraph(&gd, &gm, ""); setcolor(WHITE); settextstyle(DEFAULT_FONT, HORIZ_DIR, 2); outtextxy(10, 20, (char*)"BC123456789"); setcolor(WHITE); setfillstyle(SOLID_FILL,WHITE); rectangle(left, top, right, bottom); bar(200,20,430,460); setcolor(LIGHTRED); setfillstyle(SOLID_FILL,LIGHTRED); circle(left+100,top+280,50); floodfill(left+100,top+280,LIGHTRED); setcolor(LIGHTGREEN); setfillstyle(SOLID_FILL,LIGHTGREEN); circle(left+160,top+340,30); floodfill(left+160,top+340,LIGHTGREEN); setcolor(LIGHTBLUE); line(left,top+280,right,bottom-20); setcolor(LIGHTGREEN); line(left,top+300,right,bottom); setcolor(LIGHTRED); line(left,top+320,right-30,bottom); getch(); // closegraph function closes the graphics // mode and deallocates all memory allocated // by graphics system . closegraph(); }

1

2

3

4

5

## Latest Activity

Muhammad Samam joined + M.Tariq Malik's group

### MGT201 Financial Management

7 minutes ago
40 minutes ago
Hafiz Abdul Basit joined + M.Tariq Malik's group

### HRM626 Recruitment and selection

40 minutes ago
43 minutes ago
Hafiz Abdul Basit joined + M.Tariq Malik's group

### HRM617 Training and Development

1 hour ago
Feriha joined + M.Tariq Malik's group

### CS609 System Programming

1 hour ago
1 hour ago
waqas ali posted a discussion

1 hour ago