Commit graph

3760 commits

Author SHA1 Message Date
Hermet Park
c807010554 examples FillRule: added shape::fillRule() example
one shape shows Winding, the other one shows EvenOdd.
2020-10-22 13:50:04 +09:00
Hermet Park
04aa038339 common fill: add fill-rule interface.
Fill rule is used to select how paths are filled.

For both fill rules, wheter or not a point is included in the fill is determined by taking a ray
from that point to infinity and looking at intersections with the path. The ray can be in any
direction, as long as it doens't pass through the end point of a segment or have a tricky
intersection such as intersecting tangent to the path.

@API Addtions:

enum class TVG_EXPORT FillRule { Winding = 0, EvenOdd };
Result Fill::rule(FillRule r) noexcept;
FillRule Fill::rule() const noexcept;

@Examples:

shape->rule(FillRule::EvenOdd);

@issue: 97
2020-10-20 20:10:59 +09:00
Mira Grudzinska
380450c95b Bezier curve: introducing BEZIER_EPSILON
BEZIER_EPSILON is used instead of EPSILON_FLT, because its
value was to small causing in some cases an infinite loop.
2020-10-20 16:12:59 +09:00
Hermet Park
389b028be4 svg_loader XmlParser: just renamed file name to simplify.
XmlParser without "Simple" is enough to address itself.
2020-10-15 20:44:53 +09:00
Shinwoo Kim
1e030004ed wasm test: update sample index.html
Update index.html according to updated wasm interface.
Missed chance to update index.html during review.
2020-10-15 15:09:10 +09:00
Hermet Park
0aaa04cd47
Update CONTRIBUTING.md 2020-10-15 12:14:50 +09:00
Hermet Park
5b36ce827d
Update CONTRIBUTING.md 2020-10-15 12:09:08 +09:00
Hermet Park
a16a9409e4
Update CONTRIBUTING.md 2020-10-15 12:04:05 +09:00
Hermet Park
9a9d29ede0
Create CONTRIBUTING.md
First guideline for contribution.
2020-10-15 12:01:01 +09:00
Shinwoo Kim
cc81e46343 thorvg viewer: fix scale problem
If viewer calls load() with a data which does not have size changes of both
viewbox and canvas, then load() does not set a scale value.
This makes incorrect result on viewer side.

So thorvg wasm should set a scale value, whenever load() is called.
2020-10-15 10:19:20 +09:00
Shinwoo Kim
acac884257 thorvg viewer: add getDefualtData interface
The 'getDefaultData' interface will be used when the svg data area
of thorvg viewer does not have any value.
2020-10-14 19:22:13 +09:00
Hermet Park
a4b828c556 svg_loader: fix wasm data type compile error. 2020-10-14 17:51:59 +09:00
Hermet Park
3e5d3b06c3 improve svg logo design quality. 2020-10-14 17:51:33 +09:00
Hermet Park
d3ec8ba16b
Update README.md 2020-10-13 19:15:17 +09:00
Hermet Park
1d76b3cd2a
Update README.md 2020-10-13 19:13:46 +09:00
Shinwoo Kim
0c68c45ef7 thorvg viewer: introduce thorvg viewer
Support Emscripten wasm build for thorvg viewer
2020-10-13 19:04:46 +09:00
Hermet Park
32f40bf7b0 re-tourched logo design for better quality. 2020-10-13 17:23:11 +09:00
Hermet Park
2a239714af sw_engine: fix missing shape update issue.
It missed to update shape data if visilibity is changed from false to true by alpha.

Also, it needs to update engine shape data for every requests.

There scenario can be allowed,

1. update shape
2. change shape property
3. update shape
4. draw

previously engine could skip step 3, its result was not properly expected.

@fix #84
2020-10-13 17:07:54 +09:00
JunsuChoi
77ccbcc6fe
tvgSvgLoader: Add points copy of missing polygon/polyline
When using <use> node, do atrribute copy.
At that time, when target(url) is polygon or polyline,
points array is not copied, causing a problem in output.
So, add missing array copy.
2020-10-13 13:45:40 +09:00
JunsuChoi
098c94819c tvgSvgLoader: Fix wrong bracket 2020-10-13 13:43:54 +09:00
JunsuChoi
e73cf7db60 tvgSvgLoader: Add "clip-path" attribute
Below node types support clip-path.
<circle>
<ellipse>
<g>
<path>
<polygon>
<polyline>
<rect>
2020-10-13 13:43:54 +09:00
JunsuChoi
ea0ce1f496 SvgLoader: Implement ClipPath style
Supports case of using style attribute for defined <clipPath>.
In SVG, <clipPath> can be used as a "clipPath" attribute or a style "clip-path".
This patch only supports "clip-path" of style is declared.
The remaining features will be added later.

[Example SVG case]

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
 <defs>
      <clipPath id="clipPath">
          <rect x="15" y="15" width="40" height="40" fill="#F00" />
          <circle cx="20" cy="20" r="10" fill="#F00" />
      </clipPath>
  </defs>

  <circle cx="25" cy="25" r="20"
          style="fill: #0000ff; clip-path: url(#clipPath); " />
</svg>
2020-10-13 13:43:54 +09:00
Hermet Park
31725b8d33 examples: update DirectUpdate
Shape::clear() method is changed.
Now it clear all properties, the examples must be updated.
2020-10-13 13:34:10 +09:00
Hermet Park
a8124f6782 Added thorvg logo svg resources,
Also replaced svg examples to use them.
2020-10-13 12:07:47 +09:00
Hermet Park
36df183e12 svg_loader: use designated fabsf() for float values.
fabs() is designed for double type,
but here it uses float type.
2020-10-13 09:55:40 +09:00
Hermet Park
db367d0c14
common shape: fix reset() bug. (#99)
Previous reset() doesn't implemented properly.
It resets only path data.

Now Shape resets all drawing properties.
2020-10-08 16:37:39 +09:00
Hermet Park
24a0a2554d
examples: add stacking example
This example shows how to restack paints node
2020-10-08 15:57:01 +09:00
JunsuChoi
f859cf7a84 Travis-CI: Add build options
enable examples and svg2png tool
2020-10-08 12:40:26 +09:00
Hermet Park
8422e8c62b common canvas: revise clear method.
Canvas::clear() introduces a new argument "free" that deterimes freeing the retained paints.

If free is true, Canvas won't delete the retained paints so that user keep paints valid.

In this scenario, user must have paints pointers, free them manually or push them again to the canvas.

This scenario is useful if user wants to re-organize paints order in the list or reuse them.
2020-10-08 12:07:27 +09:00
JunsuChoi
4de26d7c86
Add PULL_REQUEST_TEMPLATE.md (#92)
[Template]
- Description :

- Issue Tickets (if any) :

- Tests or Samples (if any) :

- Screen Shots (if any) :
2020-10-07 16:27:50 +09:00
Hermet Park
a200c6d4e2
common: code refactoring
renamed the enum CompMethod -> CompositionMethod

added FIXME comment
also clean up internals for less code.
2020-10-07 16:25:09 +09:00
Hermet Park
c6b3f78eca common bezier: code refactoring.
use a zero ranged macro.
2020-10-07 14:33:17 +09:00
Hermet Park
e358675d61
Bezier curve: improvement of the curve splitting algorithm (#86)
bezAt() function needed to be fixed.
Also the convergence in the while loop was sped up and
the break condition was changed.
2020-10-07 14:30:13 +09:00
Hermet Park
b5c301ba2d examples: add missing files. 2020-10-07 14:28:11 +09:00
Hermet Park
433746f2bd examples: removed test prefix 2020-10-07 14:04:08 +09:00
Hermet Park
4204030bbe examples: revise Stroke, StrokeLine 2020-10-07 13:48:09 +09:00
JunsuChoi
c70d1b1e45
SwRender & tvgPaint: Implement ClipPath feature (#68)
common sw_engine: Implement ClipPath feature

Paint object can composite by using composite API.
ClipPath composite is clipping by path unit of paint.
The following cases are supported.

Shape->composite(Shape);
Scene->composite(Shape);
Picture->composite(Shape);

Add enum
  enum CompMethod { None = 0, ClipPath };

Add APIs
  Result composite(std::unique_ptr<Paint> comp, CompMethod method) const noexcept;

* Example: Added testClipPath
2020-10-07 11:21:23 +09:00
Hermet Park
740c59debd sw_engine: code refactoring.
clean code for compaction.
2020-10-07 10:36:59 +09:00
Mateusz Palkowski
3314df89ae gradient: added check for gradient start and end set for 0 2020-10-07 10:28:41 +09:00
Hermet Park
72847b88cc updated .gitignore 2020-10-06 14:03:07 +09:00
Mira Grudzinska
910d45d93f shape: fixing 'pie' option
For a dashed arc with pie = 1 the closing line was missing.
2020-10-06 11:29:46 +09:00
Mira Grudzinska
48f1115b0b examples: testStrokeLine example expanded
Added dashed lines to circles and arcs.
2020-10-06 11:27:00 +09:00
Mira Grudzinska
9cd4d2b363 Bezier curve: improvement of the curve splitting algorithm
bezAt() function needed to be fixed.
Also the convergence in the while loop was sped up and
the break condition was changed.
2020-10-01 03:09:36 +02:00
Hermet Park
ea028a479c gl_engine: fix compile error.
After refactoring header includsion, gl_engine has a break at file dependencies.
now this fixes it.
2020-09-25 14:00:16 +09:00
Michal Szczecinski
74f8da845e gradient: Fixed radial gradient setter.
Removed check for gradient radius. Because of check, x and y values
was ignored when radius equals 0 and api was not usable
in integration with external libs which sets gradient center and
radius in separeted functions.
2020-09-25 13:58:30 +09:00
Hermet Park
56db18fbf1 common: code refactoring.
Merge shape internal bodies to one (ShapePath => ShapeImpl),
for keeping less files.
2020-09-24 17:06:16 +09:00
Hermet Park
6365d02a96 optimization: cut off file dependencies.
we should avoid code insertion during file dependencies,
such as #include "xxx.h" which has implementations.

This could increase binary size, we can avoid it as possible.

Current patch improves binary size like this:

From: file(2059008) = text(120360) data(8096) bss(80) dec(128536)
To  : file(1921832) = text(118429) data(7872) bss(56) dec(126357)

More additional patches will come in to optmize binary size.
2020-09-23 20:57:30 +09:00
mmaciola
145bafbec8
bindings/capi: Added gradient getter
Co-authored-by: Michal Maciola <m.maciola@samsung.com>
2020-09-23 15:09:08 +09:00
Hermet Park
ce69dcd416 examples: added stress test. 2020-09-23 14:42:52 +09:00
JunsuChoi
cf4edcf593 SvgPath: When path end(Z,z), Current point are returned to starting point(M,m)
When path ends with 'z' or 'Z' command, if 'm' comes as next command,
the current point is incorrectly referenced.
Since 'Z', 'z' means to close the path,
so, Save point and reuse it when 'M' or 'm' is called.
2020-09-22 14:50:15 +09:00