0% found this document useful (0 votes)
32 views

Some of The Graphics Features

The document summarizes some common graphics features in C graphics programming including initializing a graphics window, clearing the screen, setting delays, and getting keyboard input. It also covers setting graphics attributes like color, line style, and current position. Functions for drawing lines, circles, rectangles, and text are described. Getting mouse input like clicks and coordinates is also mentioned.

Uploaded by

Kaarthik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Some of The Graphics Features

The document summarizes some common graphics features in C graphics programming including initializing a graphics window, clearing the screen, setting delays, and getting keyboard input. It also covers setting graphics attributes like color, line style, and current position. Functions for drawing lines, circles, rectangles, and text are described. Getting mouse input like clicks and coordinates is also mentioned.

Uploaded by

Kaarthik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Some of the Graphics Features

Initialize the graphics window


(the maximum width is usually 1024x768 or 1280x1024)

initwindow(width,height);
l

Clearing the graphics window


cleardevice();

Delay the program, so that users can see


what is happeningsending in the number of msec
delay(milliseconds);

Wait for a keyboard hit:


getch();

or,

kbhit();

Setting Graphics Attributes.


l

Set Drawing Color (for lines and edges)


(colors typically range from 0-15; 0 is usually black and 15 is white)

setcolor(color);
Set Background Color (usually for text)
setbkcolor(color);
Set Fill Style and Color (for interiors)
l

Pattern 0-12, 0 = empty, 1 = solid

setfillstyle(pattern, color)
Set Line Style and Thickness
l

Style: 0 = solid, 1 = dotted, 3 = dashed


Thickness is the width in terms of pixels

setlinestyle(style, pattern, thickness)

The Current Positionfor graphics


l

Origin on graphics system is Upper Left


So, positive y values move DOWN
l X,Y coordinate data are always whole
numbers
l

Setting the Current Position


Move to a current position (x,y are whole numbers)
moveto(x,y);
l Move relative to the current position
moverel(x,y);
l

DrawingLines
l

Drawing a line
l

Drawing from Current Position (from current


position to the specified coordinate)

lineto(x,y);
l Drawing relative (a delta amount from the current position)
l

The delta amounts would be whole numbers

linerel(deltax,deltay);
l Drawing absolute (from one coordinate to another)
linerel(from_x, from_y, to_x, to_y);

DrawingAreas
l

Drawing a Circle
l

Given center and radius as whole numbers


circle (center_x, center_y, radius);

Drawing a filled Rectangle


(given upper left and lower right corners)

bar(ul_x, ul_y, lr_x,lr_y);


l

Drawing an unfilled Rectangle


(given upper left and lower right corners)

rectangle(ul_x, ul_y, lr_x, lr_y);

How Text Look.


l

Text Formatting
l

Set the justification


l

Horizontal: (0 = left, 1 = center, 2= right)


Vertical: (0 = bottom, 1 = center, 2 = top)

settextjustify(horizontal, vertical)
l Set the text style
Font: (0-11)
l Direction: 0 = left to right direction
l Character Size: 0 = normal, 6 is really big!
l

settextstyle(font,direction, character size)

Messages in the Graphics WIndow


l

Text Output
Set Text color (index ranges 0-15)
setcolor(index);
l Output a message on the graphics window
at the current position
outtext(messages on graphics window);
l Output a message on the graphics window
at the given x,y coordinate
outtextxy(x,y,message);
l

Mouse Input!
l

Has there been a mouse click?


l
l

Right Click is 513


Left Click is 516

Middle Click is 519 (the wheel)

answer = ismouseclick(kind)
l

Clear the mouse click


(if you dont do this you cant get the next mouse click!)

clearmouseclick(kind);
l

What was the coordinate when the


mouse click happens
x = mousex();

y = mousey();

You might also like