Code Monkey home page Code Monkey logo

learn-computer-graphics's Introduction

learn-computer-graphics

Wrote the Code in C with the help of graphics.h headerfile

Explanation of structure of the code:

First and formost step is to include graphics.h header file which provide us access to call predefined functions like: line, rectangle, arc, ellipse, polygon, circle, etc.,

Second step to initialize the graphics drivers in our computer using initgraph function from the graphics.h header file.

void initgraph(int *graphicsDriver, int *graphicsMode, char *driverDirectoryPath);

If your using Turbocpp means:

initgraph(&gd, &gm, "C:\\Turboc3\\BGI");

It initializes the graphics system by loading the passed graphics driver then changing the system into graphics mode. It also resets or initializes all graphics settings like color, palette, current position etc, to their default values. Below is the description of input parameters of initgraph function.

graphicsDriver:
It is a pointer to an integer specifying the graphics driver to be used. It tells the compiler that what graphics driver to use or to automatically detect the drive. In all our programs we will use "DETECT" macro of "graphics.h" library that instruct compiler for auto detection of graphics driver.
graphicsMode:
It is a pointer to an integer that specifies the graphics mode to be used. If "*gd" is set to "DETECT", then initgraph sets "*gm" to the highest resolution available for the detected driver.
driverDirectoryPath:
It specifies the directory path where graphics driver files (BGI files) are located. If directory path is not provided, then it will search for driver files in current working directory directory.
After these two steps we are free to use any predefined function from `graphics.h` to create a amazing graphics.

Predefined Function

A Stright Line

If we want to draw a straight line we need to call line() function.

Syntax:

line(x1,y1 ,x2,y2);

Here Elements in the parament are the x and y coordinates of the first point and second point. This line() function will draw a line joining these two points.

learn-computer-graphics's People

Contributors

suriya-1403 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.