[DEV] correct color integration

This commit is contained in:
Edouard DUPIN 2015-12-02 21:43:29 +01:00
parent 1b8fb2f3e4
commit a776582367
7 changed files with 181 additions and 56 deletions

View File

@ -1,12 +1,7 @@
language: language: cpp
- cpp
sudo: false sudo: false
os:
- linux
- osx
branches: branches:
only: only:
- master - master
@ -18,33 +13,70 @@ addons:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
packages: packages:
- g++-4.9 - 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: install:
- cd ..
- pip install --user lutin - pip install --user lutin
- if [ "$TAG" == "Android" ]; then
env: git clone --depth 1 --branch master https://github.com/HeeroYui/android-download-tool;
- CONF=debug BOARD=Linux BUILDER=clang GCOV= ./android-download-tool/dl-android.sh;
- CONF=release BOARD=Linux BUILDER=clang GCOV= fi
- CONF=debug BOARD=Linux BUILDER=gcc GCOV= - git clone --depth 1 --branch master https://github.com/atria-soft/ci.git
- CONF=release BOARD=Linux BUILDER=gcc GCOV= - cd -
- CONF=debug BOARD=Linux BUILDER=gcc GCOV=--gcov
before_script: before_script:
- cd .. - 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/etk.git
- git clone https://github.com/atria-soft/exml.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/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 - pwd
- ls -l - 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: 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: notifications:
email: email:

View File

@ -1,14 +1,64 @@
esvg esvg
===== =====
`esvg` is svg image renderer `esvg` is c++ svg image parser and renderer.
Release (master)
----------------
[![Build Status](https://travis-ci.org/atria-soft/esvg.svg?branch=master)](https://travis-ci.org/atria-soft/esvg) [![Build Status](https://travis-ci.org/atria-soft/esvg.svg?branch=master)](https://travis-ci.org/atria-soft/esvg)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Linux)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=MacOs)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Mingw)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Android)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=IOs)](http://atria-soft.com/ci/atria-soft/esvg)
Developement (dev)
------------------
[![Build Status](https://travis-ci.org/atria-soft/esvg.svg?branch=dev)](https://travis-ci.org/atria-soft/esvg)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Linux)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=MacOs)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Mingw)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Android)](http://atria-soft.com/ci/atria-soft/esvg)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=IOs)](http://atria-soft.com/ci/atria-soft/esvg)
Instructions 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) License (APACHE v2.0)
===================== =====================

View File

@ -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> esvg::Renderer::mergeColor(etk::Color<float,4> _base, etk::Color<float,4> _integration) {
etk::Color<float,4> result; etk::Color<float,4> result;
if (_base.a() < _integration.a()) { /*
result = _base; if (_integration.a() < _base.a()) {
_base = _integration; result = _integration;
_integration = result; _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.setR(_integration.a() * _integration.r() + _base.a() * (1.0f - _integration.a()) * _base.r());
result.setB(_base.a() * _base.b() + _integration.a() * (1.0f - _base.a()) * _integration.b()); result.setG(_integration.a() * _integration.g() + _base.a() * (1.0f - _integration.a()) * _base.g());
result.setA(_base.a() + _integration.a() * (1.0f - _base.a())); 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) { if (result.a() != 0.0f) {
result.setR(result.r()/result.a()); float reverse = 1.0f/result.a();
result.setG(result.g()/result.a()); result.setR(result.r()*reverse);
result.setB(result.b()/result.a()); result.setG(result.g()*reverse);
result.setB(result.b()*reverse);
} }
return result; return result;
} }

View File

@ -38,7 +38,9 @@ def create(target, module_name):
'test/testPolyline.cpp', 'test/testPolyline.cpp',
'test/testRectangle.cpp', 'test/testRectangle.cpp',
'test/testJoin.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']) my_module.add_module_depend(['esvg', 'gtest', 'test-debug'])
return my_module return my_module

60
test/testColor.cpp Normal file
View 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);
}

View File

@ -46,28 +46,6 @@ TEST(TestRectangle, fill_and_stroke) {
doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke.bmp", g_visualDebug); 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) { TEST(TestRectangle, corned_fill) {
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>" std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<svg height='100' width='100'>" "<svg height='100' width='100'>"

0
test/testStyle.cpp Normal file
View File