From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- html/en/func/attributes.html | 49 ++++++++ html/en/func/client.html | 255 +++++++++++++++++++++++++++++++++++++++ html/en/func/clipping.html | 62 ++++++++++ html/en/func/color.html | 137 +++++++++++++++++++++ html/en/func/control.html | 63 ++++++++++ html/en/func/coordinates.html | 148 +++++++++++++++++++++++ html/en/func/filled.html | 272 ++++++++++++++++++++++++++++++++++++++++++ html/en/func/init.html | 225 ++++++++++++++++++++++++++++++++++ html/en/func/lines.html | 147 +++++++++++++++++++++++ html/en/func/marks.html | 85 +++++++++++++ html/en/func/other.html | 119 ++++++++++++++++++ html/en/func/polygon.html | 87 ++++++++++++++ html/en/func/region.html | 83 +++++++++++++ html/en/func/server.html | 84 +++++++++++++ html/en/func/text.html | 192 +++++++++++++++++++++++++++++ html/en/func/vectortext.html | 133 +++++++++++++++++++++ html/en/func/wd.html | 80 +++++++++++++ 17 files changed, 2221 insertions(+) create mode 100644 html/en/func/attributes.html create mode 100644 html/en/func/client.html create mode 100644 html/en/func/clipping.html create mode 100644 html/en/func/color.html create mode 100644 html/en/func/control.html create mode 100644 html/en/func/coordinates.html create mode 100644 html/en/func/filled.html create mode 100644 html/en/func/init.html create mode 100644 html/en/func/lines.html create mode 100644 html/en/func/marks.html create mode 100644 html/en/func/other.html create mode 100644 html/en/func/polygon.html create mode 100644 html/en/func/region.html create mode 100644 html/en/func/server.html create mode 100644 html/en/func/text.html create mode 100644 html/en/func/vectortext.html create mode 100644 html/en/func/wd.html (limited to 'html/en/func') diff --git a/html/en/func/attributes.html b/html/en/func/attributes.html new file mode 100644 index 0000000..60768e4 --- /dev/null +++ b/html/en/func/attributes.html @@ -0,0 +1,49 @@ + + + + General Attributes + + + + + +

General Attributes

+
long int cdCanvasForeground(cdCanvas* canvas, long int color); [in C]
+void cdCanvasSetForeground(cdCanvas* canvas, long int color); [in C]
+
+canvas:Foreground(color: lightuserdata) -> (old_color: lightuserdata) [in Lua]
+canvas:SetForeground(color: lightuserdata) [in Lua]
+

Configures a new current foreground color and returns the previous one. This + color is used in all primitives (lines, areas, marks and text). Default value: + CD_BLACK. Value CD_QUERY simply returns the + current value.

+

Notice that CD_QUERY conflicts with color RGBA=(255,255,255,255) (full + transparent white). Use SetForeground to avoid the + conflict. See also Color Coding.

+
long int cdCanvasBackground(cdCanvas* canvas, long int color); [in C]
+void cdCanvasSetBackground(cdCanvas* canvas, long int color); [in C]
+
+canvas:Background(color: lightuserdata) -> (old_color: lightuserdata) [in Lua]
+canvas:SetBackground(color: lightuserdata) [in Lua]
+

Configures the new current background color and returns the previous one. + However, it does not automatically change the background of a canvas. For such, + it is necessary to call the Clear function. The + background color only makes sense for Clear and for + primitives affected by the background opacity attribute. Default value: CD_WHITE. + Value CD_QUERY simply returns the current value.

+

Notice that CD_QUERY conflicts with color RGBA=(255,255,255,255) (full + transparent white). Use SetBackground to avoid the + conflict. See also Color Coding.

+
int cdCanvasWriteMode(cdCanvas* canvas, int mode); [in C]
+
+canvas:WriteMode(mode: number) -> (old_mode: number) [in Lua]
+

Defines the writing type for all drawing primitives. Values: CD_REPLACE, + CD_XOR or CD_NOT_XOR. Returns the previous + value. Default value: CD_REPLACE. Value CD_QUERY + simply returns the current value. +

+

Note: operation XOR is very useful, because, using white as the foreground + color and drawing the same image twice, you can go back to the original color, + before the drawing. This is commonly used for mouse selection feedback.

+ + diff --git a/html/en/func/client.html b/html/en/func/client.html new file mode 100644 index 0000000..20a6c4e --- /dev/null +++ b/html/en/func/client.html @@ -0,0 +1,255 @@ + + + + Client Images + + + + + +

Client Images

+

There are 2 kinds of client images: RGB and Indexed RGB (or MAP). The RGB + image is composed by 3 buffers: red, green and blue (more colors, more memory). + The MAP image is composed by 1 buffer of indices for a table and one table of + encoded RGB values (less colors, less memory). +

+

The image buffer is described by its width and height in pixels. The starting + point of the buffer is the origin of the image, which is located at its bottom + left corner. To retrieve a pixel in the image, use the formula pixel(x,y)=buffer[y*width + + x]. +

+

The Put functions may do zoom in or out; zero order interpolation is used to + scale the image. It is not possible to specify a part of the image to be drawn.

+
+
void cdCanvasGetImageRGB(cdCanvas* canvas, unsigned char *r, 
+                   unsigned char *g, 
+                   unsigned char *b, 
+                   int x, int y, int w, int h); [in C]
+
+canvas:GetImageRGB(imagergb: cdImageRGB; x, y: number) [in Lua]
+

Returns the red, green and blue components of each pixel in a server image. + The RGB components are provided in three matrices stored as byte arrays. The + (i,j) component of these matrices is at the address + (j*w+i). As occurs with all primitives from the Canvas Draw + library, the pixel (0,0) is at the bottom left + corner, and the pixel (w-1,h-1) is that the upper + right corner of the image rectangle.

+
void cdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, 
+                       const unsigned char *r, 
+                       const unsigned char *g, 
+                       const unsigned char *b, 
+                       int x, int y, int w, int h, 
+                       int xmin, int xmax, int ymin, int ymax); [in C]
+void wdCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, 
+                       const unsigned char *r, 
+                       const unsigned char *g, 
+                       const unsigned char *b, 
+                       double x, double y, double w, double h, 
+                       int xmin, int xmax, int ymin, int ymax); (WC) [in C]
+
+canvas:PutImageRectRGB(imagergb: cdImageRGB; x, y, w, h, xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wPutImageRectRGB(imagergb: cdImageRGB; x, y, w, h, xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+

Puts, in a specified area of the canvas, an image with its red, green and blue + components defined in the three matrices stored in byte arrays. The (i,j) + component of these matrices is at the address (j*iw+i). + The pixel (0,0) is at the bottom left corner, and the + pixel (iw-1,ih-1) is that the upper right corner of + the image rectangle. +

+

Parameters w and h + refer to the target rectangle of the canvas, so that it is possible to reduce + or expand the image drawn. If w and h + are 0, the size of the image is assumed (iw and + ih). +

+

It also allows specifying a rectangle inside the image to be drawn, if + xmin, xmax, ymin and ymax + are 0 then the whole image is assumed. +

+

If the driver has bpp <=8 or only 256 colors or less, then the image is + converted to 256 optimal colors using the function cdRGB2Map + and is drawn using cdPutImageRectMap.

+
void cdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, 
+                        const unsigned char *r, 
+                        const unsigned char *g, 
+                        const unsigned char *b, 
+                        const unsigned char *a, 
+                        int x, int y, int w, int h, 
+                        int xmin, int xmax, int ymin, int ymax); [in C]
+void wdCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih, 
+                        const unsigned char *r, 
+                        const unsigned char *g, 
+                        const unsigned char *b, 
+                        const unsigned char *a, 
+                        double x, double y, double w, double h, 
+                        int xmin, int xmax, int ymin, int ymax); (WC) [in C]
+
+canvas:PutImageRectRGBA(imagergba: cdImageRGBA; x, y, w, h, xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wPutImageRectRGBA(imagergba: cdImageRGBA; x, y, w, h, xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+

The same as function  cdPutImageRectRGB, + except for the fact that it is possible to specify an alpha channel. The + resulting color is the image color weighted by the alpha value, using the + formula result=(source * alpha + destiny * (255 - alpha))/255. + This means that, if alpha is 0, the resulting color is the target color + (completely transparent), and, if alpha is 255, the resulting color is the + original image color (completely opaque).

+

If this function is not defined for a given driver or if alpha is NULL, + then the function cdPutImageRectRGB is used, as + long as it is defined.

+
void cdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, 
+                       const unsigned char *index, 
+                       const long int *colors, 
+                       int x, int y, int w, int h, 
+                       int xmin, int xmax, int ymin, int ymax); [in C]
+void wdCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih, 
+                       const unsigned char *index, 
+                       const long int *colors, 
+                       double x, double y, double w, double h, 
+                       int xmin, int xmax, int ymin, int ymax); (WC) [in C]
+
+canvas:PutImageRectMap(imagemap: cdImageMap; palette: cdPalette; x, y, w, h, xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wPutImageRectMap(imagemap: cdImageMap; palette: cdPalette; x, y, w, h, xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+

The same as function  cdPutImageRectRGB, + except for the fact that the colors are provided by means of an index matrix + (map). The color corresponding to a given index is given in  colors[index]. + The map is also a matrix stored as a byte vector. If the color vector is null, + then a vector with 256 gray tones is assumed.

+
void cdRGB2Map(int iw, int ih, 
+               const unsigned char *r, 
+               const unsigned char *g, 
+               const unsigned char *b, 
+               unsigned char *index, 
+               int pal_size, long *color); [in C]
+
+cd.RGB2Map(imagergb: cdImageRGB, imagemap: cdImageMap, palette: cdPalette) [in Lua]
+

Converts an RGB image into an image with 256 indexed colors. The resulting + image must have the same size (width x length) as the RGB image. It is + necessary to allocate memory for the arrays map and + colors. This is the same algorithm used in the IM + library - in fact, the same code.

+

Extras

+

The following functions are used only for encapsulating the several types of + client images from the library in a single structure, simplifying their + treatment. 

+

For such, a public structure was created, called cdBitmap, + which will store the image. From this structure, the following fields are + officially defined:

+
cdBitmap:
+  int w      /* image width */
+  int h      /* image heigth */
+  int type   /* image type: CD_RGBA, CD_RGB or CD_MAP */
+
cdBitmap* cdCreateBitmap(int w, int h, int type); [in C]
+
+cd.CreateBitmap(w, h, type: number) -> (bitmap: cdBitmap) [in Lua]
+

Creates an image with width w, and height h and + of type type. The type can be CD_RGBA, CD_RGB or CD_MAP. + However, CD_MAP only means that the image will have 256 colors if + type is greater than 0. It is assumed that the image will be MAP + with the same number of colors in the palette as type. + Internally, the color palette is always allocated with 256 entries, which may + or may not be totally fulfilled. In this case, the value of type + can be changed as wished.

+
cdBitmap* cdInitBitmap(int w, int h, int type, ...); [in C]
+
+[There is no equivalent in Lua]
+

Similar to cdCreateBitmap, but it accepts the + data area already allocated by the user. The parameters vary according to the + image type.

+
CD_RGBA - (unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha)
+CD_RGB - (unsigned char* red, unsigned char* green, unsigned char* blue)
+CD_MAP - (unsigned char* index, lont int* colors)
+
void cdKillBitmap(cdBitmap* image); [in C]
+
+cd.KillBitmap(bitmap: cdBitmap) [in Lua]
+

Liberates the memory allocated for the image. If this function is not + called in Lua, the garbage collector will call it.

+
unsigned char* cdBitmapGetData(cdBitmap* image, int dataptr); [in C]
+
+cd.BitmapGetData(bitmap: cdBitmap; dataptr: number) -> (data: cdImageChannel) [in Lua]
+

Returns a pointer to the image's data area according to dataptr. + The following values are defined for dataptr:

+
CD_IRED - red component of an RGB image. cdImageChannel in Lua.
+CD_IGREEN - green component of an RGB image. cdImageChannel in Lua.
+CD_IBLUE - blue component of an RGB image. cdImageChannel in Lua.
+CD_IALPHA - alpha component of an RGBA image. cdImageChannel in Lua.
+CD_INDEX - indices of a MAP image. cdImageChannel in Lua.
+CD_COLORS - color table of a MAP image. In this case, a type conversion must be made to (long int*).  cdPalette in Lua.
+

In Lua, channels are also available as tables, see Data + Access.  +

+
void cdBitmapSetRect(cdBitmap* image, int xmin, int xmax, int ymin, int ymax); [in C]
+
+cd.BitmapSetRect(bitmap: cdBitmap; xmin, xmax, ymin, ymax: number) [in Lua]
+

Allows specifying a region of interest inside the image to be used by the + function cdPutBitmap. If no region was defined, the whole + image is used, that is, (0, w-1, 0, h-1).

+
void cdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* image, int x, int y, int w, int h); [in C]
+void wdCanvasPutBitmap(cdCanvas* canvas, cdBitmap* image, double x, double y, double w, double h); (WC) [in C]
+
+canvas:PutBitmap(image: cdBitmap; x, y, w, h: number) [in Lua]
+canvas:wPutBitmap(bitmap: cdBitmap; x, y, w, h: number) (WC) [in Lua]
+

Draws the  image in the position (x,y), changing the scale. It + encapsulates cdPutImageRectRGB, cdPutImageRectRGBA + and cdPutImageRectMap. The region of the image + drawn depends on the rectangle defined by cdBitmapSetRect. + If no rectangle was defined, then the whole image is used.

+

The parameters w and h allow scaling the + image, increasing or decreasing its dimensions when drawn. If  w + and/or h are 0, then no scale change is assumed. +

+
void cdCanvasGetBitmap(cdCanvas* canvas, cdBitmap* image, int x, int y); [in C]
+
+canvas:GetBitmap(bitmap: cdBitmap; x, y: number) [in Lua]
+

Encapsulates cdGetImageRGB. Nothing happens if + the image is MAP.

+
void cdBitmapRGB2Map(cdBitmap* image_rgb, cdBitmap* image_map); [in C]
+
+cd.BitmapRGB2Map(bitmap_rgb: cdBitmap, bitmap_map: cdBitmap) [in Lua]
+

Encapsulates cdRGB2Map. The images must be of + types RGB(A) and MAP, respectively.

+

Extras in Lua (Deprecated)

+
cd.CreateImageRGB(width, height: number) -> (imagergb: cdImageRGB)
+

Creates an RGB image in Lua. Deprecated use cd.CreateBitmap.

+
cd.KillImageRGB(imagergb: cdImageRGB)
+

Destroys the created RGB image and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it. Deprecated use + cd.KillBitmap.

+
cd.CreateImageRGBA(width, height: number) -> (imagergba: cdImageRGBA)
+

Creates an RGBA image in Lua. Deprecated use cd.CreateBitmap.

+
cd.KillImageRGBA(imagergba: cdImageRGBA)
+

Destroys the created RGBA image and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it. Deprecated use + cd.KillBitmap.

+
cd.CreateImageMap(width, height: number) -> (imagemap: cdImageMap)
+

Creates a Map image in Lua. Deprecated use cd.CreateBitmap.

+
cd.KillImageMap(imagemap: cdImageMap)
+

Destroys the created Map image and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it. Deprecated use + cd.KillBitmap.

+

Data Access

+

Data access in Lua is done directly using the operator "[y*width + x]" + in image channels. Each channel works as a value table which should be + consulted or modified in the following way:

+
image = cd.CreateBitmap(100, 200)
+...
+image.r[y*100 + x] = 255
+image.g[y*100 + x] = 128
+image.b[y*100 + x] = 0
+...
+green = image.g[y*100 + x] -- it will return 128
+

The order of the tables is important, so that image[n].r + has no meaning to CDLua and the expression will cause an error. Finally, + the user could expect the value of image[n] to be of type + lightuserdata. Unfortunately, this is not the case, and such expression + will cause the same error.

+

In the old cdImageMap images, the channel must be not + specified: imagemap[y*100+x].

+

Known channel names are:

+
r - red channel of RGB or RGBA images.
+g - gree channel of RGB or RGBA images.
+b - blue channel of RGB or RGBA images.
+a - alpha channel of RGBA images.
+m - indices channel of MAP images (valid only for cdBitmap objects).
+p - colors table of MAP images (valid only for cdBitmap objects). It is a cdPalette object.
+ + \ No newline at end of file diff --git a/html/en/func/clipping.html b/html/en/func/clipping.html new file mode 100644 index 0000000..b30db55 --- /dev/null +++ b/html/en/func/clipping.html @@ -0,0 +1,62 @@ + + + + Clipping + + + + + +

Clipping

+

The clipping area is an area that limits the available drawing area inside the + canvas. Any primitive is drawn only inside the clipping area. It affects all + primitives.

+

You can set the clipping area by using the function cdClipArea, and + retrieve it using cdGetClipArea. The clipping area is a rectangle by + default, but it can has other shapes. In some drivers a polygon area can be + defined, and in display based drivers a complex region can be defined. The + complex region can be a combination of boxes, polygons, sectors, chords and + texts.

+

The cdClip function activates and deactivaes the clipping.

+
+
int cdCanvasClip(cdCanvas* canvas, int mode); [in C]
+
+canvas:Clip(mode: number) -> (old_mode: number) [in Lua]
+

Activates or deactivates clipping. Returns the previous status. Values: CD_CLIPAREA, + CD_CLIPPOLYGON, CD_CLIPREGION or CD_CLIPOFF. The value CD_QUERY + simply returns the current status. Default value: CD_CLIPOFF.

+

The value CD_CLIPAREA activates a rectangular area as the clipping + region. +

+

The value CD_CLIPPOLYGON activates a polygon as a clipping region, but + works only in some drivers (please refer to the notes of each driver). The + clipping polygon must be defined before activating the polygon clipping; if it + is not defined, the current clipping state remains unchanged. See the + documentation of cdBegin/cdVertex/cdEnd to create a + polygon.

+

The value CD_CLIPREGION activates a complex clipping region. See the + documentation of Regions.

+
void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]
+void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C]
+void wdCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); (WC) [in C]
+
+canvas:ClipArea(xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wClipArea(xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+

Defines a rectangle for clipping. Only the points in the interval xmin<= + x <= xmax and ymin <= y <= ymax will + be printed. Default region: (0, w-1, 0, h-1). +

+
int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); [in C]
+int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); [in C]
+int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C]
+
+canvas:GetClipArea() -> (xmin, xmax, ymin, ymax, status: number) [in Lua]
+canvas:wGetClipArea() -> (xmin, xmax, ymin, ymax, status: number) (WC) [in Lua]
+

Returns the rectangle and the clipping status. It is not necessary to provide + all return pointers, you can provide only the desired values and NULL + for the others.

+

Polygons

+

A polygon for clipping can be created using cdBegin(CD_CLIP)/cdVertex(x,y)/.../cdEnd().

+

See the documentation of cdBegin/cdVertex/cdEnd.

+ + diff --git a/html/en/func/color.html b/html/en/func/color.html new file mode 100644 index 0000000..9ec9928 --- /dev/null +++ b/html/en/func/color.html @@ -0,0 +1,137 @@ + + + + Color Coding + + + + + +

Color Coding

+

The library's color system is RGB. In order to simplify some functions, a + compact representation was created for the 3 values. To make a conversion from + this representation to the 3 separate values and vice-versa, use functions + cdDecodeColor + and cdEncodeColor. +

+

When the canvas used does not support more than 8 bpp of color resolution, you + can use function Palette to give the driver an idea of which + colors to prioritize. Palette's behavior is driver dependent.

+

There are some predefined colors:

+
CD_RED          = (255,  0,  0)
+CD_DARK_RED     = (128,  0,  0)
+CD_GREEN        = (0  ,255,  0)
+CD_DARK_GREEN   = (  0,128,  0)
+CD_BLUE         = (  0,  0,255)
+CD_DARK_BLUE    = (  0,  0,128)
+CD_YELLOW       = (255,255,  0)
+CD_DARK_YELLOW  = (128,128,  0)
+CD_MAGENTA      = (255,  0,255)
+CD_DARK_MAGENTA = (128,  0,128)
+CD_CYAN         = (  0,255,255)
+CD_DARK_CYAN    = (  0,128,128)
+CD_WHITE        = (255,255,255)
+CD_BLACK        = (  0,  0 , 0)
+CD_DARK_GRAY    = (128,128,128)
+CD_GRAY         = (192,192,192)
+
+
+
long int cdEncodeColor(unsigned char red, unsigned char green, unsigned char blue) [in C]
+
+cd.EncodeColor(r, g, b: number) -> (old_color: lightuserdata) [in Lua]
+

Returns a codified triple (r,g,b) in a long integer such as 0x00RRGGBB, + where RR are the red components, GG are the + green ones and BB are the blue ones. The code is used in the CD + library to define colors. It can be used without an active canvas.

+
void cdDecodeColor(long int color, unsigned char *red, unsigned char *green, unsigned char *blue) [in C]
+
+cd.DecodeColor(color: lightuserdata) -> (r, g, b: number) [in Lua]
+

Returns the red, green and blue components of a color in the CD library. Can + be used without an active canvas.

+
long int cdEncodeAlpha(long int color, unsigned char alpha) [in C]
+
+cd.EncodeAlpha(color: lightuserdata, alpha: number) -> (color: lightuserdata) [in Lua]
+

Returns the given color coded with the alpha information. ATENTION: At the + moment only the Win32 with GDI+ and the IMAGERGB drivers support alpha + components in color coding. Se in Windows Using + GDI+ Base Driver and IMAGERGB driver. The + internal representation of the component is inverted, because the default value + must be 0 and opaque for backward compatibility, so you should use the cdDecodeAlpha + function ot the cdAlpha macro to retrieve the alpha component.

+
unsigned char cdDecodeAlpha(long int color) [in C]
+
+cd.DecodeAlpha(color: lightuserdata) -> (a: number) [in Lua]
+

Returns the alpha component of a color in the CD library. Can be used without + an active canvas. 0 is transparent, 255 is opaque.

+
unsigned char cdAlpha(long int color); [in C]
+
+cd.Alpha(color: lightuserdata) -> (r: number) [in Lua]
+

Macro that returns the alpha component of a color in the CD library. Can be + used without an active canvas.

+
unsigned char cdRed(long int color); [in C]
+
+cd.Red(color: lightuserdata) -> (r: number) [in Lua]
+

Macro that returns the red component of a color in the CD library. Can be used + without an active canvas.

+
unsigned char cdGreen(long int color); [in C]
+
+cd.Green(color: lightuserdata) -> (g: number) [in Lua]
+

Macro that returns the green component of a color in the CD library. Can be + used without an active canvas.

+
unsigned char cdBlue(long int color); [in C]
+
+cd.Blue(color: lightuserdata) -> (b: number) [in Lua]
+

Macro that returns the blue component of a color in the CD library. Can be + used without an active canvas.

+
+
int cdCanvasGetColorPlanes(cdCanvas* canvas); [in C]
+
+canvas:GetColorPlanes() -> (bpp: number) [in Lua]
+

Returns a given number, for instance p, which defines the number of + colors supported by the current device as 2p, representing + the number of bits by pixel. +

+
void cdCanvasPalette(cdCanvas* canvas, int n, const long int *color, int mode); [in C]
+
+canvas:Palette(palette: cdPalette; mode: number) [in Lua]
+

In systems limited to 256 palette colors, this function aims at adding  + n colors to the system's palette. In such systems, the colors + demanded forward or backward which are not in the palette are approximated to + the closest available color. The type can be CD_FORCE or CD_POLITE. + CD_FORCE ignores the system colors and interface elements, + since the menus and dialogues may be in illegible colors, but there will be + more colors available. CD_POLITE is the recommended type. It + must always be used before drawing. It cannot be queried.

+ +

Palette

+ +
cd.CreatePalette(size: number) -> (palette: cdPalette) [in Lua Only]
+

Creates a palette.

+
cd.KillPalette(palette: cdPalette) [in Lua Only]
+

Destroys the created palette and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it.

+ +

Palette Data Access

+ +

Data access in Lua is done directly using the array access operators. The + colors can have their values checked or changed directly as if they + were Lua tables:

+ +
palette[index] = cd.EncodeColor(r, g, b)
+count = #palette
+...
+color = palette[index]
+r, g, b = cd.DecodeColor(color)
+ +

Notice that the type of value returned or received by + palette[index] is a + lightuserdata, the same type used with functions + cdEncodeColor, + cdDecodeColor, + cdPixel, + cdForeground + and cdBackground.

+ + + + \ No newline at end of file diff --git a/html/en/func/control.html b/html/en/func/control.html new file mode 100644 index 0000000..5ccdd1c --- /dev/null +++ b/html/en/func/control.html @@ -0,0 +1,63 @@ + + + + Canvas Control + + + + + +

Canvas Control

+
void cdCanvasClear(cdCanvas* canvas); [in C]
+
+canvas:Clear() [in Lua]
+

Cleans the active canvas using the current background color. This action is + interpreted very differently by each driver. Many drivers simply draw a + rectangle with the current background color. It is NOT necessary to call cdClear + when the canvas has just been created, as at this moment it is already clean. + Most file-based drivers do not implement this function.

+
void cdCanvasFlush(cdCanvas* canvas); [in C]
+    
+canvas:Flush() [in Lua]
+

Has a different meaning for each driver. It is useful to send information to + buffered devices and to move to a new page or layer. In all cases, the current + canvas attributes are preserved.

+
+
cdState* cdCanvasSaveState(cdCanvas* canvas); [in C]
+    
+canvas:SaveState() -> (state: cdState) [in Lua]
+

Saves the state of attributes of the active canvas. It does not save cdPlay + callbacks, polygon creation states (begin/vertex/vertex/...), the palette, + complex clipping regions and driver internal attributes.

+
void cdCanvasRestoreState(cdCanvas* canvas, cdState* state); [in C]
+    
+canvas:RestoreState(state: cdState) [in Lua]
+

Restores the attribute state of the active canvas. It can be used between + canvases of different contexts. It can be used several times for the same + state.

+
void cdReleaseState(cdState* state); [in C]
+
+cd.ReleaseState(state: cdState) [in Lua]
+

Releases the memory allocated by the cdSaveState + function. If this function is not called in Lua, the garbage collector + will call it.

+
+
void cdCanvasSetAttribute(cdCanvas* canvas, const char* name, char* data); [in C]
+    
+canvas:SetAttribute(name, data: string) [in Lua]
+

Modifies a custom attribute directly in the driver of the active canvas. If + the driver does not have this attribute, the call is ignored.

+
void cdCanvasSetfAttribute(cdCanvas* canvas, const char* name, const char* format, ...); [in C]
+    
+[There is no equivalent in Lua]
+

Same as cdSetAttribute, used for the case in + which the parameter data is a string composed by several + parameters. It can be  used with parameters equivalent to those of the + printf function from the standard C library.

+
char* cdCanvasGetAttribute(cdCanvas* canvas, const char* name); [in C]
+    
+canvas:SetAttribute(name: string) -> (data: string) [in Lua]
+

Returns a custom attribute from the driver of the active canvas. If the driver + does not have this attribute, it returns NULL.

+ + \ No newline at end of file diff --git a/html/en/func/coordinates.html b/html/en/func/coordinates.html new file mode 100644 index 0000000..9f119bb --- /dev/null +++ b/html/en/func/coordinates.html @@ -0,0 +1,148 @@ + + + + + + +Coordinate System + + + + + +

Coordinate System

+
void cdCanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm); [in C]
+
+canvas:GetSize() -> (width, height, mm_width, mm_height: number) [in Lua]
+ +

Returns the canvas size in pixels and in millimeters. You can provide only + the desired values and NULL for the others.

+ +
int cdCanvasUpdateYAxis(cdCanvas* canvas, int *y); [in C]
+double cdfCanvasUpdateYAxis(cdCanvas* canvas, double *y); [in C]
+int cdCanvasInvertYAxis(cdCanvas* canvas, int y); [in C]
+double cdfCanvasInvertYAxis(cdCanvas* canvas, double y); [in C]
+
+canvas:UpdateYAxis(yc: number) -> (yr: number) [in Lua]
+canvas:InvertYAxis(yc: number) -> (yr: number) [in Lua]
+ +

In some graph systems, the origin is at the upper left corner of the + canvas, with the direction of the Y axis pointing down. In this case, the + function converts the coordinate system of the CD library into the internal + system of the active canvas' driver, and the other way round. If this is not + the case, nothing happens. This is just "y = height-1 - + y". It returns the changed value. The "Invert" will always invert + the given value, the "Update" function will invert only if the canvas has the + Y axis inverted.

+ +
void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy); [in C]
+void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy); [in C]
+
+canvas:MM2Pixel(mm_dx, mm_dy: number) -> (dx, dy: number) [in Lua]
+canvas:fMM2Pixel(mm_dx, mm_dy: number) -> (dx, dy: number) [in Lua]
+ +

Converts sizes in millimeters into pixels (canvas coordinates). You can + provide only the desired values and NULL for the + others.

+ +
void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy); [in C]
+void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy); [in C]
+
+canvas:Pixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]
+canvas:fPixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]
+ +

Converts sizes in pixels (canvas coordinates) into millimeters. You can + provide only the desired values and NULL for the + others. Use this function to obtain the horizontal and vertical resolution of + the canvas by passing 1 as parameter in dx and + dy. The resolution value is obtained using the + formula res=1.0/mm.

+ +
void cdCanvasOrigin(cdCanvas* canvas, int x, int y); [in C]
+void cdfCanvasOrigin(cdCanvas* canvas, double x, double y); [in C]
+
+canvas:Origin(x, y: number) [in Lua]
+canvas:fOrigin(x, y: number) [in Lua]
+ +

Allows translating the origin - for instance, to the center of the canvas. + The function profits from the architecture of the library to simulate a + translation of the origin, which in fact is never actually passed to the + canvas in the respective driver. Default values: (0, 0)

+ + +
void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y); [in C]
+void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y); [in C]
+
+canvas:GetOrigin() -> (x, y: number) [in Lua]
+canvas:fGetOrigin() -> (x, y: number) [in Lua]
+ +

Returns the origin.

+ + +

Transformation Matrix

+ +
void cdCanvasTransform(cdCanvas* canvas, const double* matrix); [in C]
+
+canvas:Transform(matrix: table) [in Lua]
+ +

Defines a transformation matrix with 6 elements. If the matrix is NULL, + the + transformation is reset to the identity. Default value: NULL.

+

The matrix contains scale, rotation and translation elements as follows:

+
|x'|   |sx*cos(angle)    -sin(angle)  dx|   |x|                     |0   2   4| 
+|y'| = |   sin(angle)  sy*cos(angle)  dy| * |y|      with indices   |1   3   5|
+                                            |1|
+

But notice that the indices are different of the + cdCanvasVectorTextTransform.

+

Functions that retrieve images from the canvas are not affected by the +transformation matrix, such as GetImage, GetImageRGB +and ScrollArea.

+

Transformation matrix is independent of the World Coordinate +and Origin +functions. And those are affected if a transformation is set, just like other +regular primitives.

+ + +
double* cdCanvasGetTransform(cdCanvas* canvas); [in C]
+
+canvas:GetTransformation() -> (matrix: table) [in Lua]
+ +

Returns the transformation matrix. If the identity is set, returns NULL.

+ + +
void cdCanvasTransforMultiply(cdCanvas* canvas, const double* matrix); [in C]
+
+canvas:TransformMultiply(matrix: table) [in Lua]
+ +

Left multiply the current transformation by the given transformation.

+ +
void cdCanvasTransformTranslate(cdCanvas* canvas, double dx, double dy); [in C]
+
+canvas:TransformTranslate(dx, dy: number) [in Lua]
+ +

Applies a translation to the current transformation.

+ +
void cdCanvasTransformScale(cdCanvas* canvas, double sx, double sy); [in C]
+
+canvas:TransformScale(sx, sy: number) [in Lua]
+ +

Applies a scale to the current transformation.

+ +
void cdCanvasTransformRotate(cdCanvas* canvas, double angle); [in C]
+
+canvas:TransformRotate(angle: number) [in Lua]
+ +

Applies a rotation to the current transformation. Angle is in degrees, + oriented counter-clockwise from the horizontal axis.

+ +
void cdCanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty); [in C]
+void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty); [in C]
+
+canvas:TransformPoint(x, y: number) -> (tx, ty: number) [in Lua]
+canvas:fTransformPoint(x, y: number) -> (tx, ty: number) [in Lua]
+ +

Applies a transformation to a given point.

+ + + + \ No newline at end of file diff --git a/html/en/func/filled.html b/html/en/func/filled.html new file mode 100644 index 0000000..2ae1083 --- /dev/null +++ b/html/en/func/filled.html @@ -0,0 +1,272 @@ + + + + + + +Filled Areas + + + + + +

Filled Areas

+ +

It is an area filled with the foreground color, but it depends on the + current interior style. The SOLID style + depends only on the foreground color. The HATCH + and + STIPPLE style depend on the foreground color, background color and on the back opacity attribute. The + hatch lines drawn with this style do not depend on the other line attributes. The + PATTERN style depends only on global canvas + attributes.

+

The filled area includes the line at the edge of the area. So if you draw a +filled rectangle, sector or polygon on top of a non filled one using the same +coordinates, no style and 1 pixel width, the non filled primitive should be +obscured by the filled primitive. But depending on the driver implementation +some pixels at the edges may be not included. IMPORTANT: In the Postscript and +PDF drivers the line at the edge is not included at all.

+

If + either the background or the foreground color are modified, the hatched and + monochromatic fillings must be modified again in order to be updated.

+

Note that when a Filling Attribute is modified, the active filling style is + now that of the modified attribute (hatch, stipple or pattern). Notice that + this is not true for the clipping area. When the clipping area is modified, + the clipping is only affected if it is active.

+ +
+
Filled Polygons
+ +

Filled polygons can be created using cdBegin(CD_FILL)/cdVertex(x,y)/.../cdEnd().

+

See the documentation of cdBegin/cdVertex/cdEnd.

+ +
void cdCanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]
+void cdfCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C]
+void wdCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); (WC) [in C]
+
+canvas:Box(xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:fBox(xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wBox(xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+ +

Fills a rectangle according to the current interior style. All points in + the interval x_min<=x<=x_max, y_min<=y<=y_max + will be painted. When the interior style CD_HOLLOW + is defined, the function behaves like its equivalent + cdRect.

+ +
void cdCanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); [in C]
+void cdfCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); [in C]
+void wdCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); (WC) [in C]
+
+canvas:Sector(xc, yc, w, h, angle1, angle2: number) [in Lua]
+canvas:fSector(xc, yc, w, h, angle1, angle2: number) [in Lua]
+canvas:wSector(xc, yc, w, h, angle1, angle2: number) (WC) [in Lua]
+ +

Fills the arc of an ellipse aligned with the axis, according to the current + interior style, in the shape of a pie. It is drawn counter-clockwise. The + coordinate (xc,yc) defines the center of the ellipse. + Dimensions w and h define the elliptic axes X + and Y, respectively.

+

Angles angle1 and angle2, in degrees, + define the arc's beginning and end, but they are not the angle relative to the + center, except when w==h and the ellipse is reduced to a circle. The arc + starts at the point (xc+(w/2)*cos(angle1),yc+(h/2)*sin(angle1)) + and ends at (xc+(w/2)*cos(angle2),yc+(h/2)*sin(angle2)). A + complete ellipse can be drawn using 0 and 360 as the angles.

+

The angles are specified so if the size of the ellipse (w x h) is changed, + its shape is preserved. So the angles relative to the center are dependent + from the ellipse size. The actual angle can be obtained using rangle = + atan2((h/2)*sin(angle),(w/2)*cos(angle)).

+

The angles are given in degrees. To specify the angle in radians, you can + use the definition CD_RAD2DEG + to multiply the value in radians before passing the angle to CD.

+

When the interior style CD_HOLLOW is defined, + the function behaves like its equivalent cdArc, + plus two lines connecting to the center.

+

Sector Parameters
+

+ +
void cdCanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); [in C]
+void cdfCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); [in C]
+void wdCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); (WC) [in C]
+
+canvas:Chord(xc, yc, w, h, angle1, angle2: number) [in Lua]
+canvas:fChord(xc, yc, w, h, angle1, angle2: number) [in Lua]
+canvas:wChord(xc, yc, w, h, angle1, angle2: number) (WC) [in Lua]
+ +

Fills the arc of an ellipse aligned with the axis, according to the current + interior style, the start and end points of the arc are connected. The + parameters are the same as the cdSector.

+

When the interior style CD_HOLLOW is defined, + the function behaves like its equivalent cdArc, + plus a line connecting the arc start and end points.

+

Chord Parameters
+

+ +

Attributes

+
int cdCanvasBackOpacity(cdCanvas* canvas, int opacity); [in C]
+
+canvas:BackOpacity(opacity: number) -> (old_opacity: number) [in Lua]
+ +

Configures the background opacity to filling primitives based on the + foreground and background colors. Values: + CD_TRANSPARENT or CD_OPAQUE. If it is opaque + the primitive will erase whatever is in background with the background color. + If it is transparent, only the foreground color is painted. It returns the previous value. Default value: + CD_TRANSPARENT. Value CD_QUERY simply returns the + current value. In some drivers is always opaque.

+

Back Opacity Attribute
+

+ +
int cdCanvasFillMode(cdCanvas* canvas, int mode); [in C]
+
+canvas:FillMode(mode: number) -> (old_mode: number) [in Lua]
+ +

Selects a predefined polygon fill rule (CD_EVENODD or CD_WINDING). Returns the previous value. Default value: + CD_EVENODD. Value CD_QUERY simply returns the current + value.

+

Fill Modes
+

+ +
int cdCanvasInteriorStyle(cdCanvas* canvas, int style); [in C]
+
+canvas:InteriorStyle(style: number) -> (old_style: number) [in Lua]
+ +

Configures the current style for the area filling primitives: + CD_SOLID, CD_HOLLOW, CD_HATCH, + CD_STIPPLE or CD_PATTERN. Note that + CD_HATCH and CD_STIPPLE are affected by the backopacity. It returns the previous value. Default value: CD_SOLID. Value + CD_QUERY simply returns the + current value.

+

If a stipple or a pattern were not defined, when they are + selected the state of the + attribute is not changed.

+

When the style CD_HOLLOW is defined, functions + cdBox and cdSector behave as their + equivalent cdRect and cdArc+Lines, and the + polygons with style CD_FILL behave like CD_CLOSED_LINES.

+ +
int cdCanvasHatch(cdCanvas* canvas, int style); [in C]
+
+canvas:Hatch(style: number) -> (old_style: number) [in Lua]
+ +

Selects a predefined hatch style (CD_HORIZONTAL, CD_VERTICAL, + CD_FDIAGONAL, CD_BDIAGONAL, + CD_CROSS or CD_DIAGCROSS) and sets the + interior style to CD_HATCH. The lines are drawn with the foreground + color, and the background is drawn with the background color if back opacity + is opaque. Returns the previous value. + Default value: CD_HORIZONTAL. Value CD_QUERY + simply returns the current value. The foreground and background colors must be + set before setting the style. In some drivers is always opaque.

+

Hatch Styles
+

+ +
void cdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char *fgbg) [in C]
+
+canvas:Stipple(stipple: cdStipple) [in Lua]
+ +

Defines a wxh matrix of zeros (0) and ones (1). The zeros are + mapped to the background color or are transparent, according to the background + opacity attribute. The ones are mapped to the foreground color. The function + sets the interior style to CD_STIPPLE. To avoid having to deal + with matrices in C, the element (i,j) of fgbg + is stored as fgbg[j*w+i]. The origin is the left bottom corner + of the image. It does not need to be stored by the + application, as it is internally replicated by the library.  In some + drivers is always opaque. The foreground and background colors must be set + before setting the style.

+ +
void wdCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char *fgbg, double w_mm, double h_mm); [in C]
+
+canvas:wStipple(stipple: cdStipple, w_mm, h_mm: number) [in Lua]
+ +

Allows specifying the stipple in world coordinates. Another stipple will be + created with the size in pixels corresponding to the specified size in + millimeters. The new size in pixels will be an integer factor of the original + size that is closets to the size in millimeters. The use of this function may produce very large or very small + stipples.

+ +
unsigned char* cdCanvasGetStipple(cdCanvas* canvas, int* w, int* h); [in C]
+
+canvas:GetStipple() - > (stipple: cdStipple) [in Lua]
+ +

Returns the current stipple and its dimensions. Returns NULL if no + stipple was defined.

+ +
void cdCanvasPattern(cdCanvas* canvas, int w, int h, const long int *color); [in C]
+
+canvas:Pattern(pattern: cdPattern) [in Lua]
+ +

Defines a new wxh color matrix and sets the interior style + to CD_PATTERN. To avoid having to deal with matrices in C, the + color element (i,j) is stored as color[j*w+i]. + The origin is the left bottom corner of the image. It + does not need to be stored by the application, as it is internally replicated + by the library.

+ +
void wdCanvasPattern(cdCanvas* canvas, int w, int h, const long int *color, double w_mm, double h_mm); [in C]
+
+canvas:wPattern(pattern: cdPattern, w_mm, h_mm: number) [in Lua]
+ +

Allows specifying the pattern in world coordinates. Another pattern will be + created with the size in pixels corresponding to the specified size in + millimeters. The new size in pixels will be an integer factor of the original + size that is closets to the size in millimeters. The use of this function may produce very large or very small + patterns.

+ +
long int* cdCanvasGetPattern(cdCanvas* canvas, int* w, int* h); [in C]
+
+canvas:GetPattern() - > (pattern: cdPattern) [in Lua]
+ +

Returns the current pattern and its dimensions. Returns NULL if no + pattern was defined.

+ +

Extras in Lua

+
cd.CreatePattern(width, height: number) -> (pattern: cdPattern)
+ +

Creates a pattern in Lua.

+ +
cd.KillPattern(pattern: cdPattern)
+ +

Destroys the created pattern and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it.

+ +
cd.CreateStipple(width, height: number) -> (stipple: cdStipple)
+ +

Creates a stipple in Lua.

+ +
cd.KillStipple(stipple: cdStipple)
+ +

Destroys the created stipple and liberates allocated memory. If this + function is not called in Lua, the garbage collector will call it.

+ +

Data Access

+ +

Data access in Lua is done directly using the operator "[y*width + + x]".

+

All new types can have their values checked or changed directly as if they + were Lua tables:

+ +
pattern[y*16 + x] = cd.EncodeColor(r, g, b)
+...
+color = pattern[y*16 + x]
+r, g, b = cd.DecodeColor(color)
+...
+cd.Pattern(pattern)
+ +

Notice that the type of value returned or received by + pattern[i] is a + lightuserdata, the same type used with functions + cdEncodeColor, + cdDecodeColor, + cdPixel, + cdForeground + and cdBackground. The value + returned or received by stipple[i] + is a number.

+ + + + + \ No newline at end of file diff --git a/html/en/func/init.html b/html/en/func/init.html new file mode 100644 index 0000000..c6e08b3 --- /dev/null +++ b/html/en/func/init.html @@ -0,0 +1,225 @@ + + + + + + +Canvas Initialization + + + + + +

Canvas Initialization

+
cdCanvas *cdCreateCanvas(cdContext* ctx, void *data); [in C]
+
+cd.CreateCanvas(ctx: number, data: string or userdata) -> (canvas: cdCanvas) [in Lua]
+ +

Creates a CD canvas for a virtual visualization surface (VVS). A VVS may be the canvas of a user-interface window, + the page of a document sent to a printer, an offscreen image, the clipboard, a metafile, and so on. To create the + canvas, it is necessary to specify the driver in which each canvas is implemented.

+

The driver is set by the driver variable with additional information provided in the + data + parameter. Even though it is possible to create more than one canvas with the same + driver/data pair, + this is not recommended, and its behavior is not specified. Each canvas maintains its own features.

+

In case of failure, a  NULL value is returned. The following predefined drivers are available:

+ + +

Window-Base Drivers

+ + + + + +

Device-Based Drivers

+ + + +

Image-Based Drivers 

+ +

File-Based Drivers 

+ + +
cdCanvas* cdCreateCanvasf(cdContext *ctx, const char* format, ...); [in C]
+
+[There is no equivalent in Lua]
+ +

Same as cdCreateCanvas, used in the case that the parameter + data is a string composed by several parameters. This function can be used with + parameters equivalent to the printf function from the default C library.

+ +
void cdKillCanvas(cdCanvas *canvas); [in C]
+
+cd.KillCanvas(canvas: cdCanvas) [in Lua]
+ +

Destroys a previously created canvas. If this function is not called in + Lua, the garbage collector will call it.

+ +
int cdCanvasActivate(cdCanvas *canvas); [in C]
+
+canvas:Activate(canvas: cdCanvas) -> (status: number) [in Lua]
+ +

Activates a canvas for drawing. This is used only for a few drivers. Native + Window and IUP drivers will update the canvas size if the window size has + changed. Double Buffer driver will recreate the image buffer if the window + canvas size has changed. In these cases the function MUST be called, for other + drivers is useless. Returns CD_ERROR or CD_OK.

+ +
void cdCanvasDeactivate(cdCanvas* canvas); [in C]
+
+canvas:Deactivate(canvas: cdCanvas) [in Lua]
+ +

Called when the application has finished drawing in the canvas. It is + optional, but if used for the Native Window driver in Windows when the handle + can not be retained, the drawing can only be done again after a + cdCanvasActivate. On some drivers will simply call + Flush.

+
int cdUseContextPlus(int use); [in C]
+
+cd.UseContextPlus(use: number) -> (old_use: number) [in Lua]
+

Activates or deactivates the use of an external context for the next calls of the + cdCreateCanvas + function.

+ +
void cdInitContextPlus(void); [in C]
+
+cd.InitContextPlus() [in Lua]
+

Initializes the context driver to use another context replacing the standard drivers. +This functions is only available when a library containing a "ContextPlus" +context driver is used. See the GDI+ base +driver and the XRender base driver.

+

In Lua, when using require"cdluacontextplus" this function will be +automatically called.

+ +
+
cdContext* cdCanvasGetContext(cdCanvas *canvas); [in C]
+
+canvas:GetContext(canvas: cdCanvas) -> (ctx: number) [in Lua]
+ +

Returns the context of a given canvas, which can be compared with the predefined contexts, such as "CD_PS".

+ +
int cdContextCaps(cdContext* ctx); [in C]
+
+cd.ContextCaps(ctx: number) -> (caps: number) [in Lua]
+ +

Returns the resources available for that context. To verify if a given resource is available, perform a binary AND + ('&.html with the following values:

+ +

CD_CAP_FLUSH
+ CD_CAP_CLEAR
+ CD_CAP_PLAY
+ CD_CAP_YAXIS
- The Y axis has the same orientation as the CD axis.
+ CD_CAP_CLIPAREA
+ CD_CAP_CLIPPOLY
- Usually is not implemented.
+ CD_CAP_MARK - Marks are implemented directly in the driver (they are usually simulated).
+ CD_CAP_RECT - Rectangles are implemented directly in the driver (they are usually + simulated).
+ CD_CAP_VECTORTEXT - Vector text is implemented directly in the driver (it is usually + simulated).
+ CD_CAP_IMAGERGB
+ CD_CAP_IMAGERGBA
- If this is not implemented, but cdGetImageRGB is, then it is + simulated using cdGetImageRGB and cdPutImageRGB.
+ CD_CAP_IMAGEMAP
+ CD_CAP_GETIMAGERGB
+ CD_CAP_IMAGESRV
- Usually is only implemented in contexts of window graphics systems (Native Window and IUP).
+ CD_CAP_BACKGROUND
+ CD_CAP_BACKOPACITY
+ CD_CAP_WRITEMODE
+ CD_CAP_LINESTYLE
+ CD_CAP_LINEWITH
+ CD_CAP_WD
- Functions of world coordinates are implemented directly in the driver (they are usually + simulated).
+ CD_CAP_HATCH
+ CD_CAP_STIPPLE
+ CD_CAP_PATTERN
+ CD_CAP_FONT
+ CD_CAP_FONTDIM
- If not defined, the function is implemented using an internal heuristics of the library.
+ CD_CAP_TEXTSIZE - If not defined, the function is implemented using an internal + heuristics of the library.
+ CD_CAP_TEXTORIENTATION - Usually is not implemented.
+ CD_CAP_PALETTE - Usually is only implemented in contexts of window graphics systems + (Native Window and IUP).

+ + +
int cdCanvasSimulate(cdCanvas* canvas, int mode); [in C]
+
+canvas:Simulate(mode: number) -> (old_mode: number) [in Lua]
+ +

Activates the simulation of one or more primitives. It is ignored for the canvas + in the ImageRGB context, because in this case everything is already simulated. It also has no effect for primitives that + are usually simulated. It returns the previous simulation, but does not include primitives that are usually simulated. + The simulation can be activated at any moment. For instance, if a line simulation is required only for a situation, + the simulation can be activated for the line to be drawn, and then deactivated.

+

If simulation is activated the driver transformation matrix is disabled.

+

See in the Simulation sub-driver the information on how each simulation is performed.

+

To activate a given simulation, perform a binary OR ('|.html using one or more of the following values (in Lua, the + values must be added '+.html:

+

CD_SIM_NONE - Deactivates all kinds of simulation.
+ CD_SIM_LINE
+ CD_SIM_RECT
+ CD_SIM_BOX
+ CD_SIM_ARC
+ CD_SIM_SECTOR
+ CD_SIM_CHORD
+ CD_SIM_POLYLINE
+ CD_SIM_POLYGON
+ CD_SIM_TEXT
+ CD_SIM_ALL
- Activates all simulation options.
+ CD_SIM_LINES - Combination of CD_SIM_LINE, CD_SIM_RECT, CD_SIM_ARC + and CD_SIM_POLYLINE.
+ CD_SIM_FILLS - Combination of CD_SIM_BOX, CD_SIM_SECTOR, CD_SIM_CHORD and + CD_SIM_POLYGON.
+

+ +

Extras

+
int cdlua_open(lua_State* L); [for Lua 5]
+ +

Initializes the CDLua binding. In Lua 5 the binding is lua state safe, this means that several states can be + initialized any time.

+ +
int cdlua_close(lua_State* L); [for Lua 5]
+ +

Releases the memory allocated by the CDLua binding.

+ +
cdCanvas* cdlua_checkcanvas(lua_State* L, int pos); [for Lua 5]
+ +

Returns the canvas in the Lua stack at position pos. The function will call lua_error if there is not a valid canvas in + the stack at the given position.

+ + +
void cdlua_pushcanvas(lua_State* L, cdCanvas* canvas);
+

Pushes the given canvas into the stack.

+ + + + + \ No newline at end of file diff --git a/html/en/func/lines.html b/html/en/func/lines.html new file mode 100644 index 0000000..33dd7e4 --- /dev/null +++ b/html/en/func/lines.html @@ -0,0 +1,147 @@ + + + + + + +Lines + + + + + +

Lines

+ +

Line are segments that connects 2 or more points. The Line + function includes the 2 given points and draws the line using the foreground + color. Line thickness is controlled by the LineWidth function. + By using function LineStyle you can draw dashed lines with some + variations. Lines with a style other than continuous are affected by the back + opacity attribute and by the background color.

+ +
+
void cdCanvasLine(cdCanvas* canvas, int x1, int y1, int x2, int y2); [in C]
+void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); [in C]
void wdCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); (WC) [in C] + +canvas:Line(x1, y1, x2, y2: number) [in Lua] +canvas:fLine(x1, y1, x2, y2: number) [in Lua] +canvas:wLine(x1, y1, x2, y2: number) (WC) [in Lua]
+ +

Draws a line from (x1,y1) to (x2,y2) using + the current foreground color and line width and style. Both points are + included in the line.

+ +
Polygons and Bezier Lines
+ +

Open polygons can be created using cdBegin(CD_OPEN_LINES)/cdVertex(x,y)/.../cdEnd().

+

Closed polygons use the same number of vertices but the last point is + automatically connected to the first point. Closed polygons can be created + using cdBegin(CD_CLOSED_LINES)/cdVertex(x,y)/.../cdEnd().

+

Bezier lines can be created using cdBegin(CD_BEZIER)/cdVertex(x,y)/.../cdEnd(). + At least 4 vertices must be defined. The two vertices of the middle are the + control vertices. A sequence of bezier lines can be defined using more 3 + vertices, two control points and an end point, the last point of the previous + bezier will be used as the start point.

+

See the documentation of cdBegin/cdVertex/cdEnd.

+ +
void cdCanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]
void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C] +void wdCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); (WC) [in C] + +canvas:Rect(xmin, xmax, ymin, ymax: number) [in Lua] +canvas:fRect(xmin, xmax, ymin, ymax: number) [in Lua]
canvas:wRect(xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+ +

Draws a rectangle with no filling. All points in the limits of interval + x_min<=x<=x_max, y_min<=y<=y_max + will be painted. It is affected by line attributes and the foreground color. + If the active driver does not include this primitive, it will be simulated + using the cdLine primitive.

+ +
void cdCanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); [in C]
void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); [in C] +void wdCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); (WC) [in C] + +canvas:Arc(xc, yc, w, h, angle1, angle2: number) [in Lua] +canvas:fArc(xc, yc, w, h, angle1, angle2: number) [in Lua] +canvas:wArc(xc, yc, w, h, angle1, angle2: number) (WC) [in Lua]
+ +

Draws the arc of an ellipse aligned with the axis, using the current + foreground color and line width and style. It is drawn counter-clockwise. The + coordinate (xc,yc) defines the center of the ellipse. + Dimensions w and h define the elliptic axes X + and Y, respectively.

+

Angles angle1 and angle2, in degrees define + the arc's beginning and end, but they are not the angle relative to the + center, except when w==h and the ellipse is reduced to a circle. The arc + starts at the point (xc+(w/2)*cos(angle1),yc+(h/2)*sin(angle1)) + and ends at (xc+(w/2)*cos(angle2),yc+(h/2)*sin(angle2)). A + complete ellipse can be drawn using 0 and 360 as the angles.

+

The angles are specified so if the size of the ellipse (w x h) is changed, + its shape is preserved. So the angles relative to the center are dependent + from the ellipse size. The actual angle can be obtained using rangle = + atan2((h/2)*sin(angle),(w/2)*cos(angle)).

+

The angles are given in degrees. To specify the angle in radians, you can + use the definition CD_RAD2DEG + to multiply the value in radians before passing the angle to CD.

+

Arc Parameters
+
 

+ +

Attributes

+
int cdCanvasLineStyle(cdCanvas* canvas, int style); [in C]
+
+canvas:LineStyle(style: number) -> (old_style: number) [in Lua]
+ +

Configures the current line style for: CD_CONTINUOUS, CD_DASHED, + CD_DOTTED, CD_DASH_DOT, CD_DASH_DOT_DOT, or CD_CUSTOM. Returns the + previous value. Default value: CD_CONTINUOUS. Value + CD_QUERY simply returns the current value. When CD_CUSTOM + is used the cdLineStyleDahes function must be called before to + initialize the custom dashes. The spaces are drawn with the background color, + except when back opacity is transparent then the background is left unchanged. + See BackOpacity.

+

Line Styles
+

+ +
void cdCanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count); [in C]
+
+canvas:LineStyleDashes(dashes: table, count: number) -> (old_style: number) [in Lua]
+ +

Defines the custom line style dashes. The first value is the lenght of the + first dash, the second value is the leght of the first space, and so on. For + example: "10 2 5 2" means dash size 10, space size 2, dash size 5, space size + 2, and repeats the pattern.

+ +
int cdCanvasLineWidth(cdCanvas* canvas, int width); [in C]
double wdCanvasLineWidth(double width_mm); (WC) [in C] + +canvas:LineWidth(width: number) -> (old_width: number) [in Lua] +canvas:wLineWidth(width_mm: number) -> (old_width_mm: number) (WC) [in Lua]
+ +

Configures the width of the current line (in pixels). Returns the previous + value. Default value: 1. Value CD_QUERY simply returns the + current value. Valid width interval: >= 1.

+

In WC, it configures the current line width in millimeters. 

+ +
int cdCanvasLineJoin(cdCanvas* canvas, int style); [in C]
+
+canvas:LineJoin(style: number) -> (old_style: number) [in Lua]
+ +

Configures the current line style for: CD_MITER, + CD_BEVEL or CD_ROUND. Returns the previous value. + Default value: CD_MITER. Value CD_QUERY simply + returns the current value.

+

Line Joins
+

+ +
int cdCanvasLineCap(cdCanvas* canvas, int style); [in C]
+
+canvas:LineCap(style: number) -> (old_style: number) [in Lua]
+ +

Configures the current line style for: CD_CAPFLAT, + CD_CAPSQUARE or CD_CAPROUND. Returns the previous + value. Default value: CD_CAPFLAT. Value CD_QUERY + simply returns the current value.

+

Line Caps
+

+ + + + + diff --git a/html/en/func/marks.html b/html/en/func/marks.html new file mode 100644 index 0000000..b68db35 --- /dev/null +++ b/html/en/func/marks.html @@ -0,0 +1,85 @@ + + + + + + +Marks + + + + + +

Marks

+ +

A mark is a punctual representation. It can have different sizes and types. + All types are affected only by mark attributes and by the foreground color.

+

All marks in all drivers are simulated using other CD primitives, except +cdPixel.

+ +
+
void cdCanvasPixel(cdCanvas* canvas, int x, int y, long int color); [in C]
+void wdCanvasPixel(cdCanvas* canvas, double x, double y, long int color); (WC) [in C]
+
+canvas:Pixel(x, y: number, color: lightuserdata) [in Lua]
+canvas:wPixel(x, y: number, color: lightuserdata) (WC) [in Lua]
+ +

Configures the pixel (x,y) with the color defined by color. It is the smallest element of the canvas. It depends only + on global attributes of the canvas.

+ +
void cdCanvasMark(cdCanvas* canvas, int x, int y); [in C]
+void wdCanvasMark(cdCanvas* canvas, double x, double y); (WC) [in C]
+
+canvas:Mark(x, y: number) [in Lua]
+canvas:wMark(x, y: number) (WC) [in Lua]
+ +

Draws a mark in (x,y) using the current foreground color. + It is not possible to use this function between a call to functions + cdBegin and cdEnd + if the type of mark is set to CD_DIAMOND. If the active driver + does not include this primitive, it will be simulated using other primitives + from the library, such as cdLine.

+

If you will call function cdMark + or wdMark several times in a + sequence, then it is recommended that the application changes the filling and + line attributes to those used by the cdMark + function:

+ +
cdInteriorStyle(CD_SOLID);
+cdLineStyle(CD_CONTINUOUS);
+cdLineWidth(1);
+ +

This will greatly increase this function's performance. Also in this case, + if the mark is very small, we suggest using the cdPixel + function so that the application itself draws the mark. In many cases, this + also increases this function's performance.

+ +

Attributes

+
int cdCanvasMarkType(cdCanvas* canvas, int type); [in C]
+
+canvas:MarkType(type: number) -> (old_type: number) [in Lua]
+ +

Configures the current mark type for: CD_PLUS, + CD_STAR, CD_CIRCLE, CD_X, + CD_BOX, CD_DIAMOND, CD_HOLLOW_CIRCLE, + CD_HOLLOW_BOX or CD_HOLLOW_DIAMOND. Returns + the previous value. Default value: CD_STAR. Value + CD_QUERY simply returns the current value.

+

Mark Types
+

+ +
int cdCanvasMarkSize(cdCanvas* canvas, int size); [in C]
+double wdCanvasMarkSize(cdCanvas* canvas, double size); (WC) [in C]
+
+canvas:MarkSize(size: number) -> (old_size: number) [in Lua]
+canvas:wMarkSize(size: number) -> (old_size: number) (WC) [in Lua]
+ +

Configures the mark size in pixels. Returns the previous value. Default + value: 10. Value CD_QUERY simply returns the current value. + Valid width interval: >= 1.

+

In WC, it configures the current line width in millimeters. 

+ + + + + diff --git a/html/en/func/other.html b/html/en/func/other.html new file mode 100644 index 0000000..f0d7284 --- /dev/null +++ b/html/en/func/other.html @@ -0,0 +1,119 @@ + + + + + + +Other + + + + + +

System

+
char* cdVersion(void); [in C]
+
+cd.Version() -> (version: string) [in Lua]
+ +

Returns the current version number of the library. The string with the + version number has a format "major.minor.build". + For instance, the string "2.1.3" has number 2 as the main (major) version + number, 1 as the secondary (minor) version number, and 3 as the build number. + The major version number represents a change in the structure or behavior of + functions; the minor version number represents one or more new drivers and + functions added to the library; and the build version number represents one or + more corrected bugs.

+ +
char* cdVersionDate(void); [in C]
+
+cd.VersionDate() -> (versiondate: string) [in Lua]
+

Returns the release date of the current version of the library.

+
int cdVersionNumber(void); [in C]
+
+cd.VersionNumber() -> (version: number) [in Lua]
+

Returns the current version number of the library.

+
[in C]
+CD_NAME           "CD - Canvas Draw"
+CD_DESCRIPTION    "A 2D Graphics Library"
+CD_COPYRIGHT      "Copyright (C) 1994-2007 Tecgraf/PUC-Rio and PETROBRAS S/A"
+CD_VERSION        "5.0.0"
+CD_VERSION_DATE   "2007/04/09"
+CD_VERSION_NUMBER 500000
+
+[in Lua]
+cd._NAME
+cd._DESCRIPTION
+cd._COPYRIGHT
+cd._VERSION
+cd._VERSION_DATE
+cd._VERSION_NUMBER
+ +

Usefull definitions. They have the same value returned by cdVersion* + functions.

+ +
+

Metafile Interpretation

+
int cdCanvasPlay(cdCanvas* canvas, cdContext* ctx, int xmin, int xmax, int ymin, int ymax, void *data); [in C]
+
+canvas:Play(ctx, xmin, xmax, ymin, ymax: number, data: string) -> (status: number) [in Lua]
+ +

Interprets the graphical contents (primitives and attributes) in a given + driver and calls equivalent functions of the CD library using the given + canvas. The primitives are drawn inside the region defined by the given + limits. If limits are 0 (xmin, xmax, + ymin and ymax) the primitives will be drawn with their coordinates having the original + values in the file.

+ +

Only some drivers implement this function:

+ + + + +
int cdContextRegisterCallback(cdContext *ctx, int cb, int(*func)(cdCanvas* canvas, ...)); [in C]
+
+cd.ContextRegisterCallback(ctx, cb: number, func: function) -> (status: number) [in Lua]
+ +

Used to customize the behavior of the  Play + function. If you register a known callback function, it will be called during + the processing loop of cdPlay.

+

The callback should return CD_CONTINUE, if it + returns CD_ABORT, the cdPlay + function is aborted. The callback identifiers of a given driver must be in the + header file relative to that driver, with prefix "CD_XXYYYCB", + where XX identifies that driver and + YYY identifies the callback name.

+

There is a default callback common to all implementations of + cdPlay, CD_SIZECB. Its definition + is:

+
int cdResizeCB(cdCanvas* canvas, int width, int height, double mm_width, double mm_height)
+

It returns the size of the image in the + file before any function in the CD library is called, so that you can call the  + cdPlay function without an active canvas and + create the canvas inside the callback. It works as a  + cdCanvasGetSize function.

+ + + + + \ No newline at end of file diff --git a/html/en/func/polygon.html b/html/en/func/polygon.html new file mode 100644 index 0000000..4e18664 --- /dev/null +++ b/html/en/func/polygon.html @@ -0,0 +1,87 @@ + + + + + + +Polygons + + + + + +

Open, Closed and Filled Polygons,
+Bezier Lines and
+Regions Creation

+ +

The functions cdBegin, + cdVertex and + cdEnd are use for many situations. + cdBegin is called once, + cdVertex can be called many + times, and cdEnd is called once + to actually do something. If you call cdBegin + again before cdEnd the process is + restarted, except for cdBegin(CD_REGION) + that can contains one or more polygons inside.

+ +
+
void cdCanvasBegin(cdCanvas* canvas, int mode); [in C]
+
+canvas:Begin(mode: number) [in Lua]
+ +

Starts defining a polygon to be drawn (or filled) according to the mode:  + CD_CLOSED_LINES, CD_OPEN_LINES, CD_FILL, + CD_CLIP, CD_REGION or CD_BEZIER. + Do not create embedded polygons, that is, do not call function + cdBegin twice without a call to + cdEnd in between.

+ + +

Open, Closed and Filled Polygons
+

+

Bezier Lines
+

+
void cdCanvasVertex(cdCanvas* canvas, int x, int y); [in C]
+void cdfCanvasVertex(cdCanvas* canvas, double x, double y); [in C]
+void wdCanvasVertex(cdCanvas* canvas, double x, double y); (WC) [in C]
+
+canvas:Vertex(x, y: number) [in Lua]
+canvas:wVertex(x, y: number) (WC) [in Lua]
+ +

Adds a vertex to the polygon definition.

+ +
void cdCanvasEnd(cdCanvas* canvas); [in C]
+
+canvas:End() [in Lua]
+ +

Ends the polygon's definition and draws it.

+ + + + + diff --git a/html/en/func/region.html b/html/en/func/region.html new file mode 100644 index 0000000..e503733 --- /dev/null +++ b/html/en/func/region.html @@ -0,0 +1,83 @@ + + + + + + +Complex Clipping Regions + + + + + +

Complex Clipping Regions

+ +

A complex region can composed of boxes, sectors, chords, polygons and + texts. It is implemented only in the Windows GDI, GDI+ and X-Windows base drivers.

+ +

Complex clipping regions can be created using + cdBegin(CD_REGION)/(filled + primtives)/.../cdEnd(). For more about cdBegin and cdEnd see + Polygons.

+

Between a cdBegin(CD_REGION) + and a cdEnd(), all calls to + cdBox, + cdSector, cdChord, + cdBegin(CD_FILL)/cdVertex(x,y)/.../cdEnd() and + cdText will be composed in a + region for clipping. This is the only exception when you can call a + cdBegin after another + cdBegin.

+

When you call cdBegin(CD_REGION) + a new empty region will be created. So for the first operation you should use + CD_UNION or CD_NOTINTERSECT combine modes. + When you finished to compose the region call + cdEnd().

+

To make the region active you must call + cdClip(CD_CLIPREGION). + For other clipping regions see Clipping.

+

Complex clipping regions are not saved by cdSaveState.

+ +
+
int cdCanvasRegionCombineMode(cdCanvas* canvas, int mode); [in C]
+
+canvas:RegionCombineMode(mode: number) -> (old_mode: number) [in Lua]
+ +

Changes the way regions are combined when created. Returns the previous + status. Values: CD_UNION, CD_INTERSECT, CD_DIFFERENCE or + CD_NOTINTERSECT. The value CD_QUERY simply returns + the current status. Default value: CD_UNION.

+

Combine Modes
+

+ +
int cdCanvasIsPointInRegion(cdCanvas* canvas, int x, int y); [in C]
+
+canvas:IsPointInRegion(x, y: number) -> (status: number) [in Lua]
+ +

Returns a non zero value if the point is contained inside the current + region.

+ +
void cdCanvasOffsetRegion(cdCanvas* canvas, int dx, int dy); [in C]
+void wdCanvasOffsetRegion(cdCanvas* canvas, double dx, double dy); (WC) [in C]
+
+canvas:OffsetRegion(dx, dy: number) [in Lua]
+canvas:wOffsetRegion(dx, dy: number) (WC) [in Lua]
+ +

Moves the current region by the given offset. In X-Windows, if the region + moves to outside the canvas border, the part moved outside will be lost, the + region will need to be reconstruted.

+ +
void cdCanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); [in C]
+void wdCanvasGetRegionBox(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C]
+
+canvas:GetRegionBox() -> (xmin, xmax, ymin, ymax, status: number) [in Lua]
+canvas:wGetRegionBox() -> (xmin, xmax, ymin, ymax, status: number) (WC) [in Lua]
+ +

Returns the rectangle of the bounding box of the current region. It is not + necessary to provide all return pointers, you can provide only the desired + values and NULL for the others.

+ + + + + diff --git a/html/en/func/server.html b/html/en/func/server.html new file mode 100644 index 0000000..6663de5 --- /dev/null +++ b/html/en/func/server.html @@ -0,0 +1,84 @@ + + + + + + +Server Images + + + + + +

Server Images

+ +

It is a high performance image compatible with a specific canvas. It is + faster than user image functions, but less flexible. It is commonly used for + off-screen drawing in Window Systems.

+

You can make gets and puts on several canvases but they must be created + using the same driver. It is possible to specify a part of the image to be + drawn, but it is not possible to zoom.

+

It is called "server" images because the data is stored in a system private + format, that the application (or the client) does not have access.

+

To create a server image there must be an active canvas of a driver with + server image support.

+ +
+
cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h); [in C]
+
+canvas:CreateImage(w, h: number) -> (image: cdImage) [in Lua]
+ +

Creates a compatible image with size = w x h pixels. A + compatible image has the same color representation (number of bits per pixel) + of the active canvas. Once the server image is created it is independent of + the active canvas. The server image can only be used with an other canvas of + the same type as the canvas that was active when the image was created. The + default background is the same as the canvas, CD_WHITE.

+ +
void cdKillImage(cdImage* image); [in C]
+
+image:KillImage() [in Lua]
+ +

Liberates memory allocated for the image. If this function is not called in + Lua, the garbage collector will call it.

+ +
void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y); [in C]
+
+canvas:GetImage(image: cdImage; x, y: number) [in Lua]
+ +

Copies a rectangular region from the current rectangular context to the + memory (image). (x,y) + is the coordinate of the bottom left corner of the rectangular region. The + width and length of the rectangular region are defined in the image structure + (when the image is created).

+ +
void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); [in C]
+void wdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); (WC) [in C]
+
+canvas:PutImageRect(image: cdImage; x, y, xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wPutImageRect(image: cdImage; x, y, xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+ +

Copies an image in a rectangular region of the canvas with the bottom left + corner in (x,y). Allows specifying a rectangle inside the + image to be drawn, if xmin, + xmax, ymin + and ymax are 0, then the whole + image is assumed.

+ +
void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); [in C]
+
+canvas:ScrollArea(xmin, xmax, ymin, ymax, dx, dy: number) [in Lua]
+ +

Copies the rectangle defined by the coordinates (xmin,ymin) + and (xmax,ymax) to the rectangle defined by + (xmin+dx,ymin+dy) and (xmax+dx,ymax+dy). It has the + same effect as cdGetImage followed by cdPutImage, + but it should be faster and does not require the explicit creation of an image + to be executed. Note that the region belonging to the first rectangle, but not + to the second, remains unchanged (the function does not clean this region). +

+ + + + + \ No newline at end of file diff --git a/html/en/func/text.html b/html/en/func/text.html new file mode 100644 index 0000000..6243325 --- /dev/null +++ b/html/en/func/text.html @@ -0,0 +1,192 @@ + + + + + + +Text + + + + + +

Text

+ +

A raster text using a font with styles. The position the text is drawn depends on the text alignment attribute.

+

The library has at least 4 standard typefaces: "System" (which depends on the driver and platform), + "Courier" (mono spaced + with serif), "Times" (proportional with serif) and "Helvetica" (proportional without serif). Each typeface can have + some styles: Plain, Bold, Italic and a combination of Bold and Italic. + As an alternative to the standard typefaces, you can use other typefaces or native driver typefaces with the function + NativeFont, but they may work in a reduced set of drivers. +

+

You may retrieve the dimensions of the selected font with function + GetFontDim. Also you + may retrieve the bounding box of a specific text before drawing by using the + GetTextSize + and GetTextBox functions.

+

The text is drawn using a reference point; you can change the alignment relative to this point using the + TextAligment function.

+ +
+
void cdCanvasText(cdCanvas* canvas, int x, int y, const char* text); [in C]
+void cdfCanvasText(cdCanvas* canvas, double x, double y, const char* text); [in C]
+void wdCanvasText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C]
+
+canvas:Text(x, y: number, text: string) [in Lua]
+canvas:fText(x, y: number, text: string) [in Lua]
+canvas:wText(x, y: number, text: string) (WC) [in Lua]
+ +

Inserts a text in (x,y) according to the current font and + text alignment. It expects an ANSI string with no line breaks.

+ +

Attributes

+
void cdCanvasFont(cdCanvas* canvas, const char* typeface, int style, int size); [in C]
+void wdCanvasFont(cdCanvas* canvas, const char* typeface, int style, double size); (WD) [in C]
+
+canvas:Font(typeface, style, size: number) [in Lua]
+canvas:wFont(typeface, style, size: number) (WD) [in Lua]
+ +

Selects a text font. The font type can be one of the standard type faces or + other driver dependent type face. Since font face names are not a standard + between drivers, a few names are specially handled to improve application + portability. If you want to use names that work for all systems we recommend + using: "Courier", "Times" and "Helvetica".

+

The style can be a combination of: CD_PLAIN, + CD_BOLD, CD_ITALIC, CD_UNDERLINE + or CD_STRIKEOUT. Only the Windows and PDF drivers support underline and + strikeout. The size is provided in points (1/72 inch) or in pixels (using + negative values).

+

Default values: "System", CD_PLAIN, 12.

+

You can specify partial parameters using NULL, -1 and 0 for typeface, style + and size. When these parameters are specified the current font parameter is + used. For example: CanvasFont(NULL, -1, 10) will only change the font + size.

+

To convert between pixels and points use the function + cdPixel2MM + to convert from pixels to millimeters and use the formula "(value in points) = CD_MM2PT * + (value in millimeters)".

+

In WC, the size is specified in millimeters, but is internally converted to points.

+

Fonts can heavily benefit from the ANTIALIAS attribute where available in the +driver.

+
+
+ + + + + +
+

Type Faces
+

+

Font Styles
+

+
+
+ +
void cdCanvasGetFont(cdCanvas* canvas, char* typeface, int *style, int *size); [in C]
+void wdCanvasGetFont(cdCanvas* canvas, char* typeface, int *style, double *size); (WC) [in C]
+
+canvas:GetFont() -> (typeface: string, style, size: number) [in Lua]
+canvas:wGetFont() -> (typeface: string, style, size: number) (WC) [in Lua]
+ +

Returns the values of the current font. It is not necessary to provide all + return pointers; you can provide only the desired values.

+

In WC, the size is returned in millimeters.

+ +
char* cdCanvasNativeFont(cdCanvas* canvas, const char* nativefont); [in C]
+
+canvas:NativeFont(font: string) -> (old_font: string) [in Lua]
+ +

Selects a font based on a string description. The description can depend on the driver + and the platform, but a common definition is available for all drivers. It + does not need to be stored by the application, as it is internally replicated + by the library. The string is case sensitive. It returns the previous string.

+

The string is parsed and the font typeface, style and size are set according +to the parsed values, as if cdCanvasFont was called. The native font string is +cleared when a font is set +using cdCanvasFont.

+

The common format definition is similar to the the +Pango library Font Description, used by GTK+2. It is defined as having 3 parts: <font +family>, <font styles> <font size>. For ex: "Times, Bold 18", or +"Arial,Helvetica, Italic Underline -24". The supported styles include: +Bold, Italic, Underline and Strikeout. Underline, Strikeout, and negative +pixel values are not supported by the standard Pango Font Description. The Pango +format include many other definitions not supported by the CD format, they are +just ignored.

+

The IUP "FONT" attribute internal formats are also accepted in all drivers +and platforms.

+

Using "NULL" as a parameter, it only returns the previous string and does not change the font. The value returned + is the last attributed value, which may not correspond exactly to the font selected by the driver.

+ +

Using "(char*)CD_QUERY" as a parameter, it returns the current selected + font in the common format definition.

+ +
int cdCanvasTextAlignment(cdCanvas* canvas, int alignment); [in C]
+
+canvas:TextAlignment(alignment: number) -> (old_alignment: number) [in Lua]
+ +

Defines the vertical and horizontal alignment of a text as: CD_NORTH, CD_SOUTH, + CD_EAST, CD_WEST, CD_NORTH_EAST, CD_NORTH_WEST, + CD_SOUTH_EAST, CD_SOUTH_WEST, CD_CENTER, CD_BASE_LEFT, + CD_BASE_CENTER, or CD_BASE_RIGHT. Returns the previous value. Default value: + CD_BASE_LEFT. Value CD_QUERY simply returns the current value.

+

Text Alignment
+

+ +
double cdCanvasTextOrientation(cdCanvas* canvas, double angle); [in C]
+
+canvas:TextOrientation(angle: number) -> (old_angle: number) [in Lua]
+ +

Defines the text orientation, which is an angle provided in degrees relative to the horizontal line according to + which the text is drawn. Returns the previous value. Value CD_QUERY simply returns the current value. + The default value is 0.

+ +

Properties

+
void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent); [in C]
+void wdCanvasGetFontDim(cdCanvas* canvas, double *max_width, double *height, double *ascent, double *descent); (WC) [in C]
+
+canvas:GetFontDim() -> (max_width, height, ascent, descent: number) [in Lua]
+canvas:wGetFontDim() -> (max_width, height, ascent, descent: number) (WC) [in Lua]
+ +

Returns the maximum width of a character, the line's height, the ascent and descent of the + characters of the currently selected font. The line's height is the sum of the + ascent and descent of a + given additional space (if this is the case). All values are given in pixels + and are positive. It is not necessary to provide all return pointers, you can provide only + the desired values and NULL for the others.

+

Font Dimension Attributes
+

+ +
void cdCanvasGetTextSize(cdCanvas* canvas, const char* text, int *width, int *height); [in C]
+void wdCanvasGetTextSize(cdCanvas* canvas, const char* text, double *width, double *height); (WC) [in C]
+
+canvas:GetTextSize(text: string) -> (width, heigth: number) [in Lua]
+canvas:wGetTextSize(text: string) -> (width, heigth: number) (WC) [in Lua]
+ +

Returns the width and height of a text's minimum box with the currently selected font. If the driver does not + support this kind of query, the values will be given 0 (zero). It is not necessary to provide all return pointers, you + can provide only the desired values and NULL for the others.

+ +
void cdCanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax); [in C]
+void wdCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C]
+
+canvas:GetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) [in Lua]
+canvas:wGetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) (WC) [in Lua]
+ +

Returns the horizontal bounding rectangle of a text box, even if the text has an orientation. It is not necessary + to provide all return pointers, you can provide only the desired values and NULL for the others.

+ +
void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char *text, int *rect); [in C]
+void wdCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* text, double *rect); (WC) [in C]
+
+canvas:GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) [in Lua]
+canvas:wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) (WC) [in Lua]
+ +

Returns the oriented bounding rectangle of a text box. The rectangle corners are returned in counter-clock wise + order starting with the bottom left corner, (x,y) arranged (x0,y0,x1,y1,x2,y2,x3,y3).

+ + + + + \ No newline at end of file diff --git a/html/en/func/vectortext.html b/html/en/func/vectortext.html new file mode 100644 index 0000000..e1b1d6e --- /dev/null +++ b/html/en/func/vectortext.html @@ -0,0 +1,133 @@ + + + + Vector Text + + + + + +

Vector Text

+

It is a text that uses a font created only with line segments. It is very + useful to be scaled and very fast. You must set the text size before drawing + any text. The functions ignore the new line character "\n"; only the wdMultiLineVectorText + function will consider this character. The default direction is horizontal from + left to right.

+

Vector Text Parameters
+

+

All vector text drawing in all drivers are simulated using other CD + primitives.

+
+
void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* text); [in C]
+void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C]
+    
+canvas:VectorText(x, y: number, text: string) [in Lua]
+canvas:wVectorText(x, y: number, text: string) (WC) [in Lua]
+

Draws a vector text in position (x,y), respecting the + alignment defined by cdTextAlignment. It ignores + the configuration cdBackOpacity, being always + transparent. It also ignores strings with multiple lines. It is ESSENTIAL to + call cdVectorTextSize or cdVectorCharSize + before using cdVectorText or cdMultiLineVetorText.

+
void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* text); [in C]
+void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C]
+
+canvas:MultiLineVectorText(x, y: number, text: string) [in Lua]
+canvas:wMultiLineVectorText(x, y: number, text: string) (WC) [in Lua]
+

Draws a vector text with several lines in position (x,y), + respecting the alignment defined by cdTextAlignment. + It ignores the configuration cdBackOpacity, being + always transparent. Lines are broken by characters "\n". Each line + respects the scale defined in cdVectorTextSize or + cdVectorCharSize. This function's purpose is to make + function cdVectorText more efficient, not being + concerned with multiple lines.

+

Attributes

+
void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2); [in C]
+void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); (WC) [in C]
+
+canvas:VectorTextDirection(x1, y1, x2, y2: number) [in Lua]
+canvas:wVectorTextDirection(x1, y1, x2, y2: number) (WC) [in Lua]
+

Defines the text direction by means of two points, (x1,y1) and + (x2,y2). The default direction is horizontal from left to right.

+
double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix); [in C]
+
+canvas:VectorTextTransform(matrix: table) -> (old_matrix: table) [in Lua] 
+

Defines a transformation matrix with 6 elements. If the matrix is NULL, no + transformation is set. The default direction is no transformation. The origin + is the left bottom corner of matrix. It returns the previous matrix, and the + returned vector is only valid until the following call to the function.

+

The matrix contains scale, rotation and translation elements. It is applied after + computing the position and orientation normal to the vector text. We can + describe the elements as follows:

+
|x'|   | scl_x*cos(ang)       -sin(ang)  trans_x |   |x|                     | 3   4   5| 
+|y'| = |       sin(ang)  scl_y*cos(ang)  trans_y | * |y|      with indices   | 0   1   2|
+                                                     |1|
+
void cdCanvasVectorTextSize(cdCanvas* canvas, int w, int h, const char * text); [in C]
+void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* text); (WC) [in C]
+
+canvas:VectorTextSize(w, h: number, text: string) [in Lua]
+canvas:wVectorTextSize(w, h: number, text: string) (WC) [in Lua]
+

Modifies the scale of the vector text so that it corresponds to the string of + the bounding box defined by w and h. It ignores + strings with multiple lines.

+
double cdCanvasVectorCharSize(cdCanvas* canvas, int size); [in C]
+double wdCanvasVectorCharSize(double size); (WC) [in C]
+
+canvas:VectorCharSize(size: number) -> (old_size: number) [in Lua]
+canvas:wVectorCharSize(size: number) -> (old_size: number) (WC) [in Lua]
+

Sets the height of the characters and adjusts the width according to it. + Returns the previous value. CD_QUERY returns the + current value.

+
char* cdCanvasVectorFont(cdCanvas* canvas, const char *filename); [in C]
+
+canvas:VectorFont(filename: string) -> (fontname: string) [in Lua]
+

Replaces the current vector font with a font stored in a file with a given + name. Returns the name of the font loaded or NULL, if it fails. If filename + is NULL, it activates the default font "Simplex II" (There is no file + associated to this font, it is an embedded font). The library will attempt to + load a font from the current directory, if it fails then it will try the + directory defined by the environment variable "CDDIR", + if it fails, it will attempt to + load it using the filename as a string containing the font as + if the file was loaded into that string, if it fails again the font is reset + to the default font and returns NULL. The file format is + compatible with the GKS file format (text mode).

+

Properties

+
void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, int *w, int *h); [in C]
+void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *x, double *y); (WC) [in C]
+
+canvas:GetVectorTextSize(text: string) -> (w, h: number) [in Lua]
+canvas:wGetVectorTextSize(text: string) -> (w, h: number) (WC) [in Lua]
+

Queries the string's bounding box. Ignores strings with multiple lines. It is + not necessary to provide all return pointers, you can provide only the desired + values and NULL for the others.

+
void cdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, int px, int py, int *rect); [in C]
+void wdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect); (WC) [in C]
+
+canvas:GetVectorTextBounds(text: string, px,py: number) -> (rect: table) [in Lua]
+canvas:wGetVectorTextBounds(text: string, px,py: number) -> (rect: table) (WC) [in Lua] 
+

Returns the bounding rectangle of the text specified in the current vector + font, alignment and direction. Eight values are returned, corresponding to + pairs (x,y) of the rectangle's vertices ordered conter-clockwise, starting by + the bottom left corner.

+

Character Codes

+

The old GKS format contains ASCII codes so a convertion from ANSI to ASCII is + done when possible, unmapped characters are left unchanged, but some rearrage + was necessary to acomodate the convertion. +

+

The default vector font was changed from the original Simplex II to contain + all ANSI accented characters. So some ASCII characters were replaced.

+

Bellow is the character code table of the default font.

+

+
+ Default Font

+

The original Simplex II font is available in the file + "cd/etc/vectorfont00.txt". Bellow is the character code table of the original + font (the table displays the characters after the convertion from ANSI to + ASCII):

+

+
+ Original Simplex II

+ + \ No newline at end of file diff --git a/html/en/func/wd.html b/html/en/func/wd.html new file mode 100644 index 0000000..9c83ec5 --- /dev/null +++ b/html/en/func/wd.html @@ -0,0 +1,80 @@ + + + + World Coordinates + + + + + +

World Coordinates

+

Allows the use of a World Coordinate System. In this system you can attribute + coordinates to any unit you want. After you define a window (rectangular + region) in your world, each given coordinate is then mapped to canvas + coordinates to draw the primitives. You can define a viewport in your canvas to + change the coordinate mapping from world to canvas. The image below shows the + relation between Window and Viewport.

+

Window x Viewport
+

+

If you want to map coordinates from one system to another, use the wdWorld2Canvas + e wdCanvas2World functions. +

+

The quality of the picture depends on the conversion from World to Canvas, so + if the canvas has a small size the picture quality will be poor. To increase + picture quality create a canvas with a larger size, if possible.

+

All World Coordinate drawing in all drivers are simulated using other CD + primitives.

+
+
void wdCanvasWindow(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C]
+    
+canvas:wWindow(xmin, xmax, ymin, ymax: number) [in Lua]
+

Configures a window in the world coordinate system to be used to convert world + coordinates (with values in real numbers) into canvas coordinates (with values + in integers). The default window is the size in millimeters of the whole + canvas.

+
void wdCanvasGetWindow(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); [in C]
+
+canvas:wGetWindow() -> (xmin, xmax, ymin, ymax: number) [in Lua]
+

Queries the current window in the world coordinate system being used to + convert world coordinates into canvas coordinates (and the other way round). It + is not necessary to provide all return pointers, you can provide only the + desired values.

+
void wdCanvasViewport(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]
+
+canvas:wViewport(xmin, xmax, ymin, ymax: number) [in Lua]
+

Configures a viewport in the canvas coordinate system to be used to convert + world coordinates (with values in real numbers) into canvas coordinates (with + values in integers). The default viewport is the whole canvas (0,w-1,0,h-1). + If the canvas size is changed, the viewport will not be automatically updated. +

+
void wdCanvasGetViewport(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); [in C]
+
+canvas:wGetViewport() -> (xmin, xmax, ymin, ymax: number) [in Lua]
+

Queries the current viewport in the world coordinate system being used to + convert world coordinates into canvas coordinates (and the other way round). It + is not necessary to provide all return pointers, you can provide only the + desired values and NULL for the others.

+
void wdCanvasWorld2Canvas(cdCanvas* canvas, double xw, double yw, int *xv, int *yv); [in C]
+
+canvas:wWorld2Canvas(xw, yw: number) -> (xv, yv: number) [in Lua]
+

Converts world coordinates into canvas coordinates. It is not necessary to + provide all return pointers, you can provide only the desired values and NULL + for the others.

+
void wdCanvasCanvas2World(cdCanvas* canvas, int xv, int yv, double *xw, double *yw); [in C]
+
+canvas:wCanvas2World(xv, yv: number) -> (xw, yw: number) [in Lua]
+

Converts canvas coordinates into world coordinates. It is not necessary to + provide all return pointers, you can provide only the desired values and NULL + for the others.

+

Extra

+
void wdCanvasHardcopy(cdCanvas *canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)); [in C]
+
+canvas:wCanvasHardcopy(ctx: number, data: string or userdata, draw_func: function) [in Lua]
+

Creates a new canvas, prepares Window and Viewport according to + the provided canvas, maintaining the aspect ratio and making the drawing occupy + the largest possible area of the new canvas, calls the drawing function (which + must use routines in WC) and, finally, removes the new canvas.

+

It is usually used for "hard copies" of drawings (print equivalent copy). The + most common used contexts are Printer, PS and PDF.

+ + -- cgit v1.2.3