Compare commits
16 Commits
5706c70a22
...
f96479c074
Author | SHA1 | Date | |
---|---|---|---|
f96479c074 | |||
db35b7c75b | |||
38e338d731 | |||
e060e381b1 | |||
bf9d5a126a | |||
eaa443d484 | |||
1e0de1fc98 | |||
ebdfeb99d8 | |||
9ab4c0f7ab | |||
f02b8b47b9 | |||
6d504b31ec | |||
8553ffec06 | |||
7563abcf5a | |||
343f289fe2 | |||
aca0e071cd | |||
edf2c04a07 |
373
LICENSE
Normal file
373
LICENSE
Normal file
@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
@ -61,15 +61,15 @@ Compile software:
|
||||
lutin -C -P esvg-test
|
||||
|
||||
|
||||
License (APACHE v2.0)
|
||||
License (MPL v2.0)
|
||||
=====================
|
||||
Copyright esvg Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
https://www.mozilla.org/MPL/2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -36,16 +36,16 @@ Are there any licensing restrictions? {#esvg_mainpage_license_restric
|
||||
ESVG is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||
|
||||
|
||||
License (APACHE-2.0) {#esvg_mainpage_license}
|
||||
====================
|
||||
License (MPL v2.0) {#esvg_mainpage_license}
|
||||
==================
|
||||
|
||||
Copyright ESVG Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||
<https://www.mozilla.org/MPL/2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
122
esvg/Base.cpp
122
esvg/Base.cpp
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
const float esvg::kappa90(0.5522847493f);
|
||||
|
||||
esvg::PaintState::PaintState() :
|
||||
fill(std::pair<etk::Color<float,4>, std::string>(etk::color::black, "")),
|
||||
stroke(std::pair<etk::Color<float,4>, std::string>(etk::color::none, "")),
|
||||
fill(etk::Pair<etk::Color<float,4>, etk::String>(etk::color::black, "")),
|
||||
stroke(etk::Pair<etk::Color<float,4>, etk::String>(etk::color::none, "")),
|
||||
strokeWidth(1.0f),
|
||||
flagEvenOdd(false),
|
||||
lineCap(esvg::cap_butt),
|
||||
@ -25,8 +25,8 @@ esvg::PaintState::PaintState() :
|
||||
}
|
||||
|
||||
void esvg::PaintState::clear() {
|
||||
fill = std::pair<etk::Color<float,4>, std::string>(etk::color::black, "");
|
||||
stroke = std::pair<etk::Color<float,4>, std::string>(etk::color::none, "");
|
||||
fill = etk::Pair<etk::Color<float,4>, etk::String>(etk::color::black, "");
|
||||
stroke = etk::Pair<etk::Color<float,4>, etk::String>(etk::color::none, "");
|
||||
strokeWidth = 1.0;
|
||||
viewPort.first.setValue(0.0f,0.0f);
|
||||
viewPort.first.setValue(0.0f,0.0f);
|
||||
@ -43,9 +43,9 @@ esvg::Base::Base(PaintState _parentPaintState) {
|
||||
m_paint = _parentPaintState;
|
||||
}
|
||||
|
||||
std::string extractTransformData(const std::string& _value, const std::string& _base) {
|
||||
etk::String extractTransformData(const etk::String& _value, const etk::String& _base) {
|
||||
size_t posStart = _value.find(_base);
|
||||
if (posStart == std::string::npos) {
|
||||
if (posStart == etk::String::npos) {
|
||||
// Not find element is a normal case ...
|
||||
return "";
|
||||
}
|
||||
@ -69,35 +69,35 @@ std::string extractTransformData(const std::string& _value, const std::string& _
|
||||
return "";
|
||||
}
|
||||
size_t posEnd = _value.find(')', posStart);
|
||||
if (posEnd == std::string::npos) {
|
||||
if (posEnd == etk::String::npos) {
|
||||
ESVG_ERROR("Missing element ')' in '" << _value << "' for " << _base);
|
||||
return "";
|
||||
}
|
||||
ESVG_VERBOSE("Find : '" << std::string(_value.begin()+posStart, _value.begin()+posEnd) << "' for " << _base);
|
||||
return std::string(_value.begin()+posStart, _value.begin()+posEnd);
|
||||
ESVG_VERBOSE("Find : '" << etk::String(_value.begin()+posStart, _value.begin()+posEnd) << "' for " << _base);
|
||||
return etk::String(_value.begin()+posStart, _value.begin()+posEnd);
|
||||
}
|
||||
|
||||
void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
if (_element.exist() == false) {
|
||||
return;
|
||||
}
|
||||
std::string inputString = _element.attributes["transform"];
|
||||
etk::String inputString = _element.attributes["transform"];
|
||||
if (inputString.size() == 0) {
|
||||
return;
|
||||
}
|
||||
ESVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
for (int32_t iii=0; iii<inputString.size(); iii++) {
|
||||
for (size_t iii=0; iii<inputString.size(); iii++) {
|
||||
if (inputString[iii] == ',') {
|
||||
inputString[iii] = ' ';
|
||||
}
|
||||
}
|
||||
ESVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
// need to find elements in order ...
|
||||
std::string data = extractTransformData(inputString, "matrix");
|
||||
etk::String data = extractTransformData(inputString, "matrix");
|
||||
if (data.size() != 0) {
|
||||
double matrix[6];
|
||||
if (sscanf(data.c_str(), "%lf %lf %lf %lf %lf %lf", &matrix[0], &matrix[1], &matrix[2], &matrix[3], &matrix[4], &matrix[5]) == 6) {
|
||||
m_transformMatrix = mat2(matrix);
|
||||
m_transformMatrix = mat2x3(matrix);
|
||||
// find a matrix : simply exit ...
|
||||
return;
|
||||
} else {
|
||||
@ -108,10 +108,10 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
if (data.size() != 0) {
|
||||
float xxx, yyy;
|
||||
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
||||
m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy));
|
||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, yyy));
|
||||
ESVG_VERBOSE("Translate : " << xxx << ", " << yyy);
|
||||
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
||||
m_transformMatrix *= etk::mat2Translate(vec2(xxx, 0));
|
||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, 0));
|
||||
ESVG_VERBOSE("Translate : " << xxx << ", " << 0);
|
||||
} else {
|
||||
ESVG_ERROR("Parsing translate() with wrong data ... '" << data << "'");
|
||||
@ -121,10 +121,10 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
if (data.size() != 0) {
|
||||
float xxx, yyy;
|
||||
if (sscanf(data.c_str(), "%f %f", &xxx, &yyy) == 2) {
|
||||
m_transformMatrix *= etk::mat2Scale(vec2(xxx, yyy));
|
||||
m_transformMatrix *= etk::mat2x3Scale(vec2(xxx, yyy));
|
||||
ESVG_VERBOSE("Scale : " << xxx << ", " << yyy);
|
||||
} else if (sscanf(data.c_str(), "%f", &xxx) == 1) {
|
||||
m_transformMatrix *= etk::mat2Scale(xxx);
|
||||
m_transformMatrix *= etk::mat2x3Scale(xxx);
|
||||
ESVG_VERBOSE("Scale : " << xxx << ", " << xxx);
|
||||
} else {
|
||||
ESVG_ERROR("Parsing scale() with wrong data ... '" << data << "'");
|
||||
@ -135,13 +135,13 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
float angle, xxx, yyy;
|
||||
if (sscanf(data.c_str(), "%f %f %f", &angle, &xxx, &yyy) == 3) {
|
||||
angle = angle / 180 * M_PI;
|
||||
m_transformMatrix *= etk::mat2Translate(vec2(-xxx, -yyy));
|
||||
m_transformMatrix *= etk::mat2Rotate(angle);
|
||||
m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy));
|
||||
m_transformMatrix *= etk::mat2x3Translate(vec2(-xxx, -yyy));
|
||||
m_transformMatrix *= etk::mat2x3Rotate(angle);
|
||||
m_transformMatrix *= etk::mat2x3Translate(vec2(xxx, yyy));
|
||||
} else if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||
angle = angle / 180 * M_PI;
|
||||
ESVG_VERBOSE("rotate : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||
m_transformMatrix *= etk::mat2Rotate(angle);
|
||||
m_transformMatrix *= etk::mat2x3Rotate(angle);
|
||||
} else {
|
||||
ESVG_ERROR("Parsing rotate() with wrong data ... '" << data << "'");
|
||||
}
|
||||
@ -152,7 +152,7 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||
angle = angle / 180 * M_PI;
|
||||
ESVG_VERBOSE("skewX : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||
m_transformMatrix *= etk::mat2Skew(vec2(angle, 0.0f));
|
||||
m_transformMatrix *= etk::mat2x3Skew(vec2(angle, 0.0f));
|
||||
} else {
|
||||
ESVG_ERROR("Parsing skewX() with wrong data ... '" << data << "'");
|
||||
}
|
||||
@ -163,7 +163,7 @@ void esvg::Base::parseTransform(const exml::Element& _element) {
|
||||
if (sscanf(data.c_str(), "%f", &angle) == 1) {
|
||||
angle = angle / 180 * M_PI;
|
||||
ESVG_VERBOSE("skewY : " << angle << "rad, " << (angle/M_PI*180) << "°");
|
||||
m_transformMatrix *= etk::mat2Skew(vec2(0.0f, angle));
|
||||
m_transformMatrix *= etk::mat2x3Skew(vec2(0.0f, angle));
|
||||
} else {
|
||||
ESVG_ERROR("Parsing skewY() with wrong data ... '" << data << "'");
|
||||
}
|
||||
@ -177,7 +177,7 @@ void esvg::Base::parsePosition(const exml::Element& _element, vec2 &_pos, vec2 &
|
||||
if (_element.exist() == false) {
|
||||
return;
|
||||
}
|
||||
std::string content = _element.attributes["x"];
|
||||
etk::String content = _element.attributes["x"];
|
||||
if (content.size()!=0) {
|
||||
_pos.setX(parseLength(content));
|
||||
}
|
||||
@ -196,57 +196,57 @@ void esvg::Base::parsePosition(const exml::Element& _element, vec2 &_pos, vec2 &
|
||||
}
|
||||
|
||||
|
||||
std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string& _dataInput) {
|
||||
etk::Pair<float, enum esvg::distance> esvg::Base::parseLength2(const etk::String& _dataInput) {
|
||||
ESVG_VERBOSE(" lenght : '" << _dataInput << "'");
|
||||
float n = stof(_dataInput);
|
||||
std::string unit;
|
||||
for (int32_t iii=0; iii<_dataInput.size(); ++iii) {
|
||||
float n = _dataInput.to<float>();
|
||||
etk::String unit;
|
||||
for (size_t iii=0; iii<_dataInput.size(); ++iii) {
|
||||
if( (_dataInput[iii]>='0' && _dataInput[iii]<='9')
|
||||
|| _dataInput[iii]=='+'
|
||||
|| _dataInput[iii]=='-'
|
||||
|| _dataInput[iii]=='.') {
|
||||
continue;
|
||||
}
|
||||
unit = std::string(_dataInput, iii);
|
||||
unit = etk::String(_dataInput, iii);
|
||||
break;
|
||||
}
|
||||
ESVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
|
||||
// note : ";" is for the parsing of the style elements ...
|
||||
if(unit.size() == 0) {
|
||||
return std::make_pair(n, esvg::distance_pixel);
|
||||
return etk::makePair(n, esvg::distance_pixel);
|
||||
} else if (unit[0] == '%') { // xxx %
|
||||
return std::make_pair(n, esvg::distance_pourcent);
|
||||
return etk::makePair(n, esvg::distance_pourcent);
|
||||
} else if ( unit[0] == 'e'
|
||||
&& unit[1] == 'm') { // xxx em
|
||||
return std::make_pair(n, esvg::distance_element);
|
||||
return etk::makePair(n, esvg::distance_element);
|
||||
} else if ( unit[0] == 'e'
|
||||
&& unit[1] == 'x') { // xxx ex
|
||||
return std::make_pair(n, esvg::distance_ex);
|
||||
return etk::makePair(n, esvg::distance_ex);
|
||||
} else if ( unit[0] == 'p'
|
||||
&& unit[1] == 'x') { // xxx px
|
||||
return std::make_pair(n, esvg::distance_pixel);
|
||||
return etk::makePair(n, esvg::distance_pixel);
|
||||
} else if ( unit[0] == 'p'
|
||||
&& unit[1] == 't') { // xxx pt
|
||||
return std::make_pair(n, esvg::distance_point);
|
||||
return etk::makePair(n, esvg::distance_point);
|
||||
} else if ( unit[0] == 'p'
|
||||
&& unit[1] == 'c') { // xxx pc
|
||||
return std::make_pair(n, esvg::distance_pc);
|
||||
return etk::makePair(n, esvg::distance_pc);
|
||||
} else if ( unit[0] == 'm'
|
||||
&& unit[1] == 'm') { // xxx mm
|
||||
return std::make_pair(n, esvg::distance_millimeter);
|
||||
return etk::makePair(n, esvg::distance_millimeter);
|
||||
} else if ( unit[0] == 'c'
|
||||
&& unit[1] == 'm') { // xxx cm
|
||||
return std::make_pair(n, esvg::distance_centimeter);
|
||||
return etk::makePair(n, esvg::distance_centimeter);
|
||||
} else if ( unit[0] == 'i'
|
||||
&& unit[1] == 'n') { // xxx in
|
||||
return std::make_pair(n, esvg::distance_inch);
|
||||
return etk::makePair(n, esvg::distance_inch);
|
||||
}
|
||||
return std::make_pair(0.0f, esvg::distance_pixel);
|
||||
return etk::makePair(0.0f, esvg::distance_pixel);
|
||||
}
|
||||
|
||||
|
||||
float esvg::Base::parseLength(const std::string& _dataInput) {
|
||||
std::pair<float, enum esvg::distance> value = parseLength2(_dataInput);
|
||||
float esvg::Base::parseLength(const etk::String& _dataInput) {
|
||||
etk::Pair<float, enum esvg::distance> value = parseLength2(_dataInput);
|
||||
ESVG_VERBOSE(" lenght : '" << value.first << "' => unit=" << value.second);
|
||||
float font_size = 20.0f;
|
||||
switch (value.second) {
|
||||
@ -280,13 +280,13 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
||||
bool fillNone = false;
|
||||
bool strokeNone = false;
|
||||
*/
|
||||
std::string content;
|
||||
etk::String content;
|
||||
// ---------------- get unique ID ----------------
|
||||
m_id = _element.attributes["id"];
|
||||
// ---------------- stroke ----------------
|
||||
content = _element.attributes["stroke"];
|
||||
if (content == "none") {
|
||||
m_paint.stroke = std::pair<etk::Color<float,4>, std::string>(etk::color::none, "");
|
||||
m_paint.stroke = etk::Pair<etk::Color<float,4>, etk::String>(etk::color::none, "");
|
||||
} else {
|
||||
if (content.size()!=0) {
|
||||
m_paint.stroke = parseColor(content);
|
||||
@ -298,7 +298,7 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
||||
content = _element.attributes["stroke-opacity"];
|
||||
if (content.size()!=0) {
|
||||
float opacity = parseLength(content);
|
||||
opacity = std::avg(0.0f, opacity, 1.0f);
|
||||
opacity = etk::avg(0.0f, opacity, 1.0f);
|
||||
m_paint.stroke.first.setA(opacity);
|
||||
}
|
||||
|
||||
@ -339,13 +339,13 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
||||
content = _element.attributes["stroke-miterlimit"];
|
||||
if (content.size()!=0) {
|
||||
float tmp = parseLength(content);
|
||||
m_paint.miterLimit = std::max(0.0f, tmp);
|
||||
m_paint.miterLimit = etk::max(0.0f, tmp);
|
||||
}
|
||||
}
|
||||
// ---------------- FILL ----------------
|
||||
content = _element.attributes["fill"];
|
||||
if (content == "none") {
|
||||
m_paint.fill = std::pair<etk::Color<float,4>, std::string>(etk::color::none, "");
|
||||
m_paint.fill = etk::Pair<etk::Color<float,4>, etk::String>(etk::color::none, "");
|
||||
} else {
|
||||
if (content.size()!=0) {
|
||||
m_paint.fill = parseColor(content);
|
||||
@ -353,7 +353,7 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
||||
content = _element.attributes["fill-opacity"];
|
||||
if (content.size()!=0) {
|
||||
float opacity = parseLength(content);
|
||||
opacity = std::avg(0.0f, opacity, 1.0f);
|
||||
opacity = etk::avg(0.0f, opacity, 1.0f);
|
||||
m_paint.fill.first.setA(opacity);
|
||||
}
|
||||
content = _element.attributes["fill-rule"];
|
||||
@ -370,13 +370,13 @@ void esvg::Base::parsePaintAttr(const exml::Element& _element) {
|
||||
content = _element.attributes["opacity"];
|
||||
if (content.size()!=0) {
|
||||
m_paint.opacity = parseLength(content);
|
||||
m_paint.opacity = std::avg(0.0f, m_paint.opacity, 1.0f);
|
||||
m_paint.opacity = etk::avg(0.0f, m_paint.opacity, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<etk::Color<float,4>, std::string> esvg::Base::parseColor(const std::string& _inputData) {
|
||||
std::pair<etk::Color<float,4>, std::string> localColor(etk::color::white, "");
|
||||
etk::Pair<etk::Color<float,4>, etk::String> esvg::Base::parseColor(const etk::String& _inputData) {
|
||||
etk::Pair<etk::Color<float,4>, etk::String> localColor(etk::color::white, "");
|
||||
|
||||
if( _inputData.size() > 4
|
||||
&& _inputData[0] == 'u'
|
||||
@ -384,19 +384,19 @@ std::pair<etk::Color<float,4>, std::string> esvg::Base::parseColor(const std::st
|
||||
&& _inputData[2] == 'l'
|
||||
&& _inputData[3] == '(') {
|
||||
if (_inputData[4] == '#') {
|
||||
std::string color(_inputData.begin() + 5, _inputData.end()-1);
|
||||
localColor = std::pair<etk::Color<float,4>, std::string>(etk::color::none, color);
|
||||
etk::String color(_inputData.begin() + 5, _inputData.end()-1);
|
||||
localColor = etk::Pair<etk::Color<float,4>, etk::String>(etk::color::none, color);
|
||||
} else {
|
||||
ESVG_ERROR("Problem in parsing the color : \"" << _inputData << "\" == > url(XXX) is not supported now ...");
|
||||
}
|
||||
} else {
|
||||
localColor = std::pair<etk::Color<float,4>, std::string>(_inputData, "");
|
||||
localColor = etk::Pair<etk::Color<float,4>, etk::String>(_inputData, "");
|
||||
}
|
||||
ESVG_VERBOSE("Parse color : \"" << _inputData << "\" == > " << localColor.first << " " << localColor.second);
|
||||
return localColor;
|
||||
}
|
||||
|
||||
bool esvg::Base::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Base::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
// TODO : UNDERSTAND why nothing is done here ...
|
||||
// Parse basic elements (ID...):
|
||||
m_id = _element.attributes["id"];
|
||||
@ -413,26 +413,26 @@ const char * esvg::Base::spacingDist(int32_t _spacing) {
|
||||
return tmpValue + 20*4 - _spacing*4;
|
||||
}
|
||||
|
||||
void esvg::Base::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Base::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_WARNING(spacingDist(_level) << "DRAW esvg::Base ... ==> No drawing availlable");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::string& esvg::Base::getId() const {
|
||||
const etk::String& esvg::Base::getId() const {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void esvg::Base::setId(const std::string& _newId) {
|
||||
void esvg::Base::setId(const etk::String& _newId) {
|
||||
// TODO : Check if it is UNIQUE ...
|
||||
m_id = _newId;
|
||||
}
|
||||
|
||||
|
||||
void esvg::Base::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Base::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Matrix2.hpp>
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <esvg/render/Path.hpp>
|
||||
|
||||
@ -38,21 +38,21 @@ namespace esvg {
|
||||
PaintState();
|
||||
void clear();
|
||||
public:
|
||||
std::pair<etk::Color<float,4>, std::string> fill;
|
||||
std::pair<etk::Color<float,4>, std::string> stroke;
|
||||
etk::Pair<etk::Color<float,4>, etk::String> fill;
|
||||
etk::Pair<etk::Color<float,4>, etk::String> stroke;
|
||||
float strokeWidth;
|
||||
bool flagEvenOdd; //!< Fill rules
|
||||
enum esvg::cap lineCap;
|
||||
enum esvg::join lineJoin;
|
||||
float miterLimit;
|
||||
std::pair<vec2, vec2> viewPort; //!< min pos, max pos
|
||||
etk::Pair<vec2, vec2> viewPort; //!< min pos, max pos
|
||||
float opacity;
|
||||
};
|
||||
|
||||
class Base {
|
||||
protected:
|
||||
PaintState m_paint;
|
||||
mat2 m_transformMatrix; //!< specific render of the curent element
|
||||
mat2x3 m_transformMatrix; //!< specific render of the curent element
|
||||
const char * spacingDist(int32_t _spacing);
|
||||
public:
|
||||
Base() {};
|
||||
@ -63,14 +63,14 @@ namespace esvg {
|
||||
* @param[in] _element standart XML node
|
||||
* @return true if no problem arrived
|
||||
*/
|
||||
virtual bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax);
|
||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
||||
/**
|
||||
* @brief Draw the form in the renderer
|
||||
* @param[in] _myRenderer Renderer engine
|
||||
* @param[in] _basicTrans Parant transformation of the environement
|
||||
* @param[in] _level Level of the tree
|
||||
*/
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level=1);
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level=1);
|
||||
/**
|
||||
* @brief Draw rhe shape with all points
|
||||
* @param[in] _out where the lines are added
|
||||
@ -79,10 +79,10 @@ namespace esvg {
|
||||
* @param[in] _basicTrans Parant transformation of the environement
|
||||
* @param[in] _level Level of the tree
|
||||
*/
|
||||
virtual void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
virtual void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1);
|
||||
|
||||
virtual void display(int32_t _spacing) { };
|
||||
@ -99,8 +99,8 @@ namespace esvg {
|
||||
* @param[in] _dataInput Data C String with the printed lenght
|
||||
* @return standard number of pixels
|
||||
*/
|
||||
float parseLength(const std::string& _dataInput);
|
||||
std::pair<float, enum esvg::distance> parseLength2(const std::string& _dataInput);
|
||||
float parseLength(const etk::String& _dataInput);
|
||||
etk::Pair<float, enum esvg::distance> parseLength2(const etk::String& _dataInput);
|
||||
/**
|
||||
* @brief parse a Painting attribute of a specific node
|
||||
* @param[in] _element Basic node of the XML that might be parsed
|
||||
@ -111,19 +111,19 @@ namespace esvg {
|
||||
* @param[in] _inputData Data C String with the xml definition
|
||||
* @return The parsed color (color used and the link if needed)
|
||||
*/
|
||||
std::pair<etk::Color<float,4>, std::string> parseColor(const std::string& _inputData);
|
||||
etk::Pair<etk::Color<float,4>, etk::String> parseColor(const etk::String& _inputData);
|
||||
protected:
|
||||
std::string m_id; //!< unique ID of the element.
|
||||
etk::String m_id; //!< unique ID of the element.
|
||||
public:
|
||||
/**
|
||||
* @brief Get the ID of the Element
|
||||
* @return UniqueId in the svg file
|
||||
*/
|
||||
const std::string& getId() const;
|
||||
const etk::String& getId() const;
|
||||
/**
|
||||
* @brief Set the ID of the Element
|
||||
* @param[in] _newId New Id of the element
|
||||
*/
|
||||
void setId(const std::string& _newId);
|
||||
void setId(const etk::String& _newId);
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -17,7 +17,7 @@ esvg::Circle::~Circle() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Circle::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Circle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
m_radius = 0.0;
|
||||
m_position.setValue(0,0);
|
||||
if (_element.exist() == false) {
|
||||
@ -29,7 +29,7 @@ bool esvg::Circle::parseXML(const exml::Element& _element, mat2& _parentTrans, v
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
std::string content = _element.attributes["cx"];
|
||||
etk::String content = _element.attributes["cx"];
|
||||
if (content.size()!=0) {
|
||||
m_position.setX(parseLength(content));
|
||||
}
|
||||
@ -82,7 +82,7 @@ esvg::render::Path esvg::Circle::createPath() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Circle");
|
||||
if (m_radius <= 0.0f) {
|
||||
ESVG_VERBOSE(spacingDist(_level+1) << "Too small radius" << m_radius);
|
||||
@ -90,7 +90,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
}
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -108,7 +108,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -118,7 +118,7 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -143,24 +143,24 @@ void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
#endif
|
||||
}
|
||||
|
||||
void esvg::Circle::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Circle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Circle");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,13 +15,13 @@ namespace esvg {
|
||||
public:
|
||||
Circle(PaintState _parentPaintState);
|
||||
~Circle();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/Dimension.hpp>
|
||||
@ -33,7 +33,7 @@ esvg::Dimension::Dimension(const vec2& _size, enum esvg::distance _type) :
|
||||
set(_size, _type);
|
||||
}
|
||||
|
||||
void esvg::Dimension::set(std::string _config) {
|
||||
void esvg::Dimension::set(etk::String _config) {
|
||||
m_data.setValue(0,0);
|
||||
m_type = esvg::distance_pixel;
|
||||
enum distance type = esvg::distance_pixel;
|
||||
@ -71,7 +71,7 @@ void esvg::Dimension::set(std::string _config) {
|
||||
ESVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
|
||||
}
|
||||
|
||||
static enum esvg::distance parseType(std::string& _config) {
|
||||
static enum esvg::distance parseType(etk::String& _config) {
|
||||
enum esvg::distance type = esvg::distance_pixel;
|
||||
if (etk::end_with(_config, "%", false) == true) {
|
||||
type = esvg::distance_pourcent;
|
||||
@ -105,7 +105,7 @@ static enum esvg::distance parseType(std::string& _config) {
|
||||
}
|
||||
|
||||
|
||||
void esvg::Dimension::set(std::string _configX, std::string _configY) {
|
||||
void esvg::Dimension::set(etk::String _configX, etk::String _configY) {
|
||||
m_data.setValue(0,0);
|
||||
m_type = esvg::distance_pixel;
|
||||
enum distance type = esvg::distance_pixel;
|
||||
@ -125,8 +125,8 @@ esvg::Dimension::~Dimension() {
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
esvg::Dimension::operator std::string() const {
|
||||
std::string str;
|
||||
esvg::Dimension::operator etk::String() const {
|
||||
etk::String str;
|
||||
str = getValue();
|
||||
switch(getType()) {
|
||||
case esvg::distance_pourcent:
|
||||
@ -214,7 +214,7 @@ vec2 esvg::Dimension::getPixel(const vec2& _upperSize) const {
|
||||
return vec2(128.0f, 128.0f);
|
||||
}
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::distance _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::distance _obj) {
|
||||
switch(_obj) {
|
||||
case esvg::distance_pourcent:
|
||||
_os << "%";
|
||||
@ -256,24 +256,24 @@ std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::distance _obj) {
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, const esvg::Dimension& _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, const esvg::Dimension& _obj) {
|
||||
_os << _obj.getValue() << _obj.getType();
|
||||
return _os;
|
||||
}
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<esvg::Dimension>(const esvg::Dimension& _obj) {
|
||||
template<> etk::String toString<esvg::Dimension>(const esvg::Dimension& _obj) {
|
||||
return _obj;
|
||||
}
|
||||
template<> std::u32string to_u32string<esvg::Dimension>(const esvg::Dimension& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
template<> etk::UString toUString<esvg::Dimension>(const esvg::Dimension& _obj) {
|
||||
return etk::toUString(etk::toString(_obj));
|
||||
}
|
||||
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const std::string& _value) {
|
||||
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const etk::String& _value) {
|
||||
_variableRet = esvg::Dimension(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const etk::UString& _value) {
|
||||
return from_string(_variableRet, etk::toString(_value));
|
||||
}
|
||||
};
|
||||
|
||||
@ -289,7 +289,7 @@ esvg::Dimension1D::Dimension1D(float _size, enum esvg::distance _type) :
|
||||
set(_size, _type);
|
||||
}
|
||||
|
||||
void esvg::Dimension1D::set(std::string _config) {
|
||||
void esvg::Dimension1D::set(etk::String _config) {
|
||||
m_data = 0;
|
||||
m_type = esvg::distance_pixel;
|
||||
enum distance type = esvg::distance_pixel;
|
||||
@ -330,8 +330,8 @@ esvg::Dimension1D::~Dimension1D() {
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
esvg::Dimension1D::operator std::string() const {
|
||||
std::string str;
|
||||
esvg::Dimension1D::operator etk::String() const {
|
||||
etk::String str;
|
||||
str = getValue();
|
||||
switch(getType()) {
|
||||
case esvg::distance_pourcent:
|
||||
@ -419,24 +419,24 @@ float esvg::Dimension1D::getPixel(float _upperSize) const {
|
||||
return 128.0f;
|
||||
}
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, const esvg::Dimension1D& _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, const esvg::Dimension1D& _obj) {
|
||||
_os << _obj.getValue() << _obj.getType();
|
||||
return _os;
|
||||
}
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<esvg::Dimension1D>(const esvg::Dimension1D& _obj) {
|
||||
template<> etk::String toString<esvg::Dimension1D>(const esvg::Dimension1D& _obj) {
|
||||
return _obj;
|
||||
}
|
||||
template<> std::u32string to_u32string<esvg::Dimension1D>(const esvg::Dimension1D& _obj) {
|
||||
return etk::to_u32string(etk::to_string(_obj));
|
||||
template<> etk::UString toUString<esvg::Dimension1D>(const esvg::Dimension1D& _obj) {
|
||||
return etk::toUString(etk::toString(_obj));
|
||||
}
|
||||
template<> bool from_string<esvg::Dimension1D>(esvg::Dimension1D& _variableRet, const std::string& _value) {
|
||||
template<> bool from_string<esvg::Dimension1D>(esvg::Dimension1D& _variableRet, const etk::String& _value) {
|
||||
_variableRet = esvg::Dimension1D(_value);
|
||||
return true;
|
||||
}
|
||||
template<> bool from_string<esvg::Dimension1D>(esvg::Dimension1D& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, etk::to_string(_value));
|
||||
template<> bool from_string<esvg::Dimension1D>(esvg::Dimension1D& _variableRet, const etk::UString& _value) {
|
||||
return from_string(_variableRet, etk::toString(_value));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -46,7 +46,7 @@ namespace esvg {
|
||||
* @brief Constructor
|
||||
* @param[in] _config dimension configuration.
|
||||
*/
|
||||
Dimension(const std::string& _config) :
|
||||
Dimension(const etk::String& _config) :
|
||||
m_data(0,0),
|
||||
m_type(esvg::distance_pixel) {
|
||||
set(_config);
|
||||
@ -56,7 +56,7 @@ namespace esvg {
|
||||
* @param[in] _configX dimension X configuration.
|
||||
* @param[in] _configY dimension Y configuration.
|
||||
*/
|
||||
Dimension(const std::string& _configX, const std::string& _configY) :
|
||||
Dimension(const etk::String& _configX, const etk::String& _configY) :
|
||||
m_data(0,0),
|
||||
m_type(esvg::distance_pixel) {
|
||||
set(_configX, _configY);
|
||||
@ -69,7 +69,7 @@ namespace esvg {
|
||||
/**
|
||||
* @brief string cast :
|
||||
*/
|
||||
operator std::string() const;
|
||||
operator etk::String() const;
|
||||
|
||||
/**
|
||||
* @brief get the current dimention.
|
||||
@ -97,13 +97,13 @@ namespace esvg {
|
||||
* @brief set the current dimention in requested type
|
||||
* @param[in] _config dimension configuration.
|
||||
*/
|
||||
void set(std::string _config);
|
||||
void set(etk::String _config);
|
||||
/**
|
||||
* @brief set the current dimention in requested type
|
||||
* @param[in] _configX dimension X configuration.
|
||||
* @param[in] _configY dimension Y configuration.
|
||||
*/
|
||||
void set(std::string _configX, std::string _configY);
|
||||
void set(etk::String _configX, etk::String _configY);
|
||||
public:
|
||||
/**
|
||||
* @brief get the current dimention in pixel
|
||||
@ -142,8 +142,8 @@ namespace esvg {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::distance _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const esvg::Dimension& _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::distance _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, const esvg::Dimension& _obj);
|
||||
/**
|
||||
* @brief in the dimention class we store the data as the more usefull unit (pixel)
|
||||
* but one case need to be dynamic the %, then when requested in % the register the % value
|
||||
@ -167,7 +167,7 @@ namespace esvg {
|
||||
* @brief Constructor
|
||||
* @param[in] _config dimension configuration.
|
||||
*/
|
||||
Dimension1D(const std::string& _config) :
|
||||
Dimension1D(const etk::String& _config) :
|
||||
m_data(0.0f),
|
||||
m_type(esvg::distance_pixel) {
|
||||
set(_config);
|
||||
@ -180,7 +180,7 @@ namespace esvg {
|
||||
/**
|
||||
* @brief string cast :
|
||||
*/
|
||||
operator std::string() const;
|
||||
operator etk::String() const;
|
||||
|
||||
/**
|
||||
* @brief get the current dimention.
|
||||
@ -208,7 +208,7 @@ namespace esvg {
|
||||
* @brief set the current dimention in requested type
|
||||
* @param[in] _config dimension configuration.
|
||||
*/
|
||||
void set(std::string _config);
|
||||
void set(etk::String _config);
|
||||
public:
|
||||
/**
|
||||
* @brief get the current dimention in pixel
|
||||
@ -247,6 +247,6 @@ namespace esvg {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const esvg::Dimension1D& _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, const esvg::Dimension1D& _obj);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -17,7 +17,7 @@ esvg::Ellipse::~Ellipse() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Ellipse::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Ellipse::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
if (_element.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -30,7 +30,7 @@ bool esvg::Ellipse::parseXML(const exml::Element& _element, mat2& _parentTrans,
|
||||
m_c.setValue(0,0);
|
||||
m_r.setValue(0,0);
|
||||
|
||||
std::string content = _element.attributes["cx"];
|
||||
etk::String content = _element.attributes["cx"];
|
||||
if (content.size()!=0) {
|
||||
m_c.setX(parseLength(content));
|
||||
}
|
||||
@ -86,7 +86,7 @@ esvg::render::Path esvg::Ellipse::createPath() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Ellipse");
|
||||
if ( m_r.x()<=0.0f
|
||||
|| m_r.y()<=0.0f) {
|
||||
@ -95,7 +95,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
}
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -113,7 +113,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -123,7 +123,7 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -149,24 +149,24 @@ void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
}
|
||||
|
||||
|
||||
void esvg::Ellipse::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Ellipse::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Ellipse");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,13 +15,13 @@ namespace esvg {
|
||||
public:
|
||||
Ellipse(PaintState _parentPaintState);
|
||||
~Ellipse();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -26,7 +26,7 @@ esvg::Group::~Group() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Group::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Group::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
if (_element.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -76,7 +76,7 @@ bool esvg::Group::parseXML(const exml::Element& _element, mat2& _parentTrans, ve
|
||||
} else {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") node not suported : '" << child.getValue() << "' must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
||||
}
|
||||
if (elementParser == nullptr) {
|
||||
if (elementParser == null) {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") error on node: '" << child.getValue() << "' allocation error or not supported ...");
|
||||
continue;
|
||||
}
|
||||
@ -85,10 +85,10 @@ bool esvg::Group::parseXML(const exml::Element& _element, mat2& _parentTrans, ve
|
||||
elementParser.reset();
|
||||
continue;
|
||||
}
|
||||
_sizeMax.setValue(std::max(_sizeMax.x(), tmpPos.x()),
|
||||
std::max(_sizeMax.y(), tmpPos.y()));
|
||||
_sizeMax.setValue(etk::max(_sizeMax.x(), tmpPos.x()),
|
||||
etk::max(_sizeMax.y(), tmpPos.y()));
|
||||
// add element in the system
|
||||
m_subElementList.push_back(elementParser);
|
||||
m_subElementList.pushBack(elementParser);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -98,30 +98,30 @@ void esvg::Group::display(int32_t _spacing) {
|
||||
<< " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second
|
||||
<< " stroke-width=" << m_paint.strokeWidth );
|
||||
for (auto &it : m_subElementList) {
|
||||
if (it != nullptr) {
|
||||
if (it != null) {
|
||||
it->display(_spacing+1);
|
||||
}
|
||||
}
|
||||
ESVG_DEBUG(spacingDist(_spacing) << "Group (STOP)");
|
||||
}
|
||||
|
||||
void esvg::Group::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Group::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::group");
|
||||
for (auto &it : m_subElementList) {
|
||||
if (it != nullptr) {
|
||||
if (it != null) {
|
||||
it->draw(_myRenderer, _basicTrans, _level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void esvg::Group::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Group::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW shape esvg::group");
|
||||
for (auto &it : m_subElementList) {
|
||||
if (it != nullptr) {
|
||||
if (it != null) {
|
||||
it->drawShapePoints(_out, _recurtionMax, _threshold, _basicTrans, _level+1);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esvg/Base.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
namespace esvg {
|
||||
class Group : public esvg::Base {
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub elements ...
|
||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub elements ...
|
||||
public:
|
||||
Group(PaintState _parentPaintState);
|
||||
~Group();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -18,7 +18,7 @@ esvg::Line::~Line() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Line::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Line::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
if (_element.exist() == false) {
|
||||
@ -30,7 +30,7 @@ bool esvg::Line::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
std::string content = _element.attributes["x1"];
|
||||
etk::String content = _element.attributes["x1"];
|
||||
if (content.size() != 0) {
|
||||
m_startPos.setX(parseLength(content));
|
||||
}
|
||||
@ -46,8 +46,8 @@ bool esvg::Line::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
if (content.size() != 0) {
|
||||
m_stopPos.setY(parseLength(content));
|
||||
}
|
||||
_sizeMax.setValue(std::max(m_startPos.x(), m_stopPos.x()),
|
||||
std::max(m_startPos.y(), m_stopPos.y()));
|
||||
_sizeMax.setValue(etk::max(m_startPos.x(), m_stopPos.x()),
|
||||
etk::max(m_startPos.y(), m_stopPos.y()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -64,12 +64,12 @@ esvg::render::Path esvg::Line::createPath() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line");
|
||||
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -89,7 +89,7 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
|
||||
// Check if we need to display background
|
||||
// No background ...
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -116,24 +116,24 @@ void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
|
||||
}
|
||||
|
||||
|
||||
void esvg::Line::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Line::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Line");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,13 +15,13 @@ namespace esvg {
|
||||
public:
|
||||
Line(PaintState _parentPaintState);
|
||||
~Line();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -25,7 +25,7 @@ esvg::LinearGradient::~LinearGradient() {
|
||||
}
|
||||
|
||||
|
||||
bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
//m_paint.strokeWidth = 1;
|
||||
if (_element.exist() == false) {
|
||||
@ -41,8 +41,8 @@ bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
std::string contentX = _element.attributes["x1"];
|
||||
std::string contentY = _element.attributes["y1"];
|
||||
etk::String contentX = _element.attributes["x1"];
|
||||
etk::String contentY = _element.attributes["y1"];
|
||||
if ( contentX != ""
|
||||
&& contentY != "") {
|
||||
m_pos1.set(contentX, contentY);
|
||||
@ -78,7 +78,7 @@ bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
// note: xlink:href is incompatible with subNode "stop"
|
||||
m_href = _element.attributes["xlink:href"];
|
||||
if (m_href.size() != 0) {
|
||||
m_href = std::string(m_href.begin()+1, m_href.end());
|
||||
m_href = etk::String(m_href.begin()+1, m_href.end());
|
||||
}
|
||||
// parse all sub node :
|
||||
for(const auto it : _element.nodes) {
|
||||
@ -90,9 +90,9 @@ bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
if (child.getValue() == "stop") {
|
||||
float offset = 100;
|
||||
etk::Color<float,4> stopColor = etk::color::none;
|
||||
std::string content = child.attributes["offset"];
|
||||
etk::String content = child.attributes["offset"];
|
||||
if (content.size()!=0) {
|
||||
std::pair<float, enum esvg::distance> tmp = parseLength2(content);
|
||||
etk::Pair<float, enum esvg::distance> tmp = parseLength2(content);
|
||||
if (tmp.second == esvg::distance_pixel) {
|
||||
// special case ==> all time % then no type define ==> % in [0.0 .. 1.0]
|
||||
offset = tmp.first*100.0f;
|
||||
@ -110,11 +110,11 @@ bool esvg::LinearGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
content = child.attributes["stop-opacity"];
|
||||
if (content.size()!=0) {
|
||||
float opacity = parseLength(content);
|
||||
opacity = std::avg(0.0f, opacity, 1.0f);
|
||||
opacity = etk::avg(0.0f, opacity, 1.0f);
|
||||
stopColor.setA(opacity);
|
||||
ESVG_VERBOSE(" opacity : '" << content << "' == > " << stopColor);
|
||||
}
|
||||
m_data.push_back(std::pair<float, etk::Color<float,4>>(offset, stopColor));
|
||||
m_data.pushBack(etk::Pair<float, etk::Color<float,4>>(offset, stopColor));
|
||||
} else {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") node not suported : '" << child.getValue() << "' must be [stop]");
|
||||
}
|
||||
@ -135,7 +135,7 @@ void esvg::LinearGradient::display(int32_t _spacing) {
|
||||
}
|
||||
}
|
||||
|
||||
void esvg::LinearGradient::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::LinearGradient::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient");
|
||||
}
|
||||
|
||||
@ -147,23 +147,23 @@ const esvg::Dimension& esvg::LinearGradient::getPosition2() {
|
||||
return m_pos2;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<float, etk::Color<float,4>>>& esvg::LinearGradient::getColors(esvg::Document* _document) {
|
||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& esvg::LinearGradient::getColors(esvg::Document* _document) {
|
||||
if (m_href == "") {
|
||||
return m_data;
|
||||
}
|
||||
if (_document == nullptr) {
|
||||
ESVG_ERROR("Get nullptr input for document");
|
||||
if (_document == null) {
|
||||
ESVG_ERROR("Get null input for document");
|
||||
return m_data;
|
||||
}
|
||||
ememory::SharedPtr<esvg::Base> base = _document->getReference(m_href);
|
||||
if (base == nullptr) {
|
||||
if (base == null) {
|
||||
ESVG_ERROR("Can not get base : '" << m_href << "'");
|
||||
return m_data;
|
||||
}
|
||||
ememory::SharedPtr<esvg::RadialGradient> gradientR = ememory::dynamicPointerCast<esvg::RadialGradient>(base);
|
||||
if (gradientR == nullptr) {
|
||||
if (gradientR == null) {
|
||||
ememory::SharedPtr<esvg::LinearGradient> gradientL = ememory::dynamicPointerCast<esvg::LinearGradient>(base);
|
||||
if (gradientL == nullptr) {
|
||||
if (gradientL == null) {
|
||||
ESVG_ERROR("Can not cast in a linear/radial gradient: '" << m_href << "' ==> wrong type");
|
||||
return m_data;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -19,18 +19,18 @@ namespace esvg {
|
||||
enum gradientUnits m_unit;
|
||||
enum spreadMethod m_spread;
|
||||
private:
|
||||
std::string m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||
std::vector<std::pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||
public:
|
||||
LinearGradient(PaintState _parentPaintState);
|
||||
~LinearGradient();
|
||||
virtual bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax);
|
||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level);
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
||||
public:
|
||||
const esvg::Dimension& getPosition1();
|
||||
const esvg::Dimension& getPosition2();
|
||||
const std::vector<std::pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -19,19 +19,19 @@ esvg::Path::~Path() {
|
||||
|
||||
|
||||
// return the next char position ... (after 'X' or NULL)
|
||||
const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _outputList) {
|
||||
const char * extractCmd(const char* _input, char& _cmd, etk::Vector<float>& _outputList) {
|
||||
if (*_input == '\0') {
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
_outputList.clear();
|
||||
_cmd = '\0';
|
||||
const char * outputPointer = nullptr;
|
||||
const char * outputPointer = null;
|
||||
if (!( ( _input[0] <= 'Z'
|
||||
&& _input[0] >= 'A')
|
||||
|| ( _input[0] <= 'z'
|
||||
&& _input[0] >= 'a') ) ) {
|
||||
ESVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
_cmd = _input[0];
|
||||
ESVG_VERBOSE("Find command : " << _cmd);
|
||||
@ -46,7 +46,7 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
|
||||
while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|
||||
|| sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) {
|
||||
ESVG_VERBOSE("Find element : " << element);
|
||||
_outputList.push_back(element);
|
||||
_outputList.pushBack(element);
|
||||
iii += nbElementRead;
|
||||
}
|
||||
outputPointer = &_input[iii];
|
||||
@ -56,8 +56,8 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
|
||||
//outputPointer++;
|
||||
return outputPointer;
|
||||
}
|
||||
std::string cleanBadSpaces(const std::string& _input) {
|
||||
std::string out;
|
||||
etk::String cleanBadSpaces(const etk::String& _input) {
|
||||
etk::String out;
|
||||
bool haveSpace = false;
|
||||
for (auto &it : _input) {
|
||||
if ( it == ' '
|
||||
@ -76,7 +76,7 @@ std::string cleanBadSpaces(const std::string& _input) {
|
||||
return out;
|
||||
}
|
||||
|
||||
bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Path::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
if (_element.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -87,7 +87,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
|
||||
std::string elementXML1 = _element.attributes["d"];
|
||||
etk::String elementXML1 = _element.attributes["d"];
|
||||
if (elementXML1.size() == 0) {
|
||||
ESVG_WARNING("(l "<<_element.getPos()<<") path: missing 'd' attribute or empty");
|
||||
return false;
|
||||
@ -95,12 +95,12 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
ESVG_VERBOSE("Parse Path : \"" << elementXML1 << "\"");
|
||||
|
||||
char command;
|
||||
std::vector<float> listDot;
|
||||
etk::Vector<float> listDot;
|
||||
elementXML1 = cleanBadSpaces(elementXML1);
|
||||
const char* elementXML = elementXML1.c_str();
|
||||
|
||||
for( const char *sss=extractCmd(elementXML, command, listDot);
|
||||
sss != nullptr;
|
||||
sss != null;
|
||||
sss=extractCmd(sss, command, listDot) ) {
|
||||
bool relative = false;
|
||||
switch(command) {
|
||||
@ -116,7 +116,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
m_listElement.moveTo(relative,
|
||||
vec2(listDot[0], listDot[1]));
|
||||
}
|
||||
for(int32_t iii=2; iii<listDot.size(); iii+=2) {
|
||||
for (size_t iii=2; iii<listDot.size(); iii+=2) {
|
||||
m_listElement.lineTo(relative,
|
||||
vec2(listDot[iii], listDot[iii+1]));
|
||||
}
|
||||
@ -129,7 +129,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
||||
m_listElement.lineTo(relative,
|
||||
vec2(listDot[iii], listDot[iii+1]));
|
||||
}
|
||||
@ -143,7 +143,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=1) {
|
||||
m_listElement.lineToV(relative,
|
||||
listDot[iii]);
|
||||
}
|
||||
@ -153,11 +153,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'H': // Horizantal Line to (absolute)
|
||||
// 1 Element ...
|
||||
if(listDot.size() == 0) {
|
||||
if (listDot.size() == 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=1) {
|
||||
m_listElement.lineToH(relative,
|
||||
listDot[iii]);
|
||||
}
|
||||
@ -167,11 +167,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'Q': // Quadratic Bezier curve (absolute)
|
||||
// 4 Elements ...
|
||||
if(listDot.size()%4 != 0) {
|
||||
if (listDot.size()%4 != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
||||
m_listElement.bezierCurveTo(relative,
|
||||
vec2(listDot[iii],listDot[iii+1]),
|
||||
vec2(listDot[iii+2],listDot[iii+3]));
|
||||
@ -182,11 +182,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'T': // smooth quadratic Bezier curve to (absolute)
|
||||
// 2 Elements ...
|
||||
if(listDot.size()%2 != 0) {
|
||||
if (listDot.size()%2 != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=2) {
|
||||
m_listElement.bezierSmoothCurveTo(relative,
|
||||
vec2(listDot[iii],listDot[iii+1]));
|
||||
}
|
||||
@ -196,11 +196,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'C': // curve to (absolute)
|
||||
// 6 Elements ...
|
||||
if(listDot.size()%6 != 0) {
|
||||
if (listDot.size()%6 != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=6) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=6) {
|
||||
m_listElement.curveTo(relative,
|
||||
vec2(listDot[iii],listDot[iii+1]),
|
||||
vec2(listDot[iii+2],listDot[iii+3]),
|
||||
@ -212,11 +212,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'S': // smooth curve to (absolute)
|
||||
// 4 Elements ...
|
||||
if(listDot.size()%4 != 0) {
|
||||
if (listDot.size()%4 != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=4) {
|
||||
m_listElement.smoothCurveTo(relative,
|
||||
vec2(listDot[iii],listDot[iii+1]),
|
||||
vec2(listDot[iii+2],listDot[iii+3]));
|
||||
@ -227,11 +227,11 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'A': // elliptical Arc (absolute)
|
||||
// 7 Elements ...
|
||||
if(listDot.size()%7 != 0) {
|
||||
if (listDot.size()%7 != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
for(int32_t iii=0; iii<listDot.size(); iii+=7) {
|
||||
for (size_t iii=0; iii<listDot.size(); iii+=7) {
|
||||
bool largeArcFlag = true;
|
||||
bool sweepFlag = true;
|
||||
if (listDot[iii+3] == 0.0f) {
|
||||
@ -252,7 +252,7 @@ bool esvg::Path::parseXML(const exml::Element& _element, mat2& _parentTrans, vec
|
||||
relative = true;
|
||||
case 'Z': // closepath (absolute)
|
||||
// 0 Element ...
|
||||
if(listDot.size() != 0) {
|
||||
if (listDot.size() != 0) {
|
||||
ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||
break;
|
||||
}
|
||||
@ -270,10 +270,10 @@ void esvg::Path::display(int32_t _spacing) {
|
||||
m_listElement.display(_spacing);
|
||||
}
|
||||
|
||||
void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Path");
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -291,7 +291,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -299,7 +299,7 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
|
||||
tmpFill.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -325,25 +325,25 @@ void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _l
|
||||
}
|
||||
|
||||
|
||||
void esvg::Path::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Path::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Path");
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = m_listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,13 +15,13 @@ namespace esvg {
|
||||
public:
|
||||
Path(PaintState _parentPaintState);
|
||||
~Path();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -17,7 +17,7 @@ esvg::Polygon::~Polygon() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Polygon::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Polygon::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
if (_element.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -31,7 +31,7 @@ bool esvg::Polygon::parseXML(const exml::Element& _element, mat2& _parentTrans,
|
||||
|
||||
ESVG_VERBOSE("parsed P2. trans: " << m_transformMatrix);
|
||||
|
||||
const std::string sss1 = _element.attributes["points"];
|
||||
const etk::String sss1 = _element.attributes["points"];
|
||||
if (sss1.size() == 0) {
|
||||
ESVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
|
||||
return false;
|
||||
@ -43,10 +43,10 @@ bool esvg::Polygon::parseXML(const exml::Element& _element, mat2& _parentTrans,
|
||||
vec2 pos(0,0);
|
||||
int32_t n;
|
||||
if (sscanf(sss, "%f,%f%n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||
m_listPoint.push_back(pos);
|
||||
m_listPoint.pushBack(pos);
|
||||
sss += n;
|
||||
_sizeMax.setValue(std::max(_sizeMax.x(), pos.x()),
|
||||
std::max(_sizeMax.y(), pos.y()));
|
||||
_sizeMax.setValue(etk::max(_sizeMax.x(), pos.x()),
|
||||
etk::max(_sizeMax.y(), pos.y()));
|
||||
if(sss[0] == ' ' || sss[0] == ',') {
|
||||
sss++;
|
||||
}
|
||||
@ -64,19 +64,19 @@ void esvg::Polygon::display(int32_t _spacing) {
|
||||
esvg::render::Path esvg::Polygon::createPath() {
|
||||
esvg::render::Path out;
|
||||
out.moveTo(false, m_listPoint[0]);
|
||||
for( int32_t iii=1; iii< m_listPoint.size(); iii++) {
|
||||
for(size_t iii=1; iii< m_listPoint.size(); iii++) {
|
||||
out.lineTo(false, m_listPoint[iii]);
|
||||
}
|
||||
out.close();
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polygon");
|
||||
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -94,7 +94,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -104,7 +104,7 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -130,24 +130,24 @@ void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t
|
||||
}
|
||||
|
||||
|
||||
void esvg::Polygon::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Polygon::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Polygon");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esvg/Base.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
namespace esvg {
|
||||
/*
|
||||
@ -17,18 +17,18 @@ namespace esvg {
|
||||
*/
|
||||
class Polygon : public esvg::Base {
|
||||
private:
|
||||
std::vector<vec2 > m_listPoint; //!< list of all point of the polygone
|
||||
etk::Vector<vec2 > m_listPoint; //!< list of all point of the polygone
|
||||
//enum esvg::polygonMode m_diplayMode; //!< polygone specific display mode
|
||||
public:
|
||||
Polygon(PaintState parentPaintState);
|
||||
~Polygon();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -17,7 +17,7 @@ esvg::Polyline::~Polyline() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Polyline::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Polyline::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
if (_element.exist() == false) {
|
||||
@ -29,7 +29,7 @@ bool esvg::Polyline::parseXML(const exml::Element& _element, mat2& _parentTrans,
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
std::string sss1 = _element.attributes["points"];
|
||||
etk::String sss1 = _element.attributes["points"];
|
||||
if (sss1.size() == 0) {
|
||||
ESVG_ERROR("(l "<<_element.getPos()<<") polyline: missing points attribute");
|
||||
return false;
|
||||
@ -41,9 +41,9 @@ bool esvg::Polyline::parseXML(const exml::Element& _element, mat2& _parentTrans,
|
||||
vec2 pos;
|
||||
int32_t n;
|
||||
if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||
m_listPoint.push_back(pos);
|
||||
_sizeMax.setValue(std::max(_sizeMax.x(), pos.x()),
|
||||
std::max(_sizeMax.y(), pos.y()));
|
||||
m_listPoint.pushBack(pos);
|
||||
_sizeMax.setValue(etk::max(_sizeMax.x(), pos.x()),
|
||||
etk::max(_sizeMax.y(), pos.y()));
|
||||
sss += n;
|
||||
} else {
|
||||
break;
|
||||
@ -61,19 +61,19 @@ esvg::render::Path esvg::Polyline::createPath() {
|
||||
esvg::render::Path out;
|
||||
out.clear();
|
||||
out.moveTo(false, m_listPoint[0]);
|
||||
for( int32_t iii=1; iii< m_listPoint.size(); iii++) {
|
||||
for(size_t iii=1; iii< m_listPoint.size(); iii++) {
|
||||
out.lineTo(false, m_listPoint[iii]);
|
||||
}
|
||||
out.stop();
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline");
|
||||
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -91,7 +91,7 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -101,7 +101,7 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_
|
||||
listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -127,23 +127,23 @@ void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_
|
||||
}
|
||||
|
||||
|
||||
void esvg::Polyline::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Polyline::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Polyline");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esvg/Base.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
namespace esvg {
|
||||
class Polyline : public esvg::Base {
|
||||
private:
|
||||
std::vector<vec2 > m_listPoint; //!< list of all point of the polyline
|
||||
etk::Vector<vec2 > m_listPoint; //!< list of all point of the polyline
|
||||
public:
|
||||
Polyline(PaintState _parentPaintState);
|
||||
~Polyline();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -26,7 +26,7 @@ esvg::RadialGradient::~RadialGradient() {
|
||||
}
|
||||
|
||||
|
||||
bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
//m_paint.strokeWidth = 1;
|
||||
if (_element.exist() == false) {
|
||||
@ -42,8 +42,8 @@ bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
std::string contentX = _element.attributes["cx"];
|
||||
std::string contentY = _element.attributes["cy"];
|
||||
etk::String contentX = _element.attributes["cx"];
|
||||
etk::String contentY = _element.attributes["cy"];
|
||||
if ( contentX != ""
|
||||
&& contentY != "") {
|
||||
m_center.set(contentX, contentY);
|
||||
@ -83,7 +83,7 @@ bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
// note: xlink:href is incompatible with subNode "stop"
|
||||
m_href = _element.attributes["xlink:href"];
|
||||
if (m_href.size() != 0) {
|
||||
m_href = std::string(m_href.begin()+1, m_href.end());
|
||||
m_href = etk::String(m_href.begin()+1, m_href.end());
|
||||
}
|
||||
// parse all sub node :
|
||||
for(auto it : _element.nodes) {
|
||||
@ -95,9 +95,9 @@ bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
if (child.getValue() == "stop") {
|
||||
float offset = 100;
|
||||
etk::Color<float,4> stopColor = etk::color::none;
|
||||
std::string content = child.attributes["offset"];
|
||||
etk::String content = child.attributes["offset"];
|
||||
if (content.size()!=0) {
|
||||
std::pair<float, enum esvg::distance> tmp = parseLength2(content);
|
||||
etk::Pair<float, enum esvg::distance> tmp = parseLength2(content);
|
||||
if (tmp.second == esvg::distance_pixel) {
|
||||
// special case ==> all time % then no type define ==> % in [0.0 .. 1.0]
|
||||
offset = tmp.first*100.0f;
|
||||
@ -115,11 +115,11 @@ bool esvg::RadialGradient::parseXML(const exml::Element& _element, mat2& _parent
|
||||
content = child.attributes["stop-opacity"];
|
||||
if (content.size()!=0) {
|
||||
float opacity = parseLength(content);
|
||||
opacity = std::avg(0.0f, opacity, 1.0f);
|
||||
opacity = etk::avg(0.0f, opacity, 1.0f);
|
||||
stopColor.setA(opacity);
|
||||
ESVG_VERBOSE(" opacity : '" << content << "' == > " << stopColor);
|
||||
}
|
||||
m_data.push_back(std::pair<float, etk::Color<float,4>>(offset, stopColor));
|
||||
m_data.pushBack(etk::Pair<float, etk::Color<float,4>>(offset, stopColor));
|
||||
} else {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") node not suported : '" << child.getValue() << "' must be [stop]");
|
||||
}
|
||||
@ -140,7 +140,7 @@ void esvg::RadialGradient::display(int32_t _spacing) {
|
||||
}
|
||||
}
|
||||
|
||||
void esvg::RadialGradient::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::RadialGradient::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::RadialGradient");
|
||||
}
|
||||
|
||||
@ -156,23 +156,23 @@ const esvg::Dimension1D& esvg::RadialGradient::getRadius() {
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<float, etk::Color<float,4>>>& esvg::RadialGradient::getColors(esvg::Document* _document) {
|
||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& esvg::RadialGradient::getColors(esvg::Document* _document) {
|
||||
if (m_href == "") {
|
||||
return m_data;
|
||||
}
|
||||
if (_document == nullptr) {
|
||||
ESVG_ERROR("Get nullptr input for document");
|
||||
if (_document == null) {
|
||||
ESVG_ERROR("Get null input for document");
|
||||
return m_data;
|
||||
}
|
||||
ememory::SharedPtr<esvg::Base> base = _document->getReference(m_href);
|
||||
if (base == nullptr) {
|
||||
if (base == null) {
|
||||
ESVG_ERROR("Can not get base : '" << m_href << "'");
|
||||
return m_data;
|
||||
}
|
||||
ememory::SharedPtr<esvg::RadialGradient> gradientR = ememory::dynamicPointerCast<esvg::RadialGradient>(base);
|
||||
if (gradientR == nullptr) {
|
||||
if (gradientR == null) {
|
||||
ememory::SharedPtr<esvg::LinearGradient> gradientL = ememory::dynamicPointerCast<esvg::LinearGradient>(base);
|
||||
if (gradientL == nullptr) {
|
||||
if (gradientL == null) {
|
||||
ESVG_ERROR("Can not cast in a linear/radial gradient: '" << m_href << "' ==> wrong type");
|
||||
return m_data;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -20,19 +20,19 @@ namespace esvg {
|
||||
enum gradientUnits m_unit;
|
||||
enum spreadMethod m_spread;
|
||||
private:
|
||||
std::string m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||
std::vector<std::pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||
etk::String m_href; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data; //!< incompatible with href
|
||||
public:
|
||||
RadialGradient(PaintState _parentPaintState);
|
||||
~RadialGradient();
|
||||
virtual bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax);
|
||||
virtual bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level);
|
||||
virtual void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level);
|
||||
public:
|
||||
const esvg::Dimension& getCenter();
|
||||
const esvg::Dimension& getFocal();
|
||||
const esvg::Dimension1D& getRadius();
|
||||
const std::vector<std::pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||
const etk::Vector<etk::Pair<float, etk::Color<float,4>>>& getColors(esvg::Document* _document);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -19,7 +19,7 @@ esvg::Rectangle::~Rectangle() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Rectangle::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Rectangle::parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
if (_element.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
@ -35,7 +35,7 @@ bool esvg::Rectangle::parseXML(const exml::Element& _element, mat2& _parentTrans
|
||||
|
||||
parsePosition(_element, m_position, m_size);
|
||||
|
||||
std::string content = _element.attributes["rx"];
|
||||
etk::String content = _element.attributes["rx"];
|
||||
if (content.size()!=0) {
|
||||
m_roundedCorner.setX(parseLength(content));
|
||||
}
|
||||
@ -85,12 +85,12 @@ esvg::render::Path esvg::Rectangle::createPath() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Rectangle: fill=" << m_paint.fill.first << "/" << m_paint.fill.second
|
||||
<< " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second);
|
||||
esvg::render::Path listElement = createPath();
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
esvg::render::PointList listPoints;
|
||||
@ -108,7 +108,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32
|
||||
colorStroke = esvg::render::createColor(m_paint.stroke, mtx);
|
||||
}
|
||||
// Check if we need to display background
|
||||
if (colorFill != nullptr) {
|
||||
if (colorFill != null) {
|
||||
listSegmentFill.createSegmentList(listPoints);
|
||||
colorFill->setViewPort(listSegmentFill.getViewPort());
|
||||
listSegmentFill.applyMatrix(mtx);
|
||||
@ -118,7 +118,7 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32
|
||||
listSegmentFill);
|
||||
}
|
||||
// check if we need to display stroke:
|
||||
if (colorStroke != nullptr) {
|
||||
if (colorStroke != null) {
|
||||
listSegmentStroke.createSegmentListStroke(listPoints,
|
||||
m_paint.strokeWidth,
|
||||
m_paint.lineCap,
|
||||
@ -144,23 +144,23 @@ void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32
|
||||
}
|
||||
|
||||
|
||||
void esvg::Rectangle::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Rectangle::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW Shape esvg::Rectangle");
|
||||
esvg::render::Path listElement = createPath();
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mat2x3 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
esvg::render::PointList listPoints;
|
||||
listPoints = listElement.generateListPoints(_level, _recurtionMax, _threshold);
|
||||
listPoints.applyMatrix(mtx);
|
||||
for (auto &it : listPoints.m_data) {
|
||||
std::vector<vec2> listPoint;
|
||||
etk::Vector<vec2> listPoint;
|
||||
for (auto &itDot : it) {
|
||||
listPoint.push_back(itDot.m_pos);
|
||||
listPoint.pushBack(itDot.m_pos);
|
||||
}
|
||||
_out.push_back(listPoint);
|
||||
_out.pushBack(listPoint);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -16,13 +16,13 @@ namespace esvg {
|
||||
public:
|
||||
Rectangle(PaintState _parentPaintState);
|
||||
~Rectangle();
|
||||
bool parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) override;
|
||||
bool parseXML(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) override;
|
||||
void display(int32_t _spacing) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) override;
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
private:
|
||||
esvg::render::Path createPath();
|
||||
|
@ -1,12 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
#include <esvg/Renderer.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/Uri.hpp>
|
||||
#include <etk/uri/provider/provider.hpp>
|
||||
|
||||
esvg::Renderer::Renderer(const ivec2& _size, esvg::Document* _document, bool _visualDebug) :
|
||||
#ifdef DEBUG
|
||||
@ -57,12 +58,12 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
const esvg::render::Weight& _weightStroke,
|
||||
ememory::SharedPtr<esvg::render::DynamicColor>& _colorStroke,
|
||||
float _opacity) {
|
||||
if (_colorFill != nullptr) {
|
||||
//_colorFill->setViewPort(std::pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
||||
if (_colorFill != null) {
|
||||
//_colorFill->setViewPort(etk::Pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
||||
_colorFill->generate(m_document);
|
||||
}
|
||||
if (_colorStroke != nullptr) {
|
||||
//_colorStroke->setViewPort(std::pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
||||
if (_colorStroke != null) {
|
||||
//_colorStroke->setViewPort(etk::Pair<vec2, vec2>(vec2(0,0), vec2(sizeX, sizeY)));
|
||||
_colorStroke->generate(m_document);
|
||||
}
|
||||
// all together
|
||||
@ -74,12 +75,12 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
// calculate merge of stroke and fill value:
|
||||
etk::Color<float,4> intermediateColorFill(etk::color::none);
|
||||
etk::Color<float,4> intermediateColorStroke(etk::color::none);
|
||||
if ( _colorFill != nullptr
|
||||
if ( _colorFill != null
|
||||
&& valueFill != 0.0f) {
|
||||
intermediateColorFill = _colorFill->getColor(pos);
|
||||
intermediateColorFill.setA(intermediateColorFill.a()*valueFill);
|
||||
}
|
||||
if ( _colorStroke != nullptr
|
||||
if ( _colorStroke != null
|
||||
&& valueStroke != 0.0f) {
|
||||
intermediateColorStroke = _colorStroke->getColor(pos);
|
||||
intermediateColorStroke.setA(intermediateColorStroke.a()*valueStroke);
|
||||
@ -101,7 +102,7 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
#ifdef DEBUG
|
||||
// display the gradient position:
|
||||
ememory::SharedPtr<esvg::render::DynamicColorSpecial> tmpColor = ememory::dynamicPointerCast<esvg::render::DynamicColorSpecial>(_colorFill);
|
||||
if (tmpColor != nullptr) {
|
||||
if (tmpColor != null) {
|
||||
esvg::render::SegmentList listSegment;
|
||||
// Display bounding box
|
||||
listSegment.addSegment(esvg::render::Point(tmpColor->m_viewPort.first),
|
||||
@ -122,8 +123,8 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
esvg::render::Point(tmpColor->m_pos2),
|
||||
false);
|
||||
/*
|
||||
mat2 m_matrix;
|
||||
std::pair<vec2, vec2> m_viewPort;
|
||||
mat2x3 m_matrix;
|
||||
etk::Pair<vec2, vec2> m_viewPort;
|
||||
vec2 m_pos1;
|
||||
vec2 m_pos2;
|
||||
*/
|
||||
@ -141,25 +142,25 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
// for each lines:
|
||||
for (int32_t yyy=0; yyy<dynamicSize.y(); ++yyy) {
|
||||
// Reduce the number of lines in the subsampling parsing:
|
||||
std::vector<esvg::render::Segment> availlableSegmentPixel;
|
||||
etk::Vector<esvg::render::Segment> availlableSegmentPixel;
|
||||
for (auto &it : _listSegment.m_data) {
|
||||
if ( it.p0.y() * m_factor <= float(yyy+1)
|
||||
&& it.p1.y() * m_factor >= float(yyy)) {
|
||||
availlableSegmentPixel.push_back(it);
|
||||
availlableSegmentPixel.pushBack(it);
|
||||
}
|
||||
}
|
||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||
float subSamplingCenterPos = yyy + 0.5f;
|
||||
std::vector<esvg::render::Segment> availlableSegment;
|
||||
etk::Vector<esvg::render::Segment> availlableSegment;
|
||||
// find in the subList ...
|
||||
for (auto &it : availlableSegmentPixel) {
|
||||
if ( it.p0.y() * m_factor <= subSamplingCenterPos
|
||||
&& it.p1.y() * m_factor >= subSamplingCenterPos ) {
|
||||
availlableSegment.push_back(it);
|
||||
availlableSegment.pushBack(it);
|
||||
}
|
||||
}
|
||||
// x position, angle
|
||||
std::vector<std::pair<float, float>> listPosition;
|
||||
etk::Vector<etk::Pair<float, float>> listPosition;
|
||||
for (auto &it : availlableSegment) {
|
||||
vec2 delta = it.p0 * m_factor - it.p1 * m_factor;
|
||||
// x = coefficent*y+bbb;
|
||||
@ -181,29 +182,29 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
// for each colomn:
|
||||
for (int32_t xxx=0; xxx<dynamicSize.x(); ++xxx) {
|
||||
// Reduce the number of lines in the subsampling parsing:
|
||||
std::vector<esvg::render::Segment> availlableSegmentPixel;
|
||||
etk::Vector<esvg::render::Segment> availlableSegmentPixel;
|
||||
for (auto &it : _listSegment.m_data) {
|
||||
if ( ( it.p0.x() * m_factor <= float(xxx+1)
|
||||
&& it.p1.x() * m_factor >= float(xxx) )
|
||||
|| ( it.p0.x() * m_factor >= float(xxx+1)
|
||||
&& it.p1.x() * m_factor <= float(xxx) ) ) {
|
||||
availlableSegmentPixel.push_back(it);
|
||||
availlableSegmentPixel.pushBack(it);
|
||||
}
|
||||
}
|
||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||
float subSamplingCenterPos = xxx + 0.5f;
|
||||
std::vector<esvg::render::Segment> availlableSegment;
|
||||
etk::Vector<esvg::render::Segment> availlableSegment;
|
||||
// find in the subList ...
|
||||
for (auto &it : availlableSegmentPixel) {
|
||||
if ( ( it.p0.x() * m_factor <= subSamplingCenterPos
|
||||
&& it.p1.x() * m_factor >= subSamplingCenterPos)
|
||||
|| ( it.p0.x() * m_factor >= subSamplingCenterPos
|
||||
&& it.p1.x() * m_factor <= subSamplingCenterPos) ) {
|
||||
availlableSegment.push_back(it);
|
||||
availlableSegment.pushBack(it);
|
||||
}
|
||||
}
|
||||
// x position, angle
|
||||
std::vector<std::pair<float, float>> listPosition;
|
||||
etk::Vector<etk::Pair<float, float>> listPosition;
|
||||
for (auto &it : availlableSegment) {
|
||||
vec2 delta = it.p0 * m_factor - it.p1 * m_factor;
|
||||
// x = coefficent*y+bbb;
|
||||
@ -229,13 +230,17 @@ void esvg::Renderer::print(const esvg::render::Weight& _weightFill,
|
||||
#endif
|
||||
|
||||
|
||||
void esvg::Renderer::writePPM(const std::string& _fileName) {
|
||||
void esvg::Renderer::writePPM(const etk::Uri& _uri) {
|
||||
if (m_buffer.size() == 0) {
|
||||
return;
|
||||
}
|
||||
etk::FSNode tmpFile(_fileName);
|
||||
if(tmpFile.fileOpenWrite() == false) {
|
||||
ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
auto fileIo = etk::uri::get(_uri);
|
||||
if (fileIo == null) {
|
||||
ESVG_ERROR("Can not create the uri: " << _uri);
|
||||
return;
|
||||
}
|
||||
if (fileIo->open(etk::io::OpenMode::Write) == false) {
|
||||
ESVG_ERROR("Can not open (r) the file : " << _uri);
|
||||
return;
|
||||
}
|
||||
int32_t sizeX = m_size.x();
|
||||
@ -247,12 +252,12 @@ void esvg::Renderer::writePPM(const std::string& _fileName) {
|
||||
ESVG_DEBUG("Generate ppm : " << m_size << " debug size=" << ivec2(sizeX,sizeY));
|
||||
char tmpValue[1024];
|
||||
sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY);
|
||||
tmpFile.fileWrite(tmpValue,1,sizeof(tmpValue));
|
||||
fileIo->write(tmpValue,1,sizeof(tmpValue));
|
||||
for (int32_t iii=0 ; iii<sizeX*sizeY; iii++) {
|
||||
etk::Color<uint8_t,3> tmp = m_buffer[iii];
|
||||
tmpFile.fileWrite(&tmp, 1, 3);
|
||||
fileIo->write(&tmp, 1, 3);
|
||||
}
|
||||
tmpFile.fileClose();
|
||||
fileIo->close();
|
||||
}
|
||||
#define PLOPPP
|
||||
extern "C" {
|
||||
@ -290,14 +295,17 @@ extern "C" {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
void esvg::Renderer::writeBMP(const std::string& _fileName) {
|
||||
void esvg::Renderer::writeBMP(const etk::Uri& _uri) {
|
||||
if (m_buffer.size() == 0) {
|
||||
return;
|
||||
}
|
||||
etk::FSNode tmpFile(_fileName);
|
||||
|
||||
if(tmpFile.fileOpenWrite() == false) {
|
||||
ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
auto fileIo = etk::uri::get(_uri);
|
||||
if (fileIo == null) {
|
||||
ESVG_ERROR("Can not create the uri: " << _uri);
|
||||
return;
|
||||
}
|
||||
if (fileIo->open(etk::io::OpenMode::Write) == false) {
|
||||
ESVG_ERROR("Can not open (r) the file : " << _uri);
|
||||
return;
|
||||
}
|
||||
struct bitmapFileHeader fileHeader;
|
||||
@ -339,15 +347,15 @@ void esvg::Renderer::writeBMP(const std::string& _fileName) {
|
||||
infoHeader.biBitMaskGreen = 0x00FF0000;
|
||||
infoHeader.biBitMaskBlue =0x0000FF00;
|
||||
infoHeader.biBitMaskAlpha = 0x000000FF;
|
||||
infoHeader.biLCSColorSpace = 0x73524742; // "???"
|
||||
infoHeader.biLCSColorSpace = 0x73524742; // "Win "
|
||||
for (int32_t jjj=0; jjj<16; ++jjj) {
|
||||
infoHeader.biUnused[jjj] = 0;
|
||||
}
|
||||
infoHeader.biUnused[12] = 0x00000002;
|
||||
#endif
|
||||
// get the data :
|
||||
tmpFile.fileWrite(&fileHeader, sizeof(struct bitmapFileHeader), 1);
|
||||
tmpFile.fileWrite(&infoHeader, sizeof(struct bitmapInfoHeader), 1);
|
||||
fileIo->write(&fileHeader, sizeof(struct bitmapFileHeader), 1);
|
||||
fileIo->write(&infoHeader, sizeof(struct bitmapInfoHeader), 1);
|
||||
|
||||
uint8_t data[16];
|
||||
for(int32_t yyy=sizeY-1; yyy>=0; --yyy) {
|
||||
@ -365,10 +373,10 @@ void esvg::Renderer::writeBMP(const std::string& _fileName) {
|
||||
*pointer++ = tmpColor.g();
|
||||
*pointer++ = tmpColor.r();
|
||||
#endif
|
||||
tmpFile.fileWrite(data,1,4);
|
||||
fileIo->write(data,1,4);
|
||||
}
|
||||
}
|
||||
tmpFile.fileClose();
|
||||
fileIo->close();
|
||||
}
|
||||
|
||||
|
||||
@ -385,7 +393,7 @@ const ivec2& esvg::Renderer::getSize() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
std::vector<etk::Color<float,4>> esvg::Renderer::getData() {
|
||||
etk::Vector<etk::Color<float,4>> esvg::Renderer::getData() {
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
@ -393,7 +401,7 @@ std::vector<etk::Color<float,4>> esvg::Renderer::getData() {
|
||||
|
||||
|
||||
void esvg::Renderer::setInterpolationRecurtionMax(int32_t _value) {
|
||||
m_interpolationRecurtionMax = std::avg(1, _value, 200);
|
||||
m_interpolationRecurtionMax = etk::avg(1, _value, 200);
|
||||
}
|
||||
|
||||
int32_t esvg::Renderer::getInterpolationRecurtionMax() const {
|
||||
@ -401,7 +409,7 @@ int32_t esvg::Renderer::getInterpolationRecurtionMax() const {
|
||||
}
|
||||
|
||||
void esvg::Renderer::setInterpolationThreshold(float _value) {
|
||||
m_interpolationThreshold = std::avg(0.0f, _value, 20000.0f);
|
||||
m_interpolationThreshold = etk::avg(0.0f, _value, 20000.0f);
|
||||
}
|
||||
|
||||
float esvg::Renderer::getInterpolationThreshold() const {
|
||||
@ -409,7 +417,7 @@ float esvg::Renderer::getInterpolationThreshold() const {
|
||||
}
|
||||
|
||||
void esvg::Renderer::setNumberSubScanLine(int32_t _value) {
|
||||
m_nbSubScanLine = std::avg(1, _value, 200);
|
||||
m_nbSubScanLine = etk::avg(1, _value, 200);
|
||||
}
|
||||
|
||||
int32_t esvg::Renderer::getNumberSubScanLine() const {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include <etk/Color.hpp>
|
||||
#include <esvg/render/Weight.hpp>
|
||||
#include <esvg/render/DynamicColor.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace esvg {
|
||||
class Document;
|
||||
@ -28,9 +29,9 @@ namespace esvg {
|
||||
void setSize(const ivec2& _size);
|
||||
const ivec2& getSize() const;
|
||||
protected:
|
||||
std::vector<etk::Color<float,4>> m_buffer;
|
||||
etk::Vector<etk::Color<float,4>> m_buffer;
|
||||
public:
|
||||
std::vector<etk::Color<float,4>> getData();
|
||||
etk::Vector<etk::Color<float,4>> getData();
|
||||
protected:
|
||||
int32_t m_interpolationRecurtionMax;
|
||||
public:
|
||||
@ -47,8 +48,8 @@ namespace esvg {
|
||||
void setNumberSubScanLine(int32_t _value);
|
||||
int32_t getNumberSubScanLine() const;
|
||||
public:
|
||||
void writePPM(const std::string& _fileName);
|
||||
void writeBMP(const std::string& _fileName);
|
||||
void writePPM(const etk::Uri& _uri);
|
||||
void writeBMP(const etk::Uri& _uri);
|
||||
protected:
|
||||
etk::Color<float,4> mergeColor(etk::Color<float,4> _base, etk::Color<float,4> _integration);
|
||||
public:
|
||||
@ -59,7 +60,7 @@ namespace esvg {
|
||||
float _opacity);
|
||||
#ifdef DEBUG
|
||||
void addDebugSegment(const esvg::render::SegmentList& _listSegment);
|
||||
void addDebug(const std::vector<std::pair<vec2,vec2>>& _info);
|
||||
void addDebug(const etk::Vector<etk::Pair<vec2,vec2>>& _info);
|
||||
#endif
|
||||
protected:
|
||||
esvg::Document* m_document;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -15,7 +15,7 @@ esvg::Text::~Text() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Text::parse(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
bool esvg::Text::parse(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax) {
|
||||
_sizeMax.setValue(0,0);
|
||||
ESVG_ERROR("NOT IMPLEMENTED");
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -12,7 +12,7 @@ namespace esvg {
|
||||
public:
|
||||
Text(PaintState _parentPaintState);
|
||||
~Text();
|
||||
bool parse(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax);
|
||||
bool parse(const exml::Element& _element, mat2x3& _parentTrans, vec2& _sizeMax);
|
||||
void display(int32_t _spacing) override;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/cap.hpp>
|
||||
@ -13,7 +13,7 @@ static const char* values[] = {
|
||||
"square"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::cap _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::cap _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace esvg {
|
||||
enum cap {
|
||||
@ -16,6 +17,6 @@ namespace esvg {
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::cap _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::cap _obj);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
122
esvg/esvg.cpp
122
esvg/esvg.cpp
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -20,7 +20,7 @@
|
||||
#include <esvg/RadialGradient.hpp>
|
||||
|
||||
esvg::Document::Document() {
|
||||
m_fileName = "";
|
||||
m_uri = "";
|
||||
m_version = "0.0";
|
||||
m_loadOK = false;
|
||||
m_size.setValue(0,0);
|
||||
@ -35,33 +35,33 @@ esvg::Document::~Document() {
|
||||
void esvg::Document::displayDebug() {
|
||||
ESVG_DEBUG("Main SVG: size=" << m_size);
|
||||
ESVG_DEBUG(" refs:");
|
||||
for (int32_t iii=0; iii<m_refList.size(); iii++) {
|
||||
if (m_refList[iii] != nullptr) {
|
||||
for (size_t iii=0; iii<m_refList.size(); iii++) {
|
||||
if (m_refList[iii] != null) {
|
||||
m_refList[iii]->display(2);
|
||||
}
|
||||
}
|
||||
ESVG_DEBUG(" Nodes:");
|
||||
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||
if (m_subElementList[iii] != nullptr) {
|
||||
for (size_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||
if (m_subElementList[iii] != null) {
|
||||
m_subElementList[iii]->display(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void esvg::Document::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
|
||||
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||
if (m_subElementList[iii] != nullptr) {
|
||||
void esvg::Document::draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level) {
|
||||
for (size_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||
if (m_subElementList[iii] != null) {
|
||||
m_subElementList[iii]->draw(_myRenderer, _basicTrans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FOR TEST only ...
|
||||
void esvg::Document::generateAnImage(const std::string& _fileName, bool _visualDebug) {
|
||||
generateAnImage(m_size, _fileName, _visualDebug);
|
||||
void esvg::Document::generateAnImage(const etk::Uri& _uri, bool _visualDebug) {
|
||||
generateAnImage(m_size, _uri, _visualDebug);
|
||||
}
|
||||
void esvg::Document::generateAnImage(const ivec2& _size, const std::string& _fileName, bool _visualDebug) {
|
||||
void esvg::Document::generateAnImage(const ivec2& _size, const etk::Uri& _uri, bool _visualDebug) {
|
||||
ivec2 sizeRender = _size;
|
||||
if (sizeRender.x() <= 0) {
|
||||
sizeRender.setX(m_size.x());
|
||||
@ -73,22 +73,22 @@ void esvg::Document::generateAnImage(const ivec2& _size, const std::string& _fil
|
||||
|
||||
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(sizeRender, this, _visualDebug);
|
||||
// create the first element matrix modification ...
|
||||
mat2 basicTrans;
|
||||
basicTrans *= etk::mat2Scale(vec2(sizeRender.x()/m_size.x(), sizeRender.y()/m_size.y()));
|
||||
mat2x3 basicTrans;
|
||||
basicTrans *= etk::mat2x3Scale(vec2(sizeRender.x()/m_size.x(), sizeRender.y()/m_size.y()));
|
||||
|
||||
draw(*renderedElement, basicTrans);
|
||||
|
||||
if (etk::end_with(_fileName, ".ppm") == true) {
|
||||
renderedElement->writePPM(_fileName);
|
||||
} else if (etk::end_with(_fileName, ".bmp") == true) {
|
||||
renderedElement->writeBMP(_fileName);
|
||||
if (_uri.getPath().getExtention() == "ppm") {
|
||||
renderedElement->writePPM(_uri);
|
||||
} else if (_uri.getPath().getExtention() == "bmp") {
|
||||
renderedElement->writeBMP(_uri);
|
||||
} else {
|
||||
ESVG_ERROR("Can not store with this extention : " << _fileName << " not in .bmp/.ppm");
|
||||
ESVG_ERROR("Can not store with this extention : " << _uri << " not in .bmp/.ppm");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _size) {
|
||||
etk::Vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _size) {
|
||||
if (_size.x() <= 0) {
|
||||
_size.setX(m_size.x());
|
||||
}
|
||||
@ -98,18 +98,18 @@ std::vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _si
|
||||
ESVG_DEBUG("Generate size " << _size);
|
||||
ememory::SharedPtr<esvg::Renderer> renderedElement = ememory::makeShared<esvg::Renderer>(_size, this);
|
||||
// create the first element matrix modification ...
|
||||
mat2 basicTrans;
|
||||
basicTrans *= etk::mat2Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||
mat2x3 basicTrans;
|
||||
basicTrans *= etk::mat2x3Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||
draw(*renderedElement, basicTrans);
|
||||
|
||||
// direct return the generated data ...
|
||||
return renderedElement->getData();
|
||||
}
|
||||
|
||||
std::vector<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(ivec2& _size) {
|
||||
std::vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
etk::Vector<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(ivec2& _size) {
|
||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
// Reduce scope:
|
||||
std::vector<etk::Color<float,3>> out;
|
||||
etk::Vector<etk::Color<float,3>> out;
|
||||
out.resize(data.size());
|
||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||
out[iii] = data[iii];
|
||||
@ -117,10 +117,10 @@ std::vector<etk::Color<float,3>> esvg::Document::renderImageFloatRGB(ivec2& _siz
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(ivec2& _size) {
|
||||
std::vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
etk::Vector<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(ivec2& _size) {
|
||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
// Reduce scope:
|
||||
std::vector<etk::Color<uint8_t,4>> out;
|
||||
etk::Vector<etk::Color<uint8_t,4>> out;
|
||||
out.resize(data.size());
|
||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||
out[iii] = data[iii];
|
||||
@ -128,10 +128,10 @@ std::vector<etk::Color<uint8_t,4>> esvg::Document::renderImageU8RGBA(ivec2& _siz
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<etk::Color<uint8_t,3>> esvg::Document::renderImageU8RGB(ivec2& _size) {
|
||||
std::vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
etk::Vector<etk::Color<uint8_t,3>> esvg::Document::renderImageU8RGB(ivec2& _size) {
|
||||
etk::Vector<etk::Color<float,4>> data = renderImageFloatRGBA(_size);
|
||||
// Reduce scope:
|
||||
std::vector<etk::Color<uint8_t,3>> out;
|
||||
etk::Vector<etk::Color<uint8_t,3>> out;
|
||||
out.resize(data.size());
|
||||
for (size_t iii=0; iii<data.size(); ++iii) {
|
||||
out[iii] = data[iii];
|
||||
@ -140,7 +140,7 @@ std::vector<etk::Color<uint8_t,3>> esvg::Document::renderImageU8RGB(ivec2& _size
|
||||
}
|
||||
|
||||
void esvg::Document::clear() {
|
||||
m_fileName = "";
|
||||
m_uri = "";
|
||||
m_version = "0.0";
|
||||
m_loadOK = true;
|
||||
m_paint.clear();
|
||||
@ -148,22 +148,22 @@ void esvg::Document::clear() {
|
||||
}
|
||||
|
||||
|
||||
bool esvg::Document::parse(const std::string& _data) {
|
||||
bool esvg::Document::parse(const etk::String& _data) {
|
||||
clear();
|
||||
exml::Document doc;
|
||||
if (doc.parse(_data) == false) {
|
||||
ESVG_ERROR("Error occured when loading SVG: " << m_fileName);
|
||||
ESVG_ERROR("Error occured when loading SVG: " << m_uri);
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
if (doc.nodes.size() == 0) {
|
||||
ESVG_ERROR("(l ?) No nodes in the SVG file ... '" << m_fileName << "'");
|
||||
ESVG_ERROR("(l ?) No nodes in the SVG file ... '" << m_uri << "'");
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
exml::Element root = doc.nodes["svg"];
|
||||
if (root.exist() == false) {
|
||||
ESVG_ERROR("(l ?) main node not find: 'svg' in '" << m_fileName << "'");
|
||||
ESVG_ERROR("(l ?) main node not find: 'svg' in '" << m_uri << "'");
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
@ -172,27 +172,27 @@ bool esvg::Document::parse(const std::string& _data) {
|
||||
return m_loadOK;
|
||||
}
|
||||
|
||||
bool esvg::Document::generate(std::string& _data) {
|
||||
bool esvg::Document::generate(etk::String& _data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool esvg::Document::load(const std::string& _file) {
|
||||
bool esvg::Document::load(const etk::Uri& _uri) {
|
||||
clear();
|
||||
m_fileName = _file;
|
||||
m_uri = _uri;
|
||||
exml::Document doc;
|
||||
if (doc.load(m_fileName) == false) {
|
||||
ESVG_ERROR("Error occured when loading SVG : " << m_fileName);
|
||||
if (doc.load(m_uri) == false) {
|
||||
ESVG_ERROR("Error occured when loading SVG : " << m_uri);
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
if (doc.nodes.size() == 0) {
|
||||
ESVG_ERROR("(l ?) No nodes in the SVG file ... '" << m_fileName << "'");
|
||||
ESVG_ERROR("(l ?) No nodes in the SVG file ... '" << m_uri << "'");
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
exml::Element root = doc.nodes["svg"];
|
||||
if (root.exist() == false) {
|
||||
ESVG_ERROR("(l ?) main node not find: 'svg' in '" << m_fileName << "'");
|
||||
ESVG_ERROR("(l ?) main node not find: 'svg' in '" << m_uri << "'");
|
||||
m_loadOK = false;
|
||||
return m_loadOK;
|
||||
}
|
||||
@ -201,7 +201,7 @@ bool esvg::Document::load(const std::string& _file) {
|
||||
return m_loadOK;
|
||||
}
|
||||
|
||||
bool esvg::Document::store(const std::string& _file) {
|
||||
bool esvg::Document::store(const etk::Uri& _uri) {
|
||||
ESVG_TODO("not implemented store in SVG...");
|
||||
return false;
|
||||
}
|
||||
@ -215,11 +215,11 @@ bool esvg::Document::cleanStyleProperty(const exml::Element& _root) {
|
||||
}
|
||||
// get attribute style:
|
||||
if (child.attributes.exist("style") == true) {
|
||||
std::string content = child.attributes["style"];
|
||||
etk::String content = child.attributes["style"];
|
||||
if (content.size() != 0) {
|
||||
std::vector<std::string> listStyle = etk::split(content, ';');
|
||||
etk::Vector<etk::String> listStyle = etk::split(content, ';');
|
||||
for (auto &it : listStyle) {
|
||||
std::vector<std::string> value = etk::split(it, ':');
|
||||
etk::Vector<etk::String> value = etk::split(it, ':');
|
||||
if (value.size() != 2) {
|
||||
ESVG_ERROR("parsing style with a wrong patern : " << it << " missing ':'");
|
||||
continue;
|
||||
@ -316,7 +316,7 @@ bool esvg::Document::parseXMLData(const exml::Element& _root, bool _isReference)
|
||||
} else {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") node not suported : '" << child.getValue() << "' must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
||||
}
|
||||
if (elementParser == nullptr) {
|
||||
if (elementParser == null) {
|
||||
ESVG_ERROR("(l " << child.getPos() << ") error on node: '" << child.getValue() << "' allocation error or not supported ...");
|
||||
continue;
|
||||
}
|
||||
@ -333,9 +333,9 @@ bool esvg::Document::parseXMLData(const exml::Element& _root, bool _isReference)
|
||||
}
|
||||
// add element in the system
|
||||
if (_isReference == false) {
|
||||
m_subElementList.push_back(elementParser);
|
||||
m_subElementList.pushBack(elementParser);
|
||||
} else {
|
||||
m_refList.push_back(elementParser);
|
||||
m_refList.pushBack(elementParser);
|
||||
}
|
||||
}
|
||||
if ( m_size.x() == 0
|
||||
@ -352,13 +352,13 @@ bool esvg::Document::parseXMLData(const exml::Element& _root, bool _isReference)
|
||||
|
||||
|
||||
|
||||
ememory::SharedPtr<esvg::Base> esvg::Document::getReference(const std::string& _name) {
|
||||
ememory::SharedPtr<esvg::Base> esvg::Document::getReference(const etk::String& _name) {
|
||||
if (_name == "") {
|
||||
ESVG_ERROR("request a reference with no name ... ");
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
for (auto &it : m_refList) {
|
||||
if (it == nullptr) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (it->getId() == _name) {
|
||||
@ -366,11 +366,11 @@ ememory::SharedPtr<esvg::Base> esvg::Document::getReference(const std::string& _
|
||||
}
|
||||
}
|
||||
ESVG_ERROR("Can not find reference name : '" << _name << "'");
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
|
||||
std::vector<std::vector<vec2>> esvg::Document::getLines(vec2 _size) {
|
||||
std::vector<std::vector<vec2>> out;
|
||||
etk::Vector<etk::Vector<vec2>> esvg::Document::getLines(vec2 _size) {
|
||||
etk::Vector<etk::Vector<vec2>> out;
|
||||
if (_size.x() <= 0) {
|
||||
_size.setX(m_size.x());
|
||||
}
|
||||
@ -379,21 +379,21 @@ std::vector<std::vector<vec2>> esvg::Document::getLines(vec2 _size) {
|
||||
}
|
||||
ESVG_DEBUG("lineification size " << _size);
|
||||
// create the first element matrix modification ...
|
||||
mat2 basicTrans;
|
||||
basicTrans *= etk::mat2Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||
mat2x3 basicTrans;
|
||||
basicTrans *= etk::mat2x3Scale(vec2(_size.x()/m_size.x(), _size.y()/m_size.y()));
|
||||
drawShapePoints(out, 10, 0.25f, basicTrans);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void esvg::Document::drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void esvg::Document::drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW shape esvg::Document");
|
||||
for (auto &it : m_subElementList) {
|
||||
if (it != nullptr) {
|
||||
if (it != null) {
|
||||
it->drawShapePoints(_out, _recurtionMax, _threshold, _basicTrans, _level+1);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
#include <esvg/Base.hpp>
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
namespace esvg {
|
||||
class Document : public esvg::Base {
|
||||
private:
|
||||
std::string m_fileName;
|
||||
etk::Uri m_uri;
|
||||
bool m_loadOK;
|
||||
std::string m_version;
|
||||
std::string m_title;
|
||||
std::vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub-element list
|
||||
std::vector<ememory::SharedPtr<esvg::Base>> m_refList; //!< reference elements ...
|
||||
etk::String m_version;
|
||||
etk::String m_title;
|
||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_subElementList; //!< sub-element list
|
||||
etk::Vector<ememory::SharedPtr<esvg::Base>> m_refList; //!< reference elements ...
|
||||
vec2 m_size;
|
||||
public:
|
||||
Document();
|
||||
@ -35,28 +35,28 @@ namespace esvg {
|
||||
* @return false : An error occured
|
||||
* @return true : Parsing is OK
|
||||
*/
|
||||
bool parse(const std::string& _data);
|
||||
bool parse(const etk::String& _data);
|
||||
/**
|
||||
* @brief generate a string that contain the created SVG
|
||||
* @param[out] _data Data where the svg is stored
|
||||
* @return false : An error occured
|
||||
* @return true : Parsing is OK
|
||||
*/
|
||||
bool generate(std::string& _data);
|
||||
bool generate(etk::String& _data);
|
||||
/**
|
||||
* @brief Load the file that might contain the svg
|
||||
* @param[in] _file Filename of the svg (compatible with etk FSNode naming)
|
||||
* @param[in] _uri File of the svg
|
||||
* @return false : An error occured
|
||||
* @return true : Parsing is OK
|
||||
*/
|
||||
bool load(const std::string& _file);
|
||||
bool load(const etk::Uri& _uri);
|
||||
/**
|
||||
* @brief Store the SVG in the file
|
||||
* @param[in] _file Filename of the svg (compatible with etk FSNode naming)
|
||||
* @param[in] _uri File of the svg
|
||||
* @return false : An error occured
|
||||
* @return true : Parsing is OK
|
||||
*/
|
||||
bool store(const std::string& _file);
|
||||
bool store(const etk::Uri& _uri);
|
||||
protected:
|
||||
/**
|
||||
* @brief change all style in a xml atribute
|
||||
@ -72,33 +72,33 @@ namespace esvg {
|
||||
*/
|
||||
void displayDebug();
|
||||
// TODO: remove this fucntion : use generic function ...
|
||||
void generateAnImage(const std::string& _fileName, bool _visualDebug=false);
|
||||
void generateAnImage(const ivec2& _size, const std::string& _fileName, bool _visualDebug=false);
|
||||
void generateAnImage(const etk::Uri& _uri, bool _visualDebug=false);
|
||||
void generateAnImage(const ivec2& _size, const etk::Uri& _uri, bool _visualDebug=false);
|
||||
/**
|
||||
* @brief Generate Image in a specific format.
|
||||
* @param[in,out] _size Size expected of the rendered image (value <=0 if it need to be automatic.) return the size generate
|
||||
* @return Vector of the data used to display (simple vector: generic to transmit)
|
||||
*/
|
||||
std::vector<etk::Color<float,4>> renderImageFloatRGBA(ivec2& _size);
|
||||
etk::Vector<etk::Color<float,4>> renderImageFloatRGBA(ivec2& _size);
|
||||
//! @previous
|
||||
std::vector<etk::Color<float,3>> renderImageFloatRGB(ivec2& _size);
|
||||
etk::Vector<etk::Color<float,3>> renderImageFloatRGB(ivec2& _size);
|
||||
//! @previous
|
||||
std::vector<etk::Color<uint8_t,4>> renderImageU8RGBA(ivec2& _size);
|
||||
etk::Vector<etk::Color<uint8_t,4>> renderImageU8RGBA(ivec2& _size);
|
||||
//! @previous
|
||||
std::vector<etk::Color<uint8_t,3>> renderImageU8RGB(ivec2& _size);
|
||||
std::vector<std::vector<vec2>> getLines(vec2 _size=vec2(256,256));
|
||||
etk::Vector<etk::Color<uint8_t,3>> renderImageU8RGB(ivec2& _size);
|
||||
etk::Vector<etk::Vector<vec2>> getLines(vec2 _size=vec2(256,256));
|
||||
protected:
|
||||
void draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level=0) override;
|
||||
void draw(esvg::Renderer& _myRenderer, mat2x3& _basicTrans, int32_t _level=0) override;
|
||||
public:
|
||||
vec2 getDefinedSize() {
|
||||
return m_size;
|
||||
};
|
||||
ememory::SharedPtr<esvg::Base> getReference(const std::string& _name);
|
||||
ememory::SharedPtr<esvg::Base> getReference(const etk::String& _name);
|
||||
protected:
|
||||
void drawShapePoints(std::vector<std::vector<vec2>>& _out,
|
||||
void drawShapePoints(etk::Vector<etk::Vector<vec2>>& _out,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
mat2& _basicTrans,
|
||||
mat2x3& _basicTrans,
|
||||
int32_t _level=1) override;
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/gradientUnits.hpp>
|
||||
@ -12,7 +12,7 @@ static const char* values[] = {
|
||||
"objectBoundingBox"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::gradientUnits _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::gradientUnits _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace esvg {
|
||||
enum gradientUnits {
|
||||
@ -15,5 +16,5 @@ namespace esvg {
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::gradientUnits _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::gradientUnits _obj);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/join.hpp>
|
||||
@ -13,7 +13,7 @@ static const char* values[] = {
|
||||
"bevel"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::join _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::join _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace esvg {
|
||||
enum join {
|
||||
@ -16,7 +17,7 @@ namespace esvg {
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::join _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::join _obj);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -10,7 +10,7 @@
|
||||
#include <esvg/RadialGradient.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
|
||||
esvg::render::DynamicColorSpecial::DynamicColorSpecial(const std::string& _link, const mat2& _mtx) :
|
||||
esvg::render::DynamicColorSpecial::DynamicColorSpecial(const etk::String& _link, const mat2x3& _mtx) :
|
||||
m_linear(true),
|
||||
m_colorName(_link),
|
||||
m_matrix(_mtx),
|
||||
@ -18,7 +18,7 @@ esvg::render::DynamicColorSpecial::DynamicColorSpecial(const std::string& _link,
|
||||
|
||||
}
|
||||
|
||||
void esvg::render::DynamicColorSpecial::setViewPort(const std::pair<vec2, vec2>& _viewPort) {
|
||||
void esvg::render::DynamicColorSpecial::setViewPort(const etk::Pair<vec2, vec2>& _viewPort) {
|
||||
m_viewPort = _viewPort;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
||||
ratio -= float(int32_t(ratio));
|
||||
if (ratio <0.0f) {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
ratio = 1.0f-std::abs(ratio);
|
||||
ratio = 1.0f-etk::abs(ratio);
|
||||
#else
|
||||
ratio = 1.0f-abs(ratio);
|
||||
#endif
|
||||
@ -123,7 +123,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
||||
break;
|
||||
case spreadMethod_reflect:
|
||||
#ifndef __STDCPP_LLVM__
|
||||
ratio = std::abs(ratio);
|
||||
ratio = etk::abs(ratio);
|
||||
#else
|
||||
ratio = abs(ratio);
|
||||
#endif
|
||||
@ -136,7 +136,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
||||
ratio -= float(int32_t(ratio));
|
||||
if (ratio <0.0f) {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
ratio = 1.0f-std::abs(ratio);
|
||||
ratio = 1.0f-etk::abs(ratio);
|
||||
#else
|
||||
ratio = 1.0f-abs(ratio);
|
||||
#endif
|
||||
@ -162,7 +162,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorLinear(const ivec
|
||||
}
|
||||
return etk::color::green;
|
||||
}
|
||||
static std::pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
||||
static etk::Pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
||||
const vec2& _pos2,
|
||||
const vec2& _center = vec2(0.0f, 0.0f),
|
||||
float _radius = 1.0f) {
|
||||
@ -180,18 +180,18 @@ static std::pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
||||
|
||||
float distToCenter = (midpt - _center).length2();
|
||||
if (distToCenter > _radius * _radius) {
|
||||
return std::pair<vec2,vec2>(vec2(0.0,0.0), vec2(0.0,0.0));
|
||||
return etk::Pair<vec2,vec2>(vec2(0.0,0.0), vec2(0.0,0.0));
|
||||
}
|
||||
if (distToCenter == _radius * _radius) {
|
||||
return std::pair<vec2,vec2>(midpt, midpt);
|
||||
return etk::Pair<vec2,vec2>(midpt, midpt);
|
||||
}
|
||||
float distToIntersection;
|
||||
if (distToCenter == 0.0f) {
|
||||
distToIntersection = _radius;
|
||||
} else {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
distToCenter = std::sqrt(distToCenter);
|
||||
distToIntersection = std::sqrt(_radius * _radius - distToCenter * distToCenter);
|
||||
distToCenter = etk::sqrt(distToCenter);
|
||||
distToIntersection = etk::sqrt(_radius * _radius - distToCenter * distToCenter);
|
||||
#else
|
||||
distToCenter = sqrtf(distToCenter);
|
||||
distToIntersection = sqrtf(_radius * _radius - distToCenter * distToCenter);
|
||||
@ -200,7 +200,7 @@ static std::pair<vec2,vec2> intersectLineToCircle(const vec2& _pos1,
|
||||
// normalize...
|
||||
v1.safeNormalize();
|
||||
v1 *= distToIntersection;
|
||||
return std::pair<vec2,vec2>(midpt + v1, midpt - v1);
|
||||
return etk::Pair<vec2,vec2>(midpt + v1, midpt - v1);
|
||||
}
|
||||
|
||||
etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec2& _pos) const {
|
||||
@ -252,7 +252,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec
|
||||
if (focalCenter == currentPoint) {
|
||||
ratio = 0.0f;
|
||||
} else {
|
||||
std::pair<vec2,vec2> positions = intersectLineToCircle(focalCenter, currentPoint);
|
||||
etk::Pair<vec2,vec2> positions = intersectLineToCircle(focalCenter, currentPoint);
|
||||
float lenghtBase = (currentPoint - focalCenter).length();
|
||||
float lenghtBorder1 = (positions.first - focalCenter).length();
|
||||
float lenghtBorder2 = (positions.second - focalCenter).length();
|
||||
@ -274,7 +274,7 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec
|
||||
ratio -= float(int32_t(ratio));
|
||||
if (ratio <0.0f) {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
ratio = 1.0f-std::abs(ratio);
|
||||
ratio = 1.0f-etk::abs(ratio);
|
||||
#else
|
||||
ratio = 1.0f-abs(ratio);
|
||||
#endif
|
||||
@ -302,18 +302,18 @@ etk::Color<float,4> esvg::render::DynamicColorSpecial::getColorRadial(const ivec
|
||||
|
||||
|
||||
void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
||||
if (_document == nullptr) {
|
||||
ESVG_ERROR("Get nullptr input for document");
|
||||
if (_document == null) {
|
||||
ESVG_ERROR("Get null input for document");
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<esvg::Base> base = _document->getReference(m_colorName);
|
||||
if (base == nullptr) {
|
||||
if (base == null) {
|
||||
ESVG_ERROR("Can not get base : '" << m_colorName << "'");
|
||||
return;
|
||||
}
|
||||
// Now we can know if we use linear or radial gradient ...
|
||||
ememory::SharedPtr<esvg::LinearGradient> gradient = ememory::dynamicPointerCast<esvg::LinearGradient>(base);
|
||||
if (gradient != nullptr) {
|
||||
if (gradient != null) {
|
||||
m_linear = true;
|
||||
ESVG_VERBOSE("get for color linear:");
|
||||
gradient->display(2);
|
||||
@ -361,7 +361,7 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
||||
} else {
|
||||
m_linear = false;
|
||||
ememory::SharedPtr<esvg::RadialGradient> gradient = ememory::dynamicPointerCast<esvg::RadialGradient>(base);
|
||||
if (gradient == nullptr) {
|
||||
if (gradient == null) {
|
||||
ESVG_ERROR("Can not cast in a linear gradient: '" << m_colorName << "' ==> wrong type");
|
||||
return;
|
||||
}
|
||||
@ -439,11 +439,11 @@ void esvg::render::DynamicColorSpecial::generate(esvg::Document* _document) {
|
||||
}
|
||||
}
|
||||
|
||||
ememory::SharedPtr<esvg::render::DynamicColor> esvg::render::createColor(std::pair<etk::Color<float,4>, std::string> _color, const mat2& _mtx) {
|
||||
ememory::SharedPtr<esvg::render::DynamicColor> esvg::render::createColor(etk::Pair<etk::Color<float,4>, etk::String> _color, const mat2x3& _mtx) {
|
||||
// Check if need to create a color:
|
||||
if ( _color.first.a() == 0x00
|
||||
&& _color.second == "") {
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
if (_color.second != "") {
|
||||
return ememory::makeShared<esvg::render::DynamicColorSpecial>(_color.second, _mtx);
|
||||
|
@ -1,15 +1,16 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Pair.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Matrix2.hpp>
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
#include <esvg/gradientUnits.hpp>
|
||||
#include <esvg/spreadMethod.hpp>
|
||||
|
||||
@ -24,7 +25,7 @@ namespace esvg {
|
||||
virtual ~DynamicColor() {};
|
||||
virtual etk::Color<float,4> getColor(const ivec2& _pos) const = 0;
|
||||
virtual void generate(esvg::Document* _document) = 0;
|
||||
virtual void setViewPort(const std::pair<vec2, vec2>& _viewPort) = 0;
|
||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort) = 0;
|
||||
};
|
||||
class DynamicColorUni : public esvg::render::DynamicColor {
|
||||
public:
|
||||
@ -40,7 +41,7 @@ namespace esvg {
|
||||
virtual void generate(esvg::Document* _document) {
|
||||
// nothing to do ...
|
||||
}
|
||||
virtual void setViewPort(const std::pair<vec2, vec2>& _viewPort) {
|
||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort) {
|
||||
// nothing to do ...
|
||||
};
|
||||
};
|
||||
@ -49,9 +50,9 @@ namespace esvg {
|
||||
bool m_linear;
|
||||
esvg::spreadMethod m_spread;
|
||||
esvg::gradientUnits m_unit;
|
||||
std::string m_colorName;
|
||||
mat2 m_matrix;
|
||||
std::pair<vec2, vec2> m_viewPort;
|
||||
etk::String m_colorName;
|
||||
mat2x3 m_matrix;
|
||||
etk::Pair<vec2, vec2> m_viewPort;
|
||||
vec2 m_pos1; // in radius ==> center
|
||||
vec2 m_pos2; // in radius ==> radius end position
|
||||
vec2 m_focal; // Specific radius
|
||||
@ -61,19 +62,19 @@ namespace esvg {
|
||||
float m_focalLength;
|
||||
bool m_clipOut;
|
||||
bool m_centerIsFocal;
|
||||
std::vector<std::pair<float, etk::Color<float,4>>> m_data;
|
||||
etk::Vector<etk::Pair<float, etk::Color<float,4>>> m_data;
|
||||
public:
|
||||
DynamicColorSpecial(const std::string& _link, const mat2& _mtx);
|
||||
DynamicColorSpecial(const etk::String& _link, const mat2x3& _mtx);
|
||||
virtual etk::Color<float,4> getColor(const ivec2& _pos) const;
|
||||
private:
|
||||
etk::Color<float,4> getColorLinear(const ivec2& _pos) const;
|
||||
etk::Color<float,4> getColorRadial(const ivec2& _pos) const;
|
||||
public:
|
||||
virtual void generate(esvg::Document* _document);
|
||||
virtual void setViewPort(const std::pair<vec2, vec2>& _viewPort);
|
||||
virtual void setViewPort(const etk::Pair<vec2, vec2>& _viewPort);
|
||||
};
|
||||
|
||||
ememory::SharedPtr<DynamicColor> createColor(std::pair<etk::Color<float,4>, std::string> _color, const mat2& _mtx);
|
||||
ememory::SharedPtr<DynamicColor> createColor(etk::Pair<etk::Color<float,4>, etk::String> _color, const mat2x3& _mtx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
#include <esvg/debug.hpp>
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::render::path _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::render::path _obj) {
|
||||
switch (_obj) {
|
||||
case esvg::render::path_stop:
|
||||
_os << "path_stop";
|
||||
@ -48,9 +48,9 @@ std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::render::path _obj)
|
||||
};
|
||||
return _os;
|
||||
}
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, const esvg::render::Element& _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, const esvg::render::Element& _obj) {
|
||||
_os << _obj.getType();
|
||||
_os << ": rel=" << etk::to_string(_obj.getRelative()) << " ";
|
||||
_os << ": rel=" << etk::toString(_obj.getRelative()) << " ";
|
||||
_os << _obj.display();
|
||||
return _os;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -74,17 +74,17 @@ namespace esvg {
|
||||
m_pos2 = _val;
|
||||
}
|
||||
public:
|
||||
virtual std::string display() const = 0;
|
||||
virtual etk::String display() const = 0;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, const esvg::render::Element& _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, const esvg::render::Element& _obj);
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::render::path _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::render::path _obj);
|
||||
}
|
||||
|
||||
#include <esvg/render/ElementStop.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementBezierCurveTo::ElementBezierCurveTo(bool _relative, const v
|
||||
m_pos1 = _pos1;
|
||||
}
|
||||
|
||||
std::string esvg::render::ElementBezierCurveTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos) + " pos1=" + etk::to_string(m_pos1);
|
||||
etk::String esvg::render::ElementBezierCurveTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos) + " pos1=" + etk::toString(m_pos1);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementBezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementBezierSmoothCurveTo::ElementBezierSmoothCurveTo(bool _relat
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementBezierSmoothCurveTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos);
|
||||
etk::String esvg::render::ElementBezierSmoothCurveTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementBezierSmoothCurveTo(bool _relative, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -12,7 +12,7 @@ esvg::render::ElementClose::ElementClose(bool _relative):
|
||||
|
||||
}
|
||||
|
||||
std::string esvg::render::ElementClose::display() const {
|
||||
etk::String esvg::render::ElementClose::display() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementClose(bool _relative=false);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -16,6 +16,6 @@ esvg::render::ElementCurveTo::ElementCurveTo(bool _relative, const vec2& _pos1,
|
||||
|
||||
|
||||
|
||||
std::string esvg::render::ElementCurveTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos) + " pos1=" + etk::to_string(m_pos1) + " pos2=" + etk::to_string(m_pos2);
|
||||
etk::String esvg::render::ElementCurveTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos) + " pos1=" + etk::toString(m_pos1) + " pos2=" + etk::toString(m_pos2);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
@ -14,7 +14,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -22,10 +22,10 @@ esvg::render::ElementElliptic::ElementElliptic(bool _relative,
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementElliptic::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos)
|
||||
+ " radius=" + etk::to_string(m_pos1)
|
||||
+ " angle=" + etk::to_string(m_angle)
|
||||
+ " largeArcFlag=" + etk::to_string(m_largeArcFlag)
|
||||
+ " sweepFlag=" + etk::to_string(m_sweepFlag);
|
||||
etk::String esvg::render::ElementElliptic::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos)
|
||||
+ " radius=" + etk::toString(m_pos1)
|
||||
+ " angle=" + etk::toString(m_angle)
|
||||
+ " largeArcFlag=" + etk::toString(m_largeArcFlag)
|
||||
+ " sweepFlag=" + etk::toString(m_sweepFlag);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -24,7 +24,7 @@ namespace esvg {
|
||||
bool _sweepFlag,
|
||||
const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementLineTo::ElementLineTo(bool _relative, const vec2& _pos):
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementLineTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos);
|
||||
etk::String esvg::render::ElementLineTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementLineTo(bool _relative, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementLineToH::ElementLineToH(bool _relative, float _posX):
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementLineToH::display() const {
|
||||
return std::string("posX=") + etk::to_string(m_pos.x());
|
||||
etk::String esvg::render::ElementLineToH::display() const {
|
||||
return etk::String("posX=") + etk::toString(m_pos.x());
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementLineToH(bool _relative, float _posX);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementLineToV::ElementLineToV(bool _relative, float _posY):
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementLineToV::display() const {
|
||||
return std::string("posY=") + etk::to_string(m_pos.y());
|
||||
etk::String esvg::render::ElementLineToV::display() const {
|
||||
return etk::String("posY=") + etk::toString(m_pos.y());
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementLineToV(bool _relative, float _posY);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -13,6 +13,6 @@ esvg::render::ElementMoveTo::ElementMoveTo(bool _relative, const vec2& _pos):
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementMoveTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos);
|
||||
etk::String esvg::render::ElementMoveTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementMoveTo(bool _relative, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -14,6 +14,6 @@ esvg::render::ElementSmoothCurveTo::ElementSmoothCurveTo(bool _relative, const v
|
||||
}
|
||||
|
||||
|
||||
std::string esvg::render::ElementSmoothCurveTo::display() const {
|
||||
return std::string("pos=") + etk::to_string(m_pos) + " pos2=" + etk::to_string(m_pos2);
|
||||
etk::String esvg::render::ElementSmoothCurveTo::display() const {
|
||||
return etk::String("pos=") + etk::toString(m_pos) + " pos2=" + etk::toString(m_pos2);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementSmoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos);
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Element.hpp>
|
||||
@ -12,7 +12,7 @@ esvg::render::ElementStop::ElementStop():
|
||||
|
||||
}
|
||||
|
||||
std::string esvg::render::ElementStop::display() const {
|
||||
etk::String esvg::render::ElementStop::display() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
public:
|
||||
ElementStop();
|
||||
public:
|
||||
virtual std::string display() const;
|
||||
virtual etk::String display() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <esvg/debug.hpp>
|
||||
#include <esvg/render/Path.hpp>
|
||||
@ -12,43 +12,43 @@ void esvg::render::Path::clear() {
|
||||
}
|
||||
|
||||
void esvg::render::Path::stop() {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementStop>());
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementStop>());
|
||||
}
|
||||
|
||||
void esvg::render::Path::close(bool _relative) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementClose>(_relative));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementClose>(_relative));
|
||||
}
|
||||
|
||||
void esvg::render::Path::moveTo(bool _relative, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementMoveTo>(_relative, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementMoveTo>(_relative, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::lineTo(bool _relative, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementLineTo>(_relative, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineTo>(_relative, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::lineToH(bool _relative, float _posX) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementLineToH>(_relative, _posX));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineToH>(_relative, _posX));
|
||||
}
|
||||
|
||||
void esvg::render::Path::lineToV(bool _relative, float _posY) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementLineToV>(_relative, _posY));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementLineToV>(_relative, _posY));
|
||||
}
|
||||
|
||||
void esvg::render::Path::curveTo(bool _relative, const vec2& _pos1, const vec2& _pos2, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementCurveTo>(_relative, _pos1, _pos2, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementCurveTo>(_relative, _pos1, _pos2, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::smoothCurveTo(bool _relative, const vec2& _pos2, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementSmoothCurveTo>(_relative, _pos2, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementSmoothCurveTo>(_relative, _pos2, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::bezierCurveTo(bool _relative, const vec2& _pos1, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementBezierCurveTo>(_relative, _pos1, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierCurveTo>(_relative, _pos1, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::bezierSmoothCurveTo(bool _relative, const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementBezierSmoothCurveTo>(_relative, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementBezierSmoothCurveTo>(_relative, _pos));
|
||||
}
|
||||
|
||||
void esvg::render::Path::ellipticTo(bool _relative,
|
||||
@ -57,7 +57,7 @@ void esvg::render::Path::ellipticTo(bool _relative,
|
||||
bool _largeArcFlag,
|
||||
bool _sweepFlag,
|
||||
const vec2& _pos) {
|
||||
m_listElement.push_back(ememory::makeShared<esvg::render::ElementElliptic>(_relative, _radius, _angle, _largeArcFlag, _sweepFlag, _pos));
|
||||
m_listElement.pushBack(ememory::makeShared<esvg::render::ElementElliptic>(_relative, _radius, _angle, _largeArcFlag, _sweepFlag, _pos));
|
||||
}
|
||||
|
||||
static const char* spacingDist(int32_t _spacing) {
|
||||
@ -71,7 +71,7 @@ static const char* spacingDist(int32_t _spacing) {
|
||||
void esvg::render::Path::display(int32_t _spacing) {
|
||||
ESVG_DEBUG(spacingDist(_spacing) << "Path");
|
||||
for(auto &it : m_listElement) {
|
||||
if (it == nullptr) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
ESVG_DEBUG(spacingDist(_spacing+1) << *it);
|
||||
@ -79,7 +79,7 @@ void esvg::render::Path::display(int32_t _spacing) {
|
||||
}
|
||||
|
||||
|
||||
void interpolateCubicBezier(std::vector<esvg::render::Point>& _listPoint,
|
||||
void interpolateCubicBezier(etk::Vector<esvg::render::Point>& _listPoint,
|
||||
int32_t _recurtionMax,
|
||||
float _threshold,
|
||||
vec2 _pos1,
|
||||
@ -97,15 +97,15 @@ void interpolateCubicBezier(std::vector<esvg::render::Point>& _listPoint,
|
||||
|
||||
vec2 delta = _pos4 - _pos1;
|
||||
#ifndef __STDCPP_LLVM__
|
||||
float distance2 = std::abs(((_pos2.x() - _pos4.x()) * delta.y() - (_pos2.y() - _pos4.y()) * delta.x() ));
|
||||
float distance3 = std::abs(((_pos3.x() - _pos4.x()) * delta.y() - (_pos3.y() - _pos4.y()) * delta.x() ));
|
||||
float distance2 = etk::abs(((_pos2.x() - _pos4.x()) * delta.y() - (_pos2.y() - _pos4.y()) * delta.x() ));
|
||||
float distance3 = etk::abs(((_pos3.x() - _pos4.x()) * delta.y() - (_pos3.y() - _pos4.y()) * delta.x() ));
|
||||
#else
|
||||
float distance2 = fabs(((_pos2.x() - _pos4.x()) * delta.y() - (_pos2.y() - _pos4.y()) * delta.x() ));
|
||||
float distance3 = fabs(((_pos3.x() - _pos4.x()) * delta.y() - (_pos3.y() - _pos4.y()) * delta.x() ));
|
||||
#endif
|
||||
|
||||
if ((distance2 + distance3)*(distance2 + distance3) < _threshold * delta.length2()) {
|
||||
_listPoint.push_back(esvg::render::Point(_pos4, _type) );
|
||||
_listPoint.pushBack(esvg::render::Point(_pos4, _type) );
|
||||
return;
|
||||
}
|
||||
vec2 pos123 = (pos12+pos23)*0.5f;
|
||||
@ -125,14 +125,14 @@ static float vectorAngle(vec2 _uuu, vec2 _vvv) {
|
||||
esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, int32_t _recurtionMax, float _threshold) {
|
||||
ESVG_VERBOSE(spacingDist(_level) << "Generate List Points ... from a path");
|
||||
esvg::render::PointList out;
|
||||
std::vector<esvg::render::Point> tmpListPoint;
|
||||
etk::Vector<esvg::render::Point> tmpListPoint;
|
||||
vec2 lastPosition(0.0f, 0.0f);
|
||||
vec2 lastAngle(0.0f, 0.0f);
|
||||
int32_t lastPointId = -1;
|
||||
bool PathStart = false;
|
||||
// Foreach element, we move in the path:
|
||||
for(auto &it : m_listElement) {
|
||||
if (it == nullptr) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
ESVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it);
|
||||
@ -161,7 +161,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
vec2 delta = (tmpListPoint.front().m_pos - tmpListPoint.back().m_pos).absolute();
|
||||
if ( delta.x() <= 0.00001
|
||||
&& delta.y() <= 0.00001) {
|
||||
tmpListPoint.pop_back();
|
||||
tmpListPoint.popBack();
|
||||
ESVG_VERBOSE(" Remove point Z property : " << tmpListPoint.back().m_pos << " with delta=" << delta);
|
||||
}
|
||||
out.addList(tmpListPoint);
|
||||
@ -183,49 +183,49 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
lastPosition = vec2(0.0f, 0.0f);
|
||||
}
|
||||
lastPosition += it->getPos();
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
lastAngle = lastPosition;
|
||||
break;
|
||||
case esvg::render::path_lineTo:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
}
|
||||
if (it->getRelative() == false) {
|
||||
lastPosition = vec2(0.0f, 0.0f);
|
||||
}
|
||||
lastPosition += it->getPos();
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
lastAngle = lastPosition;
|
||||
break;
|
||||
case esvg::render::path_lineToH:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
}
|
||||
if (it->getRelative() == false) {
|
||||
lastPosition = vec2(0.0f, 0.0f);
|
||||
}
|
||||
lastPosition += it->getPos();
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
lastAngle = lastPosition;
|
||||
break;
|
||||
case esvg::render::path_lineToV:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
|
||||
}
|
||||
if (it->getRelative() == false) {
|
||||
lastPosition = vec2(0.0f, 0.0f);
|
||||
}
|
||||
lastPosition += it->getPos();
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
lastAngle = lastPosition;
|
||||
break;
|
||||
case esvg::render::path_curveTo:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
{
|
||||
vec2 lastPosStore(lastPosition);
|
||||
@ -251,7 +251,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
case esvg::render::path_smoothCurveTo:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
{
|
||||
vec2 lastPosStore(lastPosition);
|
||||
@ -278,7 +278,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
case esvg::render::path_bezierCurveTo:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
{
|
||||
vec2 lastPosStore(lastPosition);
|
||||
@ -306,7 +306,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
case esvg::render::path_bezierSmoothCurveTo:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
{
|
||||
vec2 lastPosStore(lastPosition);
|
||||
@ -334,7 +334,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
case esvg::render::path_elliptic:
|
||||
// If no previous point, we need to create the last point has start ...
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
{
|
||||
ememory::SharedPtr<esvg::render::ElementElliptic> tmpIt(ememory::dynamicPointerCast<esvg::render::ElementElliptic>(it));
|
||||
@ -363,21 +363,21 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
|| radius.y() < 1e-6f) {
|
||||
ESVG_WARNING("Degenerate arc in Line");
|
||||
if (tmpListPoint.size() == 0) {
|
||||
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
|
||||
}
|
||||
tmpListPoint.push_back(esvg::render::Point(pos, esvg::render::Point::type::join));
|
||||
tmpListPoint.pushBack(esvg::render::Point(pos, esvg::render::Point::type::join));
|
||||
} else {
|
||||
// Convert to center point parameterization.
|
||||
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
||||
// procedure describe here : http://www.w3.org/TR/SVG11/implnote.html#ArcConversionCenterToEndpoint
|
||||
// Compute delta'
|
||||
mat2 matrixRotationCenter = etk::mat2Rotate(-rotationX);
|
||||
mat2x3 matrixRotationCenter = etk::mat2x3Rotate(-rotationX);
|
||||
vec2 deltaPrim = matrixRotationCenter * (delta*0.5f);
|
||||
ddd = (deltaPrim.x()*deltaPrim.x())/(radius.x()*radius.x())
|
||||
+ (deltaPrim.y()*deltaPrim.y())/(radius.y()*radius.y());
|
||||
if (ddd > 1.0f) {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
ddd = std::sqrt(ddd);
|
||||
ddd = etk::sqrt(ddd);
|
||||
#else
|
||||
ddd = sqrtf(ddd);
|
||||
#endif
|
||||
@ -395,7 +395,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
}
|
||||
if (ssb > 0.0f) {
|
||||
#ifndef __STDCPP_LLVM__
|
||||
sss = std::sqrt(ssa / ssb);
|
||||
sss = etk::sqrt(ssa / ssb);
|
||||
#else
|
||||
sss = sqrtf(ssa / ssb);
|
||||
#endif
|
||||
@ -406,7 +406,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
vec2 centerPrime(sss * radius.x() * deltaPrim.y() / radius.y(),
|
||||
sss * -radius.y() * deltaPrim.x() / radius.x());
|
||||
// Compute center from center'
|
||||
mat2 matrix = etk::mat2Rotate(rotationX);
|
||||
mat2x3 matrix = etk::mat2x3Rotate(rotationX);
|
||||
vec2 center = (lastPosStore + pos)*0.5f + matrix*centerPrime;
|
||||
#ifdef DEBUG
|
||||
m_debugInformation.addSegment(center-vec2(3.0,3.0), center+vec2(3.0,3.0));
|
||||
@ -442,13 +442,13 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
// Split arc into max 90 degree segments.
|
||||
// The loop assumes an iteration per end point (including start and end), this +1.
|
||||
#ifndef __STDCPP_LLVM__
|
||||
int32_t ndivs = int32_t(std::abs(deltaTheta) / (M_PI*0.5f)) + 1;
|
||||
int32_t ndivs = int32_t(etk::abs(deltaTheta) / (M_PI*0.5f)) + 1;
|
||||
#else
|
||||
int32_t ndivs = int32_t(fabs(deltaTheta) / (M_PI*0.5f)) + 1;
|
||||
#endif
|
||||
float hda = (deltaTheta / float(ndivs)) * 0.5f;
|
||||
#ifndef __STDCPP_LLVM__
|
||||
float kappa = std::abs(4.0f / 3.0f * (1.0f - std::cos(hda)) / std::sin(hda));
|
||||
float kappa = etk::abs(4.0f / 3.0f * (1.0f - etk::cos(hda)) / etk::sin(hda));
|
||||
#else
|
||||
float kappa = fabs(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
|
||||
#endif
|
||||
@ -460,7 +460,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
for (int32_t iii=0; iii<=ndivs; ++iii) {
|
||||
float a = theta1 + deltaTheta * (float(iii)/(float)ndivs);
|
||||
#ifndef __STDCPP_LLVM__
|
||||
delta = vec2(std::cos(a), std::sin(a));
|
||||
delta = vec2(etk::cos(a), etk::sin(a));
|
||||
#else
|
||||
delta = vec2(cosf(a), sinf(a));
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -18,7 +18,7 @@ namespace esvg {
|
||||
namespace render {
|
||||
class Path {
|
||||
public:
|
||||
std::vector<ememory::SharedPtr<esvg::render::Element>> m_listElement;
|
||||
etk::Vector<ememory::SharedPtr<esvg::render::Element>> m_listElement;
|
||||
#ifdef DEBUG
|
||||
esvg::render::SegmentList m_debugInformation;
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Point.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -31,6 +31,12 @@ namespace esvg {
|
||||
vec2 m_posNext;
|
||||
vec2 m_delta;
|
||||
float m_len;
|
||||
// TODO: Update etk::Vector to support not having it ...
|
||||
Point() :
|
||||
m_pos(0,0),
|
||||
m_type(esvg::render::Point::type::join) {
|
||||
// nothing to do ...
|
||||
}
|
||||
Point(const vec2& _pos, enum esvg::render::Point::type _type = esvg::render::Point::type::join) :
|
||||
m_pos(_pos),
|
||||
m_type(_type) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/debug.hpp>
|
||||
@ -11,12 +11,12 @@ esvg::render::PointList::PointList() {
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
void esvg::render::PointList::addList(std::vector<esvg::render::Point>& _list) {
|
||||
m_data.push_back(_list);
|
||||
void esvg::render::PointList::addList(etk::Vector<esvg::render::Point>& _list) {
|
||||
m_data.pushBack(_list);
|
||||
// TODO : Add a checker of correct list ...
|
||||
}
|
||||
|
||||
void esvg::render::PointList::applyMatrix(const mat2& _transformationMatrix) {
|
||||
void esvg::render::PointList::applyMatrix(const mat2x3& _transformationMatrix) {
|
||||
for (auto &it : m_data) {
|
||||
for (auto &val : it) {
|
||||
val.m_pos = _transformationMatrix * val.m_pos;
|
||||
@ -24,8 +24,8 @@ void esvg::render::PointList::applyMatrix(const mat2& _transformationMatrix) {
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<vec2, vec2> esvg::render::PointList::getViewPort() {
|
||||
std::pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
||||
etk::Pair<vec2, vec2> esvg::render::PointList::getViewPort() {
|
||||
etk::Pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
||||
for (auto &it : m_data) {
|
||||
for (auto &it2 : it) {
|
||||
out.first.setMin(it2.m_pos);
|
||||
@ -39,7 +39,7 @@ void esvg::render::PointList::display() {
|
||||
ESVG_VERBOSE(" Display list of points : size=" << m_data.size());
|
||||
for (auto &it : m_data) {
|
||||
ESVG_VERBOSE(" Find List " << it.size() << " members");
|
||||
for (int32_t iii=0;
|
||||
for (size_t iii=0;
|
||||
iii < it.size();
|
||||
++iii) {
|
||||
switch (it[iii].m_type) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Matrix2.hpp>
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
#include <etk/Pair.hpp>
|
||||
#include <esvg/render/Element.hpp>
|
||||
#include <esvg/render/Point.hpp>
|
||||
|
||||
@ -15,13 +16,13 @@ namespace esvg {
|
||||
namespace render {
|
||||
class PointList {
|
||||
public:
|
||||
std::vector<std::vector<esvg::render::Point>> m_data;
|
||||
etk::Vector<etk::Vector<esvg::render::Point>> m_data;
|
||||
public:
|
||||
PointList();
|
||||
void addList(std::vector<esvg::render::Point>& _list);
|
||||
void addList(etk::Vector<esvg::render::Point>& _list);
|
||||
void display();
|
||||
void applyMatrix(const mat2& _transformationMatrix);
|
||||
std::pair<vec2, vec2> getViewPort();
|
||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||
etk::Pair<vec2, vec2> getViewPort();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Scanline.hpp>
|
||||
#include <esvg/debug.hpp>
|
||||
|
||||
esvg::render::Scanline::Scanline(size_t _size) {
|
||||
float tmp(0);
|
||||
m_data.resize(_size, tmp);
|
||||
m_data.resize(_size, 0.0f);
|
||||
}
|
||||
|
||||
size_t esvg::render::Scanline::size() const {
|
||||
@ -23,16 +22,16 @@ void esvg::render::Scanline::clear(float _fill) {
|
||||
}
|
||||
|
||||
float esvg::render::Scanline::get(int32_t _pos) const {
|
||||
if( _pos>=0
|
||||
&& _pos<m_data.size()) {
|
||||
if( _pos >= 0
|
||||
&& size_t(_pos) < m_data.size()) {
|
||||
return m_data[_pos];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void esvg::render::Scanline::set(int32_t _pos, float _newColor) {
|
||||
if( _pos>=0
|
||||
&& _pos<m_data.size()) {
|
||||
if( _pos >= 0
|
||||
&& size_t(_pos) < m_data.size()) {
|
||||
m_data[_pos] = _newColor;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -12,7 +12,7 @@ namespace esvg {
|
||||
namespace render {
|
||||
class Scanline {
|
||||
private:
|
||||
std::vector<float> m_data;
|
||||
etk::Vector<float> m_data;
|
||||
public:
|
||||
// constructor :
|
||||
Scanline(size_t _size=32);
|
||||
|
@ -1,12 +1,18 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Segment.hpp>
|
||||
#include <esvg/debug.hpp>
|
||||
|
||||
esvg::render::Segment::Segment() {
|
||||
p0 = vec2(0,0);
|
||||
p1 = vec2(0,0);
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
esvg::render::Segment::Segment(const vec2& _p0, const vec2& _p1) {
|
||||
// segment register all time the lower at P0n then we need to register the sens of the path
|
||||
p0 = _p0;
|
||||
@ -14,7 +20,7 @@ esvg::render::Segment::Segment(const vec2& _p0, const vec2& _p1) {
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
void esvg::render::Segment::applyMatrix(const mat2& _transformationMatrix) {
|
||||
void esvg::render::Segment::applyMatrix(const mat2x3& _transformationMatrix) {
|
||||
p0 = _transformationMatrix * p0;
|
||||
p1 = _transformationMatrix * p1;
|
||||
createDirection();
|
||||
|
@ -1,23 +1,25 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Matrix2.hpp>
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
|
||||
namespace esvg {
|
||||
namespace render {
|
||||
class Segment {
|
||||
public:
|
||||
// TODO: Update etk::Vector to support not having it ...
|
||||
Segment();
|
||||
Segment(const vec2& _p0, const vec2& _p1);
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
int32_t direction;
|
||||
void applyMatrix(const mat2& _transformationMatrix);
|
||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||
void createDirection();
|
||||
};
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/SegmentList.hpp>
|
||||
#include <esvg/debug.hpp>
|
||||
#include <etk/math/Matrix2.hpp>
|
||||
#include <etk/math/Matrix2x3.hpp>
|
||||
|
||||
esvg::render::SegmentList::SegmentList() {
|
||||
|
||||
}
|
||||
#ifdef DEBUG
|
||||
void esvg::render::SegmentList::addSegment(const vec2& _pos0, const vec2& _pos1) {
|
||||
m_data.push_back(Segment(_pos0, _pos1));
|
||||
m_data.pushBack(Segment(_pos0, _pos1));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -23,7 +23,7 @@ void esvg::render::SegmentList::addSegment(const esvg::render::Point& _pos0, con
|
||||
// remove /0 operation
|
||||
return;
|
||||
}
|
||||
m_data.push_back(Segment(_pos0.m_pos, _pos1.m_pos));
|
||||
m_data.pushBack(Segment(_pos0.m_pos, _pos1.m_pos));
|
||||
}
|
||||
|
||||
void esvg::render::SegmentList::addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1, bool _disableHorizontal) {
|
||||
@ -33,11 +33,11 @@ void esvg::render::SegmentList::addSegment(const esvg::render::Point& _pos0, con
|
||||
// remove /0 operation
|
||||
return;
|
||||
}
|
||||
m_data.push_back(Segment(_pos0.m_pos, _pos1.m_pos));
|
||||
m_data.pushBack(Segment(_pos0.m_pos, _pos1.m_pos));
|
||||
}
|
||||
|
||||
std::pair<vec2, vec2> esvg::render::SegmentList::getViewPort() {
|
||||
std::pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
||||
etk::Pair<vec2, vec2> esvg::render::SegmentList::getViewPort() {
|
||||
etk::Pair<vec2, vec2> out(vec2(9999999999.0,9999999999.0),vec2(-9999999999.0,-9999999999.0));
|
||||
for (auto &it : m_data) {
|
||||
out.first.setMin(it.p0);
|
||||
out.second.setMax(it.p0);
|
||||
@ -49,7 +49,7 @@ std::pair<vec2, vec2> esvg::render::SegmentList::getViewPort() {
|
||||
void esvg::render::SegmentList::createSegmentList(const esvg::render::PointList& _listPoint) {
|
||||
for (auto &it : _listPoint.m_data) {
|
||||
// Build Segments
|
||||
for (int32_t iii=0, jjj=it.size()-1;
|
||||
for (size_t iii=0, jjj=it.size()-1;
|
||||
iii < it.size();
|
||||
jjj = iii++) {
|
||||
addSegment(it[jjj], it[iii]);
|
||||
@ -90,11 +90,11 @@ void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
|
||||
vec2 ppp1(_point1);
|
||||
vec2 ppp2(_point2);
|
||||
for (iii=baseAngle; iii<angleToDraw; iii+=baseAngle) {
|
||||
mat2 tmpMat;
|
||||
mat2x3 tmpMat;
|
||||
if (_isStart == true) {
|
||||
tmpMat = etk::mat2Rotate(-iii);
|
||||
tmpMat = etk::mat2x3Rotate(-iii);
|
||||
} else {
|
||||
tmpMat = etk::mat2Rotate(iii);
|
||||
tmpMat = etk::mat2x3Rotate(iii);
|
||||
}
|
||||
vec2 axeRotate = tmpMat * axe;
|
||||
ppp2 = _center
|
||||
@ -137,10 +137,10 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
// . * * . * * * * * * * * * * * * *
|
||||
// * *
|
||||
// * *
|
||||
for (int32_t idPevious=itListPoint.size()-1, idCurrent=0, idNext=1;
|
||||
idCurrent < itListPoint.size();
|
||||
for (int64_t idPevious=itListPoint.size()-1, idCurrent=0, idNext=1;
|
||||
idCurrent < int64_t(itListPoint.size());
|
||||
idPevious = idCurrent++, idNext++) {
|
||||
if (idNext == itListPoint.size()) {
|
||||
if (idNext == int64_t(itListPoint.size())) {
|
||||
idNext = 0;
|
||||
}
|
||||
if ( itListPoint[idCurrent].m_type == esvg::render::Point::type::join
|
||||
@ -149,7 +149,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
ESVG_ERROR("an error occure a previous ID is < 0.... ");
|
||||
continue;
|
||||
}
|
||||
if (idNext >= itListPoint.size()) {
|
||||
if (idNext >= int64_t(itListPoint.size())) {
|
||||
ESVG_ERROR("an error occure a next ID is >= nbPoint len .... ");
|
||||
continue;
|
||||
}
|
||||
@ -470,7 +470,7 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
||||
+ _point.m_miterAxe*_width*0.5f;
|
||||
vec2 right = _point.m_pos
|
||||
- _point.m_miterAxe*_width*0.5f;
|
||||
mat2 tmpMat = etk::mat2Translate(nextAxe.safeNormalize()*_width*-0.5f);
|
||||
mat2x3 tmpMat = etk::mat2x3Translate(nextAxe.safeNormalize()*_width*-0.5f);
|
||||
left = tmpMat*left;
|
||||
right = tmpMat*right;
|
||||
if (_isStart == false) {
|
||||
@ -500,7 +500,7 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
||||
}
|
||||
}
|
||||
|
||||
void esvg::render::SegmentList::applyMatrix(const mat2& _transformationMatrix) {
|
||||
void esvg::render::SegmentList::applyMatrix(const mat2x3& _transformationMatrix) {
|
||||
for (auto &it : m_data) {
|
||||
it.applyMatrix(_transformationMatrix);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -16,7 +16,7 @@ namespace esvg {
|
||||
namespace render {
|
||||
class SegmentList {
|
||||
public:
|
||||
std::vector<esvg::render::Segment> m_data;
|
||||
etk::Vector<esvg::render::Segment> m_data;
|
||||
public:
|
||||
SegmentList();
|
||||
#ifdef DEBUG
|
||||
@ -43,8 +43,8 @@ namespace esvg {
|
||||
float _width,
|
||||
bool _isStart);
|
||||
public:
|
||||
std::pair<vec2, vec2> getViewPort();
|
||||
void applyMatrix(const mat2& _transformationMatrix);
|
||||
etk::Pair<vec2, vec2> getViewPort();
|
||||
void applyMatrix(const mat2x3& _transformationMatrix);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/render/Weight.hpp>
|
||||
#include <esvg/debug.hpp>
|
||||
#include <etk/algorithm.hpp>
|
||||
|
||||
esvg::render::Weight::Weight() :
|
||||
m_size(0,0) {
|
||||
@ -67,7 +68,7 @@ void esvg::render::Weight::set(const ivec2& _pos, float _newColor) {
|
||||
void esvg::render::Weight::set(int32_t _posY, const esvg::render::Scanline& _data) {
|
||||
if ( _posY>=0
|
||||
&& _posY<m_size.y()) {
|
||||
for (size_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[xxx+_posY*m_size.x()] = _data.get(xxx);
|
||||
}
|
||||
}
|
||||
@ -76,13 +77,13 @@ void esvg::render::Weight::set(int32_t _posY, const esvg::render::Scanline& _dat
|
||||
void esvg::render::Weight::append(int32_t _posY, const esvg::render::Scanline& _data) {
|
||||
if ( _posY>=0
|
||||
&& _posY<m_size.y()) {
|
||||
for (size_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[xxx+_posY*m_size.x()] += _data.get(xxx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool sortXPosFunction(const std::pair<float,float>& _e1, const std::pair<float,float>& _e2) {
|
||||
bool sortXPosFunction(const etk::Pair<float,int32_t>& _e1, const etk::Pair<float,int32_t>& _e2) {
|
||||
return _e1.first < _e2.first;
|
||||
}
|
||||
|
||||
@ -93,11 +94,11 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
|
||||
ESVG_VERBOSE("Weighting ... " << yyy << " / " << _size.y());
|
||||
// Reduce the number of lines in the subsampling parsing:
|
||||
std::vector<Segment> availlableSegmentPixel;
|
||||
etk::Vector<Segment> availlableSegmentPixel;
|
||||
for (auto &it : _listSegment.m_data) {
|
||||
if ( it.p0.y() < float(yyy+1)
|
||||
&& it.p1.y() > float(yyy)) {
|
||||
availlableSegmentPixel.push_back(it);
|
||||
availlableSegmentPixel.pushBack(it);
|
||||
}
|
||||
}
|
||||
if (availlableSegmentPixel.size() == 0) {
|
||||
@ -111,7 +112,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
Scanline scanline(_size.x());
|
||||
//find all the segment that cross the middle of the line of the center of the pixel line:
|
||||
float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk;
|
||||
std::vector<Segment> availlableSegment;
|
||||
etk::Vector<Segment> availlableSegment;
|
||||
// find in the subList ...
|
||||
for (auto &it : availlableSegmentPixel) {
|
||||
if ( it.p0.y() <= subSamplingCenterPos
|
||||
@ -122,7 +123,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
&& availlableSegment.back().direction == it.direction) {
|
||||
// we not add this point in this case to prevent double count of the same point.
|
||||
} else {
|
||||
availlableSegment.push_back(it);
|
||||
availlableSegment.pushBack(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,18 +135,18 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
ESVG_VERBOSE(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction);
|
||||
}
|
||||
// x position, angle
|
||||
std::vector<std::pair<float, int32_t>> listPosition;
|
||||
etk::Vector<etk::Pair<float, int32_t>> listPosition;
|
||||
for (auto &it : availlableSegment) {
|
||||
vec2 delta = it.p0 - it.p1;
|
||||
// x = coefficent*y+bbb;
|
||||
float coefficient = delta.x()/delta.y();
|
||||
float bbb = it.p0.x() - coefficient*it.p0.y();
|
||||
float xpos = coefficient * subSamplingCenterPos + bbb;
|
||||
listPosition.push_back(std::pair<float,int32_t>(xpos, it.direction));
|
||||
listPosition.pushBack(etk::Pair<float,int32_t>(xpos, it.direction));
|
||||
}
|
||||
ESVG_VERBOSE(" List position " << listPosition.size());
|
||||
// now we order position of the xPosition:
|
||||
std::sort(listPosition.begin(), listPosition.end(), sortXPosFunction);
|
||||
etk::algorithm::quickSort(listPosition, sortXPosFunction);
|
||||
// move through all element in the point:
|
||||
int32_t lastState = 0;
|
||||
float currentValue = 0.0f;
|
||||
@ -160,9 +161,9 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
if (currentPos != int32_t(it.first)) {
|
||||
// fill to the new pos -1:
|
||||
#if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
|
||||
float endValue = float(std::min(1,std::abs(lastState))) * deltaSize;
|
||||
float endValue = float(etk::min(1,etk::abs(lastState))) * deltaSize;
|
||||
#else
|
||||
float endValue = float(std::min(1,abs(lastState))) * deltaSize;
|
||||
float endValue = float(etk::min(1,abs(lastState))) * deltaSize;
|
||||
#endif
|
||||
for (int32_t iii=currentPos+1; iii<int32_t(it.first); ++iii) {
|
||||
scanline.set(iii, endValue);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +15,7 @@ namespace esvg {
|
||||
class Weight {
|
||||
private:
|
||||
ivec2 m_size;
|
||||
std::vector<float> m_data;
|
||||
etk::Vector<float> m_data;
|
||||
public:
|
||||
// constructor :
|
||||
Weight();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esvg/spreadMethod.hpp>
|
||||
@ -13,7 +13,7 @@ static const char* values[] = {
|
||||
"repeat"
|
||||
};
|
||||
|
||||
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::spreadMethod _obj) {
|
||||
etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::spreadMethod _obj) {
|
||||
_os << values[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace esvg {
|
||||
enum spreadMethod {
|
||||
@ -16,7 +17,7 @@ namespace esvg {
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, enum esvg::spreadMethod _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum esvg::spreadMethod _obj);
|
||||
}
|
||||
|
||||
|
||||
|
13
license.txt
13
license.txt
@ -1,13 +0,0 @@
|
||||
Copyright esvg Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ def get_desc():
|
||||
return "eSVG converter in bitmap"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ def get_desc():
|
||||
return "eSVG test-unit"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@ -45,7 +45,7 @@ def configure(target, my_module):
|
||||
])
|
||||
my_module.add_depend([
|
||||
'esvg',
|
||||
'gtest',
|
||||
'etest',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ def get_desc():
|
||||
return "SVG image parser and generator"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@ -25,6 +25,7 @@ def get_version():
|
||||
return "version.txt"
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_extra_flags()
|
||||
my_module.add_depend(['etk', 'exml'])
|
||||
my_module.add_src_file([
|
||||
'esvg/Base.cpp',
|
||||
|
@ -1,24 +1,22 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <vector>
|
||||
#include <gtest/gtest.h>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
bool g_visualDebug = false;
|
||||
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));
|
||||
etest::init(_argc, _argv);
|
||||
etk::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
#ifdef DEBUG
|
||||
if (data == "--visual-test") {
|
||||
TEST_PRINT("visual-test=enable");
|
||||
|
@ -3,10 +3,12 @@
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -1,160 +1,158 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestCap, butt) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,75 80,75' stroke='green' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
" <polyline points='80,25 20,25' stroke='orange' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_butt.svg", data);
|
||||
doc.generateAnImage("TestCap_butt.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_butt.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_butt.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, round) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,75 80,75' stroke='green' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
" <polyline points='80,25 20,25' stroke='orange' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_round.svg", data);
|
||||
doc.generateAnImage("TestCap_round.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_round.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_round.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, square) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,75 80,75' stroke='green' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
" <polyline points='80,25 20,25' stroke='orange' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_square.svg", data);
|
||||
doc.generateAnImage("TestCap_square.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_square.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_square.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestCap, buttVert) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='25,20 25,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
" <polyline points='75,80 75,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_buttVert.svg", data);
|
||||
doc.generateAnImage("TestCap_buttVert.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_buttVert.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_buttVert.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, roundVert) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='25,20 25,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
" <polyline points='75,80 75,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_roundVert.svg", data);
|
||||
doc.generateAnImage("TestCap_roundVert.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_roundVert.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_roundVert.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, squareVert) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='25,20 25,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
" <polyline points='75,80 75,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_squareVert.svg", data);
|
||||
doc.generateAnImage("TestCap_squareVert.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_squareVert.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_squareVert.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestCap, buttDiag1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 80,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
" <polyline points='80,20 20,80' stroke='orange' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_buttDiag1.svg", data);
|
||||
doc.generateAnImage("TestCap_buttDiag1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_buttDiag1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_buttDiag1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, roundDiag1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 80,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
" <polyline points='80,20 20,80' stroke='orange' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_roundDiag1.svg", data);
|
||||
doc.generateAnImage("TestCap_roundDiag1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_roundDiag1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_roundDiag1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, squareDiag1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 80,80' stroke='green' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
" <polyline points='80,20 20,80' stroke='orange' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_squareDiag1.svg", data);
|
||||
doc.generateAnImage("TestCap_squareDiag1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_squareDiag1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_squareDiag1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestCap, buttDiag2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 80,20' stroke='green' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
" <polyline points='80,80 20,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='butt'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_buttDiag2.svg", data);
|
||||
doc.generateAnImage("TestCap_buttDiag2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_buttDiag2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_buttDiag2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, roundDiag2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 80,20' stroke='green' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
" <polyline points='80,80 20,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_roundDiag2.svg", data);
|
||||
doc.generateAnImage("TestCap_roundDiag2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_roundDiag2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_roundDiag2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCap, squareDiag2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 80,20' stroke='green' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
" <polyline points='80,80 20,20' stroke='orange' stroke-width='20' fill='none' stroke-linecap='square'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCap_squareDiag2.svg", data);
|
||||
doc.generateAnImage("TestCap_squareDiag2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCap_squareDiag2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCap_squareDiag2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
@ -1,44 +1,42 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestCircle, fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <circle cx='50' cy='50' r='40' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCircle_fill.svg", data);
|
||||
doc.generateAnImage("TestCircle_fill.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCircle_fill.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCircle_fill.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCircle, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <circle cx='50' cy='50' r='40' stroke='green' stroke-width='3' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCircle_stroke.svg", data);
|
||||
doc.generateAnImage("TestCircle_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCircle_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCircle_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestCircle, fill_and_stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <circle cx='50' cy='50' r='40' stroke='green' stroke-width='3' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestCircle_fill_and_stroke.svg", data);
|
||||
doc.generateAnImage("TestCircle_fill_and_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestCircle_fill_and_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestCircle_fill_and_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
@ -1,50 +1,48 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestColor, blending) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <rect x='12.5' y='12.5' width='75' height='50' stroke='#0F0' stroke-opacity='0.5' stroke-width='3' fill='#F00' fill-opacity='0.5' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestColor_blending.svg", data);
|
||||
doc.generateAnImage("TestColor_blending.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestColor_blending.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestColor_blending.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, opacity) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <rect x='12.5' y='12.5' width='75' height='50' stroke='#0F0' stroke-width='3' fill='#F00' opacity='0.5' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestColor_opacity.svg", data);
|
||||
doc.generateAnImage("TestColor_opacity.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestColor_opacity.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestColor_opacity.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, blending_and_opacity) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <rect x='12.5' y='12.5' width='75' height='50' stroke='#0F0' stroke-opacity='0.5' stroke-width='3' fill='#F00' fill-opacity='0.5' opacity='0.7' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestColor_blending_and_opacity.svg", data);
|
||||
doc.generateAnImage("TestColor_blending_and_opacity.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestColor_blending_and_opacity.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestColor_blending_and_opacity.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, multiple_layer) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <rect x='50' y='5' width='15' height='75' stroke='blue' stroke-width='9' fill='green'/>"
|
||||
" <rect x='12.5' y='12.5' width='75' height='30' stroke='#0F0' stroke-opacity='0.5' stroke-width='3' fill='#F00' fill-opacity='0.5' opacity='0.7' />"
|
||||
@ -52,6 +50,6 @@ TEST(TestColor, multiple_layer) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestColor_multiple_layer.svg", data);
|
||||
doc.generateAnImage("TestColor_multiple_layer.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestColor_multiple_layer.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestColor_multiple_layer.bmp"), g_visualDebug);
|
||||
}
|
||||
|
@ -1,45 +1,43 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestEllipse, fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <ellipse cx='50' cy='50' rx='80' ry='30' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestEllipse_fill.svg", data);
|
||||
doc.generateAnImage("TestEllipse_fill.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestEllipse_fill.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestEllipse_fill.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestEllipse, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <ellipse cx='50' cy='50' rx='80' ry='30' stroke='green' stroke-width='3' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestEllipse_stroke.svg", data);
|
||||
doc.generateAnImage("TestEllipse_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestEllipse_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestEllipse_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestEllipse, fill_and_stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <ellipse cx='50' cy='50' rx='80' ry='30' stroke='green' stroke-width='3' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestEllipse_fill_and_stroke.svg", data);
|
||||
doc.generateAnImage("TestEllipse_fill_and_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestEllipse_fill_and_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestEllipse_fill_and_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,15 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestGradientLinear, horizontal) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad1' x1='0%' y1='0%' x2='100%' y2='0%'>\n"
|
||||
@ -25,13 +23,13 @@ TEST(TestGradientLinear, horizontal) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_horizontal.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_horizontal.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_horizontal.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_horizontal.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, vertical) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='0%' x2='0%' y2='100%'>\n"
|
||||
@ -45,12 +43,12 @@ TEST(TestGradientLinear, vertical) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_vertical.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_vertical.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_vertical.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_vertical.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='0%' x2='100%' y2='100%'>\n"
|
||||
@ -64,12 +62,12 @@ TEST(TestGradientLinear, diag1) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag1.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag1Partiel) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='40%' y1='40%' x2='70%' y2='70%'>\n"
|
||||
@ -81,12 +79,12 @@ TEST(TestGradientLinear, diag1Partiel) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag1Partiel.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag1Partiel.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag1Partiel.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag1Partiel.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='100%' x2='100%' y2='0%'>\n"
|
||||
@ -100,14 +98,14 @@ TEST(TestGradientLinear, diag2) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag2.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestGradientLinear, diag2Rotate0) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='50%' x2='100%' y2='50%'>\n"
|
||||
@ -121,12 +119,12 @@ TEST(TestGradientLinear, diag2Rotate0) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag2Rotate0.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag2Rotate0.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag2Rotate0.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag2Rotate0.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag2Rotate1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='100%' x2='100%' y2='0%'>\n"
|
||||
@ -140,12 +138,12 @@ TEST(TestGradientLinear, diag2Rotate1) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag2Rotate1.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag2Rotate1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag2Rotate1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag2Rotate1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag2Rotate2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='100%' x2='100%' y2='0%'>\n"
|
||||
@ -159,12 +157,12 @@ TEST(TestGradientLinear, diag2Rotate2) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag2Rotate2.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag2Rotate2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag2Rotate2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag2Rotate2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, diag2scale) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='0%' y1='100%' x2='100%' y2='0%'>\n"
|
||||
@ -178,12 +176,12 @@ TEST(TestGradientLinear, diag2scale) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_diag2scale.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_diag2scale.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_diag2scale.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_diag2scale.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, internalHref) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2Values'>\n"
|
||||
@ -198,13 +196,13 @@ TEST(TestGradientLinear, internalHref) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_internalHref.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_internalHref.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_internalHref.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_internalHref.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, unitBox_spreadNone) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='40%' y1='40%' x2='60%' y2='60%'>\n"
|
||||
@ -216,12 +214,12 @@ TEST(TestGradientLinear, unitBox_spreadNone) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitBox_spreadNone.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitBox_spreadNone.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitBox_spreadNone.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitBox_spreadNone.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, unitBox_spreadPad) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='40%' y1='40%' x2='60%' y2='60%' spreadMethod='pad'>\n"
|
||||
@ -233,13 +231,13 @@ TEST(TestGradientLinear, unitBox_spreadPad) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitBox_spreadPad.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitBox_spreadPad.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitBox_spreadPad.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitBox_spreadPad.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, unitBox_spreadReflect) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='40%' y1='40%' x2='60%' y2='60%' spreadMethod='reflect'>\n"
|
||||
@ -251,13 +249,13 @@ TEST(TestGradientLinear, unitBox_spreadReflect) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitBox_spreadReflect.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitBox_spreadReflect.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitBox_spreadReflect.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitBox_spreadReflect.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, unitBox_spreadRepeat) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='40%' y1='40%' x2='60%' y2='60%' spreadMethod='repeat'>\n"
|
||||
@ -269,12 +267,12 @@ TEST(TestGradientLinear, unitBox_spreadRepeat) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitBox_spreadRepeat.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitBox_spreadRepeat.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitBox_spreadRepeat.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitBox_spreadRepeat.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, unitUser_spreadNone) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='45' y1='45' x2='55' y2='55' gradientUnits='userSpaceOnUse'>\n"
|
||||
@ -286,12 +284,12 @@ TEST(TestGradientLinear, unitUser_spreadNone) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitUser_spreadNone.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitUser_spreadNone.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitUser_spreadNone.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitUser_spreadNone.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientLinear, unitUser_spreadPad) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='45' y1='45' x2='55' y2='55' spreadMethod='pad' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -303,13 +301,13 @@ TEST(TestGradientLinear, unitUser_spreadPad) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitUser_spreadPad.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitUser_spreadPad.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitUser_spreadPad.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitUser_spreadPad.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, unitUser_spreadReflect) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='45' y1='45' x2='55' y2='55' spreadMethod='reflect' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -321,13 +319,13 @@ TEST(TestGradientLinear, unitUser_spreadReflect) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitUser_spreadReflect.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitUser_spreadReflect.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitUser_spreadReflect.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitUser_spreadReflect.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientLinear, unitUser_spreadRepeate) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <linearGradient id='grad2' x1='45' y1='45' x2='55' y2='55' spreadMethod='repeat' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -339,7 +337,7 @@ TEST(TestGradientLinear, unitUser_spreadRepeate) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientLinear_unitUser_spreadRepeate.svg", data);
|
||||
doc.generateAnImage("TestGradientLinear_unitUser_spreadRepeate.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientLinear_unitUser_spreadRepeate.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientLinear_unitUser_spreadRepeate.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,15 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestGradientRadial, circle) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='50%' fx='50%' fy='50%'>\n"
|
||||
@ -25,13 +23,13 @@ TEST(TestGradientRadial, circle) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_circle.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_circle.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_circle.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_circle.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, full) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='50%' fx='50%' fy='50%'>\n"
|
||||
@ -45,13 +43,13 @@ TEST(TestGradientRadial, full) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_full.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_full.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_full.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_full.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, partial) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad2' cx='20%' cy='30%' r='30%' fx='50%' fy='50%'>\n"
|
||||
@ -65,12 +63,12 @@ TEST(TestGradientRadial, partial) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_partial.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_partial.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_partial.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_partial.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitBox_spreadNone) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='10%' fx='50%' fy='50%'>\n"
|
||||
@ -84,12 +82,12 @@ TEST(TestGradientRadial, unitBox_spreadNone) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitBox_spreadNone.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitBox_spreadNone.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitBox_spreadNone.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitBox_spreadNone.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitBox_spreadPad) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='10%' fx='50%' fy='50%' spreadMethod='pad'>\n"
|
||||
@ -103,12 +101,12 @@ TEST(TestGradientRadial, unitBox_spreadPad) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitBox_spreadPad.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitBox_spreadPad.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitBox_spreadPad.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitBox_spreadPad.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitBox_spreadReflect) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='10%' fx='50%' fy='50%' spreadMethod='reflect'>\n"
|
||||
@ -122,13 +120,13 @@ TEST(TestGradientRadial, unitBox_spreadReflect) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitBox_spreadReflect.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitBox_spreadReflect.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitBox_spreadReflect.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitBox_spreadReflect.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, unitBox_spreadRepeat) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50%' cy='50%' r='10%' fx='50%' fy='50%' spreadMethod='repeat'>\n"
|
||||
@ -142,13 +140,13 @@ TEST(TestGradientRadial, unitBox_spreadRepeat) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitBox_spreadRepeat.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitBox_spreadRepeat.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitBox_spreadRepeat.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitBox_spreadRepeat.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadNone) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='10' fx='50' fy='50%' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -162,12 +160,12 @@ TEST(TestGradientRadial, unitUser_spreadNone) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadNone.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadNone.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadNone.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadNone.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadPad) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='10' fx='50' fy='50' spreadMethod='pad' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -181,12 +179,12 @@ TEST(TestGradientRadial, unitUser_spreadPad) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadPad.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadPad.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadPad.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadPad.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadReflect) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='10' fx='50' fy='50' spreadMethod='reflect' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -200,13 +198,13 @@ TEST(TestGradientRadial, unitUser_spreadReflect) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadReflect.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadReflect.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadReflect.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadReflect.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadRepeat) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='10' fx='50' fy='50' spreadMethod='repeat' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -220,12 +218,12 @@ TEST(TestGradientRadial, unitUser_spreadRepeat) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadRepeat.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadRepeat.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadRepeat.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadRepeat.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadPad_unCenter) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='24' fx='40' fy='40' spreadMethod='pad' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -239,12 +237,12 @@ TEST(TestGradientRadial, unitUser_spreadPad_unCenter) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadPad_unCenter.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadPad_unCenter.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadPad_unCenter.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadPad_unCenter.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadReflect_unCenter) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='24' fx='40' fy='40' spreadMethod='reflect' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -258,12 +256,12 @@ TEST(TestGradientRadial, unitUser_spreadReflect_unCenter) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadReflect_unCenter.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadReflect_unCenter.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadReflect_unCenter.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadReflect_unCenter.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadRepeat_unCenter) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='24' fx='40' fy='40' spreadMethod='repeat' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -277,12 +275,12 @@ TEST(TestGradientRadial, unitUser_spreadRepeat_unCenter) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadRepeat_unCenter.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadRepeat_unCenter.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadRepeat_unCenter.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadRepeat_unCenter.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadRepeat_unCenter2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='24' fx='60' fy='60' spreadMethod='repeat' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -296,13 +294,13 @@ TEST(TestGradientRadial, unitUser_spreadRepeat_unCenter2) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadRepeat_unCenter2.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadRepeat_unCenter2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadRepeat_unCenter2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadRepeat_unCenter2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestGradientRadial, unitUser_spreadRepeat_out) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
|
||||
"<svg height='100' width='100'>\n"
|
||||
" <defs>\n"
|
||||
" <radialGradient id='grad1' cx='50' cy='50' r='24' fx='20' fy='40' spreadMethod='reflect' gradientUnits='userSpaceOnUse' >\n"
|
||||
@ -316,6 +314,6 @@ TEST(TestGradientRadial, unitUser_spreadRepeat_out) {
|
||||
"</svg>\n");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestGradientRadial_unitUser_spreadRepeat_out.svg", data);
|
||||
doc.generateAnImage("TestGradientRadial_unitUser_spreadRepeat_out.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestGradientRadial_unitUser_spreadRepeat_out.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestGradientRadial_unitUser_spreadRepeat_out.bmp"), g_visualDebug);
|
||||
}
|
@ -1,151 +1,149 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
// ------------------------------------------------------ Miter test -----------------------------------------------------
|
||||
|
||||
TEST(TestJoin, miterRight1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterRight1.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterRight1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterRight1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterRight1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterRight2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterRight2.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterRight2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterRight2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterRight2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterRight3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterRight3.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterRight3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterRight3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterRight3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterRight4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterRight4.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterRight4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterRight4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterRight4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLeft1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLeft1.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLeft1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLeft1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLeft1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLeft2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLeft2.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLeft2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLeft2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLeft2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLeft3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLeft3.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLeft3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLeft3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLeft3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLeft4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLeft4.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLeft4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLeft4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLeft4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLimit1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='10,10 25,25 10,40' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLimit1.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLimit1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLimit1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLimit1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLimit2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='10,10 50,25 10,40' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLimit2.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLimit2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLimit2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLimit2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLimit3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='10,10 75,25 10,40' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLimit3.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLimit3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLimit3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLimit3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterLimit4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='10,10 90,25 10,40' stroke='green' stroke-width='20' fill='none' stroke-linejoin='miter'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterLimit4.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterLimit4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterLimit4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterLimit4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterCornerCasePath) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path"
|
||||
" d='m 37.984608,9.9629707 c 6.211703,0 12.423406,0 18.635109,0 0,2.5633883 0,5.1267763 0,7.6901643 -6.211703,0 -12.423406,0 -18.635109,0 0,-2.563388 0,-5.126776 0,-7.6901643 z'\n"
|
||||
@ -153,12 +151,12 @@ TEST(TestJoin, miterCornerCasePath) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterCornerCasePath.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterCornerCasePath.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterCornerCasePath.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterCornerCasePath.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, miterCornerCasePathLimit) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path"
|
||||
" d='m 37.984608,9.9629707 c 6.211703,0 12.423406,0 18.635109,0 0,2.5633883 0,5.1267763 0,7.6901643 -6.211703,0 -12.423406,0 -18.635109,0 0,-2.563388 0,-5.126776 0,-7.6901643 z'\n"
|
||||
@ -166,102 +164,102 @@ TEST(TestJoin, miterCornerCasePathLimit) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_miterCornerCasePathLimit.svg", data);
|
||||
doc.generateAnImage("TestJoin_miterCornerCasePathLimit.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_miterCornerCasePathLimit.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_miterCornerCasePathLimit.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ Round test -----------------------------------------------------
|
||||
|
||||
TEST(TestJoin, roundRight1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundRight1.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundRight1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundRight1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundRight1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundRight2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundRight2.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundRight2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundRight2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundRight2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundRight3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundRight3.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundRight3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundRight3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundRight3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundRight4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundRight4.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundRight4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundRight4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundRight4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundLeft1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundLeft1.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundLeft1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundLeft1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundLeft1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundLeft2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundLeft2.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundLeft2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundLeft2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundLeft2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundLeft3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundLeft3.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundLeft3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundLeft3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundLeft3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundLeft4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='round'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundLeft4.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundLeft4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundLeft4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundLeft4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, roundCornerCasePath) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path"
|
||||
" d='m 37.984608,9.9629707 c 6.211703,0 12.423406,0 18.635109,0 0,2.5633883 0,5.1267763 0,7.6901643 -6.211703,0 -12.423406,0 -18.635109,0 0,-2.563388 0,-5.126776 0,-7.6901643 z'\n"
|
||||
@ -269,103 +267,103 @@ TEST(TestJoin, roundCornerCasePath) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_roundCornerCasePath.svg", data);
|
||||
doc.generateAnImage("TestJoin_roundCornerCasePath.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_roundCornerCasePath.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_roundCornerCasePath.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------ Bevel test -----------------------------------------------------
|
||||
|
||||
TEST(TestJoin, bevelRight1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelRight1.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelRight1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelRight1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelRight1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelRight2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelRight2.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelRight2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelRight2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelRight2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelRight3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelRight3.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelRight3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelRight3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelRight3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelRight4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelRight4.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelRight4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelRight4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelRight4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelLeft1) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,20 50,50 80,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelLeft1.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelLeft1.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelLeft1.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelLeft1.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelLeft2) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='80,80 50,50 20,80' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelLeft2.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelLeft2.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelLeft2.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelLeft2.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelLeft3) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,80 50,50 20,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelLeft3.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelLeft3.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelLeft3.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelLeft3.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelLeft4) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 50,50 80,20' stroke='green' stroke-width='20' fill='none' stroke-linejoin='bevel'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelLeft4.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelLeft4.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelLeft4.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelLeft4.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestJoin, bevelCornerCasePath) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path"
|
||||
" d='m 37.984608,9.9629707 c 6.211703,0 12.423406,0 18.635109,0 0,2.5633883 0,5.1267763 0,7.6901643 -6.211703,0 -12.423406,0 -18.635109,0 0,-2.563388 0,-5.126776 0,-7.6901643 z'\n"
|
||||
@ -373,6 +371,6 @@ TEST(TestJoin, bevelCornerCasePath) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestJoin_bevelCornerCasePath.svg", data);
|
||||
doc.generateAnImage("TestJoin_bevelCornerCasePath.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestJoin_bevelCornerCasePath.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestJoin_bevelCornerCasePath.bmp"), g_visualDebug);
|
||||
}
|
||||
|
@ -1,24 +1,22 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestLine, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <line x1='10' y1='10' x2='90' y2='90' stroke='green' stroke-width='3' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestLine_stroke.svg", data);
|
||||
doc.generateAnImage("TestLine_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestLine_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestLine_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,107 +1,105 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestPath, fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 c -12.426,0 -22.5,10.072 -22.5,22.5 0,12.426 10.074,22.5 22.5,22.5 12.428,0 22.5,-10.074 22.5,-22.5 0,-12.427 -10.072,-22.5 -22.5,-22.5 z'"
|
||||
" fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_fill.svg", data);
|
||||
doc.generateAnImage("TestPath_fill.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_fill.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_fill.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPath, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 c -12.426,0 -22.5,10.072 -22.5,22.5 0,12.426 10.074,22.5 22.5,22.5 12.428,0 22.5,-10.074 22.5,-22.5 0,-12.427 -10.072,-22.5 -22.5,-22.5 z'"
|
||||
" stroke='green' stroke-width='3' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_stroke.svg", data);
|
||||
doc.generateAnImage("TestPath_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPath, fill_and_stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 c -12.426,0 -22.5,10.072 -22.5,22.5 0,12.426 10.074,22.5 22.5,22.5 12.428,0 22.5,-10.074 22.5,-22.5 0,-12.427 -10.072,-22.5 -22.5,-22.5 z'"
|
||||
" stroke='green' stroke-width='3' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_fill_and_stroke.svg", data);
|
||||
doc.generateAnImage("TestPath_fill_and_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_fill_and_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_fill_and_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPath, curveTo) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 c -30,0 -30,1 -20,20 z'"
|
||||
" fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_curveTo.svg", data);
|
||||
doc.generateAnImage("TestPath_curveTo.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_curveTo.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_curveTo.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestPath, smoothCurveTo) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 s -30,0 -20,20 z'"
|
||||
" fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_smoothCurveTo.svg", data);
|
||||
doc.generateAnImage("TestPath_smoothCurveTo.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_smoothCurveTo.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_smoothCurveTo.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestPath, bezierCurveTo) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 q -30,1 -20,20 z'"
|
||||
" fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_bezierCurveTo.svg", data);
|
||||
doc.generateAnImage("TestPath_bezierCurveTo.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_bezierCurveTo.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_bezierCurveTo.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestPath, bezierSmoothCurveTo) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path d='m 50,50 t -20,30 t 30,-20 z'"
|
||||
" fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_bezierSmoothCurveTo.svg", data);
|
||||
doc.generateAnImage("TestPath_bezierSmoothCurveTo.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_bezierSmoothCurveTo.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_bezierSmoothCurveTo.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPath, arc) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='300' width='800'>"
|
||||
" <path d='M20,290 l 50,-25"
|
||||
" a25,25 -30 0,1 50,-25 l 30,0"
|
||||
@ -116,15 +114,15 @@ TEST(TestPath, arc) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_arc.svg", data);
|
||||
doc.generateAnImage("TestPath_arc.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_arc.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_arc.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(TestPath, end_path_border_case) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <path\n"
|
||||
" style='fill:#9fecff;fill-opacity:1;stroke:#1b57df;stroke-width:8.81125546;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.94901961'\n"
|
||||
@ -134,6 +132,6 @@ TEST(TestPath, end_path_border_case) {
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPath_end_path_border_case.svg", data);
|
||||
doc.generateAnImage("TestPath_end_path_border_case.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPath_end_path_border_case.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPath_end_path_border_case.bmp"), g_visualDebug);
|
||||
}
|
@ -1,44 +1,42 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestPolygon, fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polygon points='50,10 90,50 10,80' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolygon_fill.svg", data);
|
||||
doc.generateAnImage("TestPolygon_fill.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolygon_fill.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolygon_fill.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPolygon, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polygon points='50,10 90,50 10,80' stroke='green' stroke-width='3' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolygon_stroke.svg", data);
|
||||
doc.generateAnImage("TestPolygon_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolygon_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolygon_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPolygon, fill_and_stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polygon points='50,10 90,50 10,80' stroke='green' stroke-width='3' fill='red' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolygon_fill_and_stroke.svg", data);
|
||||
doc.generateAnImage("TestPolygon_fill_and_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolygon_fill_and_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolygon_fill_and_stroke.bmp"), g_visualDebug);
|
||||
}
|
@ -3,44 +3,44 @@
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esvg/esvg.hpp>
|
||||
#include "main.hpp"
|
||||
|
||||
TEST(TestPolyLine, fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 40,25 60,40 80,90 90,50 5,90' fill='orange' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolyLine_fill.svg", data);
|
||||
doc.generateAnImage("TestPolyLine_fill.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolyLine_fill.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolyLine_fill.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPolyLine, stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 40,25 60,40 80,90 90,50 5,90' stroke='green' stroke-width='3' fill='none' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolyLine_stroke.svg", data);
|
||||
doc.generateAnImage("TestPolyLine_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolyLine_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolyLine_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestPolyLine, fill_and_stroke) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
" <polyline points='20,20 40,25 60,40 80,90 90,50 5,90' stroke='green' stroke-width='3' fill='orange' />"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestPolyLine_fill_and_stroke.svg", data);
|
||||
doc.generateAnImage("TestPolyLine_fill_and_stroke.bmp", g_visualDebug);
|
||||
etk::uri::writeAll(etk::Path("TestPolyLine_fill_and_stroke.svg"), data);
|
||||
doc.generateAnImage(etk::Path("TestPolyLine_fill_and_stroke.bmp"), g_visualDebug);
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user