[DEV] correct color integration
This commit is contained in:
parent
1b8fb2f3e4
commit
a776582367
72
.travis.yml
72
.travis.yml
@ -1,12 +1,7 @@
|
||||
language:
|
||||
- cpp
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
@ -18,33 +13,70 @@ addons:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.9
|
||||
- expect
|
||||
#- binutils-mingw-w64-x86-64 # 64bit MinGW
|
||||
#- gcc-mingw-w64-x86-64
|
||||
#- g++-mingw-w64-x86-64
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: CONF=release BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9"
|
||||
compiler: gcc
|
||||
- os: linux
|
||||
env: CONF=debug BUILDER=clang TARGET=Linux
|
||||
compiler: clang
|
||||
#- os: linux
|
||||
# env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
|
||||
# compiler: x86_64-w64-mingw32-gcc
|
||||
#- os: linux
|
||||
# env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
|
||||
# compiler: gcc
|
||||
- os: osx
|
||||
env: CONF=release BUILDER=clang TARGET=MacOs TAG=MacOs
|
||||
compiler: clang
|
||||
- os: osx
|
||||
env: CONF=release BUILDER=clang TARGET=IOs TAG=IOs
|
||||
compiler: clang
|
||||
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- pip install --user lutin
|
||||
|
||||
env:
|
||||
- CONF=debug BOARD=Linux BUILDER=clang GCOV=
|
||||
- CONF=release BOARD=Linux BUILDER=clang GCOV=
|
||||
- CONF=debug BOARD=Linux BUILDER=gcc GCOV=
|
||||
- CONF=release BOARD=Linux BUILDER=gcc GCOV=
|
||||
- CONF=debug BOARD=Linux BUILDER=gcc GCOV=--gcov
|
||||
- if [ "$TAG" == "Android" ]; then
|
||||
git clone --depth 1 --branch master https://github.com/HeeroYui/android-download-tool;
|
||||
./android-download-tool/dl-android.sh;
|
||||
fi
|
||||
- git clone --depth 1 --branch master https://github.com/atria-soft/ci.git
|
||||
- cd -
|
||||
|
||||
before_script:
|
||||
- cd ..
|
||||
- wget http://atria-soft.com/ci/coverage_send.py
|
||||
- wget http://atria-soft.com/ci/test_send.py
|
||||
- wget http://atria-soft.com/ci/warning_send.py
|
||||
- git clone https://github.com/atria-soft/etk.git
|
||||
- git clone https://github.com/atria-soft/exml.git
|
||||
- git clone https://github.com/atria-soft/libagg.git
|
||||
- git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||
- git clone https://github.com/generic-library/freetype-lutin.git --recursive
|
||||
- git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||
- pwd
|
||||
- ls -l
|
||||
- if [ "$BUILDER" == "gcc" ]; then COMPILATOR_OPTION="--compilator-version=4.9"; else COMPILATOR_OPTION=""; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
export PATH=$PATH:/Users/travis/Library/Python/2.7/bin/;
|
||||
fi
|
||||
- ./ci/build_send.py --tag=$TAG --status=START;
|
||||
|
||||
script:
|
||||
- lutin -w -j4 -C -P -c $BUILDER $COMPILATOR_OPTION -m $CONF $GCOV -p esvg
|
||||
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE esvg-test; STATUS=$?
|
||||
- ./ci/build_send.py --tag=$TAG --status="$STATUS";
|
||||
|
||||
after_script:
|
||||
- if [ "$GCOV" != "" ]; then
|
||||
./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/esvg/;
|
||||
fi
|
||||
- ./out/Linux_x86_64/$CONF/staging/$BUILDER/esvg-test/esvg-test.app/bin/esvg-test --etk-log-level=6 | tee out_test.txt
|
||||
- if [ "$GCOV" != "" ]; then
|
||||
./ci/test_send.py --file=out_test.txt;
|
||||
lutin -C -P $TARGET -c $BUILDER $COMPILATOR_OPTION -m $CONF -p esvg?gcov;
|
||||
./ci/coverage_send.py --json=out/Linux_x86_64/$CONF/build/$BUILDER/esvg/esvg_coverage.json;
|
||||
fi
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
54
README.md
54
README.md
@ -1,14 +1,64 @@
|
||||
esvg
|
||||
=====
|
||||
|
||||
`esvg` is svg image renderer
|
||||
`esvg` is c++ svg image parser and renderer.
|
||||
|
||||
Release (master)
|
||||
----------------
|
||||
|
||||
[](https://travis-ci.org/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
Developement (dev)
|
||||
------------------
|
||||
|
||||
[](https://travis-ci.org/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
[](http://atria-soft.com/ci/atria-soft/esvg)
|
||||
|
||||
|
||||
Instructions
|
||||
============
|
||||
|
||||
To compile and use see 'ewol' or 'edn' project
|
||||
download Build system:
|
||||
----------------------
|
||||
|
||||
sudo pip install lutin
|
||||
sudo pip install pillow
|
||||
|
||||
download the software:
|
||||
----------------------
|
||||
|
||||
mkdir WORKING_DIRECTORY
|
||||
cd WORKING_DIRECTORY
|
||||
git clone https://github.com/atria-soft/etk.git
|
||||
git clone https://github.com/atria-soft/exml.git
|
||||
git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||
git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||
|
||||
Compile software:
|
||||
-----------------
|
||||
|
||||
cd WORKING_DIRECTORY
|
||||
lutin -C -P esvg-test
|
||||
|
||||
|
||||
License (APACHE v2.0)
|
||||
=====================
|
||||
|
@ -39,19 +39,22 @@ esvg::Renderer::~Renderer() {
|
||||
|
||||
etk::Color<float,4> esvg::Renderer::mergeColor(etk::Color<float,4> _base, etk::Color<float,4> _integration) {
|
||||
etk::Color<float,4> result;
|
||||
if (_base.a() < _integration.a()) {
|
||||
result = _base;
|
||||
_base = _integration;
|
||||
_integration = result;
|
||||
/*
|
||||
if (_integration.a() < _base.a()) {
|
||||
result = _integration;
|
||||
_integration = _base;
|
||||
_base = result;
|
||||
}
|
||||
result.setR(_base.a() * _base.r() + _integration.a() * (1.0f - _base.a()) * _integration.r());
|
||||
result.setG(_base.a() * _base.g() + _integration.a() * (1.0f - _base.a()) * _integration.g());
|
||||
result.setB(_base.a() * _base.b() + _integration.a() * (1.0f - _base.a()) * _integration.b());
|
||||
result.setA(_base.a() + _integration.a() * (1.0f - _base.a()));
|
||||
*/
|
||||
result.setR(_integration.a() * _integration.r() + _base.a() * (1.0f - _integration.a()) * _base.r());
|
||||
result.setG(_integration.a() * _integration.g() + _base.a() * (1.0f - _integration.a()) * _base.g());
|
||||
result.setB(_integration.a() * _integration.b() + _base.a() * (1.0f - _integration.a()) * _base.b());
|
||||
result.setA(_integration.a() + _base.a() * (1.0f - _integration.a()));
|
||||
if (result.a() != 0.0f) {
|
||||
result.setR(result.r()/result.a());
|
||||
result.setG(result.g()/result.a());
|
||||
result.setB(result.b()/result.a());
|
||||
float reverse = 1.0f/result.a();
|
||||
result.setR(result.r()*reverse);
|
||||
result.setG(result.g()*reverse);
|
||||
result.setB(result.b()*reverse);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ def create(target, module_name):
|
||||
'test/testPolyline.cpp',
|
||||
'test/testRectangle.cpp',
|
||||
'test/testJoin.cpp',
|
||||
'test/testCap.cpp'
|
||||
'test/testCap.cpp',
|
||||
'test/testColor.cpp',
|
||||
'test/testStyle.cpp'
|
||||
])
|
||||
my_module.add_module_depend(['esvg', 'gtest', 'test-debug'])
|
||||
return my_module
|
||||
|
60
test/testColor.cpp
Normal file
60
test/testColor.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <esvg/esvg.h>
|
||||
#include "main.h"
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "TestColor"
|
||||
|
||||
TEST(TestColor, blending) {
|
||||
std::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(ivec2(100, 100), "TestColor_blending.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, opacity) {
|
||||
std::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(ivec2(100, 100), "TestColor_opacity.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, blending_and_opacity) {
|
||||
std::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(ivec2(100, 100), "TestColor_blending_and_opacity.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestColor, multiple_layer) {
|
||||
std::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' />"
|
||||
" <rect x='30' y='30' width='20' height='20' stroke='orange' stroke-width='1' fill='violet'/>"
|
||||
"</svg>");
|
||||
esvg::Document doc;
|
||||
doc.parse(data);
|
||||
etk::FSNodeWriteAllData("TestColor_multiple_layer.svg", data);
|
||||
doc.generateAnImage(ivec2(100, 100), "TestColor_multiple_layer.bmp", g_visualDebug);
|
||||
}
|
@ -46,28 +46,6 @@ TEST(TestRectangle, fill_and_stroke) {
|
||||
doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestRectangle, fill_and_stroke_blend) {
|
||||
std::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("TestRectangle_fill_and_stroke_blend.svg", data);
|
||||
doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke_blend.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestRectangle, fill_and_stroke_opacity) {
|
||||
std::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("TestRectangle_fill_and_stroke_opacity.svg", data);
|
||||
doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke_opacity.bmp", g_visualDebug);
|
||||
}
|
||||
|
||||
TEST(TestRectangle, corned_fill) {
|
||||
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
|
||||
"<svg height='100' width='100'>"
|
||||
|
0
test/testStyle.cpp
Normal file
0
test/testStyle.cpp
Normal file
Loading…
x
Reference in New Issue
Block a user