eleven - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

eleven

Description:

But not like draw programs or the pictures we've been making so far. Has a prespecified ... It allows you to explicitly retrieve (or change) the color at ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 11
Provided by: ianhor
Category:
Tags: cat | draw | eleven | how | to

less

Transcript and Presenter's Notes

Title: eleven


1
eleven
  • colors and rasters

2
Color objects
  • Meta represents colors with color objects
  • You can create a color by saying color
    r g b
  • r amount of red (0-255)
  • g amount of green (0-255)
  • b amount of blue (0-255)
  • red c, green c, blue creturn the amount of
    red, green or blue in the color c

3
Rasters (a.k.a. bitmaps)
  • A bitmap is a specific kind of data object that
    represents an image
  • E.g. JPEG files, GIF files, paint files
  • But not like draw programs or the pictures weve
    been making so far
  • Has a prespecified width and height (in pixels)
  • It allows you to explicitly retrieve (or change)
    the color at each pixel

4
Bitmap procedures
  • new Bitmap string
  • Reads in the the jpeg or gif file with name
    string
  • Converts it to internal bitmap format and returns
    it
  • height bitmap, width bitmap
  • Returns the width/height of a bitmap, in pixels
  • pixel bitmap x y
  • Returns the specified pixel of the bitmap
  • bitmap-from-procedure procedure width height
  • Makes a bitmap of size widthheight
  • Repeatedly calls procedure with the x and y
    coordinates of each pixel to get the color of the
    pixel

5
Example
? bitmap-from-procedure x y ? color x
x x 256 256 ?
  • The procedurex y ? color x x x
  • Returns a color with equal amounts of red, green,
    and blue light
  • So its grey
  • Its brightness varies with its horizontal
    position

6
Example 2
? bitmap-from-procedure x y ? color x
0 y 256 256 ?
  • The procedurex y ? color x 0 y
  • Changes red and blue independently
  • So hue varies over space

7
Example 3
? define sine-wave n ? 128
127 sin
/ n 20 ltProcedure sine-wavegt ?
bitmap-from-procedure x y ?
color 0 sine-wave x
sine-wave y 256
256
8
Bitmap procedures
  • map-bitmap procedure bitmap
  • Makes a new bitmap of the same size as bitmap
  • Calls procedure with each pixel of bitmap
  • Procedure returns the color of the respective
    pixel for the new bitmap
  • Returns the new bitmap

9
Extracting color components of an image
  • define cones
  • new Bitmap c/documents and settings/ian/my
    documents/cones.jpg

10
Extracting color components of an image
  • define gray i ? color i i i
  • ltProcedure graygt
  • map-bitmap c ? gray
    red c cones
  • map-bitmap c ? gray green c
    cones

Note the gray procedure is already built in
Write a Comment
User Comments (0)
About PowerShow.com