diff --git a/src/modules/Image/doc/Image.html b/src/modules/Image/doc/Image.html index 6a8db1176147ab8204a5ffe68781c353ba3dc901..3624cd3ee46dfcb1f63e1feb8eb311b86162bd71 100644 --- a/src/modules/Image/doc/Image.html +++ b/src/modules/Image/doc/Image.html @@ -13,6 +13,7 @@ This module adds image-drawing and -manipulating <tt><a href=Image.image.html>Image.image</a></tt> </blockquote> <h3>More documentation:</h3> - <i><tt><a href=Image.font.html>Image.font</a></tt></tt></i><br> + <i><tt><a href=Image.colortable.html>Image.colortable</a></tt></tt></i><br> + <i><tt><tt><a href=Image.font.html>Image.font</a></tt></tt></i><br> <i><tt><tt><a href=Image.image.html>Image.image</a></tt></i> diff --git a/src/modules/Image/doc/Image.image.html b/src/modules/Image/doc/Image.image.html index c2e8bed3231fc323d61704f71957ceaa94b2cb2a..34aefef9b8cc2da700798fc92550949fcda10002 100644 --- a/src/modules/Image/doc/Image.image.html +++ b/src/modules/Image/doc/Image.image.html @@ -19,7 +19,8 @@ The main object of the <tt><a href=Image.html>Image</a></tt> module, this object <tt><a href=Image.image.html#setcolor>setcolor</a></tt>, <tt><a href=Image.image.html#setpixel>setpixel</a></tt>, <tt><a href=Image.image.html#treshold>treshold</a></tt>, - <tt><a href=Image.image.html#tuned_box>tuned_box</a></tt> + <tt><a href=Image.image.html#tuned_box>tuned_box</a></tt>, + <tt><a href=Image.image.html#polyfill>polyfill</a></tt> <p> operators: <tt><a href=Image.image.html#%60%26>`&</a></tt>, <tt><a href=Image.image.html#%60*>`*</a></tt>, @@ -339,12 +340,12 @@ Using the called object as base, adds layers using masks, <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>array(int|object) layer0</tt> + <dd>image to paste <dt><tt>int x1</tt> <dt><tt>int y1</tt> <dt><tt>int x2</tt> <dt><tt>int y2</tt> - <dd>image to paste - rectangle for cropping + <dd>rectangle for cropping </dl></blockquote> <h4>RETURNS</h4> @@ -430,14 +431,14 @@ Applies a pixel-transform matrix, or filter, to the image. <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>array(array(int|array(int)))</tt> + <dd>the matrix; innermost is a value or an array with red, green, blue + values for red, green, blue separation. <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>base level of result, default is zero <dt><tt>int|float div</tt> - <dd>the matrix; innermost is a value or an array with red, green, blue - values for red, green, blue separation. - base level of result, default is zero - division factor, default is 1.0. + <dd>division factor, default is 1.0. </dl></blockquote> <h4>RETURNS</h4> @@ -470,16 +471,16 @@ Removes "unneccesary" borders around the image, adds one of <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int border</tt> + <dd>added border size in pixels <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color of the new border <dt><tt>int left</tt> <dt><tt>int right</tt> <dt><tt>int top</tt> <dt><tt>int bottom</tt> - <dd>added border size in pixels - color of the new border - which borders to scan and cut the image; + <dd>which borders to scan and cut the image; a typical example is removing the top and bottom unneccesary pixels: <pre>img=img->autocrop(0, 0,0,1,1);</pre> @@ -517,13 +518,13 @@ Draws a filled rectangle on the image. <dt><tt>int y1</tt> <dt><tt>int x2</tt> <dt><tt>int y2</tt> + <dd>box corners <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color of the box <dt><tt>int alpha</tt> - <dd>box corners - color of the box - alpha value + <dd>alpha value </dl></blockquote> <h4>RETURNS</h4> @@ -602,11 +603,11 @@ Changes one color (exakt match) to another. <dt><tt>int tor</tt> <dt><tt>int tog</tt> <dt><tt>int tob</tt> + <dd>destination color and next current color <dt><tt>int fromr</tt> <dt><tt>int fromg</tt> <dt><tt>int fromb</tt> - <dd>destination color and next current color - source color, default is current color + <dd>source color, default is current color </dl></blockquote> <h4>RETURNS</h4> @@ -634,16 +635,16 @@ Draws a line on the image. The line is <i>not</i> antialiased. <blockquote><dl> <dt><tt>int x</tt> <dt><tt>int y</tt> + <dd>circle center <dt><tt>int rx</tt> <dt><tt>int ry</tt> + <dd>circle radius in pixels <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color <dt><tt>int alpha</tt> - <dd>circle center - circle radius in pixels - color - alpha value + <dd>alpha value </dl></blockquote> <h4>RETURNS</h4> @@ -672,9 +673,9 @@ gives a new, cleared image with the same size of drawing area <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> -<dt><tt>int alpha</tt> <dd>color of the new image - new default alpha channel value +<dt><tt>int alpha</tt> + <dd>new default alpha channel value </dl></blockquote> @@ -703,17 +704,17 @@ Copies to or initialize a new image object. <blockquote><dl> <dt><tt>int xsize</tt> <dt><tt>int ysize</tt> + <dd>size of (new) image in pixels, called image + is cropped to that size <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> -<dt><tt>int alpha</tt> - <dd>size of (new) image in pixels, called image - is cropped to that size - current color of the new image, + <dd>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). - new default alpha channel value +<dt><tt>int alpha</tt> + <dd>new default alpha channel value </dl></blockquote> <h4>RETURNS</h4> @@ -755,9 +756,9 @@ Colorize an image. <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> -<dt><tt>int value</tt> <dd>red, green, blue factors - factor +<dt><tt>int value</tt> + <dd>factor </dl></blockquote> <h4>RETURNS</h4> @@ -797,13 +798,13 @@ Copies this part of the image. The requested area can <dt><tt>int y1</tt> <dt><tt>int x2</tt> <dt><tt>int y2</tt> + <dd>The requested new area. Default is the old image size. <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color of the new image <dt><tt>int alpha</tt> - <dd>The requested new area. Default is the old image size. - color of the new image - new default alpha channel value + <dd>new default alpha channel value </dl></blockquote> <h4>RETURNS</h4> @@ -815,11 +816,8 @@ a new image object <h4>NOTE</h4> <blockquote> - 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. - - +<tt><a href=Image.image.html#clone>clone</a></tt>(void) and <tt><a href=Image.image.html#copy>copy</a></tt>(void) does the same + operation </blockquote> @@ -848,14 +846,14 @@ Initializes a new image object. <blockquote><dl> <dt><tt>int xsize</tt> <dt><tt>int ysize</tt> + <dd>size of (new) image in pixels <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> -<dt><tt>int alpha</tt> - <dd>size of (new) image in pixels - background color (will also be current color), + <dd>background color (will also be current color), default color is black - default alpha channel value +<dt><tt>int alpha</tt> + <dd>default alpha channel value </dl></blockquote> @@ -925,6 +923,13 @@ Scales the image to a new size. the new image object </blockquote> + +<h4>NOTE</h4> +<blockquote> +Do NOT use this function if you don't know what + you're dealing with! Read some signal theory first... +</blockquote> + <hr> <a name=distancesq> </a> <h4>SYNOPSIS</h4> @@ -1110,29 +1115,49 @@ string <b>gif_add_fs_nomap</b>(int x, int y, array(array(int)) co <blockquote> 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. + at the given position. + +<p> The "fs" versions uses floyd-steinberg dithering, and the "nomap" + versions have no local colormap. + +<p> Example: + <pre> + 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... </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int x</tt> <dt><tt>int y</tt> + <dd>the location of this subimage <dt><tt>int delay_cs</tt> + <dd>frame delay in centiseconds <dt><tt>float delay_s</tt> + <dd>frame delay in seconds <dt><tt>int num_colors</tt> + <dd>number of colors to quantize to (default is 256) <dt><tt>array array(array(int)) colors</tt> - <dd>the location of this subimage - frame delay in centiseconds - frame delay in seconds - number of colors to quantize to (default is 256) - colors to map to, format is ({({r,g,b}),({r,g,b}),...}). + <dd>colors to map to, format is ({({r,g,b}),({r,g,b}),...}). </dl></blockquote> <h4>RETURNS</h4> <blockquote> -the GIF data +the GIF data chunk as a string +</blockquote> + + +<h4>NOTE</h4> +<blockquote> +I (Mirar) recommend reading about the GIF file format before + experementing with these. </blockquote> @@ -1140,7 +1165,7 @@ the GIF data <blockquote> <tt><a href=Image.image.html#gif_add>gif_add</a></tt>, <tt><a href=Image.image.html#gif_end>gif_end</a></tt>, <tt><a href=Image.image.html#gif_netscape_loop>gif_netscape_loop</a></tt>, - <tt><a href=Image.image.html#togif>togif</a></tt> + <tt><a href=Image.image.html#togif */>togif */</a></tt> </blockquote> <hr> @@ -1311,13 +1336,13 @@ Draws a line on the image. The line is <i>not</i> antialiased. <dt><tt>int y1</tt> <dt><tt>int x2</tt> <dt><tt>int y2</tt> + <dd>line endpoints <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color <dt><tt>int alpha</tt> - <dd>line endpoints - color - alpha value + <dd>alpha value </dl></blockquote> <h4>RETURNS</h4> @@ -1366,64 +1391,62 @@ the new image object <a name=map_closest> </a> <h4>SYNOPSIS</h4> <blockquote> -<tt>object <b>map_closest</b>(array(array(int)) colors)</tt> +<tt>array(array(int)) <b>map_closest</b>(int num_colors)</tt> </blockquote> <h4>DESCRIPTION</h4> <blockquote> -Maps all pixel colors to the colors given. - -<p> Method to find the correct color is linear search - over the colors given, selecting the nearest in the - color cube. Slow... - -<p> Floyd-steinberg error correction is added to create - a better-looking image, in many cases, anyway. +Selects the best colors to represent the image. </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> -<dt><tt>array(array(int)) color</tt> - <dd>list of destination (available) colors +<dt><tt>int num_colors</tt> + <dd>number of colors to return </dl></blockquote> <h4>RETURNS</h4> <blockquote> -the new image object +an array of colors </blockquote> <h4>SEE ALSO</h4> <blockquote> <tt><a href=Image.image.html#map_fast>map_fast</a></tt>, - <tt><a href=Image.image.html#select_colors>select_colors</a></tt>, - <tt><a href=Image.image.html#map_closest>map_closest</a></tt> + <tt><a href=Image.image.html#select_colors>select_colors</a></tt> </blockquote> <hr> -<a name=map_closest> </a> +<a name=map_fast> </a> <h4>SYNOPSIS</h4> <blockquote> -<tt>array(array(int)) <b>map_closest</b>(int num_colors)</tt> +<tt>object <b>map_fast</b>(array(array(int)) colors)</tt> </blockquote> <h4>DESCRIPTION</h4> <blockquote> -Selects the best colors to represent the image. +Maps all pixel colors to the colors given. + +<p> 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). </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> -<dt><tt>int num_colors</tt> - <dd>number of colors to return +<dt><tt>array(array(int)) color</tt> + <dd>list of destination (available) colors </dl></blockquote> <h4>RETURNS</h4> <blockquote> -an array of colors +the new image object </blockquote> @@ -1433,10 +1456,10 @@ an array of colors </blockquote> <hr> -<a name=map_fast> </a> +<a name=map_fs> </a> <h4>SYNOPSIS</h4> <blockquote> -<tt>object <b>map_fast</b>(array(array(int)) colors)</tt> +<tt>object <b>map_fs</b>(array(array(int)) colors)</tt> </blockquote> <h4>DESCRIPTION</h4> @@ -1445,11 +1468,12 @@ an array of colors <blockquote> Maps all pixel colors to the colors given. -<p> 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). +<p> Method to find the correct color is linear search + over the colors given, selecting the nearest in the + color cube. Slow... + +<p> Floyd-steinberg error correction is added to create + a better-looking image, in many cases, anyway. </blockquote> <h4>ARGUMENTS</h4> <blockquote><dl> @@ -1466,7 +1490,8 @@ the new image object <h4>SEE ALSO</h4> <blockquote> <tt><a href=Image.image.html#map_fast>map_fast</a></tt>, - <tt><a href=Image.image.html#select_colors>select_colors</a></tt> + <tt><a href=Image.image.html#select_colors>select_colors</a></tt>, + <tt><a href=Image.image.html#map_closest>map_closest</a></tt> </blockquote> <hr> @@ -1540,10 +1565,10 @@ Recolor an image from intensity values. <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>red, green, blue intensity factors <dt><tt>int|array(int) v1</tt> <dt><tt>int|array(int) vn</tt> - <dd>red, green, blue intensity factors - destination color + <dd>destination color </dl></blockquote> <h4>RETURNS</h4> @@ -1576,10 +1601,10 @@ Pastes a given image over the current image. <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>object image</tt> + <dd>image to paste <dt><tt>int x</tt> <dt><tt>int y</tt> - <dd>image to paste - where to paste the image; default is 0,0 + <dd>where to paste the image; default is 0,0 </dl></blockquote> <h4>RETURNS</h4> @@ -1617,12 +1642,12 @@ Pastes a given image over the current image, with <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>object image</tt> + <dd>image to paste <dt><tt>int alpha</tt> + <dd>alpha channel value <dt><tt>int x</tt> <dt><tt>int y</tt> - <dd>image to paste - alpha channel value - where to paste the image; default is 0,0 + <dd>where to paste the image; default is 0,0 </dl></blockquote> <h4>RETURNS</h4> @@ -1664,14 +1689,14 @@ Pastes a given color over the current image, <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>object mask</tt> + <dd>mask image <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>what color to paint with; default is current <dt><tt>int x</tt> <dt><tt>int y</tt> - <dd>mask image - what color to paint with; default is current - where to paste the image; default is 0,0 + <dd>where to paste the image; default is 0,0 </dl></blockquote> <h4>RETURNS</h4> @@ -1710,12 +1735,12 @@ Pastes a given image over the current image, <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>object image</tt> + <dd>image to paste <dt><tt>object mask</tt> + <dd>mask image <dt><tt>int x</tt> <dt><tt>int y</tt> - <dd>image to paste - mask image - where to paste the image; default is 0,0 + <dd>where to paste the image; default is 0,0 </dl></blockquote> <h4>RETURNS</h4> @@ -1731,6 +1756,44 @@ the object called <tt><a href=Image.image.html#paste_alpha_color>paste_alpha_color</a></tt> </blockquote> +<hr> +<a name=polygone> </a> +<h4>SYNOPSIS</h4> +<blockquote> +<tt>object <b>polygone</b>(array(int|float) ... curve)</tt> +</blockquote> + +<h4>DESCRIPTION</h4> + + +<blockquote> +fills an area with the current color +</blockquote> +<h4>ARGUMENTS</h4> +<blockquote><dl> +<dt><tt>array(int|float) curve</tt> + <dd>curve(s), <tt>({x1,y1,x2,y2,...,xn,yn})</tt>, + automatically closed. + +<p> If any given curve is inside another, it + will make a hole. + +<p> NOTE + This function is new (april-97) and rather untested. +</dl></blockquote> +<h4>RETURNS</h4> + + +<blockquote> +the current object +</blockquote> + + +<h4>SEE ALSO</h4> +<blockquote> <tt><a href=Image.image.html#box>box</a></tt>, + <tt><a href=Image.image.html#setcolor>setcolor</a></tt> +</blockquote> + <hr> <a name=rotate> </a> <a name=rotate_expand> </a> @@ -1764,11 +1827,11 @@ Rotates an image a certain amount of degrees (360 <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int|float angle</tt> + <dd>the number of degrees to rotate <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> - <dd>the number of degrees to rotate - color to fill with; default is current + <dd>color to fill with; default is current </dl></blockquote> <h4>RETURNS</h4> @@ -1796,10 +1859,10 @@ scales the image with a factor, <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>float factor</tt> + <dd>factor to use for both x and y <dt><tt>float xfactor</tt> <dt><tt>float yfactor</tt> - <dd>factor to use for both x and y - separate factors for x and y + <dd>separate factors for x and y </dl></blockquote> <h4>RETURNS</h4> @@ -1901,9 +1964,9 @@ set the current color <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> -<dt><tt>int alpha</tt> <dd>new color - new alpha value +<dt><tt>int alpha</tt> + <dd>new alpha value </dl></blockquote> <h4>RETURNS</h4> @@ -1925,13 +1988,13 @@ object <b>setpixel</b>(int x, int y, int r, int g, int <blockquote><dl> <dt><tt>int x</tt> <dt><tt>int y</tt> + <dd>position of the pixel <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> + <dd>color <dt><tt>int alpha</tt> - <dd>position of the pixel - color - alpha value + <dd>alpha value </dl></blockquote> <h4>RETURNS</h4> @@ -1971,16 +2034,16 @@ Skews an image an amount of pixels or a factor; <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int x</tt> -<dt><tt>float yfactor</tt> -<dt><tt>int r</tt> -<dt><tt>int g</tt> -<dt><tt>int b</tt> <dd>the number of pixels The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color. - best described as: x=yfactor*this->ysize() - color to fill with; default is current +<dt><tt>float yfactor</tt> + <dd>best described as: x=yfactor*this->ysize() +<dt><tt>int r</tt> +<dt><tt>int g</tt> +<dt><tt>int b</tt> + <dd>color to fill with; default is current </dl></blockquote> <h4>RETURNS</h4> @@ -2026,13 +2089,13 @@ Skews an image an amount of pixels or a factor; <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int y</tt> + <dd>the number of pixels <dt><tt>float xfactor</tt> + <dd>best described as: t=xfactor*this->xsize() <dt><tt>int r</tt> <dt><tt>int g</tt> <dt><tt>int b</tt> - <dd>the number of pixels - best described as: t=xfactor*this->xsize() - color to fill with; default is current + <dd>color to fill with; default is current </dl></blockquote> <h4>RETURNS</h4> @@ -2105,9 +2168,9 @@ Maps the image into a colorcube with the given <dt><tt>int red</tt> <dt><tt>int green</tt> <dt><tt>int blue</tt> -<dt><tt>string map</tt> <dd>The sides of the colorcube. Not the number of bits! - Map this position in the colorcube to another value, +<dt><tt>string map</tt> + <dd>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 @@ -2189,13 +2252,13 @@ Makes GIF data. The togif_fs variant uses floyd-steinberg <h4>ARGUMENTS</h4> <blockquote><dl> <dt><tt>int num_colors</tt> -<dt><tt>int trans_r</tt> -<dt><tt>int trans_g</tt> -<dt><tt>int trans_b</tt> <dd>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}),...}). - one color, that is to be transparent. +<dt><tt>int trans_r</tt> +<dt><tt>int trans_g</tt> +<dt><tt>int trans_b</tt> + <dd>one color, that is to be transparent. </dl></blockquote> <h4>RETURNS</h4> @@ -2306,9 +2369,9 @@ Draws a filled rectangle with colors (and alpha values) tuned <dt><tt>int y1</tt> <dt><tt>int x2</tt> <dt><tt>int y2</tt> -<dt><tt>array(array(int)) corner_color</tt> <dd>rectangle corners - colors of the corners: +<dt><tt>array(array(int)) corner_color</tt> + <dd>colors of the corners: <pre> ({x1y1,x2y1,x1y2,x2y2}) </pre> diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index 18acf1f26bba8b98bf576f066b1399a18aeef2c4..cfcf57a5c762d0404ede051d11fc0a3e5c0f444f 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.25 1997/04/19 22:57:01 grubba Exp $ */ +/* $Id: image.c,v 1.26 1997/04/30 01:46:40 mirar Exp $ */ /* **! module Image @@ -26,7 +26,8 @@ **! <ref>setcolor</ref>, **! <ref>setpixel</ref>, **! <ref>treshold</ref>, -**! <ref>tuned_box</ref> +**! <ref>tuned_box</ref>, +**! <ref>polyfill</ref> **! **! operators: <ref>`&</ref>, **! <ref>`*</ref>, @@ -97,7 +98,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: image.c,v 1.25 1997/04/19 22:57:01 grubba Exp $"); +RCSID("$Id: image.c,v 1.26 1997/04/30 01:46:40 mirar Exp $"); #include "types.h" #include "pike_macros.h" #include "object.h" @@ -108,10 +109,13 @@ RCSID("$Id: image.c,v 1.25 1997/04/19 22:57:01 grubba Exp $"); #include "array.h" #include "error.h" + #include "image.h" #include "builtin_functions.h" struct program *image_program; +extern struct program *colortable_program; + #define THIS ((struct image *)(fp->current_storage)) #define THISOBJ (fp->current_object) @@ -2176,7 +2180,7 @@ static void image_map_fast(INT32 args) } /* -**! method object map_closest(array(array(int)) colors) +**! method object map_fs(array(array(int)) colors) **! Maps all pixel colors to the colors given. **! **! Method to find the correct color is linear search @@ -2387,6 +2391,8 @@ void pike_module_init() "function(int,int,int,int,"RGB_TYPE":object)",0); add_function("tuned_box",image_tuned_box, "function(int,int,int,int,array:object)",0); + add_function("polygone",image_polygone, + "function(array(float|int) ...:object)",0); add_function("gray",image_grey, "function("RGB_TYPE":object)",0); diff --git a/src/modules/Image/image.h b/src/modules/Image/image.h index 32e226abbe788b2f38cb68df2a8c908cae21ef1e..57cf29c1d94d1f89468dfb50e45e1aa2c74a74c8 100644 --- a/src/modules/Image/image.h +++ b/src/modules/Image/image.h @@ -1,4 +1,4 @@ -/* $Id: image.h,v 1.6 1997/03/23 14:32:00 mirar Exp $ */ +/* $Id: image.h,v 1.7 1997/04/30 01:46:47 mirar Exp $ */ #define MAX_NUMCOL 32768 @@ -166,3 +166,8 @@ void image_tozbgr(INT32 args); void image_to8bit_rgbcube(INT32 args); void image_to8bit_rgbcube_rdither(INT32 args); void image_tobitmap(INT32 args); + +/* polyfill.c */ + +void image_polygone(INT32 args); + diff --git a/src/modules/Image/mkdoc.pike b/src/modules/Image/mkdoc.pike index 8aa1746a54330228d811ab934ddaab22205fd0da..39a328c2a2c2a18c0aff993d290fd91c45a58dd9 100644 --- a/src/modules/Image/mkdoc.pike +++ b/src/modules/Image/mkdoc.pike @@ -71,9 +71,8 @@ mapping keywords= "arg":lambda(string arg,int line) { if (!methodM) return complain("arg w/o method"); - if (nowM!=argM || !argM) - { if (!methodM->args) methodM->args=({}); - methodM->args+=({argM=nowM=(["args":({}),"_line":line])}); } + if (!methodM->args) methodM->args=({}); + methodM->args+=({argM=nowM=(["args":({}),"_line":line])}); argM->args+=({arg}); descM=argM; }, "note":lambda(string arg,int line) @@ -185,7 +184,7 @@ string standard_doc(mapping info,string myprefix) res+="\n\n<blockquote>\n"+fixdesc(info->desc,myprefix)+ "\n</blockquote>\n"; - if (info->note) + if (info->note && info->note->desc) res+="\n\n<h4>NOTE</h4>\n<blockquote>\n"+ fixdesc(info->note->desc,myprefix)+"\n</blockquote>\n"; @@ -277,9 +276,13 @@ void document_method(object(File) f, f->write("<h4>ARGUMENTS</h4>\n<blockquote><dl>\n"); foreach (method->args,arg) { - f->write("<dt><tt>"+arg->args*"</tt>\n<dt><tt>"+ - "</tt>\n <dd>"+ - fixdesc(arg->desc,prefix)+"\n"); + if (arg->desc) + f->write("<dt><tt>"+arg->args*"</tt>\n<dt><tt>"+ + "</tt>\n <dd>"+ + fixdesc(arg->desc,prefix)+"\n"); + else + f->write("<dt><tt>"+arg->args*"</tt>\n<dt><tt>"+ + "</tt>\n"); } f->write("</dl></blockquote>\n"); } @@ -290,10 +293,10 @@ void document_method(object(File) f, "\n\n<blockquote>\n"+method->returns+"\n</blockquote>\n"); } - if (method->note) + if (method->note && method->note->desc) { f->write("\n\n<h4>NOTE</h4>\n<blockquote>\n"+ - method->desc+"\n</blockquote>\n"); + fixdesc(method->note->desc,prefix)+"\n</blockquote>\n"); } if (method["see also"]) @@ -324,8 +327,9 @@ void document_class(string title, string *method_names_arr,method_name; mapping method; - foreach (info->methods,method) - method_names|=(method->names=get_method_names(method->decl)); + if (info->methods) + foreach (info->methods,method) + method_names|=(method->names=get_method_names(method->decl)); method_names_arr=sort(indices(method_names)); diff --git a/src/modules/Image/togif.c b/src/modules/Image/togif.c index 24cfe58f027b637b2e5f44964470606fedb8d527..9eaa10599628a2835aee072bd279611e6ac93c06 100644 --- a/src/modules/Image/togif.c +++ b/src/modules/Image/togif.c @@ -4,7 +4,7 @@ togif Pontus Hagland, law@infovav.se -$Id: togif.c,v 1.6 1997/04/03 07:00:43 mirar Exp $ +$Id: togif.c,v 1.7 1997/04/30 01:46:54 mirar Exp $ */ @@ -882,10 +882,27 @@ CHRONO("done"); **! method string gif_add_fs_nomap(int x,int y,array(array(int)) colors,int delay_cs) **! method 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. -**! returns the GIF data +**! at the given position. +**! +**! The "fs" versions uses floyd-steinberg dithering, and the "nomap" +**! versions have no local colormap. +**! +**! Example: +**! <pre> +**! 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... +**! +**! note +**! I (Mirar) recommend reading about the GIF file format before +**! experementing with these. +**! returns the GIF data chunk as a string **! **! arg int x **! arg int y @@ -898,8 +915,7 @@ CHRONO("done"); **! number of colors to quantize to (default is 256) **! arg array array(array(int)) colors **! colors to map to, format is ({({r,g,b}),({r,g,b}),...}). -**! see also: gif_add, gif_end, gif_netscape_loop, togif -*/ +**! see also: gif_add, gif_end, gif_netscape_loop, togif */ void image_gif_add(INT32 args) {