CS602 Assignment 1 Solution and Discussion
-
Re: Assignment No. 01 Semester: Spring 2019 CS602: Computer Graphics
Assignment No. 01
Semester: Spring 2020
CS602: Computer Graphics
Total Marks: 20Due 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.- Install Dev-C++ from your LMS.
- Read out the file “Add graphics in Dev cpp” thoroughly and follow the instructions in the file properly provided to you on your LMS.
Please read the following instructions carefully before submitting assignment: - You should consult the recommended books, PowerPoint slides , Handouts and video lectures to clarify your concepts.
- You can take any help from your provided labs.
- 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 [email protected]
TASK
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 <graphics.h> // 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(); }