The main object of the Image module, this object is used as drawing area, mask or result of operations.init: clear, clone, create, xsize, ysize
plain drawing: box, circle, getpixel, line, setcolor, setpixel, treshold, tuned_box, polyfill
pasting images, layers: add_layers, paste, paste_alpha, paste_alpha_color, paste_mask
getting subimages, scaling, rotating: autocrop, ccw, cw, clone, copy, dct, mirrorx, rotate, rotate_expand, scale, skewx, skewx_expand, skewy, skewy_expand
calculation by pixels: apply_matrix, change_color, color, distancesq, grey, invert, map_closest, map_fast, modify_by_intensity, select_from
converting to other datatypes: cast, fromgif, frompnm/fromppm, gif_add, gif_add_fs, gif_add_fs_nomap, gif_add_nomap, gif_begin, gif_end, gif_netscape_loop, to8bit, to8bit_closest, to8bit_fs, to8bit_rgbcube, to8bit_rgbcube_rdither, tobitmap, togif, togif_fs, toppm, tozbgr
Image, Image.font
object `&(object operand)
object `&(array(int) color)
object `&(int value)
makes a new image out of the minimum pixels values
- object operand
- the other image to compare with; the images must have the same size.
- array(int) color
- an array in format ({r,g,b}), this is equal to using an uniform-colored image.
- int value
- equal to ({value,value,value}).
the new image object
`-, `+, `|, `*, add_layers
object `*(object operand)
object `*(array(int) color)
object `*(int value)
Multiplies pixel values and creates a new image.This can be useful to lower the values of an image, making it greyer, for instance:
image=image*128+64;
- object operand
- the other image to multiply with; the images must have the same size.
- array(int) color
- an array in format ({r,g,b}), this is equal to using an uniform-colored image.
- int value
- equal to ({value,value,value}).
the new image object
`-, `+, `|, `&, add_layers
object `+(object operand)
object `+(array(int) color)
object `+(int value)
adds two images; values are truncated at 255.
- object operand
- the image which to add.
- array(int) color
- an array in format ({r,g,b}), this is equal to using an uniform-colored image.
- int value
- equal to ({value,value,value}).
the new image object
`-, `|, `&, `*, add_layers
object `-(object operand)
object `-(array(int) color)
object `-(int value)
makes a new image out of the difference
- object operand
- the other image to compare with; the images must have the same size.
- array(int) color
- an array in format ({r,g,b}), this is equal to using an uniform-colored image.
- int value
- equal to ({value,value,value}).
the new image object
`+, `|, `&, `*, add_layers
object `|(object operand)
object `|(array(int) color)
object `|(int value)
makes a new image out of the maximum pixels values
- object operand
- the other image to compare with; the images must have the same size.
- array(int) color
- an array in format ({r,g,b}), this is equal to using an uniform-colored image.
- int value
- equal to ({value,value,value}).
the new image object
`-, `+, `&, `*, add_layers
object add_layers(array(int|object)) layer0, ...)
object add_layers(int x1, int y1, int x2, int y2, array(int|object)) layer0, ...)
Using the called object as base, adds layers using masks, opaque channel values and special methods.The destination image can also be cropped, thus speeding up the process.
Each array in the layers array is one of:
({object image,object|int mask}) ({object image,object|int mask,int opaque_value}) ({object image,object|int mask,int opaque_value,int method})Given 0 as mask means the image is totally opaque.Default opaque value is 255, only using the mask.
Methods for now are:
0 no operation (just paste with mask, default) 1 maximum (`|) 2 minimum (`&) 3 multiply (`*) 4 add (`+) 5 diff (`-)The layer image and the current source are calculated through the given method and then pasted using the mask and the opaque channel value.All given images must be the same size.
- array(int|object) layer0
- image to paste
- int x1
- int y1
- int x2
- int y2
- rectangle for cropping
a new image object
paste_mask, paste_alpha, paste_alpha_color, `|, `&, `*, `+, `-
object apply_matrix(array(array(int|array(int))) matrix)
object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b)
object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b, int|float div)
Applies a pixel-transform matrix, or filter, to the image.2 2 pixel(x,y)= base+ k ( sum sum pixel(x+k-1,y+l-1)*matrix(k,l) ) k=0 l=01/k is sum of matrix, or sum of matrix multiplied with div. base is given by r,g,b and is normally black.blur (ie a 2d gauss function):
({({1,2,1}), ({2,5,2}), ({1,2,1})})sharpen (k>8, preferably 12 or 16):({({-1,-1,-1}), ({-1, k,-1}), ({-1,-1,-1})})edge detect:
({({1, 1,1}), ({1,-8,1}), ({1, 1,1})})horisontal edge detect (get the idea):
({({0, 0,0}) ({1,-8,1}), ({0, 0,0})})emboss (might prefer to begin with a grey image):
({({2, 1, 0}) ({1, 0,-1}), ({0,-1, 2})}), 128,128,128, 5This function is not very fast, and it's hard to optimize it more, not using assembler.
- array(array(int|array(int)))
- the matrix; innermost is a value or an array with red, green, blue values for red, green, blue separation.
- int r
- int g
- int b
- base level of result, default is zero
- int|float div
- division factor, default is 1.0.
the new image object
object autocrop()
object autocrop(int border)
object autocrop(int border, int r, int g, int b)
object autocrop(int border, int left, int right, int top, int bottom)
object autocrop(int border, int left, int right, int top, int bottom, int r, int g, int b)
Removes "unneccesary" borders around the image, adds one of its own if wanted to, in selected directions."Unneccesary" is all pixels that are equal -- ie if all the same pixels to the left are the same color, that column of pixels are removed.
- int border
- added border size in pixels
- int r
- int g
- int b
- color of the new border
- int left
- int right
- int top
- int bottom
- which borders to scan and cut the image; a typical example is removing the top and bottom unneccesary pixels:
img=img->autocrop(0, 0,0,1,1);
the new image object
copy
object box(int x1, int y1, int x2, int y2)
object box(int x1, int y1, int x2, int y2, int r, int g, int b)
object box(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Draws a filled rectangle on the image.
- int x1
- int y1
- int x2
- int y2
- box corners
- int r
- int g
- int b
- color of the box
- int alpha
- alpha value
the object called
string cast(string type)
string to8bit(array(array(int)) colors)
string to8bit_fs(array(array(int)) colors)
string to8bit_closest(array(array(int)) colors)
Maps the image to the given colors and returns the 8 bit data.to8bit_fs uses floyd-steinberg dithering
the calculated string
always casts to string...
to8bit_rgbcube, tozbgr, map_fast, map_closest, select_colors, tobitmap
object ccw()
rotates an image counter-clockwise, 90 degrees.
the new image object
object change_color(int tor, int tog, int tob)
object change_color(int fromr, int fromg, int fromb, int tor, int tog, int tob)
Changes one color (exakt match) to another. If non-exakt-match is preferred, check distancesq and paste_alpha_color.
- int tor
- int tog
- int tob
- destination color and next current color
- int fromr
- int fromg
- int fromb
- source color, default is current color
a new (the destination) image object
object circle(int x, int y, int rx, int ry)
object circle(int x, int y, int rx, int ry, int r, int g, int b)
object circle(int x, int y, int rx, int ry, int r, int g, int b, int alpha)
Draws a line on the image. The line is not antialiased.
- int x
- int y
- circle center
- int rx
- int ry
- circle radius in pixels
- int r
- int g
- int b
- color
- int alpha
- alpha value
the object called
void clear()
void clear(int r, int g, int b)
void clear(int r, int g, int b, int alpha)
gives a new, cleared image with the same size of drawing area
- int r
- int g
- int b
- color of the new image
- int alpha
- new default alpha channel value
copy, clone
object clone()
object clone(int xsize, int ysize)
object clone(int xsize, int ysize, int r, int g, int b)
object clone(int xsize, int ysize, int r, int g, int b, int alpha)
Copies to or initialize a new image object.
- int xsize
- int ysize
- size of (new) image in pixels, called image is cropped to that size
- int r
- int g
- int b
- current color of the new image, default is black. Will also be the background color if the cloned image is empty (no drawing area made).
- int alpha
- new default alpha channel value
the new object
copy, create
object color()
object color(int value)
object color(int r, int g, int b)
Colorize an image.The red, green and blue values of the pixels are multiplied with the given value(s). This works best on a grey image...
The result is divided by 255, giving correct pixel values.
If no arguments are given, the current color is used as factors.
- int r
- int g
- int b
- red, green, blue factors
- int value
- factor
the new image object
grey, `*, modify_by_intensity
object copy()
object copy(int x1, int y1, int x2, int y2)
object copy(int x1, int y1, int x2, int y2, int r, int g, int b)
object copy(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Copies this part of the image. The requested area can be smaller, giving a cropped image, or bigger - the new area will be filled with the given or current color.
- int x1
- int y1
- int x2
- int y2
- The requested new area. Default is the old image size.
- int r
- int g
- int b
- color of the new image
- int alpha
- new default alpha channel value
a new image object
clone(void) and copy(void) does the same operation
clone, autocrop
void create()
void create(int xsize, int ysize)
void create(int xsize, int ysize, int r, int g, int b)
void create(int xsize, int ysize, int r, int g, int b, int alpha)
Initializes a new image object.
- int xsize
- int ysize
- size of (new) image in pixels
- int r
- int g
- int b
- background color (will also be current color), default color is black
- int alpha
- default alpha channel value
copy, clone, Image.image
object cw()
rotates an image clockwise, 90 degrees.
the new image object
object dct(int newx, int newy)
Scales the image to a new size. Method for scaling is rather complex; the image is transformed via a cosine transform, and then resampled back.This gives a quality-conserving upscale, but the algorithm used is n*n+n*m, where n and m is pixels in the original and new image.
Recommended wrapping algorithm is to scale overlapping parts of the image-to-be-scaled.
This functionality is actually added as an true experiment, but works...
- int newx
- int newy
- new image size in pixels
the new image object
Do NOT use this function if you don't know what you're dealing with! Read some signal theory first...
object distancesq()
object distancesq(int r, int g, int b)
Makes an grey-scale image, for alpha-channel use. The given value (or current color) are used for coordinates in the color cube. Each resulting pixel is the distance from this point to the source pixel color, in the color cube, squared, rightshifted 8 steps:
p = pixel color o = given color d = destination pixel d.red=d.blue=d.green= ((o.red-p.red)²+(o.green-p.green)²+(o.blue-p.blue)²)>>8
- int r
- int g
- int b
- red, green, blue coordinates
the new image object
select_from
object fromgif(string gif)
Reads GIF data to the called image object.GIF animation delay or loops are ignored, and the resulting image is the written result.
- string pnm
- pnm data, as a string
the called object
yes, it does -- it may even do segment overrides...
togif, frompnm
object|string frompnm(string pnm)
object|string fromppm(string pnm)
Reads a PNM (PBM, PGM or PPM in ascii or binary) to the called image object.The method accepts P1 through P6 type of PNM data.
"fromppm" is an alias for "frompnm".
- string pnm
- pnm data, as a string
the called object or a hint of what wronged.
toppm, fromgif
array(int) getpixel(int x, int y)
- int x
- int y
- position of the pixel
color of the requested pixel -- ({int red,int green,int blue})
string gif_add()
string gif_add(int x, int y)
string gif_add(int x, int y, int delay_cs)
string gif_add(int x, int y, float delay_s)
string gif_add(int x, int y, int num_colors, int delay_cs)
string gif_add(int x, int y, int num_colors, float delay_s)
string gif_add(int x, int y, array(array(int)) colors, int delay_cs)
string gif_add(int x, int y, array(array(int)) colors, float delay_s)
string gif_add_fs()
string gif_add_fs(int x, int y)
string gif_add_fs(int x, int y, int delay_cs)
string gif_add_fs(int x, int y, float delay_s)
string gif_add_fs(int x, int y, int num_colors, int delay_cs)
string gif_add_fs(int x, int y, int num_colors, float delay_s)
string gif_add_fs(int x, int y, array(array(int)) colors, int delay_cs)
string gif_add_fs(int x, int y, array(array(int)) colors, float delay_s)
string gif_add_nomap()
string gif_add_nomap(int x, int y)
string gif_add_nomap(int x, int y, int delay_cs)
string gif_add_nomap(int x, int y, float delay_s)
string gif_add_nomap(int x, int y, int num_colors, int delay_cs)
string gif_add_nomap(int x, int y, int num_colors, float delay_s)
string gif_add_nomap(int x, int y, array(array(int)) colors, int delay_cs)
string gif_add_nomap(int x, int y, array(array(int)) colors, float delay_s)
string gif_add_fs_nomap()
string gif_add_fs_nomap(int x, int y)
string gif_add_fs_nomap(int x, int y, int delay_cs)
string gif_add_fs_nomap(int x, int y, float delay_s)
string gif_add_fs_nomap(int x, int y, int num_colors, int delay_cs)
string gif_add_fs_nomap(int x, int y, int num_colors, float delay_s)
string gif_add_fs_nomap(int x, int y, array(array(int)) colors, int delay_cs)
string gif_add_fs_nomap(int x, int y, array(array(int)) colors, float delay_s)
Makes a GIF (sub)image data chunk, to be placed at the given position.The "fs" versions uses floyd-steinberg dithering, and the "nomap" versions have no local colormap.
Example:
object img1 = Image(200,200); object img2 = Image(200,200); // load img1 and img2 with stuff write(img1->gif_begin()+ img1->gif_netscape_loop()+ img1->gif_add(0,0,100)+ img2->gif_add(0,0,100)+ img1->gif_end()); // voila, a gif animation...
- int x
- int y
- the location of this subimage
- int delay_cs
- frame delay in centiseconds
- float delay_s
- frame delay in seconds
- int num_colors
- number of colors to quantize to (default is 256)
- array array(array(int)) colors
- colors to map to, format is ({({r,g,b}),({r,g,b}),...}).
the GIF data chunk as a string
I (Mirar) recommend reading about the GIF file format before experementing with these.
gif_add, gif_end, gif_netscape_loop, togif */
string gif_begin()
string gif_begin(int num_colors)
string gif_begin(array(array(int)) colors)
Makes GIF header. With no argument, there is no global colortable (palette).
- int num_colors
- number of colors to quantize to (default is 256) array array(array(int)) colors colors to map to, format is ({({r,g,b}),({r,g,b}),...}).
the GIF data
gif_add, gif_end, togif, gif_netscape_loop
string gif_end()
Ends GIF data.
the GIF data.
gif_begin
string gif_netscape_loop()
string gif_netscape_loop(int loops)
- int loops
- number of loops, default is 65535.
a gif chunk that defines that the GIF animation should loop
gif_add, gif_begin, gif_end
object grey()
object grey(int r, int g, int b)
Makes a grey-scale image (with weighted values).
- int r
- int g
- int b
- weight of color, default is r=87,g=127,b=41, which should be pretty accurate of what the eyes see...
the new image object
color, `*, modify_by_intensity
object invert()
Invert an image. Each pixel value gets to be 255-x, where x is the old value.
the new image object
object line(int x1, int y1, int x2, int y2)
object line(int x1, int y1, int x2, int y2, int r, int g, int b)
object line(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Draws a line on the image. The line is not antialiased.
- int x1
- int y1
- int x2
- int y2
- line endpoints
- int r
- int g
- int b
- color
- int alpha
- alpha value
the object called
object map_closest(array(array(int)) colors)
Maps all pixel colors to the colors given.Method to find the correct color is linear search over the colors given, selecting the nearest in the color cube. Slow...
- array(array(int)) color
- list of destination (available) colors
the new image object
map_fast, select_colors, map_fs
array(array(int)) map_closest(int num_colors)
Selects the best colors to represent the image.
- int num_colors
- number of colors to return
an array of colors
map_fast, select_colors
object map_fast(array(array(int)) colors)
Maps all pixel colors to the colors given.Method to find the correct color is to branch in a binary space partitioning tree in the colorcube. This is fast, but in some cases it gives the wrong color (mostly when few colors are available).
- array(array(int)) color
- list of destination (available) colors
the new image object
map_fast, select_colors
object map_fs(array(array(int)) colors)
Maps all pixel colors to the colors given.Method to find the correct color is linear search over the colors given, selecting the nearest in the color cube. Slow...
Floyd-steinberg error correction is added to create a better-looking image, in many cases, anyway.
- array(array(int)) color
- list of destination (available) colors
the new image object
map_fast, select_colors, map_closest
object mirrorx()
mirrors an image:+--+ +--+ |x | <-> | x| | .| |. | +--+ +--+
the new image object
object mirrorx()
mirrors an image:+--+ +--+ |x | <-> | .| | .| |x | +--+ +--+
object modify_by_intensity(int r, int g, int b, int|array(int) v1, ..., int|array(int) vn)
Recolor an image from intensity values.For each color an intensity is calculated, from r, g and b factors (see grey), this gives a value between 0 and max.
The color is then calculated from the values given, v1 representing the intensity value of 0, vn representing max, and colors between representing intensity values between, linear.
- int r
- int g
- int b
- red, green, blue intensity factors
- int|array(int) v1
- int|array(int) vn
- destination color
the new image object
grey, `*, color
object paste(object image)
object paste(object image, int x, int y)
Pastes a given image over the current image.
- object image
- image to paste
- int x
- int y
- where to paste the image; default is 0,0
the object called
paste_mask, paste_alpha, paste_alpha_color
object paste_alpha(object image, int alpha)
object paste_alpha(object image, int alpha, int x, int y)
Pastes a given image over the current image, with the specified alpha channel value. An alpha channel value of 0 leaves nothing of the original image in the paste area, 255 is meaningless and makes the given image invisible.
- object image
- image to paste
- int alpha
- alpha channel value
- int x
- int y
- where to paste the image; default is 0,0
the object called
paste_mask, paste, paste_alpha_color
object paste_alpha_color(object mask)
object paste_alpha_color(object mask, int x, int y)
object paste_alpha_color(object mask, int r, int g, int b)
object paste_alpha_color(object mask, int r, int g, int b, int x, int y)
Pastes a given color over the current image, using the given mask as opaque channel. A pixel value of 255 makes the result become the color given, 0 doesn't change anything. The masks red, green and blue values are used separately. If no color are given, the current is used.
- object mask
- mask image
- int r
- int g
- int b
- what color to paint with; default is current
- int x
- int y
- where to paste the image; default is 0,0
the object called
paste_mask, paste_alpha, paste_alpha_color
object paste_mask(object image, object mask)
object paste_mask(object image, object mask, int x, int y)
Pastes a given image over the current image, using the given mask as opaque channel. A pixel value of 255 makes the result become a pixel from the given image, 0 doesn't change anything.The masks red, green and blue values are used separately.
- object image
- image to paste
- object mask
- mask image
- int x
- int y
- where to paste the image; default is 0,0
the object called
paste, paste_alpha, paste_alpha_color
object polygone(array(int|float) ... curve)
fills an area with the current color
- array(int|float) curve
- curve(s), ({x1,y1,x2,y2,...,xn,yn}), automatically closed.
If any given curve is inside another, it will make a hole.
NOTE This function is new (april-97) and rather untested.
the current object
box, setcolor
object rotate(int|float angle)
object rotate(int|float angle, int r, int g, int b)
object rotate_expand(int|float angle)
object rotate_expand(int|float angle, int r, int g, int b)
Rotates an image a certain amount of degrees (360° is a complete rotation) counter-clockwise:x +--+ / \ | | <-> x x | | \ / +--+ xThe "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.This rotate uses the skewx() and skewy() functions.
- int|float angle
- the number of degrees to rotate
- int r
- int g
- int b
- color to fill with; default is current
the new image object
object scale(float factor)
object scale(0.5)
object scale(float xfactor, float yfactor)
scales the image with a factor, 0.5 is an optimized case.
- float factor
- factor to use for both x and y
- float xfactor
- float yfactor
- separate factors for x and y
the new image object
object scale(int newxsize, int newysize)
object scale(0, int newysize)
object scale(int newxsize, 0)
scales the image to a specified new size, if one of newxsize or newysize is 0, the image aspect ratio is preserved.
- int newxsize
- int newysize
- new image size in pixels
the new image object
object select_from(int x, int y)
object select_from(int x, int y, int edge_value)
Makes an grey-scale image, for alpha-channel use. This is very close to a floodfill. The image is scanned from the given pixel, filled with 255 if the color is the same, or 255 minus distance in the colorcube, squared, rightshifted 8 steps (see distancesq).When the edge distance is reached, the scan is stopped. Default edge value is 30. This value is squared and compared with the square of the distance above.
- int x
- int y
- originating pixel in the image
the new image object
distancesq
object setcolor(int r, int g, int b)
object setcolor(int r, int g, int b, int alpha)
set the current color
- int r
- int g
- int b
- new color
- int alpha
- new alpha value
the object called
object setpixel(int x, int y)
object setpixel(int x, int y, int r, int g, int b)
object setpixel(int x, int y, int r, int g, int b, int alpha)
- int x
- int y
- position of the pixel
- int r
- int g
- int b
- color
- int alpha
- alpha value
the object called
object skewx(int x)
object skewx(int yfactor)
object skewx(int x, int r, int g, int b)
object skewx(int yfactor, int r, int g, int b)
object skewx_expand(int x)
object skewx_expand(int yfactor)
object skewx_expand(int x, int r, int g, int b)
object skewx_expand(int yfactor, int r, int g, int b)
Skews an image an amount of pixels or a factor; a skew-x is a transformation:+--+ +--+ | | <-> / / | | / / +--+ +--+
- int x
- the number of pixels The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.
- float yfactor
- best described as: x=yfactor*this->ysize()
- int r
- int g
- int b
- color to fill with; default is current
the new image object
object skewy(int y)
object skewy(int xfactor)
object skewy(int y, int r, int g, int b)
object skewy(int xfactor, int r, int g, int b)
object skewy_expand(int y)
object skewy_expand(int xfactor)
object skewy_expand(int y, int r, int g, int b)
object skewy_expand(int xfactor, int r, int g, int b)
Skews an image an amount of pixels or a factor; a skew-y is a transformation:+ /| +--+ / | | | <-> + + | | | / +--+ |/ +The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.
- int y
- the number of pixels
- float xfactor
- best described as: t=xfactor*this->xsize()
- int r
- int g
- int b
- color to fill with; default is current
the new image object
string tozbgr(array(array(int)) colors)
string to8bit_rgbcube(int red, int green, int blue)
string to8bit_rgbcube(int red, int green, int blue, string map)
string to8bit_rgbcube_rdither(int red, int green, int blue)
string to8bit_rgbcube_rdither(int red, int green, int blue, string map)
Maps the image into a colorcube with the given dimensions. Red is least significant, blue is most.The "rdither" type of method uses a random dither algoritm.
- int red
- int green
- int blue
- The sides of the colorcube. Not the number of bits!
- string map
- Map this position in the colorcube to another value, ie: say we have position red=1,green=2,blue=3 in a colorcube of 6×6×6, we have the index 1+2*6+3*6*6=121. If the map-string contains 'å' in position 121, the resulting byte is 'å' or 229.
the calculated string
tozbgr, to8bit, tobitmap
string tobitmap();
Maps the image to a bitmap.Bit 0 is the leftmost pixel, and the rows are aligned to bytes.
Any pixel value other then black results in a set bit.
the calculated string
tozbgr, to8bit, to8bit_rgbcube, cast
string togif()
string togif(int num_colors)
string togif(array(array(int)) colors)
string togif(int trans_r, int trans_g, int trans_b)
string togif(int num_colors, int trans_r, int trans_g, int trans_b)
string togif(array(array(int)) colors, int trans_r, int trans_g, int trans_b)
string togif_fs()
string togif_fs(int num_colors)
string togif_fs(array(array(int)) colors)
string togif_fs(int trans_r, int trans_g, int trans_b)
string togif_fs(int num_colors, int trans_r, int trans_g, int trans_b)
string togif_fs(array(array(int)) colors, int trans_r, int trans_g, int trans_b)
Makes GIF data. The togif_fs variant uses floyd-steinberg dithereing.
- int num_colors
- number of colors to quantize to (default is 256) array array(array(int)) colors colors to map to (default is to quantize to 256), format is ({({r,g,b}),({r,g,b}),...}).
- int trans_r
- int trans_g
- int trans_b
- one color, that is to be transparent.
the GIF data
togif_begin, togif_add, togif_end, toppm, fromgif
string toppm()
Returns PPM (P6, binary pixmap) data from the current image object.
PPM data
frompnm, fromgif
object treshold()
object treshold(int r, int g, int b)
Makes a black-white image.If all red, green, blue parts of a pixel is larger or equal then the given value, the pixel will become white, else black.
This method works fine with the grey method.
If no arguments are given, the current color is used for treshold values.
- int r
- int g
- int b
- red, green, blue threshold values
the new image object
grey
object tuned_box(int x1, int y1, int x2, int y2, array(array(int)) corner_color)
Draws a filled rectangle with colors (and alpha values) tuned between the corners.Tuning function is (1.0-x/xw)*(1.0-y/yw) where x and y is the distance to the corner and xw and yw are the sides of the rectangle.
- int x1
- int y1
- int x2
- int y2
- rectangle corners
- array(array(int)) corner_color
- colors of the corners:
({x1y1,x2y1,x1y2,x2y2})each of these is an array of integeres:({r,g,b}) or ({r,g,b,alpha})Default alpha channel value is 0 (opaque).
the object called
int xsize()
the width of the image
int ysize()
the height of the image