programming in srgp. intro advantages of raster displays advantages of raster displays fill areas...

54
Programming in SRGP

Upload: myrtle-patrick

Post on 25-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Programming in SRGP

Page 2: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

INTROINTRO

Advantages of Raster DisplaysAdvantages of Raster Displays Fill areas with uniform color or Fill areas with uniform color or

repeated pattern with 2 or more repeated pattern with 2 or more colors.colors.

Stores images which allows Stores images which allows manipulation @ fine level : individual manipulation @ fine level : individual pixels can be read or written and pixels can be read or written and arbitrary portions can be copied or arbitrary portions can be copied or moved.moved.

Page 3: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

SRGP(Simple Raster Graphics SRGP(Simple Raster Graphics Package)Package)

Device independent Graphics packageDevice independent Graphics package Similar to Macintosh QuickDraw Similar to Macintosh QuickDraw

Raster package and Xlib package of Raster package and Xlib package of Windows systemWindows system

Page 4: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

SRGP (Continued..)SRGP (Continued..)

Drawing with SRGPDrawing with SRGP Basic Interaction HandlingBasic Interaction Handling Raster Graphics FeaturesRaster Graphics Features Limitations of SRGPLimitations of SRGP

Page 5: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.Drawing with SRGP1.Drawing with SRGP

1.1 Specification of Graphics 1.1 Specification of Graphics PrimitivesPrimitives

1.2 Attributes1.2 Attributes 1.3 Filled primitives and attributes1.3 Filled primitives and attributes 1.4 Saving and Restoring Attributes1.4 Saving and Restoring Attributes 1.5Text1.5Text

Page 6: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.1 Specification of Graphics 1.1 Specification of Graphics PrimitivesPrimitives

Drawing in integer graphics package such as SRGP Drawing in integer graphics package such as SRGP is like plotting graphs on graph paper with very fine is like plotting graphs on graph paper with very fine gridgrid

Grid varies from 80-120 points per inch to 300 or Grid varies from 80-120 points per inch to 300 or more on high resolution displaysmore on high resolution displays

(0,0)--> bottom left of the screen . +ve x increases (0,0)--> bottom left of the screen . +ve x increases towards right and +ve Y increases towards toptowards right and +ve Y increases towards top

Page 7: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.1 continued...1.1 continued...

SRGP supports basic collections of SRGP supports basic collections of primitivesprimitives

a)a)LinesLines

b)b)PolygonsPolygons

c)c)CirclesCircles

d)d)EllipsesEllipses

e)e)TextText

Page 8: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Lines and Poly linesLines and Poly lines VoidVoid SRGP_lineCoord(int x1, int y1, int SRGP_lineCoord(int x1, int y1, int

x2, int y2);x2, int y2); eg:eg: SRGP_lineCoord(0,0,100,300)SRGP_lineCoord(0,0,100,300) (or)(or) void void SRGP_line(point pt1,point pt2);SRGP_line(point pt1,point pt2); Point is a defined type, a record holding Point is a defined type, a record holding

2 integer x,y values2 integer x,y values typedef structtypedef struct {int x,y;{int x,y; }point;}point;

Page 9: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Lines and Poly linesLines and Poly lines

A sequence of lines connecting A sequence of lines connecting successive vertices is called polyline.successive vertices is called polyline.

There are 2 polyline procedures. There are 2 polyline procedures. These take array as parameter.These take array as parameter.

VoidVoid SRGP_polyLineCoord (int vertexcount, SRGP_polyLineCoord (int vertexcount, int*xArray, int*yArray);int*xArray, int*yArray); Void Void SRGP_polyLine(int vertexcount, point SRGP_polyLine(int vertexcount, point *vertices);*vertices);

Page 10: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

continued..continued.. /* plot the axes*//* plot the axes*/ SRGP_lineCoord(175,200,320,200);SRGP_lineCoord(175,200,320,200); SRGP_lineCoord(200,140,200,280);SRGP_lineCoord(200,140,200,280); /*plot the data*//*plot the data*/ SRGP_polyLineCoord (12 ,months, SRGP_polyLineCoord (12 ,months,

balanceOfTrade);balanceOfTrade); SRGP_polyLine(7, bowtieArray);SRGP_polyLine(7, bowtieArray);

Page 11: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

contiued..contiued..

Markers and polymarkersMarkers and polymarkers It is convenient to place markers(dots,asterisks It is convenient to place markers(dots,asterisks

or circles) at the data points on graphs.or circles) at the data points on graphs. Void SRGP_markerCoord(intx,inty);Void SRGP_markerCoord(intx,inty); Void SRGP_marker(point pt)Void SRGP_marker(point pt) VoidVoid SRGP_polyMarkerCoord (int vertexcount, SRGP_polyMarkerCoord (int vertexcount,

int*xArray, int*yArray);int*xArray, int*yArray); Void Void SRGP_polyMarker(int vertexcount, point SRGP_polyMarker(int vertexcount, point

*vertices);*vertices);

Page 12: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

continued...continued...

Polygons and RectanglesPolygons and Rectangles --> To draw an outline polygon, we --> To draw an outline polygon, we

can either specify a polyline on itself can either specify a polyline on itself by making the first and last vertices by making the first and last vertices identical (or) we can useidentical (or) we can use

void SRGP_polygon(int vertexCount, point void SRGP_polygon(int vertexCount, point *vertices)*vertices)

Now bowtieArray is of only 6 points it Now bowtieArray is of only 6 points it automatically closes the figure.automatically closes the figure.

Page 13: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

ContinuedContinued Any rectangle can be specified as a Any rectangle can be specified as a

polygon having 4 vertices.polygon having 4 vertices. Uses only 2 primitives(lower left & upper Uses only 2 primitives(lower left & upper

right)right) Void SRGP_rectangleCoord(int leftx, intbottomY,int Void SRGP_rectangleCoord(int leftx, intbottomY,int

rightX, int topY);rightX, int topY); Void SRGP_rectanglePt(point bottomLeft, point Void SRGP_rectanglePt(point bottomLeft, point

topRight);topRight); void SRGP_rectangle(rectangle rect);void SRGP_rectangle(rectangle rect); typedef struct{ point bottomLeft,topRight;typedef struct{ point bottomLeft,topRight; }rectangle;}rectangle;

Page 14: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Rectangles continued..Rectangles continued..

Point SRGP_defPoint(intx,int y);Point SRGP_defPoint(intx,int y); Rectangle SRGP_defRectangle(int Rectangle SRGP_defRectangle(int

leftX,int bottomY,int rightX, int topY);leftX,int bottomY,int rightX, int topY);

Page 15: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Circles and EllipsesCircles and Ellipses

• Circles are Special types of ellipses.Circles are Special types of ellipses.• The term ellipse arc used for The term ellipse arc used for

circular,elliptical,closed or partial arcs.circular,elliptical,closed or partial arcs.• It is easy to specify arcs via upright It is easy to specify arcs via upright

rectangles (bounding boxes or extents)rectangles (bounding boxes or extents)• VoidVoid SRGP_ellipseArc( SRGP_ellipseArc(rectanglerectangle

extentRect, float startAngle, float extentRect, float startAngle, float endAngle);endAngle);

Page 16: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Circles and ellipsesCircles and ellipses Relationship between rectangular and Relationship between rectangular and

circular angle iscircular angle is Rectangular angle=arctan(tan(circularangle).width/height)+Rectangular angle=arctan(tan(circularangle).width/height)+ adjustadjust

where the angles are in radians andwhere the angles are in radians and adjust = 0, for 0<= circular angle<∏/2adjust = 0, for 0<= circular angle<∏/2 adjust = ∏/2 , for ∏/2 <=circular angle < 3∏/2adjust = ∏/2 , for ∏/2 <=circular angle < 3∏/2 adjust = 2∏, for 3∏/2<= circular angle < 2∏adjust = 2∏, for 3∏/2<= circular angle < 2∏

Page 17: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.2 Attributes1.2 Attributes• The specification of a primitive can be The specification of a primitive can be

controlled by specification of its controlled by specification of its attributesattributes

• Line style and Line widthLine style and Line width• ColorColor• PenstylePenstyle• Attributes are global state variables Attributes are global state variables

that retain their values until they are that retain their values until they are changed explicitlychanged explicitly

Void SRGP_setLineStyle(lineStyle Void SRGP_setLineStyle(lineStyle CONTINUOUS / DASHED /DOTTED/….);CONTINUOUS / DASHED /DOTTED/….);

Void SRGP_setLineWidth(int widthValue);Void SRGP_setLineWidth(int widthValue);

Page 18: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Attributes..Attributes..• Each attribute has a default.. Eg., default for Each attribute has a default.. Eg., default for

linestyle is CONTINUOUS that for line width is linestyle is CONTINUOUS that for line width is 1.1.

• Line style can be represented as bit mask and Line style can be represented as bit mask and it is scan converted by SRGP.it is scan converted by SRGP.

• For eg.. Contimuous all 1’sFor eg.. Contimuous all 1’s• DASHED DASHED 1111001111001111…..1111001111001111…..

Page 19: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Attributes for marker primitiveAttributes for marker primitive

Void SRGP_setMarkerSize(int sizeValue);Void SRGP_setMarkerSize(int sizeValue); Void SRGP_setMarkerStyle(Void SRGP_setMarkerStyle(markerStylemarkerStyle

MARKER_CIRCLE / MARKER_SQUARE/…);MARKER_CIRCLE / MARKER_SQUARE/…); The default is circle styleThe default is circle style COLORCOLOR bilevel system the color value is 0 and 1.bilevel system the color value is 0 and 1. -1 black, 0 white for black on white devices-1 black, 0 white for black on white devices 1 green, 0 black for green on black devices1 green, 0 black for green on black devices

Page 20: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Attribute-colorAttribute-color

• The integer color attribute is an index to The integer color attribute is an index to SRGP;s color table. Each entry defines SRGP;s color table. Each entry defines color or gray scale value.color or gray scale value.

• There are 2d entries and d is the depth of There are 2d entries and d is the depth of frame bufferframe buffer

• 2 methods to specify colors2 methods to specify colors• 1. use integers 0 and 1 directly1. use integers 0 and 1 directly• 2. use color names supported by SRGP2. use color names supported by SRGP• We can also select color by callingWe can also select color by calling• Void SRGP_setColor(int colorIndex)Void SRGP_setColor(int colorIndex)

Page 21: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.3 Filled Primitives and Their 1.3 Filled Primitives and Their AttributesAttributes

Primitives can be drawn in 2 waysPrimitives can be drawn in 2 ways OutlineOutline FilledFilled SRGP’s filled versions of area SRGP’s filled versions of area

defining primitives draw the interior defining primitives draw the interior pixels with no outlinepixels with no outline

Page 22: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Code for creating filled PrimitivesCode for creating filled Primitives

Page 23: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Output for the previous codeOutput for the previous code

Page 24: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Odd Parity ruleOdd Parity rule We need a rule for specifying which regions are We need a rule for specifying which regions are

interior, and thus should be filled and which is interior, and thus should be filled and which is exteriorexterior

This can done in SRGP through odd parity rule.This can done in SRGP through odd parity rule. To check whether the region lies inside/ outsideTo check whether the region lies inside/ outside1.1. Choose a test pointChoose a test point2.2. Choose a ray that starts at the test point Choose a ray that starts at the test point

extends indefinitely in any direction and does extends indefinitely in any direction and does not pass any vertices.not pass any vertices.

3.3. If this ray intersect the polygon outline an odd If this ray intersect the polygon outline an odd no of times ->interiorno of times ->interior

4.4. else exteriorelse exterior

Page 25: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Fill style and fill pattern for areasFill style and fill pattern for areas

4 ways 4 ways VoidVoid SRGP_setFillStyleSRGP_setFillStyle(drawStyle (drawStyle

SOLID/ BITMAP_PATTERN_OPAQUE / SOLID/ BITMAP_PATTERN_OPAQUE / BITMAP_PATTERN_TRANSPARENT/ BITMAP_PATTERN_TRANSPARENT/ PIXMAP_PATTERN);PIXMAP_PATTERN);

There is no distinction in opaque & There is no distinction in opaque & transparent in pix map patternstransparent in pix map patterns

Page 26: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Application screen backgroundApplication screen background

Background color Background color 0 bits in bitmap 0 bits in bitmap patterns used in opaque mode.patterns used in opaque mode.

Suppose user expects the uniform screen Suppose user expects the uniform screen background pattern then the application background pattern then the application should set up the background in desired should set up the background in desired pattern. Default pattern. Default solid color 0solid color 0

Erase primitiveErase primitive is done by redraw them is done by redraw them in the application background pattern.in the application background pattern.(Quick & dirty technique). This yield (Quick & dirty technique). This yield damaged image if primitives overlaps.damaged image if primitives overlaps.

Damage repair is done by respecifying Damage repair is done by respecifying primitives in application dataprimitives in application data

Page 27: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.4 Saving and restoring Attributes1.4 Saving and restoring Attributes

Attributes can be saved for later Attributes can be saved for later restoration.restoration.

It does not affect the global attribute It does not affect the global attribute state.state.

SRGP does this attribute group viaSRGP does this attribute group via

void SRGP_inquireAttributes(attributeGroup * group);void SRGP_inquireAttributes(attributeGroup * group);

void SRGP_setAttributes(attributeGroup * group);void SRGP_setAttributes(attributeGroup * group);

Page 28: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.5 Text1.5 Text Specifying and implementing text drawing is Specifying and implementing text drawing is

always complex in graphics package. always complex in graphics package. (style,font,bold,italic,width,spacing)(style,font,bold,italic,width,spacing)

In SRGP text is horizontally aligned and In SRGP text is horizontally aligned and character widths vary, but space b/w character widths vary, but space b/w characters is constant.characters is constant.

High quality documents need specialized High quality documents need specialized packages that offer more ctrl.packages that offer more ctrl.

Eg. Post scriptEg. Post script Text in SRGP is generated byText in SRGP is generated by void SRGP_text(point origin, char *text);void SRGP_text(point origin, char *text);

Page 29: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

1.5 Text continued..1.5 Text continued..

The location of text is ctrlled by The location of text is ctrlled by specification of its origin/Anchor pointspecification of its origin/Anchor point

Text primitive’s appearance is determined Text primitive’s appearance is determined by only 2 attributes (color and font)by only 2 attributes (color and font)

void SRGP_setFont(int valueIndex)void SRGP_setFont(int valueIndex) Each character in the font is defined as Each character in the font is defined as

rectangular bitmap.rectangular bitmap. SRGP draws a character by filling a SRGP draws a character by filling a

rectangle using character bitmap as rectangle using character bitmap as pattern in transparent mode.pattern in transparent mode.

Page 30: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Formatting textFormatting text

Void SRGP_inquireTextExtent(Char*text, int Void SRGP_inquireTextExtent(Char*text, int *width, int * height, int *descent);*width, int * height, int *descent);

Page 31: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Code for formatting textCode for formatting text

Page 32: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.Basic Interaction Handling2.Basic Interaction Handling

Topics to be discussedTopics to be discussed Human FactorsHuman Factors Logical Input DevicesLogical Input Devices Sampling versus Event driven ProcessingSampling versus Event driven Processing Sample modeSample mode Event modeEvent mode Pick correlation for Interaction HandlingPick correlation for Interaction Handling Setting Device Measure and AttributesSetting Device Measure and Attributes

Page 33: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.1 Human Factors2.1 Human Factors

Interaction style(look and feel)Interaction style(look and feel) Ease of learning and useEase of learning and use Guidelines for user computer interactionGuidelines for user computer interaction

1.1. Provide simple and Consistent interaction Provide simple and Consistent interaction sequencesequence

2.2. Do not overload the user with too many Do not overload the user with too many different optionsdifferent options

3.3. Show the available options clearlyShow the available options clearly4.4. Give appropriate feedbackGive appropriate feedback5.5. Allow the user ti recover gracefully from Allow the user ti recover gracefully from

mistakes.mistakes.

Page 34: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.2 Logical Input Devices2.2 Logical Input Devices

Device types in SRGPDevice types in SRGP 2 logical input devices supported by SRGP2 logical input devices supported by SRGP a) Locatora) Locator b) Keyboardb) Keyboard• SRGP maps the logical devices to physical SRGP maps the logical devices to physical

devices(eg locator to mouse, joystick, devices(eg locator to mouse, joystick, tablet….)tablet….)

• SRGP provides only one logical locator and SRGP provides only one logical locator and one keyboard deviceone keyboard device

Page 35: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3 Sampling versus Event driven 2.3 Sampling versus Event driven ProcessingProcessing

2 techniques to receive info created by User 2 techniques to receive info created by User InteractionsInteractions

• Sampling(Polling)Sampling(Polling)• Interrupt/Event drivenInterrupt/Event driven• SamplingSampling• AP queries the current value(AP queries the current value(measuremeasure) of ) of

logical device and continues exe.logical device and continues exe.• By continuous sampling the change in the By continuous sampling the change in the

device state is known to application.device state is known to application.• DemeritDemerit costly bcoz most of the CPU cycles costly bcoz most of the CPU cycles

waiting for measure change.waiting for measure change.

Page 36: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3 Interrupt/ Event driven2.3 Interrupt/ Event driven

Application enable 1 or more device and Application enable 1 or more device and continue exe until interrupt by some i/p continue exe until interrupt by some i/p event(asynchronous ctrl transfer)event(asynchronous ctrl transfer)

For each i/p event trigger is defined.For each i/p event trigger is defined. SRGP offers SRGP offers synchronoussynchronous event driven event driven

mechanismmechanism– Application enable devices & continue exe…In Application enable devices & continue exe…In

background the package monitors the devices background the package monitors the devices and stores info in the event queue.and stores info in the event queue.

– Appln checks the queue at its convenience Appln checks the queue at its convenience and process the events.and process the events.

Page 37: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3 interrupt / Event driven2.3 interrupt / Event driven

Queue contains one or more event ,wait Queue contains one or more event ,wait state is desired.state is desired.

Queue is empty, wait state not desiredQueue is empty, wait state not desired Queue is empty, and wait state is desiredQueue is empty, and wait state is desired Difference b/w sampling and Event drivenDifference b/w sampling and Event driven SamplingSampling event measure is collected regardless of event measure is collected regardless of

any user activity, not efficient as cpu time is wasted any user activity, not efficient as cpu time is wasted for sampling loops.for sampling loops.

EventEvent Respond only when the user acts. More Respond only when the user acts. More efficient using wait queue.efficient using wait queue.

Page 38: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Sampling vs event drivenSampling vs event driven

Think timeThink time

Page 39: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.4 Sample mode2.4 Sample mode

Activate,deactivate and seting modeActivate,deactivate and seting mode of a deviceof a device Void SRGP_setInputMode(Void SRGP_setInputMode(InputDeviceInputDevice

LOCATOR/KEYBOARD, LOCATOR/KEYBOARD, inputMode inputMode INACTIVE/SAMPLE/EVENT)INACTIVE/SAMPLE/EVENT)

Locators measure Locators measure no of buttons that most no of buttons that most recently experienced a transition recently experienced a transition

By default keyboard is operated in event mode.By default keyboard is operated in event mode.

Page 40: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.5 Event Mode2.5 Event Mode

SRGP_wait eventSRGP_wait event inputDevice SRGP_waitEvent(int maxWaitTime)inputDevice SRGP_waitEvent(int maxWaitTime)

The fn returns immediately if queue The fn returns immediately if queue is empty. is empty.

Negative maxtime(INDEFINITE)Negative maxtime(INDEFINITE) The function returns the identity of The function returns the identity of

the devicethe device

Page 41: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Event mode-KeyboardEvent mode-Keyboard

Trigger event of keyboard based on Trigger event of keyboard based on processing modeprocessing mode

1. EDIT mode->return key1. EDIT mode->return key 2. RAW mode->every key2. RAW mode->every key void SRGP_setKeyboardProcessingMode void SRGP_setKeyboardProcessingMode

((keyboardModekeyboardMode EDIT/RAW) EDIT/RAW)

Measure in RAW mode is one character Measure in RAW mode is one character length and in edit mode the measure is length and in edit mode the measure is the string appears at the time of triggerthe string appears at the time of trigger

Page 42: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Event mode-locatorEvent mode-locator

Trigger event is press or release of a Trigger event is press or release of a mouse button.mouse button.

Application tells SRGP which buttons are Application tells SRGP which buttons are trigger a locator bytrigger a locator by

void SRGP_setLocatorButtonMask(ivoid SRGP_setLocatorButtonMask(intnt active buttons) active buttons)

Values of button mask are Values of button mask are LEFT_BUTTON_MASK, LEFT_BUTTON_MASK, MIDDLE_BUTTON_MASK & MIDDLE_BUTTON_MASK & RIGHT_BUTTON_MASKRIGHT_BUTTON_MASK

Page 43: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.6 pick correlation for interaction 2.6 pick correlation for interaction HandlingHandling

Screen is divided into regions.Screen is divided into regions. User presses the locator button the User presses the locator button the

application determine exactly what application determine exactly what screen button,icon or other object is screen button,icon or other object is selected and respond. (detemination selected and respond. (detemination is called pick correlation)is called pick correlation)

GEOM_ptInRect ( ) is a boolean fn GEOM_ptInRect ( ) is a boolean fn

Page 44: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.6 High level interaction scheme 2.6 High level interaction scheme for menu handlingfor menu handling

Page 45: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.7 Setting Device measure and 2.7 Setting Device measure and AttributesAttributes

Attributes can be set @ any time, whether Attributes can be set @ any time, whether or nor the device is active.or nor the device is active.

Unlike attributes the measure is reset to a Unlike attributes the measure is reset to a default value when the device is default value when the device is deactivated. deactivated.

1.Locator echo attributes1.Locator echo attributes ( (DEFAULT is DEFAULT is cursor)cursor)

void SRGP-setLocatorEchoType( void SRGP-setLocatorEchoType( echoTypeechoType NO_ECHO/CURSOR/RUBBERLINE/RUBBERRENO_ECHO/CURSOR/RUBBERLINE/RUBBERRECT)CT)

2 .Locator measure control2 .Locator measure control (default position (default position is center)is center)

Page 46: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.7 Setting Device measure and 2.7 Setting Device measure and AttributesAttributes

3.Keyboard attributes and measure 3.Keyboard attributes and measure controlcontrol

No screen position for keyboard so the No screen position for keyboard so the position is thus an attribute of keyboard is position is thus an attribute of keyboard is set viaset via

void SRGP_setKeyboardEchoOrigin(point origin)void SRGP_setKeyboardEchoOrigin(point origin) Default measure for keyboard is Default measure for keyboard is

automatically reset to null string. The automatically reset to null string. The keyboard measure is set viakeyboard measure is set via

void SRGP_setKeyboardMeasure(char void SRGP_setKeyboardMeasure(char *measure)*measure)

Page 47: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

Raster Graphics FeaturesRaster Graphics Features

CanvasesCanvases Clipping RectanglesClipping Rectangles SRGP_copypixel operationSRGP_copypixel operation Write mode or RasterOpWrite mode or RasterOp

Page 48: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.1 Canvas2.3.1 Canvas canvascanvas

– An area of memory which is used as a buffer between An area of memory which is used as a buffer between graphics software and graphics hardware. graphics software and graphics hardware.

SRGP canvas is a data structure that stores an image as a SRGP canvas is a data structure that stores an image as a 2D array of pixels with some ctrl info(size and attributes of 2D array of pixels with some ctrl info(size and attributes of image)image)

Move Offscreen canvas to screen canvas to made visible Move Offscreen canvas to screen canvas to made visible using SRGP_copyPixel().using SRGP_copyPixel().

Properties (associated pixmap,coordinate system and Properties (associated pixmap,coordinate system and attribute group) of canvas are called attribute group) of canvas are called state/contextstate/context of of canvas.canvas.

New offscreen canvas can be created byNew offscreen canvas can be created by int SRGP_createCanvas(int width, int height);int SRGP_createCanvas(int width, int height);

Once canvas is created its size cannot be changedOnce canvas is created its size cannot be changed

Page 49: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.1 Canvas2.3.1 Canvas Void SRGP_useCanvas(int canvasID)Void SRGP_useCanvas(int canvasID) Void SRGP_deleteCanvas(int Void SRGP_deleteCanvas(int

canvasID)canvasID)

Page 50: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.2 clipping Rectangles2.3.2 clipping Rectangles

Clipping- The restriction of rendering Clipping- The restriction of rendering to a designated area. to a designated area.

Clip rectangle attribute can be Clip rectangle attribute can be changed at any time and its most changed at any time and its most recent settings is stored.recent settings is stored.

void SRGP_setClipRectangle(rectangle clipRect)void SRGP_setClipRectangle(rectangle clipRect) rectangle SRGP_inquireClipRectangle();rectangle SRGP_inquireClipRectangle();

Eg Ms wordEg Ms word

Page 51: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.3 SRGP_copyPixel operation2.3.3 SRGP_copyPixel operation

Often called bitBlt (bit block transfer) / Often called bitBlt (bit block transfer) / PixBltPixBlt

This command is used to copy an array of This command is used to copy an array of pixels from a rectangular region of a pixels from a rectangular region of a canvas(source region) to current active canvas(source region) to current active canvas(destination region)canvas(destination region)

void SRGP_copyPixel(int void SRGP_copyPixel(int sourceCanvasID, rectangle sourceRect, sourceCanvasID, rectangle sourceRect, point destCorner)point destCorner)

Page 52: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.4 Write Mode or RasterOp2.3.4 Write Mode or RasterOp

CopyPixel can also execute logical CopyPixel can also execute logical operation. It can be symbolized asoperation. It can be symbolized as

DD S S oop Dp D Op is called RasterOp /Write Mode consists Op is called RasterOp /Write Mode consists

of 16 Boolean operators.of 16 Boolean operators. Eg replace, or, xor , andEg replace, or, xor , and void SRGP_setWriteMode(writeMode void SRGP_setWriteMode(writeMode

WRITE_REPLACE/WRITE_XOR/WRITE_OR/WWRITE_REPLACE/WRITE_XOR/WRITE_OR/WRITE_AND);RITE_AND);

RasterOps are performed on pixels values.RasterOps are performed on pixels values.

Page 53: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.3.4 WriteMode continue..2.3.4 WriteMode continue..

Replace mode can be used to erase.Replace mode can be used to erase.

Page 54: Programming in SRGP. INTRO Advantages of Raster Displays Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more

2.4 Limitations of SRGP2.4 Limitations of SRGP No support for displaying 3D No support for displaying 3D

geometry applications.geometry applications. Integer coordinate system of SRGP is Integer coordinate system of SRGP is

too inflexible for appln require too inflexible for appln require greater precision, range.greater precision, range.

It stores images in canvas as a It stores images in canvas as a matrix of unconnected pixels rather matrix of unconnected pixels rather than primitives so doesnot support than primitives so doesnot support delete, move or change.delete, move or change.

As it doesnot keeps record of actions, As it doesnot keeps record of actions, refresh a screen or re-scan convert to refresh a screen or re-scan convert to display on device with diff resolution.display on device with diff resolution.