Toolkit Details: Output - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Toolkit Details: Output

Description:

Clipping. 5/1/2002. 8. Describe image as strokes (w/ color/thickness) ... Clipping ? Limit drawing to particular area of screen. Why? for performance ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 28
Provided by: james937
Category:

less

Transcript and Presenter's Notes

Title: Toolkit Details: Output


1
Toolkit Details Output
  • CS 160, Spring 2002
  • Professor James Landay
  • May 1, 2002

2
Hall of Fame or Shame?
  • eToys.com
  • example courtesy of Tiffany Chan

3
Hall of Fame!
  • Positives
  • clear navigation w/ top tabs recs. on left
  • inverse pyramid style
  • clear value prop.
  • simple name URL
  • privacy policy
  • Negatives
  • non-links in blue

4
Toolkit Details Output
  • CS 160, Spring 2002
  • Professor James Landay
  • May 1, 2002

5
Outline
  • Review of MVC
  • Models for images
  • Coordinate systems
  • Administrivia
  • Drawing
  • Clipping
  • Color models

6
Review
  • The three parts of MVC are
  • model, which is?
  • underlying information that application is
    manipulating
  • view, which is?
  • visual display of the model information
  • controller, which does?
  • handles interaction with the user decides what
    to do
  • Which two pieces are often combined?
  • view controller they always occur in pairs
    anyways
  • MVC partitions an application so that it is
  • scalable may have multiple views for a single
    model
  • maintainable add or change views later

7
2-d Computer Graphics
  • Models for images
  • strokes, pixels, regions
  • Coordinate systems
  • device, physical
  • Canvas
  • Drawing
  • paths, shapes, text
  • Clipping

8
Stroke Model
  • Describe image as strokes (w/ color/thickness)
  • Line ((10, 4), (17,4), thick 2, red)
  • Circle (( 19, 13), radius 3, thick 3, white)
  • Maps to early vector displays plotters
  • Most UI toolkits have stroked objects
  • arcs, ellipses, rounded rectangles, etc.

9
Problems with Stroke Model?
  • How would you represent with strokes?
  • Solution?

10
Pixel Model
  • Break-up complex images into discrete pixels
    store color for each
  • Resolution
  • spatial number of rows by columns
  • e.g., 1600 x 1200 is a good monitor display
  • quality laser printer 6000 x 4800
  • image depth (i.e., number of bits per pixel)
  • several styles... what are they????

11
Image Depth
  • Bit map - 1 bit/pixel (on/off)
  • BW screens or print-outs

12
Image Depth (cont.)
  • Gray scale - 2-8 bits/pixel
  • group pixels (some on, some off)
  • Full color - 24 bits/pixel
  • 8 bits per primary color (Red, Green, Blue)
  • potential problem?
  • space becomes a problem for high-res. images
  • Color mapped - 8 bits/pixel
  • store index _at_ pixel - map into table w/ 24 bits
  • cuts space computation
  • problem????
  • only 256 colors on screen at a time

13
Aliasing ?
  • Smooth objects (e.g., lines) appear jagged since
    resolution is too low
  • Solution?
  • antialiasing - fill-in some jagged places w/ gray
    scale or primary colors

14
Region Model
  • Use the stroke model to outline region
  • Fill the region with
  • colors blendings (i.e., patterns)
  • Advantages??
  • allows representation of filled shapes w/
  • little memory
  • independence from display resolution
  • Text represented this way converted to bitmaps
    inside of the printer

15
Outline Fonts
  • Used by both Postscript TrueType

16
Coordinate Systems
  • Device coordinates
  • coordinates of the display device
  • origin usually at upper left
  • Window coordinates
  • toolkit presents window as an abstraction
  • virtual display with frame around it (title,
    etc.)
  • programs coordinates placed in window as if
    frame doesnt exist
  • like device coords, always expressed in pixels
  • caveat mouse events may be in device coords -
    check

17
Coordinate Systems (cont.)
  • Physical coordinates
  • pixel-based coords dont deal well w/ devices of
    different resolutions (e.g., monitor vs. printer)
  • specify coordinates in physical units (e.g.,
    inches, centimeters, or printer points)
  • Model coordinates
  • coordinate system relative to drawn objects
  • often need to convert from model to
    physical/window coordinates back

18
Administrivia
  • Pilot user study write-ups due
  • Handout final prototype assignment today
  • slides code frozen on Wed. 5/8
  • write-up due on Mon. 5/13

19
Canvas
  • Abstraction for the drawing surface
  • most toolkits support one
  • Defines methods used for drawing
  • Each instance has a height, width, defines its
    physical units
  • Advantage use the same method interface for
  • windows
  • image in memory
  • printed output
  • Called Graphical Device Interface (GDI) by MS

20
Drawing
  • Could specify with
  • void CanvasRectangle (x1, y1, x2, y2,
    lineWidth, lineColor, fillColor)
  • Problem?
  • lots of parameters!
  • Solution
  • shapes have properties in common
  • geometry, line/border width, line/fill color,
    pattern
  • Use current settings of canvas
  • void CanvasRectangle (x1, y1, x2, y2)
  • void CanvasSetLineWidth (lw)
  • void CanvasGetLineWidth ()

21
Text Font Selection
  • Font family
  • Garamond, Arial, Modern, Times Roman, Courier
  • defines the general shape of the characters
  • some are mono-spaced (i gets same space as G)
  • serif (e.g., Times) vs. sans serif (e.g., Arial)
  • Style
  • normal, bold, italic, bold italic
  • Size
  • in points (1 point 1/72 inch)

22
Text (cont.)
  • Usually simple to draw
  • Canvas Cnv
  • Cnv.SetFont (Times, Bold, 10)
  • Cnv.Text (10, 20, This is the text)
  • Outline vs. Bitmapped fonts
  • need pixels to draw on screen so may store as BM
  • problems takes lots of space if font is in
    several sizes
  • instead store as a closed shape (e.g., outline
    only)
  • easy to scale to any size convert to bitmap

23
Clipping ?
  • Limit drawing to particular area of screen
  • Why?
  • for performance
  • Commonly clip to rectilinear regions
  • Why?
  • can be done very quickly

24
Color Models
  • 256 levels for each primary adequate
  • -gt 24 bits / pixel
  • RGB model
  • specify color by red, green, blue components
  • HSV model - hue, saturation, value
  • hue is primary wavelength (i.e., basic color)
  • saturation is a measure of how pure light is
  • high is pure, low means it is mixed w/ white/gray
  • value is intensity (dark vs. light)

25
Color Models (cont.)
  • HSV is easier for people to use. Why?
  • uses peoples intuition of what color is
  • there is a direct conversion to RGB
  • CMY model
  • in terms of mixtures of pigments
  • pigment gets color from light it absorbs
    doesnt reflect
  • mix Cyan, Magenta, Yellow
  • subtractive primaries
  • used by printers artists

26
Summary
  • Basic 2-d computer graphics
  • models for images
  • strokes, pixels, aliasing, regions
  • coordinate systems
  • device, window, physical, model
  • drawing
  • canvas paths, shapes, text
  • clipping
  • Color models
  • RGB, HSV, CMY

27
Next Time
  • Input communications
  • read Olsen chapter
Write a Comment
User Comments (0)
About PowerShow.com