From dda913804cdc6697c12c06cf29959576b6825df6 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 16 Sep 2020 19:32:43 +0900 Subject: [PATCH] Update README.md updated sample code --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9a34d521..4b3fb715 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,27 @@ canvas->target(buffer, WIDTH, WIDTH, HEIGHT); //stride, w, h Next you can draw shapes onto the canvas. ```cpp -auto shape = tvg::Shape::gen(); //generate a shape -shape->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry -shape->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH -shape->fill(255, 255, 0, 255); //r, g, b, a +auto rect = tvg::Shape::gen(); //generate a round rectangle +rect->appendRect(50, 50, 200, 200, 20, 20); //round geometry(x, y, w, h, rx, ry) +rect->fill(255, 255, 0, 255); //set round rectangle color (r, g, b, a) +canvas->push(move(rect)); //push round rectangle drawing command + +auto circle = tvg::Shape::gen(); //generate a circle +circle->appendCircle(400, 400, 100, 100); //circle geometry(cx, cy, radiusW, radiusH) + +auto fill = tvg::RadialGradient::gen(); //generate radial gradient for circle fill +fill->radial(400, 400, 150); //radial fill info(cx, cy, radius) + +tvg::Fill::ColorStop colorStops[2]; //gradient color info +colorStops[0] = {0, 255, 255, 255, 255}; //index, r, g, b, a (1st color value) +colorStops[1] = {1, 0, 0, 0, 255}; //index, r, g, b, a (2nd color value) + +fill.colorStops(colorStop, 2); //set gradient color info + +circle->fill(move(fill)); //set circle color + +canvas->push(move(circle)); //push circle drawing command -canvas->push(move(shape)); //push shape drawing command ``` This code snippet shows you how to draw SVG image.