Tuesday, January 21, 2020

How to Write C Code for Object Drawing in Computer Graphics?

How to Write C Code for Object Drawing in Computer Graphics?

Steps to be followed:

Draw rough outline of Object on paper.
Identify graphics primitives required for drawing the object.
Find command from graphics library to draw the object.
Find Coordinates of graphics primitives with respect to Object and Computer Screen.

Functions required from graphics library of C language:

•Circle: circle(int x, int y, int radius);
Ellipse:ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
Line:line(int x1, int y1, int x2, int y2)
Rectangle:rectangle(int left, int top, int right, int bottom)
Arc: arc(int x, int y, int stangle, int endangle, int radius);
Fill ellipse: fillellipse(int x, int y, int xradius, int yradius)
To set color of primitives : setcolor(int color);
•To set background color :setbkcolor(int color)

Calculate points with respect to xy coordinates as shown below.

see following video for implementation:


How to write Computer graphics Programming in C language?

How to write Computer graphics Programming in C language?



While writing computer graphics program in C-Language we have to do few changes in program as follows:


Add header file for graphics functions as 

# include <graphics.h>

Declare two variables gd, gm( Variable name can be any )  and call initgraph function

int gd=DETECT,gm;
initgraph(&gd,&gm, “full path of BGI file”); 

even  after placing full path of BGI directory in initgraph function if graphics unable to initialize then do following ulternate procedure by keeping initgraph function .

a. go to file-> DOS Shell  and click
b. here you will be in BIN directory. come out of BIN using cd.. command.
c. then type cd BGI and press ENTER.you will enter into BGI Directory.
d. type exit command so that you will reach to program window.
e. after doing above process compile and run your program.

use putpixel function for plotting pixel on computer screen.

putpixel(x,y,color)


where x and y are coordinates of pixel to be plotted and color means color for   pixel. in C language there is color range from 0 to 15. you can choose any color  from available.  


Saturday, January 18, 2020

Scilab

Scilab Introduction 

1) Introduction

Scilab is  open source powerful computing environment for scientific and engineering applications.
Scilab is one of major alternative for Matlab.
Matrix is main data type.
It includes many mathematical functions-e.g. maths and statistics, 2D and 3D visualization, signal Processing , Image Processing, control system and so on…

2) Difference between Matlab and Scilab

Computer Graphics

Computer Graphics: 

Computer graphics is defined as generation and editing of 2D or 3D images with the help of computer.

Applications of Computer Graphics:

1) Games and entertainment: Computer graphics is used for the development of computer games or mobile games. Also, computer graphics is used for creation and editing of Movies, TV programs. Few movies totally created using computer graphics only and in few movies some scene modified by adding special effects or animations.

2)Scientific Visualization: Scientists or engineers are using computer-based models for analyzing huge amount of data. Also, scientific models like solar system, galaxy, black hole are used for education purpose.  

3)Medical visualization: Computer based Medical models like cut section of human body, brain, DNA structure can be used for visualizing minute details from it. Such models are used for education and training purpose.

4)  Special Effects: it is an illusion created in movies or games using computer graphics. Today almost all movies contain special effects to make it more presentable and attractive.

5) Art: Computer graphics specialized software’s are used for painting, drawing of images and 3D sculpture creation.

6)Computer Aided Design (CAD/CAM/CAE): Computer Aided Design methods are used for design and Analysis of Automobile, Aircraft, Buildings, Spacecrafts etc.

7)Data Visualization: Today lots of data generated from markets, weather, banks, sports etc. That data is represented on Computer screen using graphs, charts, plots.

8)Image Processing: Image processing is used to improve, change or analyzing images where Computer graphics is used for creation of imagesMostly both are used together.