From d117dc8f75933e4e2b780afbb2f50756c140bdea Mon Sep 17 00:00:00 2001
From: scuri
Returns the oriented bounding rectangle occupied by a text at a given
position. The rectangle has the same dimentions returned by
diff --git a/html/en/history.html b/html/en/history.html
index 78ac63e..0acfaad 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -75,6 +75,9 @@
All the screenshots here were generated with the same
-C source code. The code contains only the
+C source code. The same example is
+available in Lua source code. The code contains only the
primitives and attributes, the canvas initialization is simply: Get the source code here:
+simple.zip. void SimpleDraw(cdCanvas*
canvas) {
@@ -56,9 +70,9 @@ cdCanvasClear(
/* Draw a reactangle and a polyline at
the bottom-left area, using a thick line with transparency. Notice that transparency is only supported in a few drivers, and line join is not supported in the IMAGERGB driver. */
+ using a thick line with transparency. Notice that transparency is only supported in a few drivers, and line join is not supported in the IMAGERGB driver. */
cdCanvasLineWidth(canvas,
3);
@@ -103,7 +117,7 @@ cdCanvasEnd(c
/* Draw the red diagonal line with a
custom line style. Notice that line styles are not supported in the IMAGERGB driver. */
+ Notice that line styles are not supported in the IMAGERGB driver. */
cdCanvasForeground(canvas,
CD_RED);
@@ -134,7 +148,7 @@ h-
/* Draw the blue diagonal line with a
pre-defined line style. Notice that the pre-defined line style is dependent on the driver. */
+ Notice that the pre-defined line style is dependent on the driver. */
cdCanvasForeground(canvas,
CD_BLUE);
@@ -160,7 +174,7 @@ cdCanvasLineWidth(/* Draw an arc at bottom-left, and a
sector at bottom-right. Notice that counter-clockwise orientation of both. */
+ Notice that counter-clockwise orientation of both. */
cdCanvasInteriorStyle(canvas,
CD_SOLID);
@@ -222,13 +236,13 @@ CD_BOLD,
/* Draw text at center, with
orientation, and draw its bounding box. Notice that in some drivers the bounding box is not precise. */ and draw its bounding box. Notice that in some drivers the bounding box is not precise. */
cdCanvasGetTextBounds(canvas,
w/2,
h/2,
-"cdMin Draw ()",
+"cdMin Draw (ηγν)",
irect);
cdCanvasForeground(canvas,
@@ -262,7 +276,7 @@ CD_BLUE);
cdCanvasText(canvas,
w/2,
h/2,
-"cdMin Draw ()");
+"cdMin Draw (ηγν)");
/* Prepare World Coordinates */
@@ -309,7 +323,7 @@ wdCanvasVectorCharSize( /* Draw vector text, and draw its
bounding box. We also use this text to show when we are using a contextplus driver. */ We also use this text to show when we are using a contextplus driver. */
cdCanvasForeground(canvas,
CD_RED);
@@ -383,7 +397,7 @@ cdCanvasLineWidth(
/* Draw a filled path at center-right
(looks like a weird fish). Notice that in PDF the arc is necessarily a circle arc, and not an ellipse.
+ Notice that in PDF the arc is necessarily a circle arc, and not an ellipse.
*/
cdCanvasForeground(canvas,
CD_GREEN);
@@ -544,7 +558,7 @@ h -
/* Draw all the line style
possibilities at bottom. Notice that they have some small differences between drivers. */
+ Notice that they have some small differences between drivers. */
cdCanvasLineWidth(canvas,
1);
@@ -596,7 +610,7 @@ w,
/* Draw all the hatch style
possibilities in the top-left corner. Notice that they have some small differences between drivers. */
+ Notice that they have some small differences between drivers. */
cdCanvasHatch(canvas,
CD_VERTICAL);Version 5.3 (26/Jan/2010)
diff --git a/html/en/screenshots.html b/html/en/screenshots.html
index d8b3c28..1d1968a 100644
--- a/html/en/screenshots.html
+++ b/html/en/screenshots.html
@@ -19,9 +19,10 @@
Screenshots
cdCanvas* canvas = canvas = cdCreateCanvas(ctx, data);
+
cdCanvas* canvas = cdCreateCanvas(ctx, data);
SimpleDraw(canvas);
diff --git a/html/en/screenshots_src_c.html b/html/en/screenshots_src_c.html
index bf33397..ec9f24a 100644
--- a/html/en/screenshots_src_c.html
+++ b/html/en/screenshots_src_c.html
@@ -9,6 +9,7 @@
p {
margin-top: 0;
margin-bottom: 0;
+ font-family: "Courier New", Courier, monospace;
}
.style1 {
color: #0000FF;
@@ -16,6 +17,12 @@
.style2 {
color: #FF00FF;
}
+.style3 {
+ font-family: Arial, Helvetica, sans-serif;
+}
+.style4 {
+ text-align: left;
+}
@@ -25,6 +32,13 @@
+
/* Draw 4 regions, in diamond shape,
-at top, bottom, left, right,
- using different interior styles.
+ at top, bottom, left, right, using different interior styles.
*/ /* At top, not filled polygon, notice that the last line style is used. */
@@ -847,9 +861,9 @@ h -
/* Adds a new page, or
-flushes the file, or
-flushes the screen, or
-swap the double buffer. */
+ flushes the file, or flushes the screen, or swap the double buffer. */
cdCanvasFlush(canvas);
diff --git a/html/en/screenshots_src_lua.html b/html/en/screenshots_src_lua.html new file mode 100644 index 0000000..2243414 --- /dev/null +++ b/html/en/screenshots_src_lua.html @@ -0,0 +1,686 @@ + + + + +Get the source code here: +simpledraw.lua.
++ + + + +
function SimpleDraw()
+-- Get size in pixels to be +used for computing coordinates.
w, +h = canvas:GetSize()
+-- Clear the background to be white
+canvas:Background(cd.WHITE) +
+canvas:Clear()
+
+-- Draw a reactangle and a polyline at +the bottom-left area,
+-- using a thick line with transparency.
+-- Notice that transparency is only supported in a few drivers,
+-- and line join is not supported in the IMAGERGB driver.
+canvas:LineWidth(3) +
+canvas:LineStyle(cd.CONTINUOUS) +
+canvas:Foreground(cd.EncodeAlpha(cd.DARK_MAGENTA, +128)) +
+canvas:Rect(100, +200, +100, +200) +
+canvas:Begin(cd.OPEN_LINES) +
+canvas:Vertex(300, +250) +
+canvas:Vertex(320, +270) +
+canvas:Vertex(350, +260) +
+canvas:Vertex(340, +200) +
+canvas:Vertex(310, +210) +
+canvas:End() +
+ +-- Draw the red diagonal line with a +custom line style. +-- Notice that line styles are not supported in the IMAGERGB driver.
+canvas:Foreground(cd.RED) +
+canvas:LineWidth(3) +
+dashes += +{20, +15, +5, +5} +
+canvas:LineStyleDashes(dashes, +4) +
++canvas:LineStyle(cd.CUSTOM) +
+canvas:Line(0, +0, +w-1, +h-1) +
+
+-- Draw the blue diagonal line with a +pre-defined line style.
+-- Notice that the pre-defined line style is dependent on the driver.
+canvas:Foreground(cd.BLUE) +
+canvas:LineWidth(10) +
+canvas:LineStyle(cd.DOTTED) +
+canvas:Line(0, +h-1, +w-1, +0) +
+
-- Reset line style and width
+canvas:LineStyle(cd.CONTINUOUS) +
+canvas:LineWidth(1) +
+ +-- Draw an arc at bottom-left, and a +sector at bottom-right. +-- Notice that counter-clockwise orientation of both.
+canvas:InteriorStyle(cd.SOLID) +
+canvas:Foreground(cd.MAGENTA) +
+canvas:Sector(w-100, +100, +100, +100, +50, +180) +
+canvas:Foreground(cd.RED) +
+canvas:Arc(100, +100, +100, +100, +50, +180) +
+
+-- Draw a solid filled rectangle at +center.
+canvas:Foreground(cd.YELLOW) +
+canvas:Box(w/2 +- +100, +w/2 ++ +100, +h/2 +- +100, +h/2 ++ +100)
++ +-- Prepare font for text.
+canvas:TextAlignment(cd.CENTER) +
+canvas:TextOrientation(70) +
+canvas:Font("Times", +cd.BOLD, +24) +
+
+-- Draw text at center, with +orientation,
+-- and draw its bounding box.
+-- Notice that in some drivers the bounding box is not precise.
++irect = canvas:GetTextBounds(w/2, +h/2, +"cdMin Draw (ηγν)")
+canvas:Foreground(cd.RED) +
+canvas:Begin(cd.CLOSED_LINES) +
+canvas:Vertex(irect[1], +irect[2]) +
+canvas:Vertex(irect[3], +irect[4]) +
+canvas:Vertex(irect[5], +irect[6]) +
+canvas:Vertex(irect[7], +irect[8]) +
+canvas:End()
++canvas:Foreground(cd.BLUE) +
+canvas:Text(w/2, +h/2, +"cdMin Draw (ηγν)") +
+
+-- Prepare World Coordinates
+canvas:wViewport(0,w-1,0,h-1) +
+if +(w>h) +then
+ +canvas:wWindow(0,w/h,0,1) +
+else
+ +canvas:wWindow(0,1,0,h/w) +
+end
+
+-- Draw a filled blue rectangle in WC
+canvas:wBox(0.20, +0.30, +0.40, +0.50) +
+canvas:Foreground(cd.RED) +
+
+-- Draw the diagonal of that rectangle in +WC
+canvas:wLine(0.20, +0.40, +0.30, +0.50) +
+
+-- Prepare Vector Text in WC.
+canvas:wVectorCharSize(0.07) +
+
-- Draw vector text, and draw its +bounding box.
+-- We also use this text to show when we are using a contextplus driver.
++canvas:Foreground(cd.RED) +
+if +(contextplus) +then
+ +drect = canvas:wGetVectorTextBounds("WDj-Plus", +0.25, +0.35) +
+else
+ +drect = canvas:wGetVectorTextBounds("WDj", +0.25, +0.35)
+end
+canvas:Begin(cd.CLOSED_LINES) +
+canvas:wVertex(drect[1], +drect[2]) +
+canvas:wVertex(drect[3], +drect[4]) +
+canvas:wVertex(drect[5], +drect[6]) +
+canvas:wVertex(drect[7], +drect[8]) +
+canvas:End()
+canvas:LineWidth(2) +
+canvas:LineStyle(cd.CONTINUOUS) +
+if +(contextplus) +then
+ +canvas:wVectorText(0.25, +0.35, +"WDj-Plus") +
+else
+ +canvas:wVectorText(0.25, +0.35, +"WDj") +
+end
+
-- Reset line width
++canvas:LineWidth(1) +
+-- Draw a filled path at center-right +(looks like a weird fish).
+-- Notice that in PDF the arc is necessarily a circle arc, and not an +ellipse.
+canvas:Foreground(cd.GREEN) +
+canvas:Begin(cd.PATH) +
+canvas:PathSet(cd.PATH_MOVETO) +
+canvas:Vertex(w/2 ++ +200, +h/2) +
+canvas:PathSet(cd.PATH_LINETO) +
+canvas:Vertex(w/2 ++ +230, +h/2 ++ +50) +
+canvas:PathSet(cd.PATH_LINETO) +
+canvas:Vertex(w/2 ++ +250, +h/2 ++ +50) +
+canvas:PathSet(cd.PATH_CURVETO) +
+canvas:Vertex(w/2+150+150, +h/2+200-50) +-- control point for start
+canvas:Vertex(w/2+150+180, +h/2+250-50) +-- control point for end
+canvas:Vertex(w/2+150+180, +h/2+200-50) +-- end point
+canvas:PathSet(cd.PATH_CURVETO) +
+canvas:Vertex(w/2+150+180, +h/2+150-50)
+ +canvas:Vertex
(w/2+150+150, +h/2+100-50) + +canvas:Vertex
(w/2+150+300, +h/2+100-50) + +canvas:PathSet
(cd.PATH_LINETO) ++canvas:Vertex(w/2+150+300, +h/2-50) +
+canvas:PathSet(cd.PATH_ARC) +
+canvas:Vertex(w/2+300, +h/2) +-- center
+canvas:Vertex(200, +100) +-- width, height
+canvas:Vertex(-30*1000, +-170*1000) +-- start angle, end angle (degrees / 1000)
+ ++canvas:PathSet(cd.PATH_FILL) +
++canvas:End()
+
+-- Draw 3 pixels at center left.
+canvas:Pixel(10, +h/2+0, +cd.RED) +
+canvas:Pixel(11, +h/2+1, +cd.GREEN) +
+canvas:Pixel(12, +h/2+2, +cd.BLUE) +
+
+-- Draw 4 mark types, distributed near +each corner.
+canvas:Foreground(cd.RED) +
+canvas:MarkSize(30) +
+canvas:MarkType(cd.PLUS) +
+canvas:Mark(200, +200) +
+canvas:MarkType(cd.CIRCLE) +
+canvas:Mark(w - +200, +200) +
+canvas:MarkType(cd.HOLLOW_CIRCLE) +
+canvas:Mark(200, +h - +200) +
+canvas:MarkType(cd.DIAMOND) +
+canvas:Mark(w - +200, +h - +200) +
+
+-- Draw all the line style +possibilities at bottom.
+-- Notice that they have some small differences between drivers.
+canvas:LineWidth(1) +
+canvas:LineStyle(cd.CONTINUOUS) +
+canvas:Line(0, +10, +w, +10) +
+canvas:LineStyle(cd.DASHED) +
+canvas:Line(0, +20, +w, +20) +
+canvas:LineStyle(cd.DOTTED) +
+canvas:Line(0, +30, +w, +30) +
+canvas:LineStyle(cd.DASH_DOT) +
+canvas:Line(0, +40, +w, +40) +
+canvas:LineStyle(cd.DASH_DOT_DOT) +
+canvas:Line(0, +50, +w, +50) +
+
+-- Draw all the hatch style +possibilities in the top-left corner.
+-- Notice that they have some small differences between drivers.
+canvas:Hatch(cd.VERTICAL)
+ +canvas:Box
(0, +50, +h - +60, +h) ++canvas:Hatch(cd.FDIAGONAL)
+ +canvas:Box
(50, +100, +h - +60, +h) ++canvas:Hatch(cd.BDIAGONAL)
+ +canvas:Box
(100, +150, +h - +60, +h) ++canvas:Hatch(cd.CROSS)
+ +canvas:Box
(150, +200, +h - +60, +h) ++canvas:Hatch(cd.HORIZONTAL)
+ +canvas:Box
(200, +250, +h - +60, +h) ++canvas:Hatch(cd.DIAGCROSS)
+ +canvas:Box
(250, +300, +h - +60, +h) + +
+-- Draw 4 regions, in diamond shape,
+-- at top, bottom, left, right,
+-- using different interior styles. +
++
-- At top, not filled polygon, notice that the last line style is used.
+canvas:Begin(cd.CLOSED_LINES) +
+canvas:Vertex(w/2, +h - +100)
+ +canvas:Vertex
(w/2 ++ +50, +h - +150) + +canvas:Vertex
(w/2, +h - +200) + +canvas:Vertex
(w/2 +- +50, +h - +150) + +canvas:End
() +
+-- At left, hatch filled polygon
+canvas:Hatch(cd.DIAGCROSS)
+ +canvas:Begin
(cd.FILL) ++canvas:Vertex(100, +h/2)
+ +canvas:Vertex
(150, +h/2 ++ +50) + +canvas:Vertex
(200, +h/2) + +canvas:Vertex
(150, +h/2 +- +50) + +canvas:End
() + +
+-- At right, pattern filled polygon
+canvas:Pattern(pattern) +
+canvas:Begin(cd.FILL) +
+canvas:Vertex(w - +100, +h/2)
+ +canvas:Vertex
(w - +150, +h/2 ++ +50) + +canvas:Vertex
(w - +200, +h/2) + +canvas:Vertex
(w - +150, +h/2 +- +50) + +canvas:End
() + +-- At bottom, stipple filled polygon+canvas:Stipple(stipple) +
+canvas:Begin(cd.FILL) +
+canvas:Vertex(w/2, +100)
+ +canvas:Vertex
(w/2 ++ +50, +150) + +canvas:Vertex
(w/2, +200) + +canvas:Vertex
(w/2 +- +50, +150) + +canvas:End
() +
+-- Draw two beziers at bottom-left
+canvas:Begin(cd.BEZIER) +
+canvas:Vertex(100, +100)
+ +canvas:Vertex
(150, +200) + +canvas:Vertex
(180, +250) + +canvas:Vertex
(180, +200) + +canvas:Vertex
(180, +150) + +canvas:Vertex
(150, +100) + +canvas:Vertex
(300, +100) + +canvas:End
() ++
-- Draw the image on the top-right corner but +increasing its actual size, and uses its full area
+canvas:PutImageRectRGBA(imagergba, +w - +400, +h - +310, +3*IMAGE_SIZE, +3*IMAGE_SIZE, +0, +0, +0, +0) +
++
-- Adds a new page, or
+-- flushes the file, or
+-- flushes the screen, or
+-- swap the double buffer.
+canvas:Flush()
+end +
+ + + + + + + diff --git a/html/examples/simpledraw.lua b/html/examples/simpledraw.lua new file mode 100644 index 0000000..cd6f77f --- /dev/null +++ b/html/examples/simpledraw.lua @@ -0,0 +1,345 @@ +require"cdlua" + +STYLE_SIZE = 10 +pattern = cd.CreatePattern(STYLE_SIZE, STYLE_SIZE) +stipple = cd.CreateStipple(STYLE_SIZE, STYLE_SIZE) + +for p = 0, STYLE_SIZE*STYLE_SIZE-1 do + pattern[p] = cd.WHITE +end + +pattern[11] = cd.RED +pattern[21] = cd.RED +pattern[31] = cd.RED +pattern[41] = cd.RED +pattern[51] = cd.RED +pattern[12] = cd.RED +pattern[22] = cd.RED +pattern[32] = cd.RED +pattern[42] = cd.RED +pattern[52] = cd.RED +pattern[13] = cd.RED +pattern[23] = cd.RED +pattern[33] = cd.RED +pattern[43] = cd.RED +pattern[53] = cd.RED +pattern[14] = cd.RED pattern[15] = cd.RED +pattern[24] = cd.RED pattern[25] = cd.RED +pattern[34] = cd.RED pattern[35] = cd.RED +pattern[44] = cd.RED pattern[45] = cd.RED +pattern[54] = cd.RED pattern[55] = cd.RED + +pattern[26] = cd.BLUE pattern[37] = cd.BLUE +pattern[36] = cd.BLUE pattern[47] = cd.BLUE +pattern[46] = cd.BLUE pattern[57] = cd.BLUE +pattern[56] = cd.BLUE pattern[67] = cd.BLUE + +pattern[48] = cd.BLUE pattern[62] = cd.GREEN +pattern[58] = cd.BLUE pattern[63] = cd.GREEN +pattern[68] = cd.BLUE pattern[64] = cd.GREEN +pattern[78] = cd.BLUE pattern[65] = cd.GREEN + pattern[66] = cd.GREEN + +pattern[73] = cd.GREEN pattern[84] = cd.GREEN +pattern[74] = cd.GREEN pattern[85] = cd.GREEN +pattern[75] = cd.GREEN pattern[86] = cd.GREEN +pattern[76] = cd.GREEN pattern[87] = cd.GREEN +pattern[77] = cd.GREEN pattern[88] = cd.GREEN + +-- initialize the stipple buffer with cross pattern +for l = 0, STYLE_SIZE-1 do + for c = 0, STYLE_SIZE-1 do + if ((c % 4) == 0) then + stipple[l*STYLE_SIZE + c] = 1 + else + stipple[l*STYLE_SIZE + c] = 0 + end + end +end + +IMAGE_SIZE = 100 +imagergba = cd.CreateImageRGBA(IMAGE_SIZE, IMAGE_SIZE) + +-- initialize the alpha image buffer with a degrade from transparent to opaque +for l = 0, IMAGE_SIZE-1 do + for c = 0, IMAGE_SIZE-1 do + if (l == 0 or l == IMAGE_SIZE-1 or c == 0 or c == IMAGE_SIZE-1) then + imagergba.r[l*IMAGE_SIZE + c] = 0 + imagergba.g[l*IMAGE_SIZE + c] = 0 + imagergba.b[l*IMAGE_SIZE + c] = 0 + else + if (l > IMAGE_SIZE/2) then + imagergba.r[l*IMAGE_SIZE + c] = 95 + imagergba.g[l*IMAGE_SIZE + c] = 143 + imagergba.b[l*IMAGE_SIZE + c] = 95 + else + imagergba.r[l*IMAGE_SIZE + c] = 255 + imagergba.g[l*IMAGE_SIZE + c] = 95 + imagergba.b[l*IMAGE_SIZE + c] = 95 + end + end + + imagergba.a[l*IMAGE_SIZE + c] = (c*255)/(IMAGE_SIZE-1); + end +end + + +function SimpleDraw() + -- Get size in pixels to be used for computing coordinates. + w, h = canvas:GetSize() + + -- Clear the background to be white + canvas:Background(cd.WHITE) + canvas:Clear() + + -- Draw a reactangle and a polyline at the bottom-left area, + -- using a thick line with transparency. + -- Notice that transparency is only supported in a few drivers, + -- and line join is not supported in the IMAGERGB driver. + canvas:LineWidth(3) + canvas:LineStyle(cd.CONTINUOUS) + canvas:Foreground(cd.EncodeAlpha(cd.DARK_MAGENTA, 128)) + canvas:Rect(100, 200, 100, 200) + canvas:Begin(cd.OPEN_LINES) + canvas:Vertex(300, 250) + canvas:Vertex(320, 270) + canvas:Vertex(350, 260) + canvas:Vertex(340, 200) + canvas:Vertex(310, 210) + canvas:End() + + -- Draw the red diagonal line with a custom line style. + -- Notice that line styles are not supported in the IMAGERGB driver. + canvas:Foreground(cd.RED) + canvas:LineWidth(3) + dashes = {20, 15, 5, 5} + canvas:LineStyleDashes(dashes, 4) + canvas:LineStyle(cd.CUSTOM) + canvas:Line(0, 0, w-1, h-1) + + -- Draw the blue diagonal line with a pre-defined line style. + -- Notice that the pre-defined line style is dependent on the driver. + canvas:Foreground(cd.BLUE) + canvas:LineWidth(10) + canvas:LineStyle(cd.DOTTED) + canvas:Line(0, h-1, w-1, 0) + + -- Reset line style and width + canvas:LineStyle(cd.CONTINUOUS) + canvas:LineWidth(1) + + -- Draw an arc at bottom-left, and a sector at bottom-right. + -- Notice that counter-clockwise orientation of both. + canvas:InteriorStyle(cd.SOLID) + canvas:Foreground(cd.MAGENTA) + canvas:Sector(w-100, 100, 100, 100, 50, 180) + canvas:Foreground(cd.RED) + canvas:Arc(100, 100, 100, 100, 50, 180) + + -- Draw a solid filled rectangle at center. + canvas:Foreground(cd.YELLOW) + canvas:Box(w/2 - 100, w/2 + 100, h/2 - 100, h/2 + 100) + + -- Prepare font for text. + canvas:TextAlignment(cd.CENTER) + canvas:TextOrientation(70) + canvas:Font("Times", cd.BOLD, 24) + + -- Draw text at center, with orientation, + -- and draw its bounding box. + -- Notice that in some drivers the bounding box is not precise. + irect = canvas:GetTextBounds(w/2, h/2, "cdMin Draw (ηγν)") + canvas:Foreground(cd.RED) + canvas:Begin(cd.CLOSED_LINES) + canvas:Vertex(irect[1], irect[2]) + canvas:Vertex(irect[3], irect[4]) + canvas:Vertex(irect[5], irect[6]) + canvas:Vertex(irect[7], irect[8]) + canvas:End() + canvas:Foreground(cd.BLUE) + canvas:Text(w/2, h/2, "cdMin Draw (ηγν)") + + -- Prepare World Coordinates + canvas:wViewport(0,w-1,0,h-1) + if (w>h) then + canvas:wWindow(0,w/h,0,1) + else + canvas:wWindow(0,1,0,h/w) + end + + -- Draw a filled blue rectangle in WC + canvas:wBox(0.20, 0.30, 0.40, 0.50) + canvas:Foreground(cd.RED) + + -- Draw the diagonal of that rectangle in WC + canvas:wLine(0.20, 0.40, 0.30, 0.50) + + -- Prepare Vector Text in WC. + canvas:wVectorCharSize(0.07) + + -- Draw vector text, and draw its bounding box. + -- We also use this text to show when we are using a contextplus driver. + canvas:Foreground(cd.RED) + if (contextplus) then + drect = canvas:wGetVectorTextBounds("WDj-Plus", 0.25, 0.35) + else + drect = canvas:wGetVectorTextBounds("WDj", 0.25, 0.35) + end + canvas:Begin(cd.CLOSED_LINES) + canvas:wVertex(drect[1], drect[2]) + canvas:wVertex(drect[3], drect[4]) + canvas:wVertex(drect[5], drect[6]) + canvas:wVertex(drect[7], drect[8]) + canvas:End() + canvas:LineWidth(2) + canvas:LineStyle(cd.CONTINUOUS) + if (contextplus) then + canvas:wVectorText(0.25, 0.35, "WDj-Plus") + else + canvas:wVectorText(0.25, 0.35, "WDj") + end + + -- Reset line width + canvas:LineWidth(1) + + -- Draw a filled path at center-right (looks like a weird fish). + -- Notice that in PDF the arc is necessarily a circle arc, and not an ellipse. + canvas:Foreground(cd.GREEN) + canvas:Begin(cd.PATH) + canvas:PathSet(cd.PATH_MOVETO) + canvas:Vertex(w/2 + 200, h/2) + canvas:PathSet(cd.PATH_LINETO) + canvas:Vertex(w/2 + 230, h/2 + 50) + canvas:PathSet(cd.PATH_LINETO) + canvas:Vertex(w/2 + 250, h/2 + 50) + canvas:PathSet(cd.PATH_CURVETO) + canvas:Vertex(w/2+150+150, h/2+200-50) -- control point for start + canvas:Vertex(w/2+150+180, h/2+250-50) -- control point for end + canvas:Vertex(w/2+150+180, h/2+200-50) -- end point + canvas:PathSet(cd.PATH_CURVETO) + canvas:Vertex(w/2+150+180, h/2+150-50) + canvas:Vertex(w/2+150+150, h/2+100-50) + canvas:Vertex(w/2+150+300, h/2+100-50) + canvas:PathSet(cd.PATH_LINETO) + canvas:Vertex(w/2+150+300, h/2-50) + canvas:PathSet(cd.PATH_ARC) + canvas:Vertex(w/2+300, h/2) -- center + canvas:Vertex(200, 100) -- width, height + canvas:Vertex(-30*1000, -170*1000) -- start angle, end angle (degrees / 1000) + canvas:PathSet(cd.PATH_FILL) + canvas:End() + + -- Draw 3 pixels at center left. + canvas:Pixel(10, h/2+0, cd.RED) + canvas:Pixel(11, h/2+1, cd.GREEN) + canvas:Pixel(12, h/2+2, cd.BLUE) + + -- Draw 4 mark types, distributed near each corner. + canvas:Foreground(cd.RED) + canvas:MarkSize(30) + canvas:MarkType(cd.PLUS) + canvas:Mark(200, 200) + canvas:MarkType(cd.CIRCLE) + canvas:Mark(w - 200, 200) + canvas:MarkType(cd.HOLLOW_CIRCLE) + canvas:Mark(200, h - 200) + canvas:MarkType(cd.DIAMOND) + canvas:Mark(w - 200, h - 200) + + -- Draw all the line style possibilities at bottom. + -- Notice that they have some small differences between drivers. + canvas:LineWidth(1) + canvas:LineStyle(cd.CONTINUOUS) + canvas:Line(0, 10, w, 10) + canvas:LineStyle(cd.DASHED) + canvas:Line(0, 20, w, 20) + canvas:LineStyle(cd.DOTTED) + canvas:Line(0, 30, w, 30) + canvas:LineStyle(cd.DASH_DOT) + canvas:Line(0, 40, w, 40) + canvas:LineStyle(cd.DASH_DOT_DOT) + canvas:Line(0, 50, w, 50) + + -- Draw all the hatch style possibilities in the top-left corner. + -- Notice that they have some small differences between drivers. + canvas:Hatch(cd.VERTICAL) + canvas:Box(0, 50, h - 60, h) + canvas:Hatch(cd.FDIAGONAL) + canvas:Box(50, 100, h - 60, h) + canvas:Hatch(cd.BDIAGONAL) + canvas:Box(100, 150, h - 60, h) + canvas:Hatch(cd.CROSS) + canvas:Box(150, 200, h - 60, h) + canvas:Hatch(cd.HORIZONTAL) + canvas:Box(200, 250, h - 60, h) + canvas:Hatch(cd.DIAGCROSS) + canvas:Box(250, 300, h - 60, h) + + -- Draw 4 regions, in diamond shape, + -- at top, bottom, left, right, + -- using different interior styles. + + -- At top, not filled polygon, notice that the last line style is used. + canvas:Begin(cd.CLOSED_LINES) + canvas:Vertex(w/2, h - 100) + canvas:Vertex(w/2 + 50, h - 150) + canvas:Vertex(w/2, h - 200) + canvas:Vertex(w/2 - 50, h - 150) + canvas:End() + + -- At left, hatch filled polygon + canvas:Hatch(cd.DIAGCROSS) + canvas:Begin(cd.FILL) + canvas:Vertex(100, h/2) + canvas:Vertex(150, h/2 + 50) + canvas:Vertex(200, h/2) + canvas:Vertex(150, h/2 - 50) + canvas:End() + + -- At right, pattern filled polygon + canvas:Pattern(pattern) + canvas:Begin(cd.FILL) + canvas:Vertex(w - 100, h/2) + canvas:Vertex(w - 150, h/2 + 50) + canvas:Vertex(w - 200, h/2) + canvas:Vertex(w - 150, h/2 - 50) + canvas:End() + + -- At bottom, stipple filled polygon + canvas:Stipple(stipple) + canvas:Begin(cd.FILL) + canvas:Vertex(w/2, 100) + canvas:Vertex(w/2 + 50, 150) + canvas:Vertex(w/2, 200) + canvas:Vertex(w/2 - 50, 150) + canvas:End() + + -- Draw two beziers at bottom-left + canvas:Begin(cd.BEZIER) + canvas:Vertex(100, 100) + canvas:Vertex(150, 200) + canvas:Vertex(180, 250) + canvas:Vertex(180, 200) + canvas:Vertex(180, 150) + canvas:Vertex(150, 100) + canvas:Vertex(300, 100) + canvas:End() + + -- Draw the image on the top-right corner but increasing its actual size, and uses its full area + canvas:PutImageRectRGBA(imagergba, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE, 0, 0, 0, 0) + + -- Adds a new page, or + -- flushes the file, or + -- flushes the screen, or + -- swap the double buffer. + canvas:Flush() +end + + +canvas = cd.CreateCanvas(cd.SVG, "cd_svg.svg 270.933x198.543 4.72441") + +SimpleDraw(canvas) + +-- Destroys the canvas and releases internal memory, +-- important for file based drivers to close the file. +canvas:Kill() diff --git a/html/wb/wb_usr.lua b/html/wb/wb_usr.lua index 9cb014a..36f55c8 100644 --- a/html/wb/wb_usr.lua +++ b/html/wb/wb_usr.lua @@ -84,6 +84,10 @@ wb_usr.tree = { name= {en= "C Source Code"}, link= "screenshots_src_c.html" + }, + { + name= {en= "Lua Source Code"}, + link= "screenshots_src_lua.html" } } }, diff --git a/html/wb_search.txt b/html/wb_search.txt index fae2db1..1d0aa7c 100644 --- a/html/wb_search.txt +++ b/html/wb_search.txt @@ -1,16 +1,17 @@ -en/history.html +en/download.html en/drv/xrender.html +en/drv/gdiplus.html en/drv/debug.html en/func/server.html en/func/wd.html en/func/client.html en/func/region.html -en/drv/gdiplus.html -en/drv/sim.html en/drv/cairo.html +en/drv/sim.html +en/drv/xwin.html en/drv/native.html en/func/control.html -en/drv/xwin.html +en/screenshots_src_lua.html en/drv/win32.html en/drv/gdk.html en/func/vectortext.html @@ -34,22 +35,22 @@ en/drv/mf.html en/drv/irgb.html en/drv/ps.html en/drv/wmf.html -en/func/marks.html +en/func/lines.html en/drv/dxf.html en/copyright.html en/drv/iup.html en/drv/svg.html en/screenshots_src_c.html en/drv/printer.html -en/func/coordinates.html +en/cdluaim.html en/guide.html en/drv/dgn.html en/drv/image.html en/func/color.html en/cdlua.html en/drv/clipbd.html -en/download.html -en/func/lines.html +en/func/marks.html +en/func/coordinates.html en/func/polygon.html en/drv/dbuf.html en/func/other.html @@ -57,5 +58,5 @@ en/toolkits.html en/internal.html en/home.html en/canvas.html -en/cdluaim.html +en/history.html en/download_tips.html diff --git a/html/wb_tree.html b/html/wb_tree.html index 3d99c7c..a7d6053 100644 --- a/html/wb_tree.html +++ b/html/wb_tree.html @@ -237,321 +237,322 @@ - + - + Initialization
Control
Coordinate System
Extra
General Attributes
Primitives
Attributes
Attributes
Extras in Lua
Attributes
Properties
Attributes
Properties
Extras
Extras in Lua
Other
System
Metafile Interpretation
Color Coding
Window Systems
Devices
Images
File
Base Drivers
Context Plus