added assignments c-6c and c-7b

This commit is contained in:
K 2023-11-30 00:26:35 +05:30
parent 6f08496a56
commit 1a7e6500d8
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F
3 changed files with 81 additions and 50 deletions

View File

@ -0,0 +1,38 @@
/*
Problem Statement: c) Write OpenGL program to draw Sun Rise and Sunset.
Code from Computer Graphics (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-codes/CG
*/
// BEGINNING OF CODE
#include<graphics.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm,NULL);
int midx,midy,r=10;
midx=getmaxx()/2;
while(r<=50) {
cleardevice();
setcolor(WHITE);
line(0,310,160,150);
line(160,150,320,310);
line(320,310,480,150);
line(480,150,640,310);
line(0,310,640,310);
arc(midx,310,225,133,r);
floodfill(midx,300,15);
if(r>20) {
setcolor(7);
floodfill(2,2,15);
setcolor(6);
floodfill(150,250,15);
floodfill(550,250,15);
setcolor(2);
floodfill(2,450,15);
}
delay(50);
r+=2;
}
getch();
closegraph();
}
// END OF CODE

View File

@ -0,0 +1,43 @@
/*
Problem Statement:
Code from Computer Graphics (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-codes/CG
*/
// BEGINNING OF CODE
#include <iostream>
#include <cstdlib>
#include <graphics.h>
using namespace std;
int main() {
int gd = DETECT, gm;
int i, x, y, flag=0;
initgraph(&gd, &gm,NULL);
/* get mid positions in x and y-axis */
x = getmaxx()/2;
y = 30;
while (1) {
if(y >= getmaxy()-30 || y <= 30) {
flag = !flag;
}
/* draws the gray board */
setcolor(RED);
//setfillstyle(SOLID_FILL, RED);
circle(x, y, 30);
floodfill(x, y, RED);
/* delay for 50 milli seconds */
delay(50);
/* clears screen */
cleardevice();
if(flag) {
y = y + 5;
}
else {
y = y - 5;
}
}
delay(5000);
closegraph();
return 0;
}
// END OF CODE

View File

@ -1,50 +0,0 @@
# CG
This repository contains notes and codes for **Computer Graphics.**
---
## Index
### Lab Notes CGL
1. [Koch and Snowflake Algorithms](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/CGL_Koch%20and%20Snowflake%20Curves.pdf)
### [Lab Manual](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/lab-manual/CGL%20Lab%20Manual.pdf)
- [Assignment Solutions 1-7 (ALL)](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/assignments/CGL%20Assignments%20%281-7%29.pdf)
### Codes
#### Digital Differential Analyzer (DDA)
> Digital Differential Analyzer (DDA) is a line-drawing algorithm for digital displays, using incremental calculations to plot points between endpoints.
1. [Line](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/DDA-line.cpp)
2. [Triangle](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/DDA-triangle.cpp)
3. [Circle](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/DDA-circle.cpp)
#### Cohen-Sutherland
1. [Cohen-Sutherland (Using Inbuilt Function)](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/CohenSutherland%28Using%20built-in%29.cpp)
2. [Cohen-Sutherland (Using DDA Line Drawing Algorithm)](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/CohenSutherland%28UsingDDA%29.cpp)
#### Transformation
1. [Translation, scaling, rotation](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/Transformation.cpp)
#### Curves
1. [Hilbert's Curve](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/HilbertCurve.cpp)
2. [Koch Curve](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/Koch-Curve.cpp)
3. [Snowflake Curve](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/Snowflake.cpp)
### Notes
1. [Unit 1 - Graphics Primitives and Scan Conversion Algorithms](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/notes/Unit%201)
2. [Unit 2 - Polygon, Windowing and Clipping](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/notes/Unit%202)
3. [Unit 3 - 2D, 3D Transformations and Projections](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/notes/Unit%203)
5. [Unit 5 - Curves and Fractals](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/notes/Unit%205)
### Question Papers
1. [IN-SEM](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/question-papers/IN-SEM)
2. [END-SEM](https://git.kska.io/sppu-se-comp-codes/CG/src/branch/main/question-papers/END-SEM)
---
Maintained by:
- [notkshitij](https://git.kska.io/notkshitij)
- [TanmaySpamzzz](https://git.kska.io/TanmaySpamzzz)
- [shh_itsourlittlesecret (Afan)](https://git.kska.io/shh_itsourlittlesecret)
- [Kalaskar_admin03](https://git.kska.io/Kalaskar_admin03/)