Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eleven colors and rasters. 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)

Similar presentations


Presentation on theme: "Eleven colors and rasters. 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)"— Presentation transcript:

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 c] return the amount of red, green or blue in the color c

3 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 we’ve 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] Return 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 width×height Repeatedly calls procedure with the x and y coordinates of each pixel to get the color of the pixel

5 Example The procedure [x y → [color x x x]] Returns a color with equal amounts of red, green, and blue light So it’s grey It’s brightness varies with its horizontal position ► [bitmap-from-procedure [x y → [color x x x]] 256 256] ►

6 Example 2 The procedure [x y → [color x 0 y]] Changes red and blue independently So hue varies over space ► [bitmap-from-procedure [x y → [color x 0 y]] 256 256] ►

7 Example 3 ► [define sine-wave [n → [+ 128 [× 127 [sin [∕ n 20]]]]]] ► [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


Download ppt "Eleven colors and rasters. 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)"

Similar presentations


Ads by Google