GIFSAVE

Synopsis
GIFSAVE filename
(GIFSAVE filename delay append loop)
(GIFSAVE filename delay append loop maxcolor)
(GIFSAVE filename delay append loop maxcolor transcolorvector)
Description

Save a picture of your work as a GIF (pronounced "jif") image so that it can be used on Web pages or Email. The dimensions of the picture are determined by ACTIVEAREA.

GIFSAVE saves the picture in a format called GIF (Graphics Interchange Format) that was created by CompuServe. The format was popular on the Web for several reasons. First, it is a compressed format and takes less time to transmit than uncompressed formats. Second, it supports "interlacing", which makes the image partially viewable as it's being transmitted (it starts off blurry and comes into focus). Third, it supports animation. Animated GIFs allow multiple images in one file with specified delays between the images.

The filename input must be a word that is the name of the file to which the GIF is written. If a file by this name already exists, it is ovewritten.

When four or more inputs are given, you can save a GIF animation frame (series of compressed bitmap images). The delay input specifies how many hundredths of a second to display the frame. The append input specifies whether to start a new animation or append a new frame to an existing animation. This should be either "TRUE or "FALSE. The loop input specifies how many times the animation should loop (the default of -1 = no loop, 0 = loop forever, n = loop n times).

You can specify the maximum color depth with the optional maxcolor input. The choices are 1 (2 colors), 4 (16 colors), or 8 (256 colors) bits per pixel (8 being the default). If your image does not use many colors you can reduce the size of the GIF file produced significantly by using this option.

The optional transcolorvector input takes the form [red green blue] and specifies the color of the pixels which are transparent in the saved image. If this input is not specified then no pixels are transparent.

Example

A single image (no animation):

REPEAT 72 [REPEAT 4 [FORWARD 100 RIGHT 90] RIGHT 5]
GIFSAVE "myfile.gif
CLEARSCREEN
GIFLOAD "myfile.gif

GIF animation:

CLEARSCREEN
SETACTIVEAREA [-150 -150 150 150]

; Flag to indicate we do not append the first frame
MAKE "append "FALSE
REPEAT 36 [
  REPEAT 4 [FORWARD 100 RIGHT 90]
  RIGHT 10
  ; Save a frame (no delay and loop forever)
  (GIFSAVE "myfile.gif 0 :append 0)
  MAKE "append "TRUE
]

Open the file myfile.gif with your Web browser (for example, Firefox or Internet Explorer).

See Also
GIFLOAD
ACTIVEAREA

SourceForge.net Logo