From 1a7e6500d89f90d91d4a26b2787f21ecb6edc039 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Thu, 30 Nov 2023 00:26:35 +0530 Subject: [PATCH] added assignments c-6c and c-7b --- Assignment C-6c (Sunrise and Sunset).cpp | 38 ++++++++++++++++++ Assignment C-7b (Bouncing Ball).cpp | 43 ++++++++++++++++++++ README.md~ | 50 ------------------------ 3 files changed, 81 insertions(+), 50 deletions(-) create mode 100644 Assignment C-6c (Sunrise and Sunset).cpp create mode 100644 Assignment C-7b (Bouncing Ball).cpp delete mode 100644 README.md~ diff --git a/Assignment C-6c (Sunrise and Sunset).cpp b/Assignment C-6c (Sunrise and Sunset).cpp new file mode 100644 index 0000000..d80fe38 --- /dev/null +++ b/Assignment C-6c (Sunrise and Sunset).cpp @@ -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 +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 \ No newline at end of file diff --git a/Assignment C-7b (Bouncing Ball).cpp b/Assignment C-7b (Bouncing Ball).cpp new file mode 100644 index 0000000..59a01a4 --- /dev/null +++ b/Assignment C-7b (Bouncing Ball).cpp @@ -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 +#include +#include +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 \ No newline at end of file diff --git a/README.md~ b/README.md~ deleted file mode 100644 index 4e279b3..0000000 --- a/README.md~ +++ /dev/null @@ -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/)