The document provides explanations of various graphics functions from the graphics.h library in C language. It discusses functions for initializing graphics mode, drawing basic shapes like lines, rectangles, circles, getting and setting colors, reading and writing pixel values, loading and saving bitmap images, handling events and cleaning up graphics memory. It also includes code snippets to demonstrate drawing a rectangle, smiley and star using these graphics functions.
hey friends
this computer graphics practicals was the time of my educational time , I am sharing with you.
i am software developer for more query contect on my e-mail id abhi.smarta02@gmail.com
For all who wish to learn c graphics programming, no knowledge of graphics concepts is required. C Graphics programming is very easy and interesting. You can use graphics programming for developing your own games, in making projects, for animation etc. It's not like traditional C programming in which you have to apply complex logic in your program and then you end up with a lot of errors and warnings in your program. In C graphics programming you have to use standard library functions ( need not worry if you don't know functions ) to get your task done. Just you pass arguments to the functions and it's done. On this website you will find almost all functions with detailed explanation and a sample program showing the usage of a function. To make things easy you are provided with executable files which you can download and execute. Firstly you should know the function initgraph which is used to initialize the graphics mode . To initialize graphics mode we use initgraph function in our program. initgraph function is present in "graphics.h" header file, so your every graphics program should include "graphics.h" header file. We will discuss initgraph withe help of following sample program:-
hey friends
this computer graphics practicals was the time of my educational time , I am sharing with you.
i am software developer for more query contect on my e-mail id abhi.smarta02@gmail.com
For all who wish to learn c graphics programming, no knowledge of graphics concepts is required. C Graphics programming is very easy and interesting. You can use graphics programming for developing your own games, in making projects, for animation etc. It's not like traditional C programming in which you have to apply complex logic in your program and then you end up with a lot of errors and warnings in your program. In C graphics programming you have to use standard library functions ( need not worry if you don't know functions ) to get your task done. Just you pass arguments to the functions and it's done. On this website you will find almost all functions with detailed explanation and a sample program showing the usage of a function. To make things easy you are provided with executable files which you can download and execute. Firstly you should know the function initgraph which is used to initialize the graphics mode . To initialize graphics mode we use initgraph function in our program. initgraph function is present in "graphics.h" header file, so your every graphics program should include "graphics.h" header file. We will discuss initgraph withe help of following sample program:-
Gentle Introduction to Functional ProgrammingSaurabh Singh
This slide is basically aimed at professionals and students to introduce them with functional programming.
I haven't used much functional programming terminologies because I personally feel they could be overwhelming to people getting introduced to FP for the first time. For similar reasons I have deliberately avoided using any functional programming language and kept the discussions programming language agnostic as far as possible.
Abstracting over Execution with Higher Kinded TypesPhilip Schwarz
(download for better quality) Abstracting over Execution with Higher Kinded Types, and how to remain Purely Functional, a study aid for the introductory chapter of the book "Functional Programming for Mortals with Scalaz" by Sam Halliday, supplemented with code from https://github.com/fommil/fpmortals
Errata Corrige:
From https://twitter.com/philderome: you are missing a Future in slide 8 for doAndThen of ExecutionFuture (right hand side of slide), parameter c: A should read as c: Future[A]
Furniture - Muebles - Colección de Muebles Epick 2015Epick
DISEÑO Y PRODUCCIÓN DE MUEBLES DE DISEÑO.
Conozca nuestra colección 2015. Diseñada con pasión, creada para generar ambientes sofisticados, confortables, estéticos y funcionales.
www.epick.com.mx
Gentle Introduction to Functional ProgrammingSaurabh Singh
This slide is basically aimed at professionals and students to introduce them with functional programming.
I haven't used much functional programming terminologies because I personally feel they could be overwhelming to people getting introduced to FP for the first time. For similar reasons I have deliberately avoided using any functional programming language and kept the discussions programming language agnostic as far as possible.
Abstracting over Execution with Higher Kinded TypesPhilip Schwarz
(download for better quality) Abstracting over Execution with Higher Kinded Types, and how to remain Purely Functional, a study aid for the introductory chapter of the book "Functional Programming for Mortals with Scalaz" by Sam Halliday, supplemented with code from https://github.com/fommil/fpmortals
Errata Corrige:
From https://twitter.com/philderome: you are missing a Future in slide 8 for doAndThen of ExecutionFuture (right hand side of slide), parameter c: A should read as c: Future[A]
Furniture - Muebles - Colección de Muebles Epick 2015Epick
DISEÑO Y PRODUCCIÓN DE MUEBLES DE DISEÑO.
Conozca nuestra colección 2015. Diseñada con pasión, creada para generar ambientes sofisticados, confortables, estéticos y funcionales.
www.epick.com.mx
Social Media Bootcamp for Church, Vancouver, 2015Bruce Reyes-Chow
These are the latest manifestation of my "Definitive-ish Bootcamp for Using Social Media in the Church" There slides were used at the Leadershift Event with the United Church of Canada, British Columbia Conference, held in North Vancouver. Slides include: Shifts, Assumptions, Pitfalls, Possibilities, Postures, Words, Platforms, 10 To Start, Bonus Networks, and What do to tomorrow.
This file contains all the practicals with output regarding GTU syllabus. so it will help to IT and Computer engineering students. It is really knowledgeable so refer these for computer graphics practicals.
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfabdulrahamanbags
Q1 Consider the below omp_trap1.c implantation, modify the code so that: i. The time used by
the parallel block is timed using the OpenMP function omp_get_wtime(). The syntax is double
omp_get_wtime ( void ) It returns the number of seconds that have elapsed since some time in
the past. ii. Now on a system with at least two cores, time the program with a. one thread and a
large value of n, and b. two threads and the same value of n. Explain what happens? Then Do the
same measurements for the omp_trap2.c code.
1. How does its performance compare with the performance of the omp_trap1.c ?
2. Explain your answers.
3. provide with your answers the code and detailed screenshots showing how did you compile
and run the code and times for each run:
/* File: omp_trap1.c * Purpose: Estimate definite integral (or area under curve) using trapezoidal
rule. * Input: a, b, n * Output: estimate of integral from a to b of f(x) * using n trapezoids. * *
Compile: gcc -g -Wall -fopenmp -o omp_trap1 omp_trap1.c * Usage: ./omp_trap1 * * Notes: *
1. The function f(x) is hardwired. * 2. In this version, each thread explicitly computes the
integral over its assigned subinterval, a critical directive is used for the global sum. * 3. This
version assumes that n is evenly divisible by the number of threads #include #include #include
#include void Usage(char* prog_name); double f(double x); /* Function we're integrating */
double Local_trap ( double a , double b , i n t n ) ; int main(int argc, char* argv[]) { double
global_result = 0.0; /* Store result in global_result */ double a, b; /* Left and right endpoints */
int n; /* Total number of trapezoids */ int thread_count; if (argc != 2) Usage(argv[0]);
thread_count = strtol(argv[1], NULL, 10); printf("Enter a, b, and n\n"); scanf("%lf %lf %d", &a,
&b, &n); if (n % thread_count != 0) Usage(argv[0]); double global_result = 0.0; # pragma omp p
a r a l l e l num_threads ( t h r e a d _ c o u n t ) { # pragma omp c r i t i c a l global_result +=
Local_trap ( double a , double b , i n t n ) ; } printf("With n = %d trapezoids, our estimate\n", n);
printf("of the integral from %f to %f = %.14e\n", a, b, global_result); return 0; } /* main */ /*----
---------------------------------------------------------------- * Function: Usage * Purpose: Print
command line for function and terminate * In arg: prog_name */ void Usage(char* prog_name) {
fprintf(stderr, "usage: %s \n", prog_name); fprintf(stderr, " number of trapezoids must be evenly
divisible by\n"); fprintf(stderr, " number of threads\n"); exit(0); } /* Usage */ /*---------------------
--------------------------------------------- * Function: f * Purpose: Compute value of function to be
integrated * Input arg: x * Return val: f(x) */ double f(double x) { double return_val; return_val
= x*x; return return_val; } /* f */ /*------------------------------------------------------------------ *
Function: Trap * Purpose: Use trapezoidal rule to estimate definite integral * Input args.
This ppt's introduced Basics of computer graphics, which helps to diploma in computer engineering, DCA BCA, BE computer science student's to improve study in computer graphics.
implement the following funtions. myg1 and myg2 are seperate. x and .pdfforladies
implement the following funtions. myg1 and myg2 are seperate. x and y represent the two points
in the graph and w is the distance. after implementing ask the user to choose which funtion they
would like to use.
* insert [myg1 | myg2] x y w
* delete [myg1 | myg2] x y
* printgraph [myg1 | myg2]
* printdegree [myg1 | myg2] // if directed, print both in- and out-degree
* printcomplement [myg1 | myg2]
* eliminatelinks [myg1 | myg2] minW maxW
* differentlinks [myg1 | myg2] [myg1 | myg2]
* commonlinks [myg1 | myg2] [myg1 | myg2]
* dfs_print [myg1 | myg2] x
* bfs_print [myg1 | myg2] x
* isconnected [myg1 | myg2]
* numofconncomp [myg1 | myg2] * quit
here is the program so far. I just need to program and put in those function. I need to make it so
the user can pick what they want to do but I can program that myself. it\'s just programming the
above functions. I put clarifications of them at the bottom.
--------------------------------------------------------------------
graph.c program
#include
#include
typedef enum {FALSE, TRUE} bool;
#define MAXV 100
typedef struct edgenode{
int y;
int weight;
struct edgenode *next;
} edgenodeT;
typedef struct{
edgenodeT *edges[MAXV+1];
int degree[MAXV+1];
int nvertices;
int nedges;
bool directed;
} graphT;
void initialize_graph(graphT *g, bool directed);
void read_graph(graphT *g, char *filename);
void insert_edge(graphT *g, int x, int y, int w);
void print_graph(graphT *g, char *name);
void free_graph(graphT *g);
graphT *copy_graph(graphT *g);
main()
// Assume that MAXV is 6
{
graphT *myg1 = NULL, *myg2 = NULL;
if(argc < 2){
fprintf(stderr, \"Usage: %s graph_filename\", argv[0]);
exit(-1);
}
myg1 = (graphT *) malloc(sizeof(graphT));
if (myg1==NULL) {
fprintf(stderr, \"Cannot allocate memory for the graph\");
exit(-1);
}
initialize_graph(myg1, FALSE);
read_graph(myg1, argv[1]);
print_graph(myg1, \"myg1\");
myg2 = copy_graph(myg1);
print_graph(myg2, \"myg2\");
// NOW in a loop get commands and
// call related functions to perform them...
free_graph(myg1);
}
initialize_graph (graphT*g, bool directed)
{
int i;
g->nvertices= 0;
g->nedges= 0;
g->directed = directed;
for (i=1; i<=MAXV; i++)
g->edges[i] = NULL;
for(i=1; i<=MAXV; i++)
g->degree[i] = 0;
}
read_graph(graphT *g)
{
int i;
int n, m, dir;
int x, y, w;
FILE *fp
if((fp=fopen(filename,\"r\"))==NULL){
fprintf(stderr, \"Cannot open the graph file\");
exit(-1);
}
scanf(”%d %d %d”, &n, &m, &dir);
g->nvertices= n;
g->nedges= 0;
g->directed= dir;
for (i=1; i<=m; i++) {
scanf(”%d %d %d”, &x, &y, &w);
insert _edge(g, x, y, w);
if(dir==FALSE)
insert _edge(g, y, x, w);
}
fclose(fp);
}
insert_edge(graphT *g, int x, int y, int w)
{
edgenodeT *pe;
pe= malloc(sizeof(edgenodeT)); // check if NULL
pe->weight = w;
pe->y = y;
pe->next = g->edges[x];
g->edges[x] = pe;
g->degree[x]++;
g->nedges++;
}
print_graph (graphT *g, char *name)
{
edgenodeT *pe;
int i;
if(!g) return;
printf(\"Graph Name: %s\ \", name);
for(i=1; i<=g->nvertices; i++){
printf(\"Node %d: \", i);
pe = g->edges[i];
wh.
Create a Java Applet that uses two integer (int) variables x and y to.docxmrichard5
Create a Java Applet that uses two integer (int) variables x and y to place the picture of four circles on the screen. Alternate the colors by setting the g.setColor method . Also, use the g.drawString to place your name above the circles.
Solution
import java.applet.*;
import java.awt.*;
public class Bullseye extends Applet {
public void paint(Graphics g) {
int appletHeight = this .getSize().height;
int appletWidth = this .getSize().width;
for ( int i=8; i >= 0; i--) {
if ((i % 2) == 0) g.setColor(Color.red);
else g.setColor(Color.white);
// Center the rectangle
int rectHeight = appletHeight*i/8;
int rectWidth = appletWidth*i/8;
int rectLeft  = appletWidth/2 - i*appletWidth/16;
int rectTop   = appletHeight/2 - i*appletHeight/16;
g.fillOval(rectLeft, rectTop, rectWidth, rectHeight);
}
}
}
.
Following are the changes mentioned in bold in order to obtain the r.pdfanithareadymade
Following are the changes mentioned in bold in order to obtain the required result and stop
scrolling in the background.
#include \"SDL/SDL.h\"
#include
//The attributes of the screen can be defined as follows
const int SCN_WIDTH = 640;
const int SCN_HEIGHT = 480;
const int SCN_BPP = 32;
//BPP defines bits per pixel
SDL_Surface* Background = NULL;
SDL_Surface* SpriteImage = NULL;
SDL_Surface* Backbuffer = NULL;
int SpriteFrame = 0;
int FrameCounter = 0;
const int MaxSpriteFrame = 12;
const int FrameDelay = 2;
int BackgroundX = 0;
SDL_Surface* LoadImage(char* fileName);
bool LoadFiles();
void FreeFiles();
void DrawImage(SDL_Surface* image, SDL_Surface* destSurface, int x, int y);
void DrawImageFrame(SDL_Surface* image, SDL_Surface* destSurface, int x, int y, int width,
int height, int frame);
bool ProgramIsRunning();
int main(int argc, char* args[])
{
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
printf(\"Failed to initialize SDL!\ \");
return 0;
}
Backbuffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);
SDL_WM_SetCaption(\"Image Animation\", NULL);
if(!LoadFiles())
{
printf(\"Failed to load all files!\ \");
FreeFiles();
SDL_Quit();
return 0;
}
while(ProgramIsRunning())
{
//Update\'s the sprites frame
FrameCounter++;
if(FrameCounter > FrameDelay)
{
FrameCounter = 0;
SpriteFrame++;
}
if(SpriteFrame > MaxSpriteFrame)
SpriteFrame = 0;
//Background scrolling can be removed from this position
//Render the scene
DrawImage(Background,Backbuffer, BackgroundX, 0);
DrawImage(Background,Backbuffer, BackgroundX+800, 0);
DrawImageFrame(SpriteImage, Backbuffer, 350,250, 150, 120, SpriteFrame);
SDL_Delay(20);
SDL_Flip(Backbuffer);
}
FreeFiles();
SDL_Quit();
return 0;
}
SDL_Surface* LoadImage(char* fileName)
{
SDL_Surface* imageLoaded = NULL;
SDL_Surface* processedImage = NULL;
imageLoaded = SDL_LoadBMP(fileName);
if(imageLoaded != NULL)
{
processedImage = SDL_DisplayFormat(imageLoaded);
SDL_FreeSurface(imageLoaded);
if(processedImage != NULL)
{
//Here we map the color key
Uint32 colorKey = SDL_MapRGB(processedImage->format, 0, 0xFF, 0xFF);
//Now, set all the pixels of color R 0,G 0*FF,B 0*FF to be transparent
SDL_SetColorKey(processedImage, SDL_SRCCOLORKEY, colorKey);
}
}
return processedImage;
}
bool LoadFiles()
{
Background = LoadImage(\"graphics/background.bmp\");
if(Background == NULL)
return false;
SpriteImage = LoadImage(\"graphics/bat.bmp\");
//The file should be preloaded and linked with the required libraries in SDL
if(SpriteImage == NULL)
return false;
else
return true;
}
void FreeFiles()
{
SDL_FreeSurface(Background);
SDL_FreeSurface(SpriteImage);
}
void DrawImage(SDL_Surface* image, SDL_Surface* destSurface, int x, int y)
//A temporary rectangle is used to hold the offsets
{
SDL_Rect destRect;
//Giving the offsets to the rectangle
destRect.x = x;
destRect.y = y;
//Blit the surface
SDL_BlitSurface(image, NULL, destSurface, &destRect);
}
//Here, we need to start the main function:
int main(int argc,char** args)
//Now, initialize all SDL subsystems
if .
please help me with this and explain in details also in the first qu.pdfnewfaransportsfitnes
please help me with this and explain in details also in the first question modify them both please
trap1 and trap2:
Q1 Consider the below omp_trap1.c implantation, modify the code so that: i. The time used by
the parallel block is timed using the OpenMP function omp_get_wtime(). The syntax is double
omp_get_wtime ( void ) It returns the number of seconds that have elapsed since some time in
the past. ii. Now on a system with at least two cores, time the program with a. one thread and a
large value of n, and b. two threads and the same value of n. Explain what happens? Then Do the
same measurements for the omp_trap2.c code.
1. How does its performance compare with the performance of the omp_trap1.c ?
2. Explain your answers.
3. provide with your answers the code and detailed screenshots showing how did you compile
and run the code and times for each run:
/* File: omp_trap1.c * Purpose: Estimate definite integral (or area under curve) using trapezoidal
rule. * Input: a, b, n * Output: estimate of integral from a to b of f(x) * using n trapezoids. * *
Compile: gcc -g -Wall -fopenmp -o omp_trap1 omp_trap1.c * Usage: ./omp_trap1 * * Notes: *
1. The function f(x) is hardwired. * 2. In this version, each thread explicitly computes the
integral over its assigned subinterval, a critical directive is used for the global sum. * 3. This
version assumes that n is evenly divisible by the number of threads #include #include #include
#include void Usage(char* prog_name); double f(double x); /* Function we're integrating */
double Local_trap ( double a , double b , i n t n ) ; int main(int argc, char* argv[]) { double
global_result = 0.0; /* Store result in global_result */ double a, b; /* Left and right endpoints */
int n; /* Total number of trapezoids */ int thread_count; if (argc != 2) Usage(argv[0]);
thread_count = strtol(argv[1], NULL, 10); printf("Enter a, b, and n\n"); scanf("%lf %lf %d", &a,
&b, &n); if (n % thread_count != 0) Usage(argv[0]); double global_result = 0.0; # pragma omp p
a r a l l e l num_threads ( t h r e a d _ c o u n t ) { # pragma omp c r i t i c a l global_result +=
Local_trap ( double a , double b , i n t n ) ; } printf("With n = %d trapezoids, our estimate\n", n);
printf("of the integral from %f to %f = %.14e\n", a, b, global_result); return 0; } /* main */ /*----
---------------------------------------------------------------- * Function: Usage * Purpose: Print
command line for function and terminate * In arg: prog_name */ void Usage(char* prog_name) {
fprintf(stderr, "usage: %s \n", prog_name); fprintf(stderr, " number of trapezoids must be evenly
divisible by\n"); fprintf(stderr, " number of threads\n"); exit(0); } /* Usage */ /*---------------------
--------------------------------------------- * Function: f * Purpose: Compute value of function to be
integrated * Input arg: x * Return val: f(x) */ double f(double x) { double return_val; return_val
= x*x; return return_val; } /* f */ /*------------------------------------------.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
Computer graphics
1. Practical 1
Q1.Study of library functions from graphics.h
1)INITGRAPH
DECLARATION
* void far initgraph(int far *graph driver)
EXPLANATION
* To start the graphic system, you must first call initgraph.
*Initgraph initializes the graphic system by loading a graphics driver from disk
(or validating a registered driver) then putting the system into graphics mode.
*Initgraph also resets all graphics settings
(color,palette,currentposition,viewport, etc) to their defaults then resets graph.
2)GETPIXEL, PUTPIXEL
DECLARATION
* Unsigned far getpixel(int x, int y)
* void far putpixel(int x, int y, int color)
EXPLANATION
*Getpixel gets the color of the pixel located at (x,y)
*Putpixel plots a point in the color defined at (x, y).
2. 3)CLOSE GRAPH
DECLARATION
*void far closegraph(void);
EXPLANATION
*Close graph deallocates all memory allocated by the graphic system.
*It then restores the screen to the mode it was in before you called initgraph.
4) ARC, CIRCLE, PIESLICE
DECLARATION
*void far arc(int x, int y, intstangle, intendangle, int radius);
*void far circle(int x, int y, int radius);
*void far pieslice(int x, int y, intstangle, intendangle, int radius);
EXPLANATION
*Arc draws a circular arc in the current drawing color
*Circle draws a circle in the current drawing color
*Pieslice draws a pieslice in the current drawing color, then fills it using the
current fillpattern and fill color.
5) ELLIPSE, FILLELIPSE, SECTOR
DECLARATION
*void far ellipse(int x, int y, intstangle, intendangle, intxradius, intyradius)
*void far fillellipse(int x, int y, intxradius, intyradius)
*void farsectoe(int x, int y, intstangle,intendangle, intxradius, intyradius)
EXPLANATION
*Ellipse draws an elliptical arc in the current drawing color.
*Fillellipse draws an elliptical arc in the current drawing color and than fills it
with fill color and fill pattern.
*Sector draws an elliptical pie slice in the current drawing color and than fills it
using the pattern and color defined by set fillstyle or setfillpattern.
3. 6) FLOODFILL
*Flood-fills a bounded region.
DECLARATION
*void far floodfill(int x, int y, int border)
EXPLANATION
*Floodfills an enclosed area on bitmap device.
*The area bounded by the colorborder is flooded with the current fill pattern and
fill color.
*If the seed is within an enclosedarea, the inside will be filled.If the seed is
outside the enclosed area, the exterior will be filled.
*Use fillpoly instead of floodfill wherever possible so you can maintain code
compatibility with future versions.
*Floodfilldoesnot work with the IBM-8514 driver.
7) GETCOLOR, SETCOLOR
*Getcolor returns the current drawing color.
*Setcolor returns the current drawing color.
DECLARATION
*int far getcolor(void);
*void far setcolor(int color)
EXPLANATION
*Getcolor returns the current drawing color.
*Setcolor sets the current drawing color to color, which can range from 0 to
getmaxcolor.
*To set a drawing color with setcolor ,you can pass either the color number or
theequivalent color name.
4. 8) LINE, LINEREL, LINETO
DECLARATION
*void far lineto(int x, int y)
EXPLANATION
*Line draws a line from (x1, y1) to (x2, y2) using the current color, line style
and thickness. It does not update the current position (CP).
*Linerel draws a line from the CP to a point that is relative distance
(dx, dy) from the CP, then advances the CP by (dx, dy).
*Lineto draws a line from the CP to
(x, y), then moves the CP to (x,y).
9)RECTANGLE
DECLARATION
*void far rectangle(int left, int top, int right, int bottom)
EXPLANATION
*It draws a rectangle in the current line style, thickness and drawing color.
*(left, top)is the upperleft cornerofthe rectangle, and (right, bottom)is its lower
right corner.
10)MOVEREL,MOVETO
DECLARATION
*void moverel(int x, int y);
*void moveto(int x, int y);
EXPLANATION
*moveto function changes the current position (CP) to (x, y)
*moverel function moves the current position to a relative distance.
11)IMAGESIZE,GETIMAGE,PUTIMAGE
DECLARATION
5. *intimagesize(int left, int top, int right, int bottom);
*void getimage(int left, int top, int right, int bottom, void *bitmap);
*void putimage(int left, int top, void *ptr, int op);
EXPLANATION
*imagesize function returns the number of bytes required to store a bitimage.
This function is used when we are using getimage.
*getimage function saves a bit image of specified region into memory, region
can be any rectangle.
*getimage copies an image from screen to memory. Left, top, right, and bottom
define the area of the screen from which the rectangle is to be copied, bitmap
points to the area in memory where the bit image is stored.
*putimage function outputs a bit image onto the screen.
*putimage puts the bit image previously saved with getimage back onto the
screen, with the upper left corner of the image placed at (left, top). ptr points to
the area in memory where the source image is stored. The op argument specifies
a operator that controls how the color for each destination pixel on screen is
computed, based on pixel already on screen and the correspondingsource pixel
in memory.
11)GETX,GETY
DECLARATION
*intgetx();
* intgety();
EXPLANATION
*getx function returns the X coordinate of current position.
*gety function returns the y coordinate of current position.
12)GETMAXX,GETMAXY
DECLARATION
*intgetmaxx();
*intgetmaxy();
EXPLANATION
*getmaxy function returns the maximum Y coordinate for current graphics
mode and driver.
6. *getmaxx function returns the maximum X coordinate for current graphics
mode and driver.
13)FILLPOLY,DRAWPOLY
DECLARATION
*void drawpoly( intnum, int *polypoints );
*void drawpoly( intnum, int *polypoints );
EXPLANATION
*Drawpoly function is used to draw polygons i.e. triangle, rectangle, pentagon,
hexagon etc.
*Fillpoly function draws and fills a polygon. It require same arguments as
drawpoly.
*num indicates (n+1) number of points where n is the number of vertices in a
polygon, polypoints points to a sequence of (n*2) integers . Each pair of
integers gives x and y coordinates of a point on the polygon. We specify (n+1)
points as first point coordinates should be equal to (n+1)th to draw a complete
figure.
*To understand more clearly we will draw a triangle using drawpoly, consider
for example the array :-
int points[] = { 320, 150, 420, 300, 250, 300, 320, 150};
points array contains coordinates of triangle which are (320, 150), (420, 300)
and (250, 300). Note that last point(320, 150) in array is same as first.
14)SETLINESTYLE
DECLARATION
*void setlinestyle( intlinestyle, unsigned upattern, int thickness );
EXPLANATION
*ItdrawsSOLID_LINE,DOTTED_LINE,CENTER_LINE,DASHED_LINE,US
ERBIT_LINE.
15)GETBKCOLOR,SETBKCOLOR
DECLARATION
*intgetbkcolor();
* void setbkcolor(intcolor);
EXPLANATION
*getbkcolor function returns the current background color
*setbkcolor function changes current background color e.g.
setbkcolor(YELLLOW) changes the current background color to YELLOW.
7. Remember that default drawing color is WHITE and background color is
BLACK.
16)GETMODENAME
DECLARATION
*char * far getmodename(int mode_number);
EXPLNATION
*Returns the name of a specified graphics mode
*getmodename accepts a graphics mode number as input and returns a
stringcontaining the name of the corresponding graphics mode.
*The mode names are embedded in each driver.
8. Q2.Write a program to draw a rectangle.
CODE
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode= graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code*/
}
left = getmaxx() / 2 - 50;
top = getmaxy() / 2 - 50;
right = getmaxx() / 2 + 50;
10. Q3.Write a program to draw a smiley.
Code:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "C:TurboC++DiskTurboC3BIN");
/* read result of initialization */
errorcode= graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code*/
}
13. Q3.Write a program to draw a star.
CODE:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "C:turboc3bgi");
/* read result of initialization */
errorcode= graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code*/
}
moveto(60,90);
lineto(100,150);
16. Practical 2
Aim :- Implement DDA Line Drawing Algorithm
CODE:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void draw(int x1,int y1,int x2,int y2);
void main()
{
int x1,y1,x2,y2;
int gdriver=DETECT,gmode,gerror;
printf(“n Enter the x and y value for starting point:n”);
scanf(“%d%d”,&x1,&y1);
printf(“n Enter the x and y value for ending point:n”);
scanf(“%d%d”,&x2,&y2);
clrscr();
initgraph(&gdriver,&gmode,””);
draw(x1,y1,x2,y2);
getch();
closegraph();
}
void draw(int x1,int y1,int x2,int y2)
{
float x,y,xinc,yinc,dx,dy;
19. Practical 3
Aim :- Implement Bresenham's Line Drawing Algorithm
CODE:
# include <stdio.h>
# include <conio.h>
# include <graphics.h>
void main()
{
int dx,dy,x,y,e,x1,y1,x2,y2;
int gd,gm;
clrscr();
printf("nntEnter the co-ordinates of first point : ");
62. printf("1.REFLECTION ABOUT X-AXIS n2.REFLECTION ABOUT Y-
AXIS n3.REFLECTION ABOUT BOTH AXISn4.REFLECTION AT
Y=Xn5.REFLECTION ABOUT Y=-Xn6.EXIT");
printf("nENTER YOUR CHOICE-->>");
scanf("%d",&ch);
switch(ch)
{
case 1:
id(rmat);
rmat[1][1]=-1;
mul(cor,rmat,n);
break;
case 2:
id(rmat);
rmat[0][0]=-1;
mul(cor,rmat,n);
break;
case 3:
id(rmat);
rmat[0][0]=-1;
rmat[1][1]=-1;
mul(cor,rmat,n);
break;
case 4:
id(rmat);
rmat[0][0]=0;
rmat[1][0]=1;
rmat[0][1]=1;
rmat[1][1]=0;
mul(cor,rmat,n);
break;
case 5:
id(rmat);
rmat[0][0]=0;
rmat[1][0]=-1;
rmat[0][1]=-1;