Programming in SRGP.

Slides:



Advertisements
Similar presentations
Chapter 4 Transforming and Distorting Objects. Objectives Transform objects Offset and outline paths Create compound paths Work with the Pathfinder panel.
Advertisements

RAPTOR Syntax and Semantics By Lt Col Schorsch
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
The GIMP Simple features tutorial By Mary A White.
Graphics Pipeline.
Chapter 3 Drawing and Composing an Illustration. Objectives Draw straight lines Draw curved lines Draw elements of an illustration Apply attributes to.
Adobe ImageReady 3 Foundation Level Course. What is ImageReady? ImageReady is a graphics program that offers several tools tailored to efficiently prepare.
© 2001 By Default! A Free sample background from Slide 1 Attributes of Output Primitives Definition Parameter that affects.
Lecture 2Slide 1 Event Driven Computing Basic Interaction Handling –Interactive programs - must pay attention to the user interface.
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
1 Model View Controller. 2 Outline Review Definitions of MVC Why do we need it? Administiriva Changing the display Event flow Dragging at interactive.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Based on slides created by Edward Angel
DIGITAL GRAPHICS & ANIMATION
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
COMPUTER GRAPHICS Prepared by S.MAHALAKSHMI Asst. Prof(Sr) / SCSE VIT University.
CGMB214: Introduction to Computer Graphics
Dr. S.M. Malaek Assistant: M. Younesi
Interactive Input Methods & Graphical User Input
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
 Starting Excel 2003  Using Help  Workbook Management  Cursor Management  Manipulating Data  Using Formulae and Functions  Formatting Spreadsheet.
Keyboarding Vocabulary Key Computer Terms. Click To rapidly press and release the mouse button To rapidly press and release the mouse button.
CGMB214: Introduction to Computer Graphics
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Input and Interaction Lecture No. 4.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
Computer Graphics I, Fall 2010 Input and Interaction.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
1 Introduction Line attribute Color and gray scale Area filled attribute Anti-aliasing.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
Introduction to Interactive Media Interactive Media Components: Text.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
Chapter 6 Working with Patterns and Brushes. Objectives Use the Move command Create a pattern Design a repeating pattern Use the Pattern Options panel.
Laboratory Exercise # 9 – Inserting Graphics to Documents Office Productivity Tools 1 Laboratory Exercise # 9 Inserting Graphics to Documents Objectives:
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Basic Editing Lesson 2.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Chapter 11: Block References and Attributes. After completing this Chapter, you will be able to use the following features: Create and insert block references.
Tkinter Canvas.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
© 2011 Delmar, Cengage Learning Chapter 6 Working with Patterns and Brushes.
Programming in the Simple Raster Graphics Package (SRGP) Chapter 2.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Chapter 8: Plotting. After completing this Chapter, you will be able to use the following features: Planning the Plot Sheet Plotting Environments Plotting.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Fall UI Design and Implementation1 Lecture 6: Output.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
Adobe Photoshop T.Ahlam Algharasi. Adobe Photoshop Adobe Photoshop is a seriously powerful photo and image edit ( treating and manipulation, compositing,
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
MS WORD INFORMATION TECHNOLOGY MANAGEMENT SERVICE Training & Research Division.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
ATTRIBUTE OF OUTPUT PRIMITIVES. Attribute of Output Primitives 30/9/2008 A.Aruna/Assistant professor/IT/SNSCE 2 Definition Line Attribute Curve Attribute.
Chapter 7 Vector Editing © 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website,
Introduction To GDI GDI Definition : It is a interface present in windows which provide function and related structures that an application can use to.
Photoshop CS6 – Nelson Unit 3: Photoshop CS6. Objectives Define photo editing software Start Photoshop and view the workspace Use the Zoom tool and the.
Getting Started with Adobe Photoshop CS6
Flash Interface, Commands and Functions
Chapter 7 Vector Editing
Otasuke GP-EX! Chapter 1 Menu Screen.
Topics Graphical User Interfaces Using the tkinter Module
Presentation transcript:

Programming in SRGP

INTRO Advantages of Raster Displays Fill areas with uniform color or repeated pattern with 2 or more colors. Stores images which allows manipulation @ fine level : individual pixels can be read or written and arbitrary portions can be copied or moved.

SRGP(Simple Raster Graphics Package) Device independent Graphics package Similar to Macintosh QuickDraw Raster package and Xlib package of Windows system

SRGP (Continued..) Drawing with SRGP Basic Interaction Handling Raster Graphics Features Limitations of SRGP

1.Drawing with SRGP 1.1 Specification of Graphics Primitives 1.2 Attributes 1.3 Filled primitives and attributes 1.4 Saving and Restoring Attributes 1.5Text

1.1 Specification of Graphics Primitives Drawing in integer graphics package such as SRGP is like plotting graphs on graph paper with very fine grid Grid varies from 80-120 points per inch to 300 or more on high resolution displays (0,0)--> bottom left of the screen . +ve x increases towards right and +ve Y increases towards top

1.1 continued... SRGP supports basic collections of primitives Lines Polygons Circles Ellipses Text

Lines and Poly lines Void SRGP_lineCoord(int x1, int y1, int x2, int y2); eg: SRGP_lineCoord(0,0,100,300) (or) void SRGP_line(point pt1,point pt2); Point is a defined type, a record holding 2 integer x,y values typedef struct {int x,y; }point;

Lines and Poly lines A sequence of lines connecting successive vertices is called polyline. There are 2 polyline procedures. These take array as parameter. Void SRGP_polyLineCoord (int vertexcount, int*xArray, int*yArray); Void SRGP_polyLine(int vertexcount, point *vertices);

continued.. /* plot the axes*/ SRGP_lineCoord(175,200,320,200); /*plot the data*/ SRGP_polyLineCoord (12 ,months, balanceOfTrade); SRGP_polyLine(7, bowtieArray);

contiued.. Markers and polymarkers It is convenient to place markers(dots,asterisks or circles) at the data points on graphs. Void SRGP_markerCoord(intx,inty); Void SRGP_marker(point pt) Void SRGP_polyMarkerCoord (int vertexcount, int*xArray, int*yArray); Void SRGP_polyMarker(int vertexcount, point *vertices);

continued... Polygons and Rectangles --> To draw an outline polygon, we can either specify a polyline on itself by making the first and last vertices identical (or) we can use void SRGP_polygon(int vertexCount, point *vertices) Now bowtieArray is of only 6 points it automatically closes the figure.

Continued Any rectangle can be specified as a polygon having 4 vertices. Uses only 2 primitives(lower left & upper right) Void SRGP_rectangleCoord(int leftx, intbottomY,int rightX, int topY); Void SRGP_rectanglePt(point bottomLeft, point topRight); void SRGP_rectangle(rectangle rect); typedef struct{ point bottomLeft,topRight; }rectangle;

Rectangles continued.. Point SRGP_defPoint(intx,int y); Rectangle SRGP_defRectangle(int leftX,int bottomY,int rightX, int topY);

Circles and Ellipses Circles are Special types of ellipses. The term ellipse arc used for circular,elliptical,closed or partial arcs. It is easy to specify arcs via upright rectangles (bounding boxes or extents) Void SRGP_ellipseArc(rectangle extentRect, float startAngle, float endAngle);

Circles and ellipses Relationship between rectangular and circular angle is Rectangular angle=arctan(tan(circularangle).width/height)+ adjust where the angles are in radians and adjust = 0, for 0<= circular angle<∏/2 adjust = ∏/2 , for ∏/2 <=circular angle < 3∏/2 adjust = 2∏, for 3∏/2<= circular angle < 2∏

1.2 Attributes The specification of a primitive can be controlled by specification of its attributes Line style and Line width Color Penstyle Attributes are global state variables that retain their values until they are changed explicitly Void SRGP_setLineStyle(lineStyle CONTINUOUS / DASHED /DOTTED/….); Void SRGP_setLineWidth(int widthValue);

Attributes.. Each attribute has a default.. Eg., default for linestyle is CONTINUOUS that for line width is 1. Line style can be represented as bit mask and it is scan converted by SRGP. For eg.. Contimuous all 1’s DASHED 1111001111001111…..

Attributes for marker primitive Void SRGP_setMarkerSize(int sizeValue); Void SRGP_setMarkerStyle(markerStyle MARKER_CIRCLE / MARKER_SQUARE/…); The default is circle style COLOR bilevel system the color value is 0 and 1. -1 black, 0 white for black on white devices 1 green, 0 black for green on black devices

Attribute-color The integer color attribute is an index to SRGP;s color table. Each entry defines color or gray scale value. There are 2d entries and d is the depth of frame buffer 2 methods to specify colors 1. use integers 0 and 1 directly 2. use color names supported by SRGP We can also select color by calling Void SRGP_setColor(int colorIndex)

1.3 Filled Primitives and Their Attributes Primitives can be drawn in 2 ways Outline Filled SRGP’s filled versions of area defining primitives draw the interior pixels with no outline

Code for creating filled Primitives

Output for the previous code

Odd Parity rule We need a rule for specifying which regions are interior, and thus should be filled and which is exterior This can done in SRGP through odd parity rule. To check whether the region lies inside/ outside Choose a test point Choose a ray that starts at the test point extends indefinitely in any direction and does not pass any vertices. If this ray intersect the polygon outline an odd no of times ->interior else exterior

Fill style and fill pattern for areas 4 ways Void SRGP_setFillStyle(drawStyle SOLID/ BITMAP_PATTERN_OPAQUE / BITMAP_PATTERN_TRANSPARENT/ PIXMAP_PATTERN); There is no distinction in opaque & transparent in pix map patterns

Application screen background Background color  0 bits in bitmap patterns used in opaque mode. Suppose user expects the uniform screen background pattern then the application should set up the background in desired pattern. Default solid color 0 Erase primitive  is done by redraw them in the application background pattern.(Quick & dirty technique). This yield damaged image if primitives overlaps. Damage repair is done by respecifying primitives in application data

1.4 Saving and restoring Attributes Attributes can be saved for later restoration. It does not affect the global attribute state. SRGP does this attribute group via void SRGP_inquireAttributes(attributeGroup * group); void SRGP_setAttributes(attributeGroup * group);

1.5 Text Specifying and implementing text drawing is always complex in graphics package. (style,font,bold,italic,width,spacing) In SRGP text is horizontally aligned and character widths vary, but space b/w characters is constant. High quality documents need specialized packages that offer more ctrl. Eg. Post script Text in SRGP is generated by void SRGP_text(point origin, char *text);

1.5 Text continued.. The location of text is ctrlled by specification of its origin/Anchor point Text primitive’s appearance is determined by only 2 attributes (color and font) void SRGP_setFont(int valueIndex) Each character in the font is defined as rectangular bitmap. SRGP draws a character by filling a rectangle using character bitmap as pattern in transparent mode.

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

Code for formatting text

2.Basic Interaction Handling Topics to be discussed Human Factors Logical Input Devices Sampling versus Event driven Processing Sample mode Event mode Pick correlation for Interaction Handling Setting Device Measure and Attributes

2.1 Human Factors Interaction style(look and feel) Ease of learning and use Guidelines for user computer interaction Provide simple and Consistent interaction sequence Do not overload the user with too many different options Show the available options clearly Give appropriate feedback Allow the user ti recover gracefully from mistakes. 1.Menus and palettes satisfy first 3 guidelines 2.Feedback occurs @ every step by highlight the menu choice/echo eg. Text appears immediately in the cursor position as keyboard input is typed or movement of cursor appears when we move mouse position. 3.Graceful recovery is provided with cancel and undo/redo features

2.2 Logical Input Devices Device types in SRGP 2 logical input devices supported by SRGP a) Locator b) Keyboard SRGP maps the logical devices to physical devices(eg locator to mouse, joystick, tablet….) SRGP provides only one logical locator and one keyboard device

2.3 Sampling versus Event driven Processing 2 techniques to receive info created by User Interactions Sampling(Polling) Interrupt/Event driven Sampling AP queries the current value(measure) of logical device and continues exe. By continuous sampling the change in the device state is known to application. Demerit costly bcoz most of the CPU cycles waiting for measure change.

2.3 Interrupt/ Event driven Application enable 1 or more device and continue exe until interrupt by some i/p event(asynchronous ctrl transfer) For each i/p event trigger is defined. SRGP offers synchronous event driven mechanism Application enable devices & continue exe…In background the package monitors the devices and stores info in the event queue. Appln checks the queue at its convenience and process the events. Event trigger user action that causes an event to occur. Eg button push , mouse click

2.3 interrupt / Event driven Queue contains one or more event ,wait state is desired. Queue is empty, wait state not desired Queue is empty, and wait state is desired Difference b/w sampling and Event driven Sampling event measure is collected regardless of any user activity, not efficient as cpu time is wasted for sampling loops. Event Respond only when the user acts. More efficient using wait queue.

Sampling vs event driven Think time

2.4 Sample mode Activate,deactivate and seting mode of a device Void SRGP_setInputMode(InputDevice LOCATOR/KEYBOARD, inputMode INACTIVE/SAMPLE/EVENT) Locators measure  no of buttons that most recently experienced a transition By default keyboard is operated in event mode.

2.5 Event Mode SRGP_wait event inputDevice SRGP_waitEvent(int maxWaitTime) The fn returns immediately if queue is empty. Negative maxtime(INDEFINITE) The function returns the identity of the device

Event mode-Keyboard Trigger event of keyboard based on processing mode 1. EDIT mode->return key 2. RAW mode->every key void SRGP_setKeyboardProcessingMode (keyboardMode EDIT/RAW) Measure in RAW mode is one character length and in edit mode the measure is the string appears at the time of trigger

Event mode-locator Trigger event is press or release of a mouse button. Application tells SRGP which buttons are trigger a locator by void SRGP_setLocatorButtonMask(int active buttons) Values of button mask are LEFT_BUTTON_MASK, MIDDLE_BUTTON_MASK & RIGHT_BUTTON_MASK

2.6 pick correlation for interaction Handling Screen is divided into regions. User presses the locator button the application determine exactly what screen button,icon or other object is selected and respond. (detemination is called pick correlation) GEOM_ptInRect ( ) is a boolean fn

2.6 High level interaction scheme for menu handling

2.7 Setting Device measure and Attributes Attributes can be set @ any time, whether or nor the device is active. Unlike attributes the measure is reset to a default value when the device is deactivated. 1.Locator echo attributes (DEFAULT is cursor) void SRGP-setLocatorEchoType( echoType NO_ECHO/CURSOR/RUBBERLINE/RUBBERRECT) 2 .Locator measure control (default position is center)

2.7 Setting Device measure and Attributes 3.Keyboard attributes and measure control No screen position for keyboard so the position is thus an attribute of keyboard is set via void SRGP_setKeyboardEchoOrigin(point origin) Default measure for keyboard is automatically reset to null string. The keyboard measure is set via void SRGP_setKeyboardMeasure(char *measure)

Raster Graphics Features Canvases Clipping Rectangles SRGP_copypixel operation Write mode or RasterOp

2.3.1 Canvas canvas An area of memory which is used as a buffer between graphics software and graphics hardware. SRGP canvas is a data structure that stores an image as a 2D array of pixels with some ctrl info(size and attributes of image) Move Offscreen canvas to screen canvas to made visible using SRGP_copyPixel(). Properties (associated pixmap,coordinate system and attribute group) of canvas are called state/context of canvas. New offscreen canvas can be created by int SRGP_createCanvas(int width, int height); Once canvas is created its size cannot be changed

2.3.1 Canvas Void SRGP_useCanvas(int canvasID) Void SRGP_deleteCanvas(int canvasID)

2.3.2 clipping Rectangles Clipping- The restriction of rendering to a designated area. Clip rectangle attribute can be changed at any time and its most recent settings is stored. void SRGP_setClipRectangle(rectangle clipRect) rectangle SRGP_inquireClipRectangle(); Eg Ms word

2.3.3 SRGP_copyPixel operation Often called bitBlt (bit block transfer) / PixBlt This command is used to copy an array of pixels from a rectangular region of a canvas(source region) to current active canvas(destination region) void SRGP_copyPixel(int sourceCanvasID, rectangle sourceRect, point destCorner)

2.3.4 Write Mode or RasterOp CopyPixel can also execute logical operation. It can be symbolized as D S op D Op is called RasterOp /Write Mode consists of 16 Boolean operators. Eg replace, or, xor , and void SRGP_setWriteMode(writeMode WRITE_REPLACE/WRITE_XOR/WRITE_OR/WRITE_AND); RasterOps are performed on pixels values.

2.3.4 WriteMode continue.. Replace mode can be used to erase.

2.4 Limitations of SRGP No support for displaying 3D geometry applications. Integer coordinate system of SRGP is too inflexible for appln require greater precision, range. It stores images in canvas as a matrix of unconnected pixels rather than primitives so doesnot support delete, move or change. As it doesnot keeps record of actions, refresh a screen or re-scan convert to display on device with diff resolution.