index.html

来自「CA仿真模型中SLEUTH模型」· HTML 代码 · 共 1,606 行 · 第 1/5 页

HTML
1,606
字号
(upper left first, then lower right) specified, using thecolor index specified. <PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	/* Draw a rectangle occupying the central area. */gdImageRectangle(im, 25, 25, 74, 74, white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageFilledPolygon">void gdImageFilledPolygon(gdImagePtr im, gdPointPtr points, int pointsTotal, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageFilledPolygon is used to fill a polygon with the verticies(at least 3) specified, using the color index specified. See also <A HREF="#gdImageFilledPolygon">gdImagePolygon</A>.<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;int red;/* Points of polygon */<A HREF="#gdPoint">gdPoint</A> points[3];im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	/* Allocate the color red. */red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);	/* Draw a triangle. */points[0].x = 50;points[0].y = 0;points[1].x = 99;points[1].y = 99;points[2].x = 0;points[2].y = 99;/* Paint it in white */gdImageFilledPolygon(im, points, 3, white);/* Outline it in red; must be done second */<A HREF="#gdImagePolygon">gdImagePolygon</A>(im, points, 3, red);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageFilledRectangle">void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)</A><STRONG>(FUNCTION)</STRONG> <DD>gdImageFilledRectangle is used to draw a solid rectangle with the two corners(upper left first, then lower right) specified, using thecolor index specified. <PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">int gdImageColorAllocate</A>(im, 255, 255, 255);	/* Draw a filled rectangle occupying the central area. */gdImageFilledRectangle(im, 25, 25, 74, 74, white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageArc">void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)</A><STRONG> (FUNCTION)</STRONG> <DD>gdImageArc is used to draw a partial ellipse centered at the given point,with the specified width and height in pixels. The arc begins atthe position in degrees specified by <code>s</code> and ends atthe position specified by <code>e</code>. The arc is drawn inthe color specified by the last argument. A circle can be drawnby beginning from 0 degrees and ending at 360 degrees, withwidth and height being equal. e must be greater than s. Values greater than 360 are interpreted modulo 360.<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	/* Inscribe an ellipse in the image. */gdImageArc(im, 50, 25, 98, 48, 0, 360, white);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageFillToBorder">void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color)<STRONG> (FUNCTION)</STRONG> <DD>gdImageFillToBorder floods a portion of the image with the specified<code>color</code>, beginning at the specified point and stopping at the specified <code>border</code> color. For a way of flooding anarea defined by the color of the starting point, see<A HREF="#gdImageFill">gdImageFill</A>.<P>The border color <em>cannot</em> be a special colorsuch as <A HREF="#gdTiled">gdTiled</A>; it must be a propersolid color. The fill color can be, however.<P>Note that gdImageFillToBorder is recursive. It is not the mostnaive implementation possible, and the implementation isexpected to improve, but there will always be degeneratecases in which the stack can become very deep. This can bea problem in MSDOS and MS Windows environments. (Of course,in a Unix or NT environment with a proper stack, this isnot a problem at all.)<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;int red;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	/* Allocate the color red. */red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);	/* Inscribe an ellipse in the image. */gdImageArc(im, 50, 25, 98, 48, 0, 360, white);/* Flood-fill the ellipse. Fill color is red, border color is 	white (ellipse). */gdImageFillToBorder(im, 50, 50, white, red);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageFill">void gdImageFill(gdImagePtr im, int x, int y, int color)<STRONG> (FUNCTION)</STRONG> <DD>gdImageFill floods a portion of the image with the specified<code>color</code>, beginning at the specified point and flooding thesurrounding region of the same color as the starting point.For a way of flooding a region defined by a specific bordercolor rather than by its interior color, see<A HREF="#gdImageFillToBorder">gdImageFillToBorder</A>.<P>The fill color can be <A HREF="#gdTiled">gdTiled</A>, resultingin a tile fill using another image as the tile. However,the tile image cannot be transparent. If the image you wishto fill with has a transparent color index, call<A HREF="#gdImageTransparent">gdImageTransparent</A> on thetile image and set the transparent color index to -1 to turn off its transparency.<P>Note that gdImageFill is recursive. It is not the mostnaive implementation possible, and the implementation isexpected to improve, but there will always be degeneratecases in which the stack can become very deep. This can bea problem in MSDOS and MS Windows environments. (Of course,in a Unix or NT environment with a proper stack, this isnot a problem at all.)<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im;int black;int white;int red;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	/* Allocate the color white (red, green and blue all maximum). */white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	/* Allocate the color red. */red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);	/* Inscribe an ellipse in the image. */gdImageArc(im, 50, 25, 98, 48, 0, 360, white);/* Flood-fill the ellipse. Fill color is red, and will replace the	black interior of the ellipse. */gdImageFill(im, 50, 50, red);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);</PRE><DT><A NAME="gdImageSetBrush">void gdImageSetBrush(gdImagePtr im, gdImagePtr brush)</A><STRONG>(FUNCTION)</STRONG> <DD>A "brush" is an image used to draw wide, shaped strokes in another image. Justas a paintbrush is not a single point, a brush image need not bea single pixel. <em>Any</em> gd image can be used as a brush, and bysetting the transparent color index of the brush image with<A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>,a brush of any shape can be created. All line-drawing functions,such as <A HREF="#gdImageLine">gdImageLine</A> and<A HREF="#gdImagePolygon">gdImagePolygon</A>, will use thecurrent brush if the special "color" <A HREF="#gdBrushed">gdBrushed</A> or <A HREF="#gdStyledBrushed">gdStyledBrushed</A>is used when calling them.<P>gdImageSetBrush is used to specify the brush to be used in aparticular image. You can set any image to be the brush.If the brush image does not have the same color map as thefirst image, any colors missing from the first imagewill be allocated. If not enough colors can be allocated,the closest colors already available will be used. Thisallows arbitrary GIFs to be used as brush images. It alsomeans, however, that you should not set a brush unless youwill actually use it; if you set a rapid succession ofdifferent brush images, you can quickly fill your color map,and the results will not be optimal.<P>You need not take any special action when you are finishedwith a brush. As for any other image, if you will notbe using the brush image for any further purpose,you should call <A HREF="#gdImageDestroy">gdImageDestroy</A>.You must not use the color <A HREF="#gdBrushed">gdBrushed</A>if the current brush has been destroyed; you can ofcourse set a new brush to replace it.<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im, brush;FILE *in;int black;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Open the brush GIF. For best results, portions of the	brush that should be transparent (ie, not part of the	brush shape) should have the transparent color index. */in = fopen("star.gif", "rb");brush = <A HREF="#gdImageCreateFromGif">gdImageCreateFromGif</A>(in);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	gdImageSetBrush(im, brush);/* Draw a line from the upper left corner to the lower right corner	using the brush. */<A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdBrushed">gdBrushed</A>);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);/* Destroy the brush image */<A HREF="#gdImageDestroy">gdImageDestroy</A>(brush);</PRE><DT><A NAME="gdImageSetTile">void gdImageSetTile(gdImagePtr im, gdImagePtr tile)</A><STRONG>(FUNCTION)</STRONG> <DD>A "tile" is an image used to fill an area with  a repeated pattern.<em>Any</em> gd image can be used as a tile, and bysetting the transparent color index of the tile image with<A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>,a tile that allows certain parts of the underlying area to shinethrough can be created. All region-filling functions,such as <A HREF="#gdImageFill">gdImageFill</A> and<A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>, will use thecurrent tile if the special "color" <A HREF="#gdTiled">gdTiled</A> is used when calling them.<P>gdImageSetTile is used to specify the tile to be used in aparticular image. You can set any image to be the tile.If the tile image does not have the same color map as thefirst image, any colors missing from the first imagewill be allocated. If not enough colors can be allocated,the closest colors already available will be used. Thisallows arbitrary GIFs to be used as tile images. It alsomeans, however, that you should not set a tile unless youwill actually use it; if you set a rapid succession ofdifferent tile images, you can quickly fill your color map,and the results will not be optimal.<P>You need not take any special action when you are finishedwith a tile. As for any other image, if you will notbe using the tile image for any further purpose,you should call <A HREF="#gdImageDestroy">gdImageDestroy</A>.You must not use the color <A HREF="#gdBrushed">gdTiled</A>if the current tile has been destroyed; you can ofcourse set a new tile to replace it.<PRE>... inside a function ...<A HREF="#gdImagePtr">gdImagePtr</A> im, tile;FILE *in;int black;im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);/* Open the tile GIF. For best results, portions of the	tile that should be transparent (ie, allowing the	background to shine through) should have the transparent 	color index. */in = fopen("star.gif", "rb");tile = <A HREF="#gdImageCreateFromGif">gdImageCreateFromGif</A>(in);/* Background color (first allocated) */black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);	gdImageSetTile(im, tile);/* Fill an area using the tile. */<A HREF="#gdImageFilledRectangle">gdImageFilledRectangle</A>(im, 25, 25, 75, 75, <A HREF="#gdTiled">gdTiled</A>);/* ... Do something with the image, such as saving it to a file... *//* Destroy it */<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);/* Destroy the tile image */<A HREF="#gdImageDestroy">gdImageDestroy</A>(tile);</PRE><DT><A NAME="gdImageSetStyle">void gdImageSetStyle(gdImagePtr im, int *style, int styleLength)</A><STRONG>(FUNCTION)</STRONG> <DD>It is often desirable to draw dashed lines, dotted lines, and othervariations on a broken line. gdImageSetStyle can be used to setany desired series of colors, including a special color thatleaves the background intact, to be repeated during the drawingof a line. <P>To use gdImageSetStyle, create an array of integers and assignthem the desired series of color values to be repeated. You can assign the special color value <A HREF="#gdTransparent">gdTransparent</A> to indicate that the existing color shouldbe left unchanged for that particular pixel (allowing a dashedline to be attractively drawn over an existing image). <P>Then, to draw a line using the style, use the normal

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?