Professional Documents
Culture Documents
Course Title: Computer Graphics Laboratory Course Code: CSE-304 3 Year 1 Semester Examination 2022
Course Title: Computer Graphics Laboratory Course Code: CSE-304 3 Year 1 Semester Examination 2022
Submitted to-
Dr. Mohammad Shorif Uddin
Professor
Department of Computer Science and Engineering
Jahangirnagar University
&
Dr. Morium Akter
Associate Professor
Department of Computer Science and Engineering
Jahangirnagar University
Savar, Dhaka-1342
I. Rotate it by 30%
Introduction: Scan conversion, also known as rasterization, is a process used in computer
graphics to convert geometric shapes into pixel-based representations on a display screen. In
this case, we'll focus on the scan conversion of a line object from the starting point (0,0) to the
endpoint (100,50) and subsequently rotating it by 30 degrees.
Source code:
#include <iostream>
#include <graphics.h>
#include <cmath>
x = (int)newX;
y = (int)newY;
void rotateLine(int x1, int y1, int x2, int y2, float angle) {
int main() {
getch();
closegraph();
return 0;
Output:
Source code:
#include <iostream>
#include <graphics.h>
void scaleLine(int x1, int y1, int x2, int y2, float scaleFactor) {
int main() {
getch();
closegraph();
return 0;
Output:
Source code:
#include <iostream>
#include <graphics.h>
void translateLine(int x1, int y1, int x2, int y2, float translateX) {
int main() {
getch();
closegraph();
return 0;
Output:
Discussion: The code attempts to translate a line object from the coordinates (0,0) to (100,50) along
the x-axis by 75% of the length of the line (75% of x2). The line is expected to be drawn at a new position
Source code:
#include <iostream>
#include <graphics.h>
int p = 2 * dy - dx;
while (x != x2) {
putpixel(x, y, WHITE);
y += yInc;
p -= 2 * dx;
x += xInc;
p += 2 * dy;
} else {
int p = 2 * dx - dy;
while (y != y2) {
putpixel(x, y, WHITE);
if (p >= 0) {
x += xInc;
p -= 2 * dy;
y += yInc;
p += 2 * dx;
int main() {
getch();
closegraph();
return 0;
Output: