namespace tvg
{
-enum class TIZENVG_EXPORT PathCommand { Close, MoveTo, LineTo, CubicTo };
+enum class TIZENVG_EXPORT PathCommand { Close = 0, MoveTo, LineTo, CubicTo };
+enum class TIZENVG_EXPORT StrokeCap { Square = 0, Round, Butt };
+enum class TIZENVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
class RenderMethod;
class Scene;
int reset() noexcept;
+ //Path
int moveTo(float x, float y) noexcept;
int lineTo(float x, float y) noexcept;
int cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
int close() noexcept;
+ //Shape
int appendRect(float x, float y, float w, float h, float cornerRadius) noexcept;
int appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept;
int appendPath(const PathCommand* cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept;
+ //Stroke
int stroke(size_t width) noexcept;
int stroke(size_t r, size_t g, size_t b, size_t a) noexcept;
int stroke(const size_t* dashPattern, size_t cnt) noexcept;
+ int stroke(StrokeCap cap) noexcept;
+ int stroke(StrokeJoin join) noexcept;
+ //Fill
int fill(size_t r, size_t g, size_t b, size_t a) noexcept;
+ //Transform
int rotate(float degree) noexcept override;
int scale(float factor) noexcept override;
int translate(float x, float y) noexcept override;
+ //Getters
size_t pathCommands(const PathCommand** cmds) const noexcept;
size_t pathCoords(const Point** pts) const noexcept;
int fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
- size_t stroke() const noexcept;
- int stroke(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
- size_t stroke(const size_t** dashPattern) const noexcept;
-
int bounds(float* x, float* y, float* w, float* h) const noexcept override;
+ size_t strokeWidth() const noexcept;
+ int strokeColor(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
+ size_t strokeDash(const size_t** dashPattern) const noexcept;
+ StrokeCap strokeCap() const noexcept;
+ StrokeJoin strokeJoin() const noexcept;
+
static std::unique_ptr<Shape> gen() noexcept;
_TIZENVG_DECLARE_ACCESSOR(Scene);
}
-size_t Shape::stroke() const noexcept
+size_t Shape::strokeWidth() const noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int Shape::stroke(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
+int Shape::strokeColor(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-size_t Shape::stroke(const size_t** dashPattern) const noexcept
+size_t Shape::strokeDash(const size_t** dashPattern) const noexcept
{
- assert(dashPattern);
-
auto impl = pImpl.get();
assert(impl);
if (!impl->stroke) return 0;
- *dashPattern = impl->stroke->dashPattern;
+ if (dashPattern) *dashPattern = impl->stroke->dashPattern;
return impl->stroke->dashCnt;
}
+int Shape::stroke(StrokeCap cap) noexcept
+{
+ auto impl = pImpl.get();
+ assert(impl);
+
+ if (!impl->strokeCap(cap)) return -1;
+
+ return 0;
+}
+
+
+int Shape::stroke(StrokeJoin join) noexcept
+{
+ auto impl = pImpl.get();
+ assert(impl);
+
+ if (!impl->strokeJoin(join)) return -1;
+
+ return 0;
+}
+
+
+StrokeCap Shape::strokeCap() const noexcept
+{
+ auto impl = pImpl.get();
+ assert(impl);
+
+ if (!impl->stroke) return StrokeCap::Square;
+
+ return impl->stroke->cap;
+}
+
+
+StrokeJoin Shape::strokeJoin() const noexcept
+{
+ auto impl = pImpl.get();
+ assert(impl);
+
+ if (!impl->stroke) return StrokeJoin::Bevel;
+
+ return impl->stroke->join;
+}
+
+
#endif //_TVG_SHAPE_CPP_
size_t color[4] = {0, 0, 0, 0};
size_t* dashPattern = nullptr;
size_t dashCnt = 0;
+ StrokeCap cap = StrokeCap::Square;
+ StrokeJoin join = StrokeJoin::Bevel;
~ShapeStroke()
{
return 0;
}
+ bool strokeCap(StrokeCap cap)
+ {
+ if (!stroke) stroke = new ShapeStroke();
+ assert(stroke);
+
+ stroke->cap = cap;
+ flag |= RenderUpdateFlag::Stroke;
+
+ return 0;
+ }
+
+ bool strokeJoin(StrokeJoin join)
+ {
+ if (!stroke) stroke = new ShapeStroke();
+ assert(stroke);
+
+ stroke->join = join;
+ flag |= RenderUpdateFlag::Stroke;
+
+ return 0;
+ }
+
bool strokeColor(size_t r, size_t g, size_t b, size_t a)
{
if (!stroke) stroke = new ShapeStroke();