<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jaspervdg</id>
	<title>Inkscape Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jaspervdg"/>
	<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/Special:Contributions/Jaspervdg"/>
	<updated>2026-05-18T19:54:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=CompilingUbuntu&amp;diff=85184</id>
		<title>CompilingUbuntu</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=CompilingUbuntu&amp;diff=85184"/>
		<updated>2012-05-30T17:12:19Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Hardy(8.04), Intrepid(8.10) and Jaunty(9.04) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Hardy(8.04), Intrepid(8.10), Jaunty(9.04) and newer ==&lt;br /&gt;
=== Consider using stable (recommended for production) ===&lt;br /&gt;
This is a short how to build the latest svn version. Please note that SVN version may be buggy and crash often. This is released for people who want to help testing or need the very latest features. If you are not of developer kind, you are suggested to install the stable version from the repositories using Synaptic or from command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using prebuilt packages (recommended) ===&lt;br /&gt;
For Ubuntu there are nightly builds available. &lt;br /&gt;
&lt;br /&gt;
Get your appropriate repository lines from launchpad (read about [https://help.ubuntu.com/community/Repositories/Ubuntu adding repositories]):&lt;br /&gt;
&lt;br /&gt;
https://launchpad.net/~inkscape-nightly/+archive/ppa&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run following command to update the repository information and install inkscape:&lt;br /&gt;
&amp;lt;pre&amp;gt;   sudo apt-get update&lt;br /&gt;
   sudo apt-get install inkscape-devel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Compiling unstable developement version ===&lt;br /&gt;
==== Installing dependencies ====&lt;br /&gt;
If you are sure you can face Inkscape being unstable, then please continue reading. First you should install all the [[Tracking Dependencies|dependencies]]. This can be done by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install build-essential autoconf automake intltool libtool \&lt;br /&gt;
libglib2.0-dev libpng12-dev libgc-dev libfreetype6-dev liblcms1-dev \&lt;br /&gt;
libgtkmm-2.4-dev libxslt1-dev libboost-dev libpopt-dev libgsl0-dev libaspell-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you should have every dependency you need to build Inkscape.&lt;br /&gt;
&lt;br /&gt;
===== Additional dependencies =====&lt;br /&gt;
If you want to have pdf support you need to install poppler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install libpoppler-dev libpoppler-glib-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to have optional features you may need to install some more packages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install libgnome-vfsmm-2.6-dev libssl-dev libmagick++9-dev libwpg-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting source from Bazaar ====&lt;br /&gt;
Inkscape now uses Bazaar, please refer to the [[Working with Bazaar]] page for details on how to get the Inkscape source code.&lt;br /&gt;
&lt;br /&gt;
==== Configuring and Compiling ====&lt;br /&gt;
Enter the newly created inkscape directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  cd inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you may have already noticed this folder contains some files with all CAPITAL letters like README, INSTALL, HACKING, COPYING and probably others. These contain the latest information about how to build the program. The README file says that if you have no configure script in the current directory you should run autogen script to create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   ./autogen.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run configure script which detects your system variables, installed software etc.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   ./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, if you want to make it install to an alternate location so that you can keep the standard version installed and untouched&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   ./configure --prefix=/home/''yourname''/opt/local&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
(replacing &amp;quot;yourname&amp;quot; with your actual directory user name, of course)&lt;br /&gt;
''All bug reporting testers may find it useful to install to use --prefix=/home/''yourname''/opt/inkscape-revision-19900 or --prefix=/opt/inkscape-19900 or something similar, replacing the revision number with correct one (this is shown when svn fetching finishes, also can be found in file .svn/entries). This way you can have several versions of inkscape installed at once.''&lt;br /&gt;
&lt;br /&gt;
If the configure script ends with no error messages, you are the lucky one, all system requirements are met. Run make to compile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may take some time, probably hours, depending on your machine's speed. On 1,4Ghz P3M with 512Mb clean build took 100 minutes.&lt;br /&gt;
&lt;br /&gt;
==== Installing ====&lt;br /&gt;
&lt;br /&gt;
If you used some --prefix=/... other than /usr, then you may install using usual 'make install' or 'sudo make install', depending on the location.&lt;br /&gt;
If the the location prefix was /usr, then &amp;quot;sudo make install&amp;quot; is not recommended, as debian package manager would know nothing about new package. The better alternative is using checkinstall. If checkinstall is not installed, you can install it the usual way &amp;quot;sudo apt-get install checkinstall&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Happy inkscapeing.&lt;br /&gt;
&lt;br /&gt;
===== Fix no icons problem =====&lt;br /&gt;
&lt;br /&gt;
If you run this and you find that you have no tool icons it's because it's looking in the wrong place for them. To fix that you need to make a symbolic link to the correct location. Here is an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo ln -s /usr/share/inkscape /usr/local/share/inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update your version ====&lt;br /&gt;
&lt;br /&gt;
If you want to update your already built inkscape to the very latest version, you need to run following commands in inkscape source directory. Please correct the configure line and use the same installation method as on first install.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    bzr update&lt;br /&gt;
    ./configure --prefix=/home/''yourname''/opt/local&lt;br /&gt;
    make&lt;br /&gt;
    make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dapper(6.06) and Edgy(6.10) ==&lt;br /&gt;
If you're going to build Inkscape, you'll need to have a full complement of build requirements.  This is very easy to do in Ubuntu Dapper and Edgy:&lt;br /&gt;
&lt;br /&gt;
Note: the libgc-6.7 that is available in Edgy removes the need for the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get build-dep inkscape&lt;br /&gt;
   sudo apt-get install liblcms-dev build-essential&lt;br /&gt;
   echo &amp;quot;deb-src http://ftp.us.debian.org/debian/ unstable main&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
   sudo apt-get update&lt;br /&gt;
   sudo apt-get source libgc-dev&lt;br /&gt;
   sudo apt-get install fakeroot debhelper&lt;br /&gt;
   cd libgc*&lt;br /&gt;
   sudo fakeroot dpkg-buildpackage -uc -us&lt;br /&gt;
   sudo dpkg -i ../libgc*.deb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want version 0.44 from Debian Unstable, you can compile it in the same way as libgc above:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   apt-get source inkscape&lt;br /&gt;
   cd inkscape*&lt;br /&gt;
   fakeroot dpkg-buildpackage -uc -us&lt;br /&gt;
   sudo dpkg -i ../inkscape*.deb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build the SVN snapshots:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Untar and navigate to the inkscape source folder&lt;br /&gt;
   ./configure&lt;br /&gt;
   make&lt;br /&gt;
   sudo make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of doing &amp;quot;make install&amp;quot;, on Debian-based distributions (such as Ubuntu) it is better to do&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
since checkinstall first builds the .deb package and then installs it, thus making the package system aware of the newly installed inkscape.&lt;br /&gt;
If you get the &amp;quot;command not found&amp;quot; message, do&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
build-dep gets all the dependencies for the version of Inkscape that comes with Ubuntu. We're not building the same version, but most of the dependencies are the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libcms-dev was required for ./configure to work&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This was done on a recently installed Dapper (Ubuntu 6.06) system. I built Inkscape version 0.44.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following packages are need to compile cvs inkscape under a default Ubuntu Hoary/Breezy/Dapper system:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   apt-get install cvs build-essential intltool libtool libgtkmm-2.4-dev \&lt;br /&gt;
libglib2.0-dev libpng12-dev libxslt1-dev libsigc++-2.0-dev libpopt-dev libgc-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inkscape requires libgc-6.7.&lt;br /&gt;
&lt;br /&gt;
Breezy uses 6.4, Dapper uses 6.6, Edgy uses 6.7&lt;br /&gt;
&lt;br /&gt;
Hoary uses version 6.3, which is provided in the Repos.  (Is there somewhere to get a .deb for 6.4?)&lt;br /&gt;
&lt;br /&gt;
To overwrite libgc-6.3 with libgc-6.4:&lt;br /&gt;
   Download gc6.4&lt;br /&gt;
   ./configure --prefix=/usr&lt;br /&gt;
   make&lt;br /&gt;
   sudo make install&lt;br /&gt;
&lt;br /&gt;
== Old libgc 6.5 debs for Breezy(5.10) ==&lt;br /&gt;
&lt;br /&gt;
http://inkscape.modevia.com/ap/libgc-dev_6.5-1_i386.deb&lt;br /&gt;
http://inkscape.modevia.com/ap/libgc1_6.5-1_i386.deb&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=CompilingUbuntu&amp;diff=85178</id>
		<title>CompilingUbuntu</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=CompilingUbuntu&amp;diff=85178"/>
		<updated>2012-05-30T17:10:34Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Installing dependencies */ Added libtool&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Hardy(8.04), Intrepid(8.10) and Jaunty(9.04) ==&lt;br /&gt;
=== Consider using stable (recommended for production) ===&lt;br /&gt;
This is a short how to build the latest svn version. Please note that SVN version may be buggy and crash often. This is released for people who want to help testing or need the very latest features. If you are not of developer kind, you are suggested to install the stable version from the repositories using Synaptic or from command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using prebuilt packages (recommended) ===&lt;br /&gt;
For Ubuntu there are nightly builds available. &lt;br /&gt;
&lt;br /&gt;
Get your appropriate repository lines from launchpad (read about [https://help.ubuntu.com/community/Repositories/Ubuntu adding repositories]):&lt;br /&gt;
&lt;br /&gt;
https://launchpad.net/~inkscape-nightly/+archive/ppa&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run following command to update the repository information and install inkscape:&lt;br /&gt;
&amp;lt;pre&amp;gt;   sudo apt-get update&lt;br /&gt;
   sudo apt-get install inkscape-devel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Compiling unstable developement version ===&lt;br /&gt;
==== Installing dependencies ====&lt;br /&gt;
If you are sure you can face Inkscape being unstable, then please continue reading. First you should install all the [[Tracking Dependencies|dependencies]]. This can be done by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install build-essential autoconf automake intltool libtool \&lt;br /&gt;
libglib2.0-dev libpng12-dev libgc-dev libfreetype6-dev liblcms1-dev \&lt;br /&gt;
libgtkmm-2.4-dev libxslt1-dev libboost-dev libpopt-dev libgsl0-dev libaspell-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you should have every dependency you need to build Inkscape.&lt;br /&gt;
&lt;br /&gt;
===== Additional dependencies =====&lt;br /&gt;
If you want to have pdf support you need to install poppler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install libpoppler-dev libpoppler-glib-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to have optional features you may need to install some more packages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install libgnome-vfsmm-2.6-dev libssl-dev libmagick++9-dev libwpg-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting source from Bazaar ====&lt;br /&gt;
Inkscape now uses Bazaar, please refer to the [[Working with Bazaar]] page for details on how to get the Inkscape source code.&lt;br /&gt;
&lt;br /&gt;
==== Configuring and Compiling ====&lt;br /&gt;
Enter the newly created inkscape directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  cd inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you may have already noticed this folder contains some files with all CAPITAL letters like README, INSTALL, HACKING, COPYING and probably others. These contain the latest information about how to build the program. The README file says that if you have no configure script in the current directory you should run autogen script to create it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   ./autogen.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run configure script which detects your system variables, installed software etc.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   ./configure&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, if you want to make it install to an alternate location so that you can keep the standard version installed and untouched&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   ./configure --prefix=/home/''yourname''/opt/local&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
(replacing &amp;quot;yourname&amp;quot; with your actual directory user name, of course)&lt;br /&gt;
''All bug reporting testers may find it useful to install to use --prefix=/home/''yourname''/opt/inkscape-revision-19900 or --prefix=/opt/inkscape-19900 or something similar, replacing the revision number with correct one (this is shown when svn fetching finishes, also can be found in file .svn/entries). This way you can have several versions of inkscape installed at once.''&lt;br /&gt;
&lt;br /&gt;
If the configure script ends with no error messages, you are the lucky one, all system requirements are met. Run make to compile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may take some time, probably hours, depending on your machine's speed. On 1,4Ghz P3M with 512Mb clean build took 100 minutes.&lt;br /&gt;
&lt;br /&gt;
==== Installing ====&lt;br /&gt;
&lt;br /&gt;
If you used some --prefix=/... other than /usr, then you may install using usual 'make install' or 'sudo make install', depending on the location.&lt;br /&gt;
If the the location prefix was /usr, then &amp;quot;sudo make install&amp;quot; is not recommended, as debian package manager would know nothing about new package. The better alternative is using checkinstall. If checkinstall is not installed, you can install it the usual way &amp;quot;sudo apt-get install checkinstall&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Happy inkscapeing.&lt;br /&gt;
&lt;br /&gt;
===== Fix no icons problem =====&lt;br /&gt;
&lt;br /&gt;
If you run this and you find that you have no tool icons it's because it's looking in the wrong place for them. To fix that you need to make a symbolic link to the correct location. Here is an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo ln -s /usr/share/inkscape /usr/local/share/inkscape&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update your version ====&lt;br /&gt;
&lt;br /&gt;
If you want to update your already built inkscape to the very latest version, you need to run following commands in inkscape source directory. Please correct the configure line and use the same installation method as on first install.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    bzr update&lt;br /&gt;
    ./configure --prefix=/home/''yourname''/opt/local&lt;br /&gt;
    make&lt;br /&gt;
    make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dapper(6.06) and Edgy(6.10) ==&lt;br /&gt;
If you're going to build Inkscape, you'll need to have a full complement of build requirements.  This is very easy to do in Ubuntu Dapper and Edgy:&lt;br /&gt;
&lt;br /&gt;
Note: the libgc-6.7 that is available in Edgy removes the need for the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get build-dep inkscape&lt;br /&gt;
   sudo apt-get install liblcms-dev build-essential&lt;br /&gt;
   echo &amp;quot;deb-src http://ftp.us.debian.org/debian/ unstable main&amp;quot; &amp;gt;&amp;gt; /etc/apt/sources.list&lt;br /&gt;
   sudo apt-get update&lt;br /&gt;
   sudo apt-get source libgc-dev&lt;br /&gt;
   sudo apt-get install fakeroot debhelper&lt;br /&gt;
   cd libgc*&lt;br /&gt;
   sudo fakeroot dpkg-buildpackage -uc -us&lt;br /&gt;
   sudo dpkg -i ../libgc*.deb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want version 0.44 from Debian Unstable, you can compile it in the same way as libgc above:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   apt-get source inkscape&lt;br /&gt;
   cd inkscape*&lt;br /&gt;
   fakeroot dpkg-buildpackage -uc -us&lt;br /&gt;
   sudo dpkg -i ../inkscape*.deb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build the SVN snapshots:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Untar and navigate to the inkscape source folder&lt;br /&gt;
   ./configure&lt;br /&gt;
   make&lt;br /&gt;
   sudo make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of doing &amp;quot;make install&amp;quot;, on Debian-based distributions (such as Ubuntu) it is better to do&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
since checkinstall first builds the .deb package and then installs it, thus making the package system aware of the newly installed inkscape.&lt;br /&gt;
If you get the &amp;quot;command not found&amp;quot; message, do&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   sudo apt-get install checkinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
build-dep gets all the dependencies for the version of Inkscape that comes with Ubuntu. We're not building the same version, but most of the dependencies are the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
libcms-dev was required for ./configure to work&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This was done on a recently installed Dapper (Ubuntu 6.06) system. I built Inkscape version 0.44.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following packages are need to compile cvs inkscape under a default Ubuntu Hoary/Breezy/Dapper system:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   apt-get install cvs build-essential intltool libtool libgtkmm-2.4-dev \&lt;br /&gt;
libglib2.0-dev libpng12-dev libxslt1-dev libsigc++-2.0-dev libpopt-dev libgc-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inkscape requires libgc-6.7.&lt;br /&gt;
&lt;br /&gt;
Breezy uses 6.4, Dapper uses 6.6, Edgy uses 6.7&lt;br /&gt;
&lt;br /&gt;
Hoary uses version 6.3, which is provided in the Repos.  (Is there somewhere to get a .deb for 6.4?)&lt;br /&gt;
&lt;br /&gt;
To overwrite libgc-6.3 with libgc-6.4:&lt;br /&gt;
   Download gc6.4&lt;br /&gt;
   ./configure --prefix=/usr&lt;br /&gt;
   make&lt;br /&gt;
   sudo make install&lt;br /&gt;
&lt;br /&gt;
== Old libgc 6.5 debs for Breezy(5.10) ==&lt;br /&gt;
&lt;br /&gt;
http://inkscape.modevia.com/ap/libgc-dev_6.5-1_i386.deb&lt;br /&gt;
http://inkscape.modevia.com/ap/libgc1_6.5-1_i386.deb&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=TestingInkscape&amp;diff=78068</id>
		<title>TestingInkscape</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=TestingInkscape&amp;diff=78068"/>
		<updated>2012-02-24T13:35:09Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Redirected page to Testing Inkscape&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Testing Inkscape]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Compiling_Inkscape_on_Windows_32-bit&amp;diff=76622</id>
		<title>Compiling Inkscape on Windows 32-bit</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Compiling_Inkscape_on_Windows_32-bit&amp;diff=76622"/>
		<updated>2012-01-11T18:25:39Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Setting up the build environment */ Changed link to TDM-GCC to point to the page that should always have the latest version.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Inkscape was originally written for Linux, but it has been ported to other platforms, including Windows. Since Windows is not POSIX compliant and doesn't have several features useful to developers (like package management), compiling Inkscape on Windows is more tedious than on Linux, but perfectly possible. To make it easier, we have compiled a package that contains all the libraries you need to build Inkscape. This reduces the effort of compiling Inkscape to: download and install 3 programs, download library package, download sourcecode, and you are ready to go.&lt;br /&gt;
&lt;br /&gt;
==Setting up the build environment==&lt;br /&gt;
&lt;br /&gt;
To develop Inkscape, you will need the following things:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.bazaar.canonical.com/WindowsDownloads Bazaar]&lt;br /&gt;
* [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] programs: puttygen.exe and pageant.exe&lt;br /&gt;
* [http://tdm-gcc.tdragon.net/download TDM's GCC (MingW)], the 32 bit bundle installer is the safe choice (it's called tdm-gcc-4.something and should be one of the very first options).&lt;br /&gt;
* Launchpad account&lt;br /&gt;
&lt;br /&gt;
In order to build the installer (not needed for most developers):&lt;br /&gt;
* [http://sourceforge.net/projects/nsis/files/NSIS%202/2.46/nsis-2.46-setup.exe/download NSIS 2.46]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Install the compiler===&lt;br /&gt;
Run the TDM-MinGW installer and install it in a path that doesn't contain spaces, like C:\mingw. If you install it into another path, set the environment variable MINGW_PATH to the TDM-MinGW installation directory, e.g. the one containing &amp;lt;tt&amp;gt;README-tdm-gcc.txt&amp;lt;/tt&amp;gt; (right click My Computer -&amp;gt; Properties -&amp;gt; Advanced -&amp;gt; Environment Variables). During the installation,  enable the &amp;quot;openmp support&amp;quot; checkbox from the components list or choose to install all packages (option &amp;quot;TDM-GCC recommended, All Packages&amp;quot; in the TDM-GCC (4.5.1) installer).&lt;br /&gt;
&lt;br /&gt;
If you have an older version of TDM-GCC (older than 4.5.1?), copy the file &amp;quot;\lib\gcc\mingw32\bin\libgomp-1.dll&amp;quot; to &amp;quot;\bin\libgomp-1.dll&amp;quot; (paths relative to your installation directory).&lt;br /&gt;
&lt;br /&gt;
===Create your Launchpad account===&lt;br /&gt;
If you do not have an SSH public/private key pair to identify yourself:&lt;br /&gt;
*run the program puttygen.exe to generate an SSH key&lt;br /&gt;
*save both its parts.&lt;br /&gt;
Log into your Launchpad account, go to your profile page and add the public part of the generated key to the list of SSH keys. Run the program pageant.exe (you can add it to Autorun). A tray icon should appear. Right click it, select &amp;quot;Add Key&amp;quot; and pick the private key file you have just generated from the dialog. Note that you need to repeat this after every login whenever you want to access Launchpad.&lt;br /&gt;
&lt;br /&gt;
Now set up Bazaar. First tell it who you are, then associate with your Launchpad account. You need to use the account name (e.g. johnq), not the display name.(John Q. Public).&lt;br /&gt;
&lt;br /&gt;
 C:\&amp;gt; bzr whoami &amp;quot;''Your Name'' &amp;lt;''your_real_email@example.com''&amp;gt;&amp;quot;&lt;br /&gt;
 C:\&amp;gt; bzr launchpad-login ''your_launchpad_account''&lt;br /&gt;
&lt;br /&gt;
===Install the developer libraries===&lt;br /&gt;
Check out Inkscape Devlibs into C:\devlibs. If you check them out elsewhere, set the environment variable DEVLIBS_PATH to the path where they are. Devlibs are a bundle of all the libraries needed to compile Inkscape. If you experience any problems, make sure you have an up to date copy of those libraries and an up to date checkout of Inkscape source. To reduce the size of the download, pass the &amp;lt;tt&amp;gt;--lightweight&amp;lt;/tt&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
 C:\&amp;gt; bzr checkout --lightweight lp:inkscape-devlibs devlibs&lt;br /&gt;
&lt;br /&gt;
To update devlibs:&lt;br /&gt;
&lt;br /&gt;
 C:\devlibs&amp;gt; bzr update&lt;br /&gt;
&lt;br /&gt;
All Inkscape developers can commit to the devlibs trunk. Advanced information about Devlibs, mainy useful when you want to update them to newly released versions of upstream libraries, is available here: [[Inkscape Devlibs]].&lt;br /&gt;
You can see some infomation from [https://launchpad.net/inkscape-devlibs launchpad:inkscape-devlibs] and [http://bazaar.launchpad.net/~inkscape.dev/inkscape-devlibs/trunk/files trunk/files].&lt;br /&gt;
&lt;br /&gt;
== Obtaining Inkscape source code ==&lt;br /&gt;
&lt;br /&gt;
You can obtain released Inkscape source from a tarball. Since version 0.47 they are hosted on [https://launchpad.net/inkscape Inkscape's Launchpad page]. There are ready-made installers provided, so there's usually little reason to compile the stable version yourself.&lt;br /&gt;
&lt;br /&gt;
To obtain cutting edge code, check out Inkscape source from the Bazaar repository. You can also use the TortoiseBZR shell extensions to do this. The recommended way is to first create a shared repository, then check out the Inkscape branch into that shared repository. Using this setup, branching will be a lot faster.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape&amp;gt; bzr init-repo --rich-root&lt;br /&gt;
 C:\src\inkscape&amp;gt; bzr checkout lp:inkscape trunk&lt;br /&gt;
&lt;br /&gt;
If you don't want to create any branches, you can skip the shared repository step.&lt;br /&gt;
&lt;br /&gt;
 C:\src&amp;gt; bzr checkout lp:inkscape&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' make sure that the path to your Inkscape source checkout does not contain spaces. Unix tools do not like them and you will end up with a lot of error messages about missing files.&lt;br /&gt;
&lt;br /&gt;
== Building Inkscape ==&lt;br /&gt;
&lt;br /&gt;
Open the command prompt, navigate to the directory with Inkscape sources. First set up some environmental variables. You only need to do this once per console session.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; mingwenv&lt;br /&gt;
&lt;br /&gt;
Now compile the build tool. Try the second command if the first one fails.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; g++ buildtool.cpp -o btool&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; g++ -DNEED_GETTIMEOFDAY buildtool.cpp -o btool&lt;br /&gt;
&lt;br /&gt;
Finally initiate the compilation. Get a coffee or take your dog out for a walk, because it will take a rather long time.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool&lt;br /&gt;
&lt;br /&gt;
Once everything is done, there should be an &amp;lt;tt&amp;gt;inkscape&amp;lt;/tt&amp;gt; directory that contains the Inkscape executable and libraries needed to run it.&lt;br /&gt;
&lt;br /&gt;
== Rebuilding ==&lt;br /&gt;
&lt;br /&gt;
If you have only changed a few files and want to rebuild, delete the &amp;lt;tt&amp;gt;inkscape&amp;lt;/tt&amp;gt; directory and run &amp;lt;tt&amp;gt;btool&amp;lt;/tt&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
To rebuild from scratch, execute the following sequence of commands:&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool clean&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool&lt;br /&gt;
&lt;br /&gt;
== Dealing With Build Errors ==&lt;br /&gt;
Feel free to add any questions or answers you have in here;&lt;br /&gt;
&lt;br /&gt;
'''Q''' - My firewall software (Comodo's Defense+ component or similar) stopped the process continuing to the next step in the build, because I wasn't there to permit an action and it timed out. What can I do?&lt;br /&gt;
&lt;br /&gt;
'''A1''' - The best thing is to disable stuff like Defense+ (put it in learning mode works) because it will stop any process that is not approved, and building makes new files which can't be approved before they're built. Disabling Comodo's Defense+ does not disable your firewall, either inbound or outbound, but just the part that scans every application for suspicious operations. Other firewalls etc may vary.&lt;br /&gt;
&lt;br /&gt;
'''A2''' - If that doesn't suit, often you can simply run btool again and wait for Defense+ (or similar) to ask for approval for the process, and it will then continue as normal with the build. But remember that approving all the processes involved in the build process once doesn't mean they will all slip through next time.&lt;br /&gt;
&lt;br /&gt;
'''A3''' - This is the more complex way to continue, but may help if you have problems with A2. If you know the stage the process was meant to be up to (look at the output in the command windows and compare to the stages in the ''build.xml'' file), you can start again from there.&lt;br /&gt;
&lt;br /&gt;
You may see something like this in the command window;&lt;br /&gt;
     =============================&lt;br /&gt;
     ## Target : link : link objects and library to create executable&lt;br /&gt;
     ---- task : rc&lt;br /&gt;
     ============ cmd ============&lt;br /&gt;
     windres -o build/inkres.o --include-dir=src src/inkscape.rc&lt;br /&gt;
     =============================&lt;br /&gt;
     ---- task : link&lt;br /&gt;
This will likely be followed by an error message. This means you were at the ''link'' stage&lt;br /&gt;
&lt;br /&gt;
Now simply type;&lt;br /&gt;
     ...&amp;gt;btool ''stage''&lt;br /&gt;
Or in this case&lt;br /&gt;
     ...&amp;gt;btool link&lt;br /&gt;
And the build will continue from there.&lt;br /&gt;
&lt;br /&gt;
After this, you will probably have to step through the remaining stages manually, one by one. The stages can include (see build.xml, where each stage is labelled 'target name=&amp;quot;''target''&amp;quot;') ''init'', ''touchabout'', ''compile'', ''java'', ''lib'', ''i18n'', ''link'', ''linkinkview'', ''dist'', ''dist-all'', ''clean''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - How do I rebuild just one ''file.o'' file? For instance if one particular file has gone wrong, or I want to try patching just one part of the code.&lt;br /&gt;
&lt;br /&gt;
'''A''' - To find the right command for building any particular file in Inkscape, just look in the compile.lst after you have used btool once. Search for the name of the particular file (eg: print.cpp) and you will find the command used to compile it. You'll need to paste this into a text file, remove any carriage reurns and then paste that onto the command line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - After I patched a file, I left a backup of the old file in the same directory called Copy of{filename}.cpp. The compiler complains about this file when building and stops.&lt;br /&gt;
&lt;br /&gt;
'''A''' - Do not leave anything with a suffix .cpp in the source directories, apart from the original (or patched) source files. The build tool will try to compile everything ending in .cpp and will complain. If you backup an old file in the same directory before patching, call it {filename}.cpp.old or similar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - I think I followed the instruction above. What could have caused the compiling error like this for src/extension/internal/pdfinput/pdf-parser.cpp?&lt;br /&gt;
&lt;br /&gt;
     src/extension/internal/pdfinput/pdf-parser.cpp:2248: error: no matching function for call to 'GfxFont::getNextChar(char*&amp;amp;, int&amp;amp;, CharCode*, Unicode [8], int, int*, double*, double*, double*, double*)'&lt;br /&gt;
&lt;br /&gt;
Same error for line 2297 as well.&lt;br /&gt;
&lt;br /&gt;
=== For more information ===&lt;br /&gt;
There is some old information on building Inkscape with either Mingw on Windows, or a cross-compiler on Linux, at http://inkscape.modevia.com/win32_inkscape_org/win32buildnotes.html&lt;br /&gt;
and old files mey be&lt;br /&gt;
http://inkscape.modevia.com/win32libs/&lt;br /&gt;
== Creating an installer ==&lt;br /&gt;
&lt;br /&gt;
To create the setup package you need the NSIS installer on your PC. Get that from http://nsis.sf.net .&lt;br /&gt;
You have successfully built Inkscape and everything is in the ...\inkscape\ directory.&lt;br /&gt;
Open the ...\packaging\win32\inkscape.nsi using the NSIS program and compile the package. Sooo easy :-)&lt;br /&gt;
&lt;br /&gt;
== Note about Unicode ==&lt;br /&gt;
&lt;br /&gt;
The GTK stack depends on functions only present in NT-based Windows (2000 and later). Therefore, Inkscape code can assume that Unicode functions from the Windows API (like GetCommandLineW) are always present. Note however that you should use the GLib/GTK functions rather the Windows API whenever possible.&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
*[[Compiling Inkscape]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=70537</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=70537"/>
		<updated>2011-06-14T09:09:56Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or (only a single color per point on the path and no blur):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;diffusionGradient id=&amp;quot;gradient&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;stop ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/diffusionGradient&amp;gt;&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       fill=&amp;quot;url(#gradient)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This could lead to an on-canvas interface (using an extended gradient tool) that looks a bit like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:fudgedDiffCurve.png]]&lt;br /&gt;
&lt;br /&gt;
Here the &amp;quot;gradient stops&amp;quot; are (necessarily) positioned on the path and represented by the circles. The color inside the circles shows the stop color.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
*Could a diffusion curve have a stop which is not completely opaque? I would find this useful for creating lighting effects over surfaces. --[[User:Pajarico|Pajarico]] 23:11, 15 January 2011 (UTC)&lt;br /&gt;
** Yes, it could. In fact, it's quite trivial to do so, as diffusion curves are handled per channel anyway. And it's not too difficult to show that this yields sensible results if you use (premultiplied) alpha. How this behaves in practice remains to be seen, however, but I would expect this to more or less just work. --[[User:Jaspervdg|Jaspervdg]] 08:16, 18 January 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper (and program to edit/view them): http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*Quality issues and using the Analytic Element Method to combat them: http://irs.ub.rug.nl/dbi/4d10adac9b054 (backup: http://home.hccnet.nl/th.v.d.gronde/ThesisJvdGFinal2.pdf)&lt;br /&gt;
*Some grid-based implementations: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;br /&gt;
*Implementation based on the Analytic Element Method: https://code.launchpad.net/~jaspervdg/+junk/aem-diffusion-curves&lt;br /&gt;
*More references: http://www.citeulike.org/user/jaspervdg/tag/diffusion_curves&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Compiling_Inkscape_on_Windows_32-bit&amp;diff=68101</id>
		<title>Compiling Inkscape on Windows 32-bit</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Compiling_Inkscape_on_Windows_32-bit&amp;diff=68101"/>
		<updated>2011-03-19T15:31:18Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Install the compiler */ Switched around workaround for difference in location of libgomp&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Inkscape was originally written for Linux, but it has been ported to other platforms, including Windows. Since Windows is not POSIX compliant and doesn't have several features useful to developers (like package management), compiling Inkscape on Windows is more tedious than on Linux, but perfectly possible.&lt;br /&gt;
&lt;br /&gt;
==Setting up the build environment==&lt;br /&gt;
&lt;br /&gt;
To develop Inkscape, you will need the following things:&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.bazaar.canonical.com/WindowsDownloads Bazaar]&lt;br /&gt;
* [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY] programs: puttygen.exe and pageant.exe&lt;br /&gt;
* [http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm-gcc-4.5.1.exe/download TDM-MinGW 4.5.1]&lt;br /&gt;
* [http://sourceforge.net/projects/nsis/files/NSIS%202/2.46/nsis-2.46-setup.exe/download NSIS 2.46]&lt;br /&gt;
* Launchpad account&lt;br /&gt;
&lt;br /&gt;
===Install the compiler===&lt;br /&gt;
Run the TDM-MinGW installer and install it in a path that doesn't contain spaces, preferably C:\mingw. If you install it into another path, set the environment variable MINGW_PATH to the TDM-MinGW installation directory, e.g. the one containing &amp;lt;tt&amp;gt;README-tdm-gcc.txt&amp;lt;/tt&amp;gt; (right click My Computer -&amp;gt; Properties -&amp;gt; Advanced -&amp;gt; Environment Variables). During the installation,  enable the &amp;quot;openmp support&amp;quot; checkbox from the components list or choose to install all packages (option &amp;quot;TDM-GCC recommended, All Packages&amp;quot; in the TDM-GCC 4.5.1 installer).&lt;br /&gt;
&lt;br /&gt;
If you have an older version of TDM-GCC (older than 4.5.1?), copy the file &amp;quot;\lib\gcc\mingw32\bin\libgomp-1.dll&amp;quot; to &amp;quot;\bin\libgomp-1.dll&amp;quot; (paths relative to your installation directory).&lt;br /&gt;
&lt;br /&gt;
===Create your Launchpad account===&lt;br /&gt;
If you do not have an SSH public/private key pair to identify yourself:&lt;br /&gt;
*run the program puttygen.exe to generate an SSH key&lt;br /&gt;
*save both its parts.&lt;br /&gt;
Log into your Launchpad account, go to your profile page and add the public part of the generated key to the list of SSH keys. Run the program pageant.exe (you can add it to Autorun). A tray icon should appear. Right click it, select &amp;quot;Add Key&amp;quot; and pick the private key file you have just generated from the dialog. Note that you need to repeat this after every login whenever you want to access Launchpad.&lt;br /&gt;
&lt;br /&gt;
Now set up Bazaar. First tell it who you are, then associate with your Launchpad account. You need to use the account name (e.g. johnq), not the display name.(John Q. Public).&lt;br /&gt;
&lt;br /&gt;
 C:\&amp;gt; bzr whoami &amp;quot;''Your Name'' &amp;lt;''your_real_email@example.com''&amp;gt;&amp;quot;&lt;br /&gt;
 C:\&amp;gt; bzr launchpad-login ''your_launchpad_account''&lt;br /&gt;
&lt;br /&gt;
===Install the developer libraries===&lt;br /&gt;
Check out Inkscape Devlibs into C:\devlibs. If you check them out elsewhere, set the environment variable DEVLIBS_PATH to the path where they are. Devlibs are a bundle of all the libraries needed to compile Inkscape. If you experience any problems, make sure you have an up to date copy of those libraries and an up to date checkout of Inkscape source. To reduce the size of the download, pass the &amp;lt;tt&amp;gt;--lightweight&amp;lt;/tt&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
 C:\&amp;gt; bzr checkout --lightweight lp:inkscape-devlibs devlibs&lt;br /&gt;
&lt;br /&gt;
To update devlibs:&lt;br /&gt;
&lt;br /&gt;
 C:\devlibs&amp;gt; bzr update&lt;br /&gt;
&lt;br /&gt;
All Inkscape developers can commit to the devlibs trunk. Advanced information about Devlibs, mainy useful when you want to update them to newly released versions of upstream libraries, is available here: [[Inkscape Devlibs]].&lt;br /&gt;
You can see some infomation from [https://launchpad.net/inkscape-devlibs launchpad:inkscape-devlibs] and [http://bazaar.launchpad.net/~inkscape.dev/inkscape-devlibs/trunk/files trunk/files].&lt;br /&gt;
&lt;br /&gt;
== Obtaining Inkscape source code ==&lt;br /&gt;
&lt;br /&gt;
You can obtain released Inkscape source from a tarball. Since version 0.47 they are hosted on [https://launchpad.net/inkscape Inkscape's Launchpad page]. There are ready-made installers provided, so there's usually little reason to compile the stable version yourself.&lt;br /&gt;
&lt;br /&gt;
To obtain cutting edge code, check out Inkscape source from the Bazaar repository. You can also use the TortoiseBZR shell extensions to do this. The recommended way is to first create a shared repository, then check out the Inkscape branch into that shared repository. Using this setup, branching will be a lot faster.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape&amp;gt; bzr init-repo --rich-root&lt;br /&gt;
 C:\src\inkscape&amp;gt; bzr checkout lp:inkscape trunk&lt;br /&gt;
&lt;br /&gt;
If you don't want to create any branches, you can skip the shared repository step.&lt;br /&gt;
&lt;br /&gt;
 C:\src&amp;gt; bzr checkout lp:inkscape&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' make sure that the path to your Inkscape source checkout does not contain spaces. Unix tools do not like them and you will end up with a lot of error messages about missing files.&lt;br /&gt;
&lt;br /&gt;
== Building Inkscape ==&lt;br /&gt;
&lt;br /&gt;
Open the command prompt, navigate to the directory with Inkscape sources. First set up some environmental variables. You only need to do this once per console session.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; mingwenv&lt;br /&gt;
&lt;br /&gt;
Now compile the build tool. Try the second command if the first one fails.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; g++ buildtool.cpp -o btool&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; g++ -DNEED_GETTIMEOFDAY buildtool.cpp -o btool&lt;br /&gt;
&lt;br /&gt;
Finally initiate the compilation. Get a coffee or take your dog out for a walk, because it will take a rather long time.&lt;br /&gt;
&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool&lt;br /&gt;
&lt;br /&gt;
Once everything is done, there should be an &amp;lt;tt&amp;gt;inkscape&amp;lt;/tt&amp;gt; directory that contains the Inkscape executable and libraries needed to run it.&lt;br /&gt;
&lt;br /&gt;
== Rebuilding ==&lt;br /&gt;
&lt;br /&gt;
If you have only changed a few files and want to rebuild, delete the &amp;lt;tt&amp;gt;inkscape&amp;lt;/tt&amp;gt; directory and run &amp;lt;tt&amp;gt;btool&amp;lt;/tt&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
To rebuild from scratch, execute the following sequence of commands:&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool clean&lt;br /&gt;
 C:\src\inkscape\trunk&amp;gt; btool&lt;br /&gt;
&lt;br /&gt;
== Dealing With Build Errors ==&lt;br /&gt;
Feel free to add any questions or answers you have in here;&lt;br /&gt;
&lt;br /&gt;
'''Q''' - My firewall software (Comodo's Defense+ component or similar) stopped the process continuing to the next step in the build, because I wasn't there to permit an action and it timed out. What can I do?&lt;br /&gt;
&lt;br /&gt;
'''A1''' - The best thing is to disable stuff like Defense+ (put it in learning mode works) because it will stop any process that is not approved, and building makes new files which can't be approved before they're built. Disabling Comodo's Defense+ does not disable your firewall, either inbound or outbound, but just the part that scans every application for suspicious operations. Other firewalls etc may vary.&lt;br /&gt;
&lt;br /&gt;
'''A2''' - If that doesn't suit, often you can simply run btool again and wait for Defense+ (or similar) to ask for approval for the process, and it will then continue as normal with the build. But remember that approving all the processes involved in the build process once doesn't mean they will all slip through next time.&lt;br /&gt;
&lt;br /&gt;
'''A3''' - This is the more complex way to continue, but may help if you have problems with A2. If you know the stage the process was meant to be up to (look at the output in the command windows and compare to the stages in the ''build.xml'' file), you can start again from there.&lt;br /&gt;
&lt;br /&gt;
You may see something like this in the command window;&lt;br /&gt;
     =============================&lt;br /&gt;
     ## Target : link : link objects and library to create executable&lt;br /&gt;
     ---- task : rc&lt;br /&gt;
     ============ cmd ============&lt;br /&gt;
     windres -o build/inkres.o --include-dir=src src/inkscape.rc&lt;br /&gt;
     =============================&lt;br /&gt;
     ---- task : link&lt;br /&gt;
This will likely be followed by an error message. This means you were at the ''link'' stage&lt;br /&gt;
&lt;br /&gt;
Now simply type;&lt;br /&gt;
     ...&amp;gt;btool ''stage''&lt;br /&gt;
Or in this case&lt;br /&gt;
     ...&amp;gt;btool link&lt;br /&gt;
And the build will continue from there.&lt;br /&gt;
&lt;br /&gt;
After this, you will probably have to step through the remaining stages manually, one by one. The stages can include (see build.xml, where each stage is labelled 'target name=&amp;quot;''target''&amp;quot;') ''init'', ''touchabout'', ''compile'', ''java'', ''lib'', ''i18n'', ''link'', ''linkinkview'', ''dist'', ''dist-all'', ''clean''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - How do I rebuild just one ''file.o'' file? For instance if one particular file has gone wrong, or I want to try patching just one part of the code.&lt;br /&gt;
&lt;br /&gt;
'''A''' - To find the right command for building any particular file in Inkscape, just look in the compile.lst after you have used btool once. Search for the name of the particular file (eg: print.cpp) and you will find the command used to compile it. You'll need to paste this into a text file, remove any carriage reurns and then paste that onto the command line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - After I patched a file, I left a backup of the old file in the same directory called Copy of{filename}.cpp. The compiler complains about this file when building and stops.&lt;br /&gt;
&lt;br /&gt;
'''A''' - Do not leave anything with a suffix .cpp in the source directories, apart from the original (or patched) source files. The build tool will try to compile everything ending in .cpp and will complain. If you backup an old file in the same directory before patching, call it {filename}.cpp.old or similar.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Q''' - I think I followed the instruction above. What could have caused the compiling error like this for src/extension/internal/pdfinput/pdf-parser.cpp?&lt;br /&gt;
&lt;br /&gt;
     src/extension/internal/pdfinput/pdf-parser.cpp:2248: error: no matching function for call to 'GfxFont::getNextChar(char*&amp;amp;, int&amp;amp;, CharCode*, Unicode [8], int, int*, double*, double*, double*, double*)'&lt;br /&gt;
&lt;br /&gt;
Same error for line 2297 as well.&lt;br /&gt;
&lt;br /&gt;
=== For more information ===&lt;br /&gt;
There is some old information on building Inkscape with either Mingw on Windows, or a cross-compiler on Linux, at http://inkscape.modevia.com/win32_inkscape_org/win32buildnotes.html&lt;br /&gt;
and old files mey be&lt;br /&gt;
http://inkscape.modevia.com/win32libs/&lt;br /&gt;
== Creating an installer ==&lt;br /&gt;
&lt;br /&gt;
To create the setup package you need the NSIS installer on your PC. Get that from http://nsis.sf.net .&lt;br /&gt;
You have successfully built Inkscape and everything is in the ...\inkscape\ directory.&lt;br /&gt;
Open the ...\packaging\win32\inkscape.nsi using the NSIS program and compile the package. Sooo easy :-)&lt;br /&gt;
&lt;br /&gt;
== Note about Unicode ==&lt;br /&gt;
&lt;br /&gt;
The GTK stack depends on functions only present in NT-based Windows (2000 and later). Therefore, Inkscape code can assume that Unicode functions from the Windows API (like GetCommandLineW) are always present. Note however that you should use the GLib/GTK functions rather the Windows API whenever possible.&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
*[[Compiling Inkscape]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer Documentation]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=67813</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=67813"/>
		<updated>2011-03-08T08:58:15Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Updated links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or (only a single color per point on the path and no blur):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;diffusionGradient id=&amp;quot;gradient&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;stop ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/diffusionGradient&amp;gt;&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       fill=&amp;quot;url(#gradient)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This could lead to an on-canvas interface (using an extended gradient tool) that looks a bit like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:fudgedDiffCurve.png]]&lt;br /&gt;
&lt;br /&gt;
Here the &amp;quot;gradient stops&amp;quot; are (necessarily) positioned on the path and represented by the circles. The color inside the circles shows the stop color.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
*Could a diffusion curve have a stop which is not completely opaque? I would find this useful for creating lighting effects over surfaces. --[[User:Pajarico|Pajarico]] 23:11, 15 January 2011 (UTC)&lt;br /&gt;
** Yes, it could. In fact, it's quite trivial to do so, as diffusion curves are handled per channel anyway. And it's not too difficult to show that this yields sensible results if you use (premultiplied) alpha. How this behaves in practice remains to be seen, however, but I would expect this to more or less just work. --[[User:Jaspervdg|Jaspervdg]] 08:16, 18 January 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper (and program to edit/view them): http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*Quality issues and using the Analytic Element Method to combat them: http://home.hccnet.nl/th.v.d.gronde/ThesisJvdGFinal2.pdf&lt;br /&gt;
*Some grid-based implementations: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;br /&gt;
*Implementation based on the Analytic Element Method: https://code.launchpad.net/~jaspervdg/+junk/aem-diffusion-curves&lt;br /&gt;
*More references: http://www.citeulike.org/user/jaspervdg/tag/diffusion_curves&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=66955</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=66955"/>
		<updated>2011-01-18T08:16:52Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Questions/Problems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or (only a single color per point on the path and no blur):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;diffusionGradient id=&amp;quot;gradient&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;stop ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/diffusionGradient&amp;gt;&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       fill=&amp;quot;url(#gradient)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This could lead to an on-canvas interface (using an extended gradient tool) that looks a bit like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:fudgedDiffCurve.png]]&lt;br /&gt;
&lt;br /&gt;
Here the &amp;quot;gradient stops&amp;quot; are (necessarily) positioned on the path and represented by the circles. The color inside the circles shows the stop color.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
*Could a diffusion curve have a stop which is not completely opaque? I would find this useful for creating lighting effects over surfaces. --[[User:Pajarico|Pajarico]] 23:11, 15 January 2011 (UTC)&lt;br /&gt;
** Yes, it could. In fact, it's quite trivial to do so, as diffusion curves are handled per channel anyway. And it's not too difficult to show that this yields sensible results if you use (premultiplied) alpha. How this behaves in practice remains to be seen, however, but I would expect this to more or less just work. --[[User:Jaspervdg|Jaspervdg]] 08:16, 18 January 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;br /&gt;
*More references: http://www.citeulike.org/user/jaspervdg/tag/diffusion_curves&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=66229</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=66229"/>
		<updated>2010-12-09T08:40:09Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Links */ Added citeulike link.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or (only a single color per point on the path and no blur):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;diffusionGradient id=&amp;quot;gradient&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;stop ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/diffusionGradient&amp;gt;&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       fill=&amp;quot;url(#gradient)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This could lead to an on-canvas interface (using an extended gradient tool) that looks a bit like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:fudgedDiffCurve.png]]&lt;br /&gt;
&lt;br /&gt;
Here the &amp;quot;gradient stops&amp;quot; are (necessarily) positioned on the path and represented by the circles. The color inside the circles shows the stop color.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;br /&gt;
*More references: http://www.citeulike.org/user/jaspervdg/tag/diffusion_curves&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=64993</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=64993"/>
		<updated>2010-10-06T07:02:54Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
This page was started as part of the response to [https://bugs.launchpad.net/inkscape/+bug/346681 bug 346681], mainly to provide an alternative for a bitmap fallback.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two images below show an example as it is rendered by Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
[[Media:LineargradientCT.svg|Download/view LineargradientCT.svg]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The images below show a linear gradient colored with the feDisplacementMap method, rendered by the Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
[[Media:LineargradientDM.svg|Download/view LineargradientDM.svg]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMDL.svg|Download/view ConicalgradientDMDL.svg]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMRD.svg|Download/view ConicalgradientDMRD.svg]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMRD2.svg|Download/view ConicalgradientDMRD2.svg]]&lt;br /&gt;
&lt;br /&gt;
===Arctan approximation quality===&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
Note that this approximation method corresponds to the approximation [http://dspguru.com/comp.dsp/tricks/alg/fxdatan2.htm described here] for quadrant 1 (with the roles of x and y reversed, just like in the graph above), scaled by &amp;lt;math&amp;gt;2/\pi&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\frac{2}{\pi}\cdot\frac{\pi}{4}\left(1-\frac{y-x}{x+y}\right)&amp;amp;=\frac{1}{2}\left(1-\frac{y-x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y}{x+y}+\frac{x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y+x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{2x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{x+y}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]], as well as [[Diffusion_Curves|this Wiki page]] for information on attempts to make Diffusion Curves suitable for implementation in Inkscape.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=64987</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=64987"/>
		<updated>2010-10-06T07:00:42Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
This page was started as part of the response to [https://bugs.launchpad.net/inkscape/+bug/346681 bug 346681], mainly to provide an alternative for a bitmap fallback.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
[[Media:LineargradientCT.svg|Download/view LineargradientCT.svg]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
[[Media:LineargradientDM.svg|Download/view LineargradientDM.svg]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMDL.svg|Download/view ConicalgradientDMDL.svg]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMRD.svg|Download/view ConicalgradientDMRD.svg]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
[[Media:ConicalgradientDMRD2.svg|Download/view ConicalgradientDMRD2.svg]]&lt;br /&gt;
&lt;br /&gt;
===Arctan approximation quality===&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
Note that this approximation method corresponds to the approximation [http://dspguru.com/comp.dsp/tricks/alg/fxdatan2.htm described here] for quadrant 1 (with the roles of x and y reversed, just like in the graph above), scaled by &amp;lt;math&amp;gt;2/\pi&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\frac{2}{\pi}\cdot\frac{\pi}{4}\left(1-\frac{y-x}{x+y}\right)&amp;amp;=\frac{1}{2}\left(1-\frac{y-x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y}{x+y}+\frac{x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y+x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{2x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{x+y}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]], as well as [[Diffusion_Curves|this Wiki page]] for information on attempts to make Diffusion Curves suitable for implementation in Inkscape.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=64537</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=64537"/>
		<updated>2010-09-07T14:00:48Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Representation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or (only a single color per point on the path and no blur):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;diffusionGradient id=&amp;quot;gradient&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;stop ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/diffusionGradient&amp;gt;&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       fill=&amp;quot;url(#gradient)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This could lead to an on-canvas interface (using an extended gradient tool) that looks a bit like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:fudgedDiffCurve.png]]&lt;br /&gt;
&lt;br /&gt;
Here the &amp;quot;gradient stops&amp;quot; are (necessarily) positioned on the path and represented by the circles. The color inside the circles shows the stop color.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:FudgedDiffCurve.png&amp;diff=64531</id>
		<title>File:FudgedDiffCurve.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:FudgedDiffCurve.png&amp;diff=64531"/>
		<updated>2010-09-07T13:54:51Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example of what an interface for editing diffusion curves in Inkscape could look like. Here it is assumed that diffusion curves are handled like just another kind of paint and can be applied using an extended version of the gradient tool. The circles represent &amp;quot;gradient stops&amp;quot;, with the stop color in the circle.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:FudgedDiffCurve.png&amp;diff=64525</id>
		<title>File:FudgedDiffCurve.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:FudgedDiffCurve.png&amp;diff=64525"/>
		<updated>2010-09-07T13:52:53Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=64519</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=64519"/>
		<updated>2010-09-07T10:01:43Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent. Or by simply treating diffusion curves as yet another paint server.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers on grids generally use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Storage can be quite bad for curved geometries (because of the number of triangles needed to approximate the curve).&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give a higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
*It might be possible to use the result of a boundary element computation directly and just combine basis functions.&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_WorkingGroup&amp;diff=62887</id>
		<title>SVG WorkingGroup</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_WorkingGroup&amp;diff=62887"/>
		<updated>2010-06-15T16:12:35Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Areas of Inkscape Interest */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Inkscape and the SVG Working Group ==&lt;br /&gt;
&lt;br /&gt;
Inkscape '''can''' influence the future of the SVG standard. This page serves as a gathering point for ideas on how the standard can be improved to the benefit of Inkscape.&lt;br /&gt;
&lt;br /&gt;
== Inkscape representitive ==&lt;br /&gt;
&lt;br /&gt;
Tavmjong Bah has joined the SVG Working group as an &amp;quot;Invited Expert&amp;quot; to represent the interests of Inkscape. You can contact him through the developer's mailing list or at tavmjong at free.fr. You can also join the meetings yourself (as several Inkscapers did after LGM2010). See the links below.&lt;br /&gt;
&lt;br /&gt;
Please add to this page any problems you have found with the existing standard or what you would like to see in a future standard.&lt;br /&gt;
&lt;br /&gt;
== SVG Working Group Links ==&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.w3.org/Graphics/SVG/WG/wiki/Main_Page Working Group Main Page]&lt;br /&gt;
* [http://lists.w3.org/Archives/Public/public-svg-wg/ Public-SVG-WG Mail Archives]&lt;br /&gt;
* [http://lists.w3.org/Archives/Public/www-svg/ WWW-SVG Mail Archives] (The true public mailing list).&lt;br /&gt;
* [http://www.w3.org/Graphics/SVG/WG/wiki/Meetings Schedule]&lt;br /&gt;
&lt;br /&gt;
=== Standards ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*[http://www.w3.org/TR/#tr_SVG  Complete List]&lt;br /&gt;
&lt;br /&gt;
==== Completed ====&lt;br /&gt;
&lt;br /&gt;
* [http://www.w3.org/TR/2003/REC-SVG11-20030114/ SVG 1.1]&lt;br /&gt;
* [http://www.w3.org/TR/2008/REC-SVGTiny12-20081222/ SVG Tiny 1.2]&lt;br /&gt;
&lt;br /&gt;
==== Proposed Standards ====&lt;br /&gt;
&lt;br /&gt;
*[http://www.w3.org/Graphics/SVG/WG/wiki/Roadmap Roadmap]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Areas of Inkscape Interest ==&lt;br /&gt;
&lt;br /&gt;
Here are some areas to consider:&lt;br /&gt;
&lt;br /&gt;
=== Multipage document support ===&lt;br /&gt;
&lt;br /&gt;
 Proposed for SVG 1.2 but dropped.&lt;br /&gt;
&lt;br /&gt;
=== Standardizing layers ===&lt;br /&gt;
&lt;br /&gt;
 Creating a standard way to indicate layers. Inkscape uses private attributes.&lt;br /&gt;
&lt;br /&gt;
=== Clones/referencing ===&lt;br /&gt;
&lt;br /&gt;
Currently there is the use element, but there are also elements (gradients and filters) that have their own &amp;quot;cloning&amp;quot; technique, it could be nice to unify these approaches? In particular, either might benefit from some kind of support for &amp;quot;parameters&amp;quot; (being either numerical/textual values or drawable elements).&lt;br /&gt;
&lt;br /&gt;
=== (Fancy) paths ===&lt;br /&gt;
&lt;br /&gt;
* A different notion of &amp;quot;closing&amp;quot; a path is needed, as the current one only operates well in the context of straight lines. For example, instead of having z be a command that draws a straight line to the first vertex in the subpath and closes the path, it could be used in place of the last pair of coordinates in a closed subpath. This would only very slightly complicate parsing while allowing for a much more natural operation in the context of curves. Currently a closed path consisting (conceptually) only of cubic beziers HAS to have at least one &amp;quot;closing&amp;quot; segment, this introduces &amp;quot;double&amp;quot; nodes, is more verbose and makes it impossible to have the exact same marker behaviour in paths consisting of straight lines and paths consisting of curves. (Also see this discussion: http://old.nabble.com/Re:--Lib2geom-devel--Geom::Path-and-boost::ptr_vector-td27535646.html)&lt;br /&gt;
* Patterns along paths,&lt;br /&gt;
* Vector effects.&lt;br /&gt;
* Power stroke.&lt;br /&gt;
&lt;br /&gt;
=== Gradients ===&lt;br /&gt;
&lt;br /&gt;
* Diffusion curves.&lt;br /&gt;
* Mesh gradients.&lt;br /&gt;
&lt;br /&gt;
=== SVG fonts ===&lt;br /&gt;
&lt;br /&gt;
Firefox and IE will not add support for SVG fonts.&lt;br /&gt;
&lt;br /&gt;
=== Filters ===&lt;br /&gt;
&lt;br /&gt;
*Increasing bit depth to reduce artifacts.&lt;br /&gt;
*The same color space (by default) as the rest of SVG (and only ONE property please). Note that it would make sense to make linearRGB the default everywhere (instead of making filters use sRGB by default as well).&lt;br /&gt;
*Margins. (--[[User:Jaspervdg|Jaspervdg]] 13:49, 15 June 2010 (UTC) I would prefer them not to have any attributes for margins. Specifically I think the only property of the filter element that should stay is primitiveUnits.)&lt;br /&gt;
*Primitive subregions are (as far as I, Jasper, know) unused and frankly not that useful. As far as I can tell they're mostly meant as an optimization, but a renderer can do that quite easily (and frankly often still has to). If you want a clipping rectangle or something, then just draw a rectangle and use it to clip a result, if you have a smart renderer it will even automagically behave reasonably efficient in such a case.&lt;br /&gt;
*Non-pixel-based convolution (based on a Laplace transform instead of the Z-transform basically). E.g. it would be more logical (at least in some cases) to specify that you want the derivative of an image rather than applying the kernel &amp;quot;1 -1&amp;quot;... (Which has to be given a certain resolution to be meaningful, meaning that you currently can't express resolution-independent convolutions.) In fact, it could make sense to simply remove the current feConvolveMatrix, and/or enable it to function in a resolution independent manner.&lt;br /&gt;
*Unification of normal compositing, feBlend, feComposite and feMerge. (Like in SVG Compositing? And then exposing that in filters in some way?)&lt;br /&gt;
*Is enable-background REALLY necessary? There are other ways to solve the same problem, like referencing an element explicitly or allowing filters (and possibly also use elements) with &amp;quot;parameters&amp;quot;. There are certain very cool things you can do with enable-background, but it's quite hard to implement correctly because you need to keep track of where the background is used in order to know which part of an object is actually needed. Other options might be less general w.r.t. accessing the &amp;quot;background&amp;quot;, but they might be easier to support and allow for much more interesting effects.&lt;br /&gt;
*Reusing filters as primitives. (Essentially allowing macro's.)&lt;br /&gt;
*A lot of filters could be &amp;quot;optimized&amp;quot; by a renderer. This would be especially helpful for editors and animation-enabled renderers. It might be good to see if some things could be built in to make this easier. I would avoid explicit flags as much as possible (users either won't use them when they could, or use them all the time, negating their usefulness), but the specification might specify some operations that are explicitly permitted for example (like collapsing two feColorMatrix operations).&lt;br /&gt;
&lt;br /&gt;
--[[User:Jaspervdg|Jaspervdg]] 16:12, 15 June 2010 (UTC) In general I'd like to stress that SVG filters should (IMO) focus less on a specific implementation and more on the desired effect (and if possible in a &amp;quot;vector-like&amp;quot; way). This makes it less complex to support filters and gives more freedom to an implementation to &amp;quot;do the right thing&amp;quot; in its own way. It's also more friendly towards the user of SVG, as more of the implementation details are hidden. (Obviously it should be possible to implement a filter, but the specification shouldn't prescribe a certain implementation.)&lt;br /&gt;
&lt;br /&gt;
=== Cacheable portion/layers ===&lt;br /&gt;
&lt;br /&gt;
*Investigate partial.s cache-ablity&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_WorkingGroup&amp;diff=62881</id>
		<title>SVG WorkingGroup</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_WorkingGroup&amp;diff=62881"/>
		<updated>2010-06-15T13:49:26Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Filters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Inkscape and the SVG Working Group ==&lt;br /&gt;
&lt;br /&gt;
Inkscape '''can''' influence the future of the SVG standard. This page serves as a gathering point for ideas on how the standard can be improved to the benefit of Inkscape.&lt;br /&gt;
&lt;br /&gt;
== Inkscape representitive ==&lt;br /&gt;
&lt;br /&gt;
Tavmjong Bah has joined the SVG Working group as an &amp;quot;Invited Expert&amp;quot; to represent the interests of Inkscape. You can contact him through the developer's mailing list or at tavmjong at free.fr. You can also join the meetings yourself (as several Inkscapers did after LGM2010). See the links below.&lt;br /&gt;
&lt;br /&gt;
Please add to this page any problems you have found with the existing standard or what you would like to see in a future standard.&lt;br /&gt;
&lt;br /&gt;
== SVG Working Group Links ==&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.w3.org/Graphics/SVG/WG/wiki/Main_Page Working Group Main Page]&lt;br /&gt;
* [http://lists.w3.org/Archives/Public/public-svg-wg/ Public-SVG-WG Mail Archives]&lt;br /&gt;
* [http://lists.w3.org/Archives/Public/www-svg/ WWW-SVG Mail Archives] (The true public mailing list).&lt;br /&gt;
* [http://www.w3.org/Graphics/SVG/WG/wiki/Meetings Schedule]&lt;br /&gt;
&lt;br /&gt;
=== Standards ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*[http://www.w3.org/TR/#tr_SVG  Complete List]&lt;br /&gt;
&lt;br /&gt;
==== Completed ====&lt;br /&gt;
&lt;br /&gt;
* [http://www.w3.org/TR/2003/REC-SVG11-20030114/ SVG 1.1]&lt;br /&gt;
* [http://www.w3.org/TR/2008/REC-SVGTiny12-20081222/ SVG Tiny 1.2]&lt;br /&gt;
&lt;br /&gt;
==== Proposed Standards ====&lt;br /&gt;
&lt;br /&gt;
*[http://www.w3.org/Graphics/SVG/WG/wiki/Roadmap Roadmap]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Areas of Inkscape Interest ==&lt;br /&gt;
&lt;br /&gt;
Here are some areas to consider:&lt;br /&gt;
&lt;br /&gt;
=== Multipage document support ===&lt;br /&gt;
&lt;br /&gt;
 Proposed for SVG 1.2 but dropped.&lt;br /&gt;
&lt;br /&gt;
=== Standardizing layers ===&lt;br /&gt;
&lt;br /&gt;
 Creating a standard way to indicate layers. Inkscape uses private attributes.&lt;br /&gt;
&lt;br /&gt;
=== Fancy paths ===&lt;br /&gt;
&lt;br /&gt;
* Patterns along paths,&lt;br /&gt;
* Vector effects.&lt;br /&gt;
* Power stroke.&lt;br /&gt;
&lt;br /&gt;
=== Gradients ===&lt;br /&gt;
&lt;br /&gt;
* Diffusion curves.&lt;br /&gt;
* Mesh gradients.&lt;br /&gt;
&lt;br /&gt;
=== SVG fonts ===&lt;br /&gt;
&lt;br /&gt;
Firefox and IE will not add support for SVG fonts.&lt;br /&gt;
&lt;br /&gt;
=== Filters ===&lt;br /&gt;
&lt;br /&gt;
*Increasing bit depth to reduce artifacts.&lt;br /&gt;
*Margins. (--[[User:Jaspervdg|Jaspervdg]] 13:49, 15 June 2010 (UTC) I would prefer them not to have any attributes for margins.)&lt;br /&gt;
&lt;br /&gt;
=== Cacheable portion/layers ===&lt;br /&gt;
&lt;br /&gt;
*Investigate partial.s cache-ablity&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Release_notes/0.48&amp;diff=62743</id>
		<title>Release notes/0.48</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Release_notes/0.48&amp;diff=62743"/>
		<updated>2010-06-09T13:10:49Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Notable bug fixes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Inkscape 0.48==&lt;br /&gt;
'''(not released yet - [[AnnouncePlanning048]])'''&lt;br /&gt;
&lt;br /&gt;
==Release highlights==&lt;br /&gt;
&lt;br /&gt;
(TODO)&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
===Node Tool===&lt;br /&gt;
&lt;br /&gt;
During Google Summer of Code 2009, the node tool underwent an extensive rewrite. Along with more maintainable code, it brings several new features.&lt;br /&gt;
&lt;br /&gt;
; '''Multi-path editing'''&lt;br /&gt;
: Any number of paths can be selected for node editing at once.&lt;br /&gt;
; '''Improved clippath / mask editing'''&lt;br /&gt;
: The clipping path or mask of an object can be edited at the same time as the object. The clip / mask editing buttons in the node tool are now toggle buttons, rather than mode switch buttons. If the object is transformed after applying a clipping path, the clipping path is no longer offset when editing it in the node tool. If the clipping path is a group, all paths in the group can be edited simultaneously.&lt;br /&gt;
; '''Improved node join'''&lt;br /&gt;
: It is now possible to join nodes from different paths. More than two endnodes can be joined at once—the distances between nodes will be used to determine which nodes to join, with the closest pairs being joined first. When nothing can be joined (less than 2 endnodes in selecion), each selected stretch of nodes will be joined into one node.&lt;br /&gt;
; '''Improved segment join'''&lt;br /&gt;
: It is now possible to create a segment between endnodes from different paths. More than one segment can be created at once—the distances between nodes will be used to determine which nodes to join with a segment, with the closest pairs being joined first. When nothing can be joined (less than 2 endnodes in selection), each selected stretch of nodes will have its middle nodes removed, leaving only one segment.&lt;br /&gt;
; '''Node transforms'''&lt;br /&gt;
: It is now possible to transform the nodes using the mouse and transformation handles similar to those in the selector tool. They can be turned on and off using the button in the node toolbar. When the handles are visible, clicking on a selected node will switch between scaling and rotation mode, instead of selecting only that node. You can also use Shift+H to switch the mode. All other operations work normally when transform handles are shown.&lt;br /&gt;
; '''Path direction tools'''&lt;br /&gt;
: Little harpoons are optionally shown in the middle of each segment, visualizing the direction of the path. This is useful when preparing a guide path for text, setting markers, and debugging extensions and Inkscape itself. The &amp;quot;Reverse&amp;quot; command (Shift+R) reverses the direction of subpaths that have some selected nodes, or all subpaths if the node selection is empty.&lt;br /&gt;
; '''Customizable path update'''&lt;br /&gt;
: Two new preferences allow you to specify when the path and its outline should be updated. Turning off live update of paths will improve performance for complex drawings.&lt;br /&gt;
; '''Improved tips'''&lt;br /&gt;
: The tips displayed for nodes and handles are more concise and affected by what modifier keys are pressed.&lt;br /&gt;
&lt;br /&gt;
For a detailed feature comparison between the old and new tool, see [[GSoC2009 Node Tool Rewrite]].&lt;br /&gt;
&lt;br /&gt;
===Text Tool===&lt;br /&gt;
&lt;br /&gt;
The text toolbar has been overhauled with many bug fixes and improvements. One can now directly access a number of text layout parameters:&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Line Spacing:&amp;quot; Distance between baselines of adjacent lines.&lt;br /&gt;
*&amp;quot;Letter Spacing:&amp;quot; Spacing between letters.&lt;br /&gt;
*&amp;quot;Word Spacing:&amp;quot; Spacing between words.&lt;br /&gt;
*&amp;quot;Horizontal kerning&amp;quot;&lt;br /&gt;
*&amp;quot;Vertical shift&amp;quot;&lt;br /&gt;
*&amp;quot;Character rotation&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In addition, support has been added for superscripts and subscripts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This work was sponsored in part by Inkscape users through LinuxFund.org.&lt;br /&gt;
&lt;br /&gt;
===Spray Tool===&lt;br /&gt;
You first need to select one or several items, then select the Spray Tool. To spray, click on the canvas, then move the mouse or scroll the mouse wheel.&lt;br /&gt;
&lt;br /&gt;
Three modes are available.&lt;br /&gt;
&lt;br /&gt;
*''Spray Copy mode :'' each sprayed item is independent from the others.&lt;br /&gt;
*''Spray Clone mode :'' each sprayed item is a clone of the selected item. Changing the properties of the original item will affect the clones.&lt;br /&gt;
*''Spray Single Path Mode :'' everything you spray is in a single path. You may need to convert your item into a path to make it work properly.&lt;br /&gt;
&lt;br /&gt;
'''Spray options'''&lt;br /&gt;
&lt;br /&gt;
*Amount : spray more or less items.&lt;br /&gt;
&lt;br /&gt;
*Rotation : randomly rotates items around the original rotation value. &lt;br /&gt;
*Scale : randomly scales items around the original scale value. &lt;br /&gt;
&lt;br /&gt;
*Scatter : low values to spray items under the cursor, high values for a more uniform repartition over the spray zone.&lt;br /&gt;
*Focus : items are sprayed following a ring. This parameters modifies the radius of the circle. Default at 0 to spray a spot. &lt;br /&gt;
&lt;br /&gt;
Use keys ↑ and ↓ to control the size of of sprayed items. Use ← and → to set the width of the cursor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Spray tool is a perfect match for the transforming, duplicating, and deleting modes of the Tweak tool.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
==Live Path Effects (LPE)==&lt;br /&gt;
&lt;br /&gt;
===Node tool changes===&lt;br /&gt;
The new node tool means slightly different LPE editing too. Such as ...&lt;br /&gt;
&lt;br /&gt;
===New effects===&lt;br /&gt;
&lt;br /&gt;
* '''Extrude''' Similar to the Python extension &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Import/Export==&lt;br /&gt;
===Improved bitmap image import===&lt;br /&gt;
&lt;br /&gt;
Bitmaps are now always embedded when pixel data is pasted or dragged into Inkscape's window (for example when copying parts of an image from GIMP). Files with automatically generated names like &amp;quot;inkscape_pasted_image_...&amp;quot; are no longer created in the document directory. When importing or opening bitmap images, a dialog is displayed that asks whether you want to link the image or embed it.&lt;br /&gt;
&lt;br /&gt;
===New LaTeX export for PDF/EPS/PS===&lt;br /&gt;
&lt;br /&gt;
Similar to GNUPlot's `epslatex' output terminal and Xfig's combined PDF/LaTeX output, Inkscape can now export graphics to PDF with an accompanying LaTeX file that overlays the text over the PDF when inputted in LaTeX. The image's text is typeset by LaTeX, so for example mathematical expressions are rendered correctly, and all text will be in the font and style of the LaTeX document (even when changing the document's font afterwards).&lt;br /&gt;
&lt;br /&gt;
''(the following description assumes export to PDF, but will work the same for EPS and PS)''&lt;br /&gt;
Two files will be created: a PDF file containing all graphics, without text; and a LaTeX file with the same name, containing all text, and code to include the PDF and overlay the text. To include the exported image in LaTeX, one writes&lt;br /&gt;
&lt;br /&gt;
  \begin{figure} &lt;br /&gt;
    \centering&lt;br /&gt;
    \def\svgwidth{\columnwidth} % sets the image width, this is optional&lt;br /&gt;
    \input{image.tex}&lt;br /&gt;
  \end{figure}&lt;br /&gt;
&lt;br /&gt;
A more thorough description of how to use the new feature (and automate the exporting/inclusion of the image in LaTeX) is given in this PDF: [http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf SVG in LaTeX].&lt;br /&gt;
&lt;br /&gt;
====From the GUI====&lt;br /&gt;
When exporting to PDF/EPS/PS from Inkscape's GUI, the usual dialog pops up after selecting to which PDF/EPS/PS file to export to. In this dialog, you can find the PDF/EPS/PS+LaTeX option.&lt;br /&gt;
&lt;br /&gt;
====Command line option====&lt;br /&gt;
When exporting to PDF/EPS/PS from the command line, adding --export-latex will turn the LaTeX export on. For example&lt;br /&gt;
&lt;br /&gt;
  inkscape image.svg -z -D --export-pdf=image.pdf --export-latex&lt;br /&gt;
&lt;br /&gt;
===Fixed PDF/EPS/PS export of non-integer sized documents===&lt;br /&gt;
The long standing [https://bugs.launchpad.net/inkscape/+bug/168275 bug 168275] has now been fixed. Documents with a non-integer height or width are now correctly exported to PDF, EPS and PS.&lt;br /&gt;
&lt;br /&gt;
==Extensions==&lt;br /&gt;
===New and improved extensions===&lt;br /&gt;
&lt;br /&gt;
* The new '''Generate from Path &amp;gt; Voronoi Pattern''' extension creates a random pattern of Voronoi cells. The pattern will be accessible from the Fill and Stroke dialog. The pattern can be made to be smooth at the edges by choosing a positive border, or sparse at the edges by using a negative border.&lt;br /&gt;
* The new '''Render &amp;gt; Wireframe Sphere''' extension draws the globe as a collection of ellipses representing a sphere's latitude and longitude lines. The number of lines is adjustable, as well as the tilt and rotation. There is an option to hide the lines at the back of the sphere.&lt;br /&gt;
* The new '''Render &amp;gt; Barcode - Datamatrix''' extension renders a DataMatrix 2D barcode, as specified in BS ISO/IEC 16022:2006. The number of rows and columns of the DataMatrix is adjustable. If more data is given than can be contained in one DataMatrix, more than one DataMatrix will be produced.&lt;br /&gt;
* The new '''Modify Path &amp;gt; Pixelsnap''' extension aligns rectangles and paths to pixel boundaries, to create sharp web and digital graphics.&lt;br /&gt;
* The new '''Color &amp;gt; Black and White''' extension turns the selection colors into black and white.&lt;br /&gt;
* The new '''Text &amp;gt; Split Text''' extension splits texts into different lines, words or letters.&lt;br /&gt;
&amp;lt;!--* The new '''JessyInk''' extension for creating presentations viewable in browsers, See&lt;br /&gt;
https://launchpad.net/jessyink --&amp;gt;&lt;br /&gt;
* The new '''Web &amp;gt; Slicer''' extensions to slice web layouts into multiple images and help the HTML+CSS creation.&lt;br /&gt;
* '''Images &amp;gt; Extract Image''': all relative paths (or filenames without path) are now relative to the user's home directory.&lt;br /&gt;
* '''Visualize Path &amp;gt; Measure Path''': new option to calculate area.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Filters== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SVG Support==&lt;br /&gt;
&lt;br /&gt;
The baseline-shift attribute is now read in and used. The Text toolbar uses the &amp;quot;super&amp;quot; and &amp;quot;sub&amp;quot; values for implementing superscripts and subscripts. At the moment there is no other GUI access to the attribute.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Editing Aids== --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other features==&lt;br /&gt;
&lt;br /&gt;
* Arch paper sizes are added in the Document Properties dialog&lt;br /&gt;
* Displaying the '''font samples''' in the drop-down list of the Text tool is now optional. In Inkscape Preferences, go to Tools, Text, and uncheck &amp;quot;Show font samples in the drop-down list&amp;quot; if you don't want to see the samples. This will speed up displaying the list the first time you open it&lt;br /&gt;
* Items in the File &amp;gt; Open Recent menu, when mouseovered, show tooltips with the full URI of each file in the list. Also, files that are in the list but are missing or unaccessible are automatically hidden&lt;br /&gt;
* When a flowed text is truncated (i.e. the frame is too small for the entire text), the frame is shown red, and the statusbar hint includes '''[truncated]'''. You need to resize the frame to see the truncated end of the text. Analogously, if the path of a text-on-path object is too short to display the entire text, the statusbar will report it as '''[truncated]'''&lt;br /&gt;
* Clicking the text alignment buttons (Left, Center, Right) on the Text tool's controls bar now does not let the text jump: it stays within the same bounding box as before, only changing the alignment&lt;br /&gt;
* The position of text's baseline anchor (the small square) is now dependent of the alignment: for left-aligned text it is, as before, at the left end, for centered text in the middle, and for the right-aligned text it is at the right end of the text's first line (this is for horizontal text; for vertical, it is correspondingly at top, middle, or bottom of the first column). This allows snapping, aligning and distributing of text relative the side to which it's aligned&lt;br /&gt;
* Snapping of gradient handles has been improved and now behaves similar to the snapping of all other handles and objects&lt;br /&gt;
* When snapping to a bounding box, that bounding box will be shown for a moment (tied to the snap indicator)&lt;br /&gt;
* If a new object is being created on the canvas with snapping enabled, then a snap indicator will also be shown for the first point&lt;br /&gt;
* There are now options for Margins when resizing a document to a selection or the drawing in Document Properties&lt;br /&gt;
* Preferences have been added to allow automatic grouping when setting a Clippath or Mask&lt;br /&gt;
* Bitmap copies created using the Make a Bitmap Copy command (Alt+B) are now embedded. Previously they were saved in an automatically generated file and linked&lt;br /&gt;
* The file preview size limit (in the File &amp;gt; Open and File &amp;gt; Import dialog box) is now 10 MB (1.3 MB in 0.47)&lt;br /&gt;
* Blur, transformation, and layer visibility and opacity support in XAML export&lt;br /&gt;
&lt;br /&gt;
===Extended input device configuration===&lt;br /&gt;
&lt;br /&gt;
The stock Input Devices dialog has been replaced with a completely redone version that provides a more useful representation of settings. It also contains a simple area for testing different inputs of different devices.&lt;br /&gt;
&lt;br /&gt;
Additionally hardware setup itself has been separated from general settings to allow for easier dynamic switching of settings appropriate to the task at hand.&lt;br /&gt;
&lt;br /&gt;
==User interface==&lt;br /&gt;
&lt;br /&gt;
===Adaptive UI===&lt;br /&gt;
(In progress [[User:JonCruz|JonCruz]])&lt;br /&gt;
&lt;br /&gt;
===Custom Swatches===&lt;br /&gt;
&lt;br /&gt;
Custom swatches can be created and used on a per-document basis. An &amp;quot;Auto&amp;quot; color palette will track swatches in the current document and allow them to be set and used. The use is &amp;quot;live&amp;quot; with changes to the swatch being applied automatically to all objects set to it. The swatches can also be gradients and not just simple colors.&lt;br /&gt;
&lt;br /&gt;
===New cursors in Selector===&lt;br /&gt;
&lt;br /&gt;
Selector tool has a new mouse cursor (arrow with an open hand) for when your mouse is over a selectable object, and another (arrow with clinched hand) for when you're dragging an object. This improves precision of selection and UI consistency (previously, the mouse cursor over a selectable object was different across platforms, e.g. hand icon on Linux or four-way arrow on Windows).&lt;br /&gt;
&lt;br /&gt;
===Translations===&lt;br /&gt;
&lt;br /&gt;
New Farsi translation (in progress).&lt;br /&gt;
&lt;br /&gt;
==Tutorials==&lt;br /&gt;
&lt;br /&gt;
* SVG files are now optimized with Scour (filesize reduced by 40%).&lt;br /&gt;
* Bitstream Vera fonts replaced with generic sans and serif fonts (solves many font substitution issues).&lt;br /&gt;
* New Interpolate tutorial (Help &amp;gt; Tutorials &amp;gt; Inkscape: Interpolate).&lt;br /&gt;
* New translations in Farsi, Belarussian and Dutch.&lt;br /&gt;
&lt;br /&gt;
==Windows port improvements==&lt;br /&gt;
&lt;br /&gt;
The quality of the Windows port was improved substantially.&lt;br /&gt;
&lt;br /&gt;
===Command line interface===&lt;br /&gt;
&lt;br /&gt;
Command line functionality on Windows is now on par with Unix.&lt;br /&gt;
&lt;br /&gt;
'''Single executable'''&lt;br /&gt;
:It's no longer needed to compile Inkscape with special flags or use third-party wrapper executables to see the command line output. Just type &amp;quot;inkscape&amp;quot; (without any extension) in the command prompt. This is made possible by a command-line wrapper named &amp;lt;tt&amp;gt;inkscape.com&amp;lt;/tt&amp;gt;.&lt;br /&gt;
'''Relative paths'''&lt;br /&gt;
:You can now specify relative paths to files in options like &amp;lt;tt&amp;gt;--export-png&amp;lt;/tt&amp;gt;. Commands like this will now execute correctly:&lt;br /&gt;
 C:\svg&amp;gt; inkscape tiger.svgz --export-png=tiger.png&lt;br /&gt;
&lt;br /&gt;
===Stability improvements===&lt;br /&gt;
&lt;br /&gt;
Thanks to library updates, Inkscape should no longer randomly crash when editing documents. Most of them were caused by a GDI resource leak in Pango. It will also no longer crash when trying to import a corrupted image.&lt;br /&gt;
&lt;br /&gt;
===Unicode compatibility===&lt;br /&gt;
&lt;br /&gt;
Inkscape will now work correctly regardless of installation path. Previously, it was unusable when installed into a directory that contains characters not representable in the system codepage (icons were not shown in the UI, and no language files were found).&lt;br /&gt;
&lt;br /&gt;
==Notable bug fixes==&lt;br /&gt;
&lt;br /&gt;
* The 3D tool no longer inserts an inkscape:perspective element into SVG when it is not needed (i.e. when the document has no 3D box objects).&lt;br /&gt;
* Wrong clippaths and masks with cyclic recursion (i.e. clippaths or masks that refer to themselves via other clippaths or masks) no longer crash Inkscape.&lt;br /&gt;
* Default unit setting for the XY grid is now respected when creating a new grid.&lt;br /&gt;
* Pasting Live Path Effect stacks now works. It adds the stack of the copied object to the end of the LPE stack (if present) of the object it is pasted to.&lt;br /&gt;
* The accuracy of the bounding box calculation has been significantly improved when converting objects to patterns or markers. This should make it much easier to create patterns where the tiles should 'connect' to each other, e.g. a tile with a plus sign to create a hatched pattern.&lt;br /&gt;
* The default font has been changed to ''Sans'', eliminating problems when the former default font, ''Bitstream Vera Sans'', is not available. (''Sans'' is a Pango pseudo-font.)&lt;br /&gt;
* The Text toolbar bold and italic/oblique buttons are more likely to work as expected.&lt;br /&gt;
* Bitmaps with transparency are now shown (and exported) correctly.&lt;br /&gt;
* The emergency save function no longer mangles the file names (which used to make it fail quite often).&lt;br /&gt;
&lt;br /&gt;
==Known issues==&lt;br /&gt;
&lt;br /&gt;
==Previous releases==&lt;br /&gt;
&lt;br /&gt;
* [[ReleaseNotes047]]&lt;br /&gt;
* [[ReleaseNotes046]]&lt;br /&gt;
* [[ReleaseNotes045]]&lt;br /&gt;
* [[ReleaseNotes044]]&lt;br /&gt;
* [[ReleaseNotes043]]&lt;br /&gt;
* [[ReleaseNotes042]]&lt;br /&gt;
* [[ReleaseNotes041]]&lt;br /&gt;
* [[ReleaseNotes040]]&lt;br /&gt;
* [[ReleaseNotes039]]&lt;br /&gt;
* [[ReleaseNotes038]]&lt;br /&gt;
* [[ReleaseNotes037]]&lt;br /&gt;
* [[ReleaseNotes036]]&lt;br /&gt;
* [[ReleaseNotes035]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Marketing]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62437</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62437"/>
		<updated>2010-05-30T08:13:31Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Representation */ Another alternative&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
Instead of defining a group that gets diffused it may also make sense to use subpaths and diffuse those:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;path d=&amp;quot;M 0,0 L 190,190 M 500,500 L 150,0&amp;quot;&lt;br /&gt;
       leftBoundary=&amp;quot;#F00 #00F #F70 #7F0&amp;quot; rightBoundary=&amp;quot;#00F #F00 #0F7 #07F&amp;quot;&lt;br /&gt;
       boundaryBlur=&amp;quot;5&amp;quot; diffuse=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers either use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62407</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62407"/>
		<updated>2010-05-29T14:23:17Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images (although it's not too bad, the gradients compress ''very'' well).&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers either use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**- A mesh is apparently hard to render in a high quality manner on existing renderers (at least Batik has problems with rendering the triangles precisely).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;br /&gt;
*An initial implementation: https://code.launchpad.net/~jaspervdg/+junk/diffuselib&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Talk:NewFromTemplateSpec&amp;diff=62383</id>
		<title>Talk:NewFromTemplateSpec</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Talk:NewFromTemplateSpec&amp;diff=62383"/>
		<updated>2010-05-29T12:09:52Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Notation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Point on the current template selector==&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
The current system in order to choose a template is deprecated. It's simply a list in the menu (see picture).&lt;br /&gt;
# You can't '''parametrize''' templates (width, height, border, ...).&lt;br /&gt;
# You can't easily '''add''' new templates.&lt;br /&gt;
# You can't '''visualize''' templates before choice.&lt;br /&gt;
# The list don't respect any '''order'''.&lt;br /&gt;
# Templates are not '''categorized'''  (CD, DVD, screen, ...).&lt;br /&gt;
# Templates '''names''' don't respect specifications:&lt;br /&gt;
#* Some contains '''_''' between words (like icon_16x16).&lt;br /&gt;
#* Some templates are in '''french''' (like &amp;quot;Défaut&amp;quot;) and others in '''english''' (like &amp;quot;business_card_...&amp;quot;).&lt;br /&gt;
# Template list is '''too long'''. It can cause problem for netbooks.&lt;br /&gt;
# You can't make template be one of your '''favourites''' or &amp;quot;recently used&amp;quot;.&lt;br /&gt;
# '''Commons templates''' of the &amp;quot;Document properties dialog&amp;quot; '''are not present''' (like A3, B2, US Letter, ...)&lt;br /&gt;
# You can't '''choose the units''' for your new drawing.&lt;br /&gt;
|&lt;br /&gt;
[[File:Template_Selector_0.47.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 21:54, 4 March 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== About attributes ==&lt;br /&gt;
Is it possible to add completely new attributes into a svg file ? like:&lt;br /&gt;
 &amp;lt;sodipodi:namedview&lt;br /&gt;
    inkscape:template-name=&amp;quot;Web banner 728x90&amp;quot;&lt;br /&gt;
    inkscape:template-name-fr=&amp;quot;Bannière Web 728x90&amp;quot;&lt;br /&gt;
    inkscape:template-category=&amp;quot;Web/Banner&amp;quot;&lt;br /&gt;
    inkscape:template-description=&amp;quot;A banner for a website, size: 728x90 px&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
 /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, is &amp;quot;sodipodi:namedview&amp;quot; the correct markup for template attributes ?&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 10:11, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
:Yes, it is possible (we use custom attributes quite a lot in Inkscape). But do it with some care. For example, the category attribute will probably be necessary, but possibly you can just use an existing property for some of the others. --[[User:Jaspervdg|Jaspervdg]] 12:07, 29 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Categories names ==&lt;br /&gt;
=== Translations ===&lt;br /&gt;
Do we have to traduce categories names ? If yes, we can add new attributes in svg files, like :&lt;br /&gt;
    inkscape:template-category-fr=&amp;quot;Fond d'écran&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See ya [[User:Binnette|Binnette]] 09:52, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Notation ===&lt;br /&gt;
Should we use underscore between words ? like :&lt;br /&gt;
    inkscape:template-category=&amp;quot;Paper_sizes&amp;quot;&lt;br /&gt;
or can we simply use:&lt;br /&gt;
    inkscape:template-category=&amp;quot;Paper sizes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 09:55, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
:I'd go with spaces.&lt;br /&gt;
&lt;br /&gt;
== Keywords ==&lt;br /&gt;
I think that keywords are optionals, because they must be traduced in too many languages. And there is categories in order to find templates. Should we use them or not ?&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 09:56, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Currents categories ==&lt;br /&gt;
=== Background ===&lt;br /&gt;
Is &amp;quot;background&amp;quot; the same category as &amp;quot;Desktop&amp;quot; ? [[User:Binnette|Binnette]] 09:57, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Defaults ===&lt;br /&gt;
&amp;quot;default_mm.svg&amp;quot; and &amp;quot;default_pt.svg&amp;quot; don't respect specifications. Must be &amp;quot;default.mm.svg&amp;quot; and &amp;quot;default.pt.svg&amp;quot;. Is it correct ? [[User:Binnette|Binnette]] 09:59, 15 May 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Talk:NewFromTemplateSpec&amp;diff=62377</id>
		<title>Talk:NewFromTemplateSpec</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Talk:NewFromTemplateSpec&amp;diff=62377"/>
		<updated>2010-05-29T12:07:28Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* About attributes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Point on the current template selector==&lt;br /&gt;
{|&lt;br /&gt;
|&lt;br /&gt;
The current system in order to choose a template is deprecated. It's simply a list in the menu (see picture).&lt;br /&gt;
# You can't '''parametrize''' templates (width, height, border, ...).&lt;br /&gt;
# You can't easily '''add''' new templates.&lt;br /&gt;
# You can't '''visualize''' templates before choice.&lt;br /&gt;
# The list don't respect any '''order'''.&lt;br /&gt;
# Templates are not '''categorized'''  (CD, DVD, screen, ...).&lt;br /&gt;
# Templates '''names''' don't respect specifications:&lt;br /&gt;
#* Some contains '''_''' between words (like icon_16x16).&lt;br /&gt;
#* Some templates are in '''french''' (like &amp;quot;Défaut&amp;quot;) and others in '''english''' (like &amp;quot;business_card_...&amp;quot;).&lt;br /&gt;
# Template list is '''too long'''. It can cause problem for netbooks.&lt;br /&gt;
# You can't make template be one of your '''favourites''' or &amp;quot;recently used&amp;quot;.&lt;br /&gt;
# '''Commons templates''' of the &amp;quot;Document properties dialog&amp;quot; '''are not present''' (like A3, B2, US Letter, ...)&lt;br /&gt;
# You can't '''choose the units''' for your new drawing.&lt;br /&gt;
|&lt;br /&gt;
[[File:Template_Selector_0.47.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 21:54, 4 March 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== About attributes ==&lt;br /&gt;
Is it possible to add completely new attributes into a svg file ? like:&lt;br /&gt;
 &amp;lt;sodipodi:namedview&lt;br /&gt;
    inkscape:template-name=&amp;quot;Web banner 728x90&amp;quot;&lt;br /&gt;
    inkscape:template-name-fr=&amp;quot;Bannière Web 728x90&amp;quot;&lt;br /&gt;
    inkscape:template-category=&amp;quot;Web/Banner&amp;quot;&lt;br /&gt;
    inkscape:template-description=&amp;quot;A banner for a website, size: 728x90 px&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
 /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, is &amp;quot;sodipodi:namedview&amp;quot; the correct markup for template attributes ?&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 10:11, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
:Yes, it is possible (we use custom attributes quite a lot in Inkscape). But do it with some care. For example, the category attribute will probably be necessary, but possibly you can just use an existing property for some of the others. --[[User:Jaspervdg|Jaspervdg]] 12:07, 29 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Categories names ==&lt;br /&gt;
=== Translations ===&lt;br /&gt;
Do we have to traduce categories names ? If yes, we can add new attributes in svg files, like :&lt;br /&gt;
    inkscape:template-category-fr=&amp;quot;Fond d'écran&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See ya [[User:Binnette|Binnette]] 09:52, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Notation ===&lt;br /&gt;
Should we use underscore between words ? like :&lt;br /&gt;
    inkscape:template-category=&amp;quot;Paper_sizes&amp;quot;&lt;br /&gt;
or can we simply use:&lt;br /&gt;
    inkscape:template-category=&amp;quot;Paper sizes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 09:55, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Keywords ==&lt;br /&gt;
I think that keywords are optionals, because they must be traduced in too many languages. And there is categories in order to find templates. Should we use them or not ?&lt;br /&gt;
&lt;br /&gt;
[[User:Binnette|Binnette]] 09:56, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Currents categories ==&lt;br /&gt;
=== Background ===&lt;br /&gt;
Is &amp;quot;background&amp;quot; the same category as &amp;quot;Desktop&amp;quot; ? [[User:Binnette|Binnette]] 09:57, 15 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Defaults ===&lt;br /&gt;
&amp;quot;default_mm.svg&amp;quot; and &amp;quot;default_pt.svg&amp;quot; don't respect specifications. Must be &amp;quot;default.mm.svg&amp;quot; and &amp;quot;default.pt.svg&amp;quot;. Is it correct ? [[User:Binnette|Binnette]] 09:59, 15 May 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62089</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62089"/>
		<updated>2010-05-17T16:07:06Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Converting to SVG */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering.&lt;br /&gt;
**+ High quality at a specific resolution.&lt;br /&gt;
**- Low quality on zooming in.&lt;br /&gt;
**- Also large for simple images.&lt;br /&gt;
*Using filters (for example, it should be possible to [[Spatially Varying Blur|simulate spatially varying blur]] by doing multiple blurs and combining the results using weights).&lt;br /&gt;
**+ Very low (almost fixed) storage requirements.&lt;br /&gt;
**- Diffusion difficult to implement efficiently (fast solvers either use multigrid methods or kernels of spatially varying size).&lt;br /&gt;
**- Spatially varying blur is difficult to implement with good quality.&lt;br /&gt;
*By solving the Laplace equations on a (Delaunay) triangulation, using barycentric interpolation between the vertices.&lt;br /&gt;
**+ Good quality at any resolution.&lt;br /&gt;
**+ Storage scales directly with the complexity of the image.&lt;br /&gt;
**- Needs &amp;quot;add&amp;quot; (and &amp;quot;in&amp;quot;) compositing, which is only available in filters in SVG 1.1 (it is also available in [http://www.w3.org/TR/SVGCompositing/ SVG Compositing]).&lt;br /&gt;
**Note that other interpolation/approximation schemes can give higher quality result but are also harder to use in the solver (as well as in the resulting SVG).&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62083</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62083"/>
		<updated>2010-05-17T15:44:02Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Mathematical Definition */ Alternative formulations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
Alternatively diffusion curves can be seen as minimizing the integral (over the entire image) of the squared gradient magnitude, with color constraints at certain points. This is convenient when using a representation based on triangles with barycentric interpolation (as this yields a piecewise linear function the Laplacian is zero everywhere, except on the boundaries).&lt;br /&gt;
&lt;br /&gt;
It might also be convenient to use an alternative method for incorporating blur, as simulating a spatially varying blur is not easy. One method might be to use an equation based on the heat equation which can be used for doing a spatially varying blur (&amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; represents the color constraints):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\gamma\frac{\partial}{\partial t}y&amp;amp;=\nabla\cdot(\beta\nabla y)&lt;br /&gt;
\\\gamma(f-C)&amp;amp;=\nabla\cdot(\beta\nabla f)&lt;br /&gt;
\\0&amp;amp;=\nabla\cdot(\beta\nabla f)+\gamma(C-f)&lt;br /&gt;
\\f&amp;amp;=\arg\min_f \int_{\mathbb{R}^2}\frac{1}{2}\|\beta^{1/2}\nabla f\|^2+(C-\frac{1}{2}f)\gamma f\,dx&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or else the color constraints could be applied using the derivative of the colors over each edge in combination with ''the'' color on the edge (which would be the average of the colors on either side). When blurring an edge the derivative would get smaller (by a factor of &amp;lt;math&amp;gt;1/blurRadius&amp;lt;/math&amp;gt; for example).&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering... (Obviously not very appealing.)&lt;br /&gt;
*Using filters (for example, it should be possible to simulate spatially varying blur by doing multiple blurs and combining the results using weights).&lt;br /&gt;
*By solving the Laplace equations on a Delaunay triangulation or something similar, and using ordinary gradients and/or blurs for the finishing touches or to make it possible to use a coarser grid. (This could give problems in the presence of &amp;quot;curved curves&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62071</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62071"/>
		<updated>2010-05-17T14:55:34Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Representation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
The links at the bottom define various features that can be useful for Diffusion Curves. Here the following features are considered:&lt;br /&gt;
&lt;br /&gt;
* Colors at nodes / gradients defined on paths (on one or both sides of the curve)&lt;br /&gt;
&amp;lt;!--* Linking colors (also per side of a curve) --&amp;gt;&lt;br /&gt;
* Diffusion across boundaries&lt;br /&gt;
&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#F00 #00F&amp;quot; rightBoundary=&amp;quot;#00F #F00&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;url(#redToBlue)&amp;quot; rightBoundary=&amp;quot;url(#blueToRed)&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also vary along the path, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering... (Obviously not very appealing.)&lt;br /&gt;
*Using filters (for example, it should be possible to simulate spatially varying blur by doing multiple blurs and combining the results using weights).&lt;br /&gt;
*By solving the Laplace equations on a Delaunay triangulation or something similar, and using ordinary gradients and/or blurs for the finishing touches or to make it possible to use a coarser grid. (This could give problems in the presence of &amp;quot;curved curves&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62053</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=62053"/>
		<updated>2010-05-17T09:37:38Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#redToBlue&amp;quot; rightBoundary=&amp;quot;#blueToRed&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also be defined by a gradient, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering... (Obviously not very appealing.)&lt;br /&gt;
*Using filters (for example, it should be possible to simulate spatially varying blur by doing multiple blurs and combining the results using weights).&lt;br /&gt;
*By solving the Laplace equations on a Delaunay triangulation or something similar, and using ordinary gradients and/or blurs for the finishing touches or to make it possible to use a coarser grid. (This could give problems in the presence of &amp;quot;curved curves&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*PhD thesis (including a method for vectorizing Diffusion Curves): http://artis.imag.fr/Publications/2009/Orz09/&lt;br /&gt;
*Diffusion constraints: http://artis.inrialpes.fr/Publications/2010/BEDT10/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61603</id>
		<title>Spatially Varying Blur</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61603"/>
		<updated>2010-04-26T16:26:36Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spatially varying blur can be important for a number of effects, not the least of which is depth-of-field. Unfortunately SVG does not support this directly and we need to make some approximation of the effect.&lt;br /&gt;
&lt;br /&gt;
One possibility is to do a simple linear interpolation between two blurs, but this tends to give an effective kernel which is only a very poor fit to the true kernel desired, it tends to give a much too sharp result. &lt;br /&gt;
&lt;br /&gt;
This page looks at possibilities for creating an improved spatially varying blur.&lt;br /&gt;
&lt;br /&gt;
== L2-minimized fit ==&lt;br /&gt;
In general the easiest global error metric to minimize is the l2-norm. This is simply (the root of) the integral of the squared error. Which in this case can be formulated as (&amp;lt;math&amp;gt;g(\sigma)&amp;lt;/math&amp;gt; is the kernel of a Gaussian blur with standard deviation &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;G(\sigma_a,\sigma_b)&amp;lt;/math&amp;gt; is the integral of the product of two kernels, &amp;lt;math&amp;gt;\sigma_1&amp;lt;\sigma&amp;lt;\sigma_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;0&amp;lt;a&amp;lt;1&amp;lt;/math&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
e(\sigma,\sigma_1,\sigma_2,a)&amp;amp;=\int_{-\infty}^{\infty}\left[g(\sigma)-\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)\right]^2dx&lt;br /&gt;
\\&amp;amp;=\int_{-\infty}^{\infty}g(\sigma)^2-2g(\sigma)\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)+\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)^2dx&lt;br /&gt;
\\&amp;amp;=G(\sigma,\sigma)-2\left[(1-a)G(\sigma,\sigma_1)+a\,G(\sigma,\sigma_2)\right]+(1-a)^2G(\sigma_1,\sigma_1)+2a(1-a)G(\sigma_1,\sigma_2)+a^2\,G(\sigma_2,\sigma_2)&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equating the derivative to zero (in order to minimize the quadratic equation in &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;) we get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
0&amp;amp;=2\left[G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)\right]-2(1-a)G(\sigma_1,\sigma_1)+2(1-2a)G(\sigma_1,\sigma_2)+2a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\0&amp;amp;=G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)-G(\sigma_1,\sigma_1)+a\,G(\sigma_1,\sigma_1)+G(\sigma_1,\sigma_2)-2a\,G(\sigma_1,\sigma_2)+a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\a&amp;amp;=\frac{G(\sigma,\sigma_2)-G(\sigma,\sigma_1)+G(\sigma_1,\sigma_1)-G(\sigma_1,\sigma_2)}{G(\sigma_1,\sigma_1)-2\,G(\sigma_1,\sigma_2)+G(\sigma_2,\sigma_2)}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&amp;lt;!-- Verified numerically for s,s1,s2=2,1,3 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This uses&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
g(\sigma)&amp;amp;=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-x^2/(2\sigma^2)}&lt;br /&gt;
\\G(\sigma_a,\sigma_b)&amp;amp;=\frac{1}{\sqrt{2\pi(\sigma_a^2+\sigma_b^2)}}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- I think it's probably just best to use feComponentTransfer with type=table&lt;br /&gt;
&lt;br /&gt;
Filling in and simplifying we get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
a&amp;amp;=\frac{G(\sigma,\sigma_2)-G(\sigma,\sigma_1)+G(\sigma_1,\sigma_1)-G(\sigma_1,\sigma_2)}{G(\sigma_1,\sigma_1)-2\,G(\sigma_1,\sigma_2)+G(\sigma_2,\sigma_2)}&lt;br /&gt;
\\&amp;amp;=\frac{\frac{1}{\sqrt{2\pi(\sigma^2+\sigma_2^2)}}-\frac{1}{\sqrt{2\pi(\sigma^2+\sigma_1^2)}}+\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_1^2)}}-\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_2^2)}}}{\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_1^2)}}-2\,\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_2^2)}}+\frac{1}{\sqrt{2\pi(\sigma_2^2+\sigma_2^2)}}}&lt;br /&gt;
\\&amp;amp;=\frac{\frac{1}{\sqrt{\sigma^2+\sigma_2^2}}-\frac{1}{\sqrt{\sigma^2+\sigma_1^2}}+\frac{1}{\sqrt{\sigma_1^2+\sigma_1^2}}-\frac{1}{\sqrt{\sigma_1^2+\sigma_2^2}}}{\frac{1}{\sqrt{\sigma_1^2+\sigma_1^2}}-2\,\frac{1}{\sqrt{\sigma_1^2+\sigma_2^2}}+\frac{1}{\sqrt{\sigma_2^2+\sigma_2^2}}}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61585</id>
		<title>Spatially Varying Blur</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61585"/>
		<updated>2010-04-26T11:32:57Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spatially varying blur can be important for a number of effects, not the least of which is depth-of-field. Unfortunately SVG does not support this directly and we need to make some approximation of the effect.&lt;br /&gt;
&lt;br /&gt;
One possibility is to do a simple linear interpolation between two blurs, but this tends to give an effective kernel which is only a very poor fit to the true kernel desired, it tends to give a much too sharp result. &lt;br /&gt;
&lt;br /&gt;
This leads to wanting to create a better fitting interpolation between the two blurs.&lt;br /&gt;
&lt;br /&gt;
== L2-minimized fit ==&lt;br /&gt;
In general the easiest global error metric to minimize is the l2-norm. This is simply (the root of) the integral of the squared error. Which in this case can be formulated as (&amp;lt;math&amp;gt;g(\sigma)&amp;lt;/math&amp;gt; is the kernel of a Gaussian blur with standard deviation &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;G(\sigma_a,\sigma_b)&amp;lt;/math&amp;gt; is the integral of the product of two kernels, &amp;lt;math&amp;gt;\sigma_1&amp;lt;\sigma&amp;lt;\sigma_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;0&amp;lt;a&amp;lt;1&amp;lt;/math&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
e(\sigma,\sigma_1,\sigma_2,a)&amp;amp;=\int_{-\infty}^{\infty}\left[g(\sigma)-\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)\right]^2dx&lt;br /&gt;
\\&amp;amp;=\int_{-\infty}^{\infty}g(\sigma)^2-2g(\sigma)\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)+\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)^2dx&lt;br /&gt;
\\&amp;amp;=G(\sigma,\sigma)-2\left[(1-a)G(\sigma,\sigma_1)+a\,G(\sigma,\sigma_2)\right]+(1-a)^2G(\sigma_1,\sigma_1)+2a(1-a)G(\sigma_1,\sigma_2)+a^2\,G(\sigma_2,\sigma_2)&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equating the derivative to zero (in order to minimize the quadratic equation in &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;) we get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
0&amp;amp;=2\left[G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)\right]-2(1-a)G(\sigma_1,\sigma_1)+2(1-2a)G(\sigma_1,\sigma_2)+2a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\0&amp;amp;=G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)-G(\sigma_1,\sigma_1)+a\,G(\sigma_1,\sigma_1)+G(\sigma_1,\sigma_2)-2a\,G(\sigma_1,\sigma_2)+a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\a&amp;amp;=\frac{G(\sigma,\sigma_2)-G(\sigma,\sigma_1)+G(\sigma_1,\sigma_1)-G(\sigma_1,\sigma_2)}{G(\sigma_1,\sigma_1)-2\,G(\sigma_1,\sigma_2)+G(\sigma_2,\sigma_2)}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&amp;lt;!-- Verified numerically for s,s1,s2=2,1,3 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This uses&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
g(\sigma)&amp;amp;=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-x^2/(2\sigma^2)}&lt;br /&gt;
\\G(\sigma_a,\sigma_b)&amp;amp;=\frac{1}{\sqrt{2\pi(\sigma_a^2+\sigma_b^2)}}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- I think it's probably just best to use feComponentTransfer with type=table&lt;br /&gt;
&lt;br /&gt;
Filling in and simplifying we get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
a&amp;amp;=\frac{G(\sigma,\sigma_2)-G(\sigma,\sigma_1)+G(\sigma_1,\sigma_1)-G(\sigma_1,\sigma_2)}{G(\sigma_1,\sigma_1)-2\,G(\sigma_1,\sigma_2)+G(\sigma_2,\sigma_2)}&lt;br /&gt;
\\&amp;amp;=\frac{\frac{1}{\sqrt{2\pi(\sigma^2+\sigma_2^2)}}-\frac{1}{\sqrt{2\pi(\sigma^2+\sigma_1^2)}}+\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_1^2)}}-\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_2^2)}}}{\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_1^2)}}-2\,\frac{1}{\sqrt{2\pi(\sigma_1^2+\sigma_2^2)}}+\frac{1}{\sqrt{2\pi(\sigma_2^2+\sigma_2^2)}}}&lt;br /&gt;
\\&amp;amp;=\frac{\frac{1}{\sqrt{\sigma^2+\sigma_2^2}}-\frac{1}{\sqrt{\sigma^2+\sigma_1^2}}+\frac{1}{\sqrt{\sigma_1^2+\sigma_1^2}}-\frac{1}{\sqrt{\sigma_1^2+\sigma_2^2}}}{\frac{1}{\sqrt{\sigma_1^2+\sigma_1^2}}-2\,\frac{1}{\sqrt{\sigma_1^2+\sigma_2^2}}+\frac{1}{\sqrt{\sigma_2^2+\sigma_2^2}}}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61537</id>
		<title>Spatially Varying Blur</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Spatially_Varying_Blur&amp;diff=61537"/>
		<updated>2010-04-23T12:25:53Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Start&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spatially varying blur can be important for a number of effects, not the least of which is depth-of-field. Unfortunately SVG does not support this directly and we need to make some approximation of the effect.&lt;br /&gt;
&lt;br /&gt;
One possibility is to do a simple linear interpolation between two blurs, but this tends to give an effective kernel which is only a very poor fit to the true kernel desired, it tends to give a much too sharp result. &lt;br /&gt;
&lt;br /&gt;
This leads to wanting to create a better fitting interpolation between the two blurs.&lt;br /&gt;
&lt;br /&gt;
== L2-minimized fit ==&lt;br /&gt;
In general the easiest global error metric to minimize is the l2-norm. This is simply (the root of) the integral of the squared error. Which in this case can be formulated as (&amp;lt;math&amp;gt;g(\sigma)&amp;lt;/math&amp;gt; is the kernel of a Gaussian blur with standard deviation &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;G(\sigma_a,\sigma_b)&amp;lt;/math&amp;gt; is the integral of the product of two kernels, &amp;lt;math&amp;gt;\sigma_1&amp;lt;\sigma&amp;lt;\sigma_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;0&amp;lt;a&amp;lt;1&amp;lt;/math&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
e(\sigma,\sigma_1,\sigma_2,a)&amp;amp;=\int_{-\infty}^{\infty}\left[g(\sigma)-\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)\right]^2dx&lt;br /&gt;
\\&amp;amp;=\int_{-\infty}^{\infty}g(\sigma)^2-2g(\sigma)\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)+\left((1-a)g(\sigma_1)+a\,g(\sigma_2)\right)^2dx&lt;br /&gt;
\\&amp;amp;=G(\sigma,\sigma)-2\left[(1-a)G(\sigma,\sigma_1)+a\,G(\sigma,\sigma_2)\right]+(1-a)^2G(\sigma_1,\sigma_1)+2a(1-a)G(\sigma_1,\sigma_2)+a^2\,G(\sigma_2,\sigma_2)&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equating the derivative to zero (in order to minimize the quadratic equation in &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;) we get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
0&amp;amp;=2\left[G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)\right]-2(1-a)G(\sigma_1,\sigma_1)+2(1-2a)G(\sigma_1,\sigma_2)+2a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\0&amp;amp;=G(\sigma,\sigma_1)-\,G(\sigma,\sigma_2)-G(\sigma_1,\sigma_1)+a\,G(\sigma_1,\sigma_1)+G(\sigma_1,\sigma_2)-2a\,G(\sigma_1,\sigma_2)+a\,G(\sigma_2,\sigma_2)&lt;br /&gt;
\\a&amp;amp;=\frac{G(\sigma_1,\sigma_1)-G(\sigma_1,\sigma_2)-(G(\sigma,\sigma_1)-G(\sigma,\sigma_2))}{G(\sigma_1,\sigma_1)-2\,G(\sigma_1,\sigma_2)+G(\sigma_2,\sigma_2)}&lt;br /&gt;
.\end{align}&amp;lt;/math&amp;gt;&amp;lt;!-- Verified numerically for s,s1,s2=2,1,3 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;g(\sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-x^2/(2\sigma^2)}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;G(\sigma_a,\sigma_b)=\frac{1}{\sqrt{2\pi(\sigma_a^2+\sigma_b^2)}}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=55453</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=55453"/>
		<updated>2009-12-29T18:03:43Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* More */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
This page was started as part of the response to [https://bugs.launchpad.net/inkscape/+bug/346681 bug 346681], mainly to provide an alternative for a bitmap fallback.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
===Arctan approximation quality===&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
Note that this approximation method corresponds to the approximation [http://dspguru.com/comp.dsp/tricks/alg/fxdatan2.htm described here] for quadrant 1 (with the roles of x and y reversed, just like in the graph above), scaled by &amp;lt;math&amp;gt;2/\pi&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\frac{2}{\pi}\cdot\frac{\pi}{4}\left(1-\frac{y-x}{x+y}\right)&amp;amp;=\frac{1}{2}\left(1-\frac{y-x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y}{x+y}+\frac{x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y+x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{2x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{x+y}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]], as well as [[Diffusion_Curves|this Wiki page]] for information on attempts to make Diffusion Curves suitable for implementation in Inkscape.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=55395</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=55395"/>
		<updated>2009-12-28T15:30:49Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Representation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#redToBlue&amp;quot; rightBoundary=&amp;quot;#blueToRed&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also be defined by a gradient, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
Normally diffusion curves will have infinite extent, but this can be controlled when needed by surrounding a set of curves with a closed path that has an outside boundary which is fully transparent.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering... (Obviously not very appealing.)&lt;br /&gt;
*Using filters (for example, it should be possible to simulate spatially varying blur by doing multiple blurs and combining the results using weights).&lt;br /&gt;
*By solving the Laplace equations on a Delaunay triangulation or something similar, and using ordinary gradients and/or blurs for the finishing touches or to make it possible to use a coarser grid. (This could give problems in the presence of &amp;quot;curved curves&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=55393</id>
		<title>Diffusion Curves</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Diffusion_Curves&amp;diff=55393"/>
		<updated>2009-12-28T15:29:08Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Created page with '[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the ...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://artis.imag.fr/Publications/2008/OBWBTS08/ Diffusion Curves] are a way of specifying very free form gradients. It works by letting colors diffuse from curves, seeding the colors along both sides of the curves using gradients (along the curves). Additionally a varying amount of blur can be applied along the curves. This makes diffusion curves extremely flexible and very interesting to have in Inkscape.&lt;br /&gt;
&lt;br /&gt;
==Representation==&lt;br /&gt;
Diffusion curves could be represented by paths with gradients attached to them, along with an enclosing group that says that the colors should be diffused within that group. For example (don't mind the exact attributes):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g diffuse=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;path d=&amp;quot;M 0,0 L 190,190&amp;quot;&lt;br /&gt;
         leftBoundary=&amp;quot;#redToBlue&amp;quot; rightBoundary=&amp;quot;#blueToRed&amp;quot; boundaryBlur=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming that the two gradients are made to go from #F00 to #00F and vice versa this would roughly look like this (note that this is just a rough approximation):&lt;br /&gt;
&lt;br /&gt;
[[Image:DiffusionCurveSimulation.png]]&lt;br /&gt;
&lt;br /&gt;
Note that with diffusion curves the blur itself can also be defined by a gradient, which could be used in the above image to let the edge be sharper in some areas. This is useful for depth of field effects for example.&lt;br /&gt;
&lt;br /&gt;
==Mathematical Definition==&lt;br /&gt;
Diffusion curves are defined as the solution to a Laplace equation (the sum of second partial derivatives is zero) with boundary conditions (the colors on the curves). This is done for both the colors and the blur and then a spatially varying blur is applied to the diffused colors using the diffused blur values.&lt;br /&gt;
&lt;br /&gt;
==Converting to SVG==&lt;br /&gt;
There would be several possible avenues for converting diffusion curves to SVG:&lt;br /&gt;
*Bitmap rendering... (Obviously not very appealing.)&lt;br /&gt;
*Using filters (for example, it should be possible to simulate spatially varying blur by doing multiple blurs and combining the results using weights).&lt;br /&gt;
*By solving the Laplace equations on a Delaunay triangulation or something similar, and using ordinary gradients and/or blurs for the finishing touches or to make it possible to use a coarser grid. (This could give problems in the presence of &amp;quot;curved curves&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
==Questions/Problems==&lt;br /&gt;
*If diffusion curves are indeed represented by paths inside a group, what happens with subgroups or shapes without having gradients defined along their edges?&lt;br /&gt;
*What should happen with 2D objects (filled shapes and strokes) in diffusion groups?&lt;br /&gt;
**It might actually be interesting to not only set colors and blur values (heat capacity?) along the sides of edges (1D), but also for surfaces (2D). This shouldn't complicate things much. In fact, it might even be slightly easier to handle the 2D case properly (as it is easier to discretize for example).&lt;br /&gt;
*It might be interesting to redefine them in some way that unifies the color diffusion and blurring. E.g. currently colors are either to be met exactly or not at all, is it possible to reformulate the problem in such a way that we can restrict colors to varying degrees?&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*Original paper: http://artis.imag.fr/Publications/2008/OBWBTS08/&lt;br /&gt;
*Faster/better solver: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-solver/&lt;br /&gt;
*Application of diffusion curves to texture rendering: http://www.cg.tuwien.ac.at/research/publications/2009/jeschke-09-rendering/&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55391</id>
		<title>File:DiffusionCurveSimulation.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55391"/>
		<updated>2009-12-28T15:07:39Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: uploaded a new version of &amp;quot;File:DiffusionCurveSimulation.png&amp;quot;: Better edges.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example of what a diffusion curve might (roughly) look like.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55389</id>
		<title>File:DiffusionCurveSimulation.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55389"/>
		<updated>2009-12-28T15:01:39Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: uploaded a new version of &amp;quot;File:DiffusionCurveSimulation.png&amp;quot;: Including blur.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example of what a diffusion curve might (roughly) look like.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55387</id>
		<title>File:DiffusionCurveSimulation.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:DiffusionCurveSimulation.png&amp;diff=55387"/>
		<updated>2009-12-28T14:55:50Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Example of what a diffusion curve might (roughly) look like.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example of what a diffusion curve might (roughly) look like.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Testing_Inkscape&amp;diff=54807</id>
		<title>Testing Inkscape</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Testing_Inkscape&amp;diff=54807"/>
		<updated>2009-11-17T10:24:54Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Rendering tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Testing Inkscape ==&lt;br /&gt;
&lt;br /&gt;
Inkscape is a young project and the emphasis is still on adding features. Nonetheless it is gratifying that the stability of Inkspace has been steadily rising with each release.&lt;br /&gt;
&lt;br /&gt;
The most important part of 'Testing' is simply to use Inkscape for [[FAQ#Is_Inkscape_ready_for_regular_users_to_use.3F|normal work]] -- confirming that Inkscape has reached this level of maturity, exercise the new features and verify that the application works as expected.&lt;br /&gt;
&lt;br /&gt;
[http://bugs.launchpad.net/inkscape/ Report a bug] if you find anything that does not behave as it should. A bug report should include at least a step-by-step description of how to trigger the bug and/or a test file that demonstrates the bug (the smaller/more focussed the test file the better).&lt;br /&gt;
&lt;br /&gt;
? Follow up&lt;br /&gt;
&lt;br /&gt;
=== Users ===&lt;br /&gt;
&lt;br /&gt;
The field is wide open. We are keen to receive [http://bugs.launchpad.net/inkscape/ bug reports] and feature requests (in the form of a bug report). These often require analysis, clarification and further action. Anyone can do this.&lt;br /&gt;
&lt;br /&gt;
Better still would be to provide patches for any part of the application that is not up to the standard you expect - it is confirmation that the project is evolving. Note that serious testing should be done with an 'unstable' build, either one that you made yourself (see [[CompilingInkscape]]), or a snapshot that you have downloaded. We would also like to hear about areas in which we do not have parity with comparable applications. If you find that you are coming up with interesting ideas concerning shortcomings in Inkscape, or plans for its future, get involved with the Inkscape testers group.&lt;br /&gt;
&lt;br /&gt;
We need people to create and update documentation, online help, tutorials and screen shots. Noting defects in these is a perfectly valid form of testing - we do not want releases to go out with obsolete documentation.&lt;br /&gt;
&lt;br /&gt;
=== Inkscape Testers ===&lt;br /&gt;
&lt;br /&gt;
A community of Inkscape testers has grown up which has its own  [http://lists.sourceforge.net/lists/listinfo/inkscape-tester mailing list], and it is to be hoped that this will spearhead all work on usability and human factors. This group should be your first port of call for these areas:&lt;br /&gt;
&lt;br /&gt;
* [[ComplianceTesting]]&lt;br /&gt;
* [[RegressionTesting]]&lt;br /&gt;
* [[InteroperabilityTesting]]&lt;br /&gt;
* [[UsabilityTesting]]&lt;br /&gt;
* [[PerformanceTesting]]&lt;br /&gt;
* [[HIG compliance]]&lt;br /&gt;
&lt;br /&gt;
See also [[TestingFramework]].&lt;br /&gt;
Note: Bryce? Jon? shouldn't the whole of that page be merged here? Or is it better to have this info in two pieces. IMHO wiki pages should not be made too long.&lt;br /&gt;
&lt;br /&gt;
=== Rendering tests ===&lt;br /&gt;
&lt;br /&gt;
In addition, Inkscape has rendering tests that do not necessarily need a developer to create, run and analyze. The actual tests can be found in SVN (see below). Below you can find information on how to run and create these tests yourself.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:larger;&amp;quot;&amp;gt;See [http://auriga.mine.nu/inkscape/ this list] for up-to-date results.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Running rendering tests ====&lt;br /&gt;
Apart from running low-level unit tests Inkscape can also be tested on a higher level (also see [[SVG Test Suite Compliance]]. Currently (2008-7-26) there is a rendering test tool (along with a few test cases) in SVN ([https://inkscape.svn.sourceforge.net/svnroot/inkscape/gsoc-testsuite/tester/]) which can be used to partially automate rendering tests.&lt;br /&gt;
&lt;br /&gt;
To run the rendering tests:&lt;br /&gt;
&lt;br /&gt;
* If needed, compile tester.cpp using 'g++ -o tester tester.cpp' (there is a precompiled .exe in SVN for Windows users).&lt;br /&gt;
* Execute runtests.py. If needed you can specify Inkscape's path and a few other things (execute 'runtests.py --help' to see which options are available).&lt;br /&gt;
&lt;br /&gt;
Note that by default only a binary comparison between the output and reference files is used, [http://pdiff.sourceforge.net/ perceptualdiff] (or any other comparison tool that returns zero on success and 1 on failure) can be used to aid comparison of images (see the available options of runtests.py). Note that perceptualdiff (1.0.2) had some problems with transparency, these might be solved by now, and if not, there is a patch in its patch tracker.&lt;br /&gt;
&lt;br /&gt;
To select a subset of tests to perform, specify one or more patterns (with Unix-style wildcards) on the command line. Each pattern is interpreted as specifying a prefix. For example, 'runtest.py bugs' will match any tests whose path relative to the directory with test cases starts with 'bugs' (for example: 'bugsy.svg' or 'bugs/bugXYZ.svg').&lt;br /&gt;
&lt;br /&gt;
The most common test results are:&lt;br /&gt;
* Pass (the output file was matched to a pass reference)&lt;br /&gt;
* Fail (the output file was matched to a fail reference)&lt;br /&gt;
* New (the output file was not matched to any reference)&lt;br /&gt;
* No references (there were no references at all)&lt;br /&gt;
&lt;br /&gt;
runtests.py puts the output files in a subdirectory 'output' (at the same level as the 'testcases' and 'references' directories).&lt;br /&gt;
&lt;br /&gt;
==== Creating rendering tests ====&lt;br /&gt;
Just put an SVG file in the 'testcases' directory (subdirectories can be used for organizing the tests).&lt;br /&gt;
&lt;br /&gt;
To add a pass/fail reference, just put it in the corresponding location under references/pass or references/fail. References are matched by prefix, so any reference that has the original name (without its extension) as a prefix is seen as a reference for that file.&lt;br /&gt;
&lt;br /&gt;
Fail references are used to distinguish between a result that is known wrong and a result that is just (perhaps only slightly) different from the correct rendering. If you are unable to create a pass reference you can even give just a fail reference.&lt;br /&gt;
&lt;br /&gt;
It is also possible to create an SVG file that should produce the exact same output as a test case but uses simpler (or just different) methods. This practice is suggested in the [http://www.w3.org/Graphics/SVG/Test/svgTest-manual.htm#GeneratingthePNG SVG Conformance Test Plan]. For example, if the test case file is called 'testcases/basic/foo.svg' you could create a &amp;quot;patch&amp;quot; file called 'testcases/basic/foo-patch.svg'. runtests.py would then use Inkscape to create a pass reference file from that (as 'references/pass/basic/foo-patch.svg') and use it as one of the references. (Note that this reference should in general not be committed to SVN.)&lt;br /&gt;
&lt;br /&gt;
=== Developers ===&lt;br /&gt;
&lt;br /&gt;
==== Build report ====&lt;br /&gt;
There is an 'inkscape build report; which is sent regularly to the inkscape-tester list (and periodically to the developer list, when new problems are seen) that gives a count of warnings spotted in the code.&lt;br /&gt;
&lt;br /&gt;
* Smoketests&lt;br /&gt;
* Defects in the build system&lt;br /&gt;
&lt;br /&gt;
==== Running unit tests ====&lt;br /&gt;
There are now some unit tests which should be performed before checking in. These may take some time to complete, and so this cannot be made a requirement for each build (Test Driven Development), nonetheless everyone is on their honour not to 'break the build' by committing code that does not pass these tests. You can execute them by:&lt;br /&gt;
* Linux: Just run 'make check', it will build and run them. It should also work on Mac OS X.&lt;br /&gt;
* Windows: Use 'buildtool check' (where buildtool is built using 'g++ -O3 -o buildtool buildtool.cpp) to build and run the unit tests. Alternatively you can use dist-all-check to build everything AND run the unit tests.&lt;br /&gt;
&lt;br /&gt;
Cxxtests will generate two (more or less equivalent) result files, an XML file and a text file with the extension 'log'. On Linux, those files are located in (buildpath)/src.&lt;br /&gt;
&lt;br /&gt;
==== Creating unit tests ====&lt;br /&gt;
Inkscape uses the [http://cxxtest.sourceforge.net/ CxxTest] framework. To enhance, modify or extend existing unit tests, just edit the existing test file (....-test.h).&lt;br /&gt;
&lt;br /&gt;
The easiest way to create a new test in a directory which already has some unit tests is to simply copy one of the existing test files, strip it (remove anything specific and rename the class, constructors, etc.) and add some test methods. Take the time to look at the different ASSERT statements CxxTest supports, the TSM_ variants can be especially useful for example when you want to test a lot of different cases. '''Important:''' to make everything build correctly you have to do the following:&lt;br /&gt;
* Add the file to the right (already existing) group in the cxxtest target in build.xml&lt;br /&gt;
* Append the file to the CXXTEST_TESTSUITES variable in dir/Makefile_insert. Watch the backslashes at the end of the lines. Note that you have to prefix &amp;quot;$(srcdir)/dir/&amp;quot; to your filename, since it is a normal variable not handled by Automake, and you have to use += rather than =, because you're appending to this variable rather than defining it.&lt;br /&gt;
&lt;br /&gt;
 # Do like this:&lt;br /&gt;
 CXXTEST_TESTSUITES += \&lt;br /&gt;
     $(srcdir)/dir/first-test.h \&lt;br /&gt;
     $(srcdir)/dir/second-test.h&lt;br /&gt;
&lt;br /&gt;
For creating a unit test in a directory which does not have any unit tests yet:&lt;br /&gt;
&lt;br /&gt;
* Update the Windows build system:&lt;br /&gt;
** Add a cxxtestpart group to the cxxtest target in build.xml (just copy and modify an existing one).&lt;br /&gt;
** &lt;br /&gt;
** Add the corresponding .o file to the exclude list of the lib target in build.xml and to the include list of the linkcxxtests target.&lt;br /&gt;
* For Unix, no changes other than adding the file to CXXTEST_TESTSUITES in Makefile_insert are necessary.&lt;br /&gt;
&lt;br /&gt;
==== Running tests unattended ====&lt;br /&gt;
For unit tests this is no problem, just set up something that runs cxxtests and you can use one of the log files it creates to see how it went.&lt;br /&gt;
&lt;br /&gt;
To be able to run the rendering tests unattended on Windows you have to compile Inkscape as a commandline executable to prevent any CRT runtime error dialog boxes (or something similar) from popping up. On Linux and other Unices, this problem doesn't exist.&lt;br /&gt;
&lt;br /&gt;
The teststatus.json file that is generated by runtests.py contains all the test results (in [http://www.json.org/ JSON] format). Note that if you only run a subset of the tests this file retains all the information on tests that do not fall into that subset. It also retains old test results. The result codes in this file can be interpreted as in runtests.py (for example, 0, 1 and 2 stand for pass, fail and new, respectively).&lt;br /&gt;
&lt;br /&gt;
==== Analyzing test coverage ====&lt;br /&gt;
To see how well the (unit) tests cover certain parts of the code, or to compare the coverage of rendering tests vs. unit tests, gcov can be used. See [[Profiling]] for more information on how to use gcov and coverage.py (a tool to get some grip on the massive amounts of data gcov can generate).&lt;br /&gt;
&lt;br /&gt;
[[Category:Help Wanted]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Testing&amp;diff=54805</id>
		<title>Testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Testing&amp;diff=54805"/>
		<updated>2009-11-17T10:20:55Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Redirected page to Testing Inkscape&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Testing_Inkscape]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=TestingInkscape&amp;diff=54803</id>
		<title>TestingInkscape</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=TestingInkscape&amp;diff=54803"/>
		<updated>2009-11-17T10:19:41Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Redirected page to TestingInkscape&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[TestingInkscape]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Testing&amp;diff=54801</id>
		<title>Testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Testing&amp;diff=54801"/>
		<updated>2009-11-17T10:19:09Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Redirected page to TestingInkscape&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[TestingInkscape]]&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52245</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52245"/>
		<updated>2009-05-08T12:30:27Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Conical gradient */ Some more info on arctan approximation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
This page was started as part of the response to [https://bugs.launchpad.net/inkscape/+bug/346681 bug 346681], mainly to provide an alternative for a bitmap fallback.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
===Arctan approximation quality===&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
Note that this approximation method corresponds to the approximation [http://dspguru.com/comp.dsp/tricks/alg/fxdatan2.htm described here] for quadrant 1 (with the roles of x and y reversed, just like in the graph above), scaled by &amp;lt;math&amp;gt;2/\pi&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
\frac{2}{\pi}\cdot\frac{\pi}{4}\left(1-\frac{y-x}{x+y}\right)&amp;amp;=\frac{1}{2}\left(1-\frac{y-x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y}{x+y}+\frac{x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{x+y+x-y}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{2}\left(\frac{2x}{x+y}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{x+y}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52243</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52243"/>
		<updated>2009-05-08T11:09:16Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Link to bug.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
This page was started as part of the response to [https://bugs.launchpad.net/inkscape/+bug/346681 bug 346681], mainly to provide an alternative for a bitmap fallback.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52241</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52241"/>
		<updated>2009-05-08T11:01:49Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Formal derivation of feDiffuseLighting method */ Cosine vs. angle can be quite visible.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but this may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52239</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52239"/>
		<updated>2009-05-08T09:30:25Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Spiral gradient */ Math formatting.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52221</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52221"/>
		<updated>2009-05-07T16:00:07Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Conical gradient */ Math formatting.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;2/r&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; (Manhattan) distance to the center (&amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt;) instead of the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; (Euclidean) distance. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_2&amp;lt;/math&amp;gt; distance to the center (the cosine) or &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; divided by the &amp;lt;math&amp;gt;l_1&amp;lt;/math&amp;gt; distance to the center (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the SVG 1.1 specification the surface normal is defined by using a Sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the [0,1] range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52219</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=52219"/>
		<updated>2009-05-07T15:51:57Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Separating shape/pattern from color */ Nicer formatting (less detail).&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;\frac{2}{r}&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by &amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt; instead of &amp;lt;math&amp;gt;\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by a cosine (&amp;lt;math&amp;gt;\frac{x}{\sqrt{x^2+y^2}}&amp;lt;/math&amp;gt;) or &amp;lt;math&amp;gt;\frac{x}{|x|+|y|}&amp;lt;/math&amp;gt; (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as &amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt; (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality). Per the SVG 1.1 specification the surface normal is defined by using a sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the [0,1] range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50384</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50384"/>
		<updated>2009-04-17T12:07:26Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Conical gradient */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f:\mathbb{R}^2\rightarrow[0,1]&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;\frac{2}{r}&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by &amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt; instead of &amp;lt;math&amp;gt;\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;. This results in the following (note that this SVG uses the alpha component for computations and apparently Batik has some problems with this):&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
The following graph shows the difference between approximating the angle by a cosine (&amp;lt;math&amp;gt;\frac{x}{\sqrt{x^2+y^2}}&amp;lt;/math&amp;gt;) or &amp;lt;math&amp;gt;\frac{x}{|x|+|y|}&amp;lt;/math&amp;gt; (note that in this graph the roles of x and y are reversed, as this corresponds better to how angles are normally defined):&lt;br /&gt;
&lt;br /&gt;
[[Image:AngleApproximationQuality.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as &amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt; (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality). Per the SVG 1.1 specification the surface normal is defined by using a sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the [0,1] range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:AngleApproximationQuality.png&amp;diff=50374</id>
		<title>File:AngleApproximationQuality.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:AngleApproximationQuality.png&amp;diff=50374"/>
		<updated>2009-04-17T12:06:32Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Graph showing that &amp;lt;math&amp;gt;\frac{y}{|x|+|y|}&amp;lt;/math&amp;gt; gives a (much) better estimate of the angle than a sine (&amp;lt;math&amp;gt;\frac{y}{\sqrt{x^2+y^2}}&amp;lt;/math&amp;gt;). Note that the blue line is the ideal line.&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:AngleApproximationQuality.png&amp;diff=50364</id>
		<title>File:AngleApproximationQuality.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:AngleApproximationQuality.png&amp;diff=50364"/>
		<updated>2009-04-17T12:05:28Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: Graph showing that &amp;lt;math&amp;gt;\frac{y}{|x|+|y|}&amp;lt;/math&amp;gt; gives a (much) better estimate of the angle than a sine (&amp;lt;math&amp;gt;\frac{y}{\sqrt{x^2+y^2}}&amp;lt;/math&amp;gt;).&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Graph showing that &amp;lt;math&amp;gt;\frac{y}{|x|+|y|}&amp;lt;/math&amp;gt; gives a (much) better estimate of the angle than a sine (&amp;lt;math&amp;gt;\frac{y}{\sqrt{x^2+y^2}}&amp;lt;/math&amp;gt;).&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50354</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50354"/>
		<updated>2009-04-17T11:37:41Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Conical gradient */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f:\mathbb{R}^2\rightarrow[0,1]&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;\frac{2}{r}&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by &amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt; instead of &amp;lt;math&amp;gt;\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;. This results in the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as &amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt; (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality). Per the SVG 1.1 specification the surface normal is defined by using a sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the [0,1] range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50344</id>
		<title>Advanced Gradients</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Advanced_Gradients&amp;diff=50344"/>
		<updated>2009-04-17T11:36:01Z</updated>

		<summary type="html">&lt;p&gt;Jaspervdg: /* Conical gradient */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.&lt;br /&gt;
&lt;br /&gt;
==Separating shape/pattern from color==&lt;br /&gt;
Any gradient can be defined by a mapping &amp;lt;math&amp;gt;f:\mathbb{R}^2\rightarrow[0,1]&amp;lt;/math&amp;gt; from any point in the plane to a value in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, combined with a mapping from the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt; to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.&lt;br /&gt;
&lt;br /&gt;
For each new gradient type it suffices to find a good method of generating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy. An example for a gradient from red to green to blue to transparent black (assumes we are in a filter definition and an image with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; on all four channels is in &amp;quot;f&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;feComponentTransfer in=&amp;quot;f&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncR type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 0 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncG type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 1 0 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncB type=&amp;quot;table&amp;quot; tableValues=&amp;quot;0 0 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feFuncA type=&amp;quot;table&amp;quot; tableValues=&amp;quot;1 1 1 0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/feComponentTransfer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three images below show an example as it is rendered by the browser, Inkscape and Batik. As can be seen the quality of the gradient is degraded in the top area, where the alpha values are low, likely due to the use of premultiplied alpha. It should be possible to fix this by separating &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; into an opaque color component and an alpha-only component, applying the component transfer tables separately and then combining them again.&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientCT.svg]]&lt;br /&gt;
[[Image:LineargradientCT-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientCT-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is pre-processed properly. Specifically, the values of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if &amp;lt;math&amp;gt;(x1,y1),(x2,y2)&amp;lt;/math&amp;gt; defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that &amp;lt;math&amp;gt;x1+scale*0.5=x2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;x2-scale*0.5=x1&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;scale=2(x2-x1)&amp;lt;/math&amp;gt;. The x displacement channel should then be set to a channel corresponding to the pre-processed &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the y displacement channel should then be set to some channel that is 0.5 everywhere. An example for the same gradient as above (we are in a defs element, the red channel is assumed to correspond to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and the green channel to one, the bounding box is assumed to be &amp;lt;math&amp;gt;(0,0),(1,1)&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolstops&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientstops&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#f00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.33&amp;quot; stop-color=&amp;quot;#0f0&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0.67&amp;quot; stop-color=&amp;quot;#00f&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; stop-opacity=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;150&amp;quot; height=&amp;quot;150&amp;quot; fill=&amp;quot;url(#gradientstops)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;g id=&amp;quot;symbolxoffset&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;linearGradient id=&amp;quot;gradientxoffset&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;0&amp;quot; stop-color=&amp;quot;#F00&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;stop offset=&amp;quot;1&amp;quot; stop-color=&amp;quot;#000&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/linearGradient&amp;gt;&lt;br /&gt;
   &amp;lt;rect width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; fill=&amp;quot;url(#gradientxoffset)&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/g&amp;gt;&lt;br /&gt;
 &amp;lt;filter ...&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolxoffset&amp;quot; result=&amp;quot;xoffset&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feComposite in=&amp;quot;f&amp;quot; in2=&amp;quot;xoffset&amp;quot; result=&amp;quot;fp&amp;quot; operator=&amp;quot;arithmetic&amp;quot; k2=&amp;quot;0.5&amp;quot; k3=&amp;quot;0.5&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feImage xlink:href=&amp;quot;#symbolstops&amp;quot; result=&amp;quot;stops&amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;feDisplacementMap in=&amp;quot;stops&amp;quot; in2=&amp;quot;fp&amp;quot; scale=&amp;quot;2&amp;quot; xChannelSelector=&amp;quot;R&amp;quot; yChannelSelector=&amp;quot;G&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/filter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last method has the advantage that there is a more direct correspondence with the gradient stops defined by the user (and does not use an approximation to the gradient as the feComponentTransfer method), but it is obviously also more complex. Also, if the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; needs a (non-linear) correction this can directly be taken into account in the feComponentTransfer method. However, the feComponentTransfer method can give a lower quality result if the alpha channel is also part of the gradient (and the viewer uses premultiplied alpha).&lt;br /&gt;
&lt;br /&gt;
The three images below show a linear gradient colored with the feDisplacementMap method, rendered by the browser, Inkscape and Batik. Clearly this method alleviates the problems with using premultiplied alpha that the feComponentTransfer method has. However, to avoid sampling just outside the defined area the linear gradient has been scaled a bit, and with it &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; (as this is more precise than scaling &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
[[Image:LineargradientDM.svg]]&lt;br /&gt;
[[Image:LineargradientDM-Inkscape.png]]&lt;br /&gt;
[[Image:LineargradientDM-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
==Conical gradient==&lt;br /&gt;
&amp;quot;A gradient which goes along the circular arc around a center.&amp;quot; In other words (ignoring rotations and so on), given a center &amp;lt;math&amp;gt;(cx,cy)&amp;lt;/math&amp;gt;, the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\frac{1}{2}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One way to mimic a conical gradient is to use a circular gradient to define a conical surface and then use feDiffuseLighting with surfaceScale set to half the radius of the gradient and a distant light source with an elevation of 45 degrees. This doesn't directly result in the right mapping, but it at least shares the property that the pixels on radial lines from the center have the same value. In addition, the generated gradient will be symmetrical, so if this is not wanted the region should be split in two along the symmetry axis.&lt;br /&gt;
&lt;br /&gt;
Another (arguably simpler) way to achieve the exact same effect would be to again use a radial gradient and approximate a directional derivative using a convolution. The offset should now be 0.5 (0 is the &amp;quot;middle&amp;quot; value) and the divisor should be &amp;lt;math&amp;gt;\frac{2}{r}&amp;lt;/math&amp;gt;, assuming the matrix is already properly scaled to truely approximate the gradient.&lt;br /&gt;
&lt;br /&gt;
The following three images show the feDiffuseLighting method (as Batik does not support feConvolveMatrix with a bias) used with the feDisplacementMap as the result appears in the browser, Inkscape and Batik:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMDL.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMDL-inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMDL-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Another method that works both with Inkscape and Batik is to simply compute the cosine directly. This can be done by creating a linear gradient corresponding to the x-coordinate and a radial gradient corresponding to the distance to the center, then computing the reciprocal of the distance function (using feComponentTransfer) and finally multiplying this by the x-coordinate (using appropriate scaling and offset) with feComposite. This has the advantage that no resolution dependent filters are used, but it the precision of the reciprocal is quite low in most (if not all) renderers. Luckily this can, to a great extent, be solved using iterative refinement, resulting in the following images:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
Using the method of multiplying by reciprocal distance we can also define a (much) better approximation to a true conical gradient by dividing by &amp;lt;math&amp;gt;|x|+|y|&amp;lt;/math&amp;gt; instead of &amp;lt;math&amp;gt;\sqrt{x^2+y^2}&amp;lt;/math&amp;gt;. This results in the following:&lt;br /&gt;
&lt;br /&gt;
[[Image:ConicalgradientDMRD2.svg]] &lt;br /&gt;
[[Image:ConicalgradientDMRD2-Inkscape.png]]&lt;br /&gt;
[[Image:ConicalgradientDMRD2-Batik.png]]&lt;br /&gt;
&lt;br /&gt;
===Formal derivation of feDiffuseLighting method===&lt;br /&gt;
To derive the right parameters, first define the (ideal) surface of the cone created by the gradient as &amp;lt;math&amp;gt;Z(x,y)=s-\frac{s}{r}\sqrt{x^2+y^2}&amp;lt;/math&amp;gt; (setting the center to &amp;lt;math&amp;gt;(0,0)&amp;lt;/math&amp;gt; without loss of generality). Per the SVG 1.1 specification the surface normal is defined by using a sobel filter, however, as this is a reasonable approximation of a directional derivative we use the derivative instead. Specifically, taking the right scale factors into account, the surface normal is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
N'_x(x,y)&amp;amp;=-2 \frac{\partial}{\partial x}Z(x,y)&lt;br /&gt;
\\&amp;amp;=\frac{2sx}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_y(x,y)&amp;amp;=\frac{2sy}{r\sqrt{x^2+y^2}}&lt;br /&gt;
\\N'_z(x,y)&amp;amp;=1&lt;br /&gt;
\\N(x,y)&amp;amp;=\frac{N'}{\|N\|}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming a distant (white) light source with a zero azimuth and a diffuse lighting constant of one, the intensity of the resulting image can now be computed as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=N(x,y)\cdot L(e)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\|N'(x,y)\|}\left(\frac{2sx}{r\sqrt{x^2+y^2}}\cos(e)+\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}\sqrt{x^2+y^2}}\left(2sx\cos(e)+r\sqrt{x^2+y^2}\sin(e)\right)&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get a nice gradient we can now demand that &amp;lt;math&amp;gt;D(x,0)&amp;lt;/math&amp;gt; is zero for negative &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and one for positive &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and solve for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,0)&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}|x|}\left(2sx\cos(e)+r|x|\sin(e)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\mbox{sign}(x)\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\D(x_-,0)&amp;amp;=0&lt;br /&gt;
\\0&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(-2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\2s\cos(e)&amp;amp;=r\sin(e)&lt;br /&gt;
\\\frac{\sin(e)}{\cos{e}}&amp;amp;=\frac{2s}{r}&lt;br /&gt;
\\e&amp;amp;=\arctan(\frac{2s}{r})&lt;br /&gt;
\\D(x_+,0)&amp;amp;=1&lt;br /&gt;
\\1&amp;amp;=\frac{1}{\sqrt{4s^2+r^2}}\left(2s\cos(e)+r\sin(e)\right)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=2r\sin(e)&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{r\sqrt{\frac{4s^2}{r^2}+1}}&lt;br /&gt;
\\\sqrt{4s^2+r^2}&amp;amp;=\frac{4rs}{\sqrt{\frac{4s^2}+r^2}}&lt;br /&gt;
\\4s^2+r^2&amp;amp;=4rs&lt;br /&gt;
\\4s^2-4rs+r^2&amp;amp;=0&lt;br /&gt;
\\(2s-r)^2&amp;amp;=0&lt;br /&gt;
\\s&amp;amp;=\frac{1}{2}r&lt;br /&gt;
\\e&amp;amp;=\arctan(1)&lt;br /&gt;
\\&amp;amp;=\frac{1}{4}\pi&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So surfaceScale should be half of the radius of the radial gradient and the elevation of the light source should be 45 degrees. By filling in this result in &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; it is apparent that the intensity now corresponds exactly to the cosine of the angle we are really interested in with a conical gradient (scaled and translated to fit in the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\begin{align}&lt;br /&gt;
D(x,y)&amp;amp;=\frac{1}{\sqrt{4(\frac{1}{2}r)^2+r^2}\sqrt{x^2+y^2}}\left(2\frac{1}{2}rx\cos(\frac{1}{4}\pi)+r\sqrt{x^2+y^2}\sin(\frac{1}{4}\pi)\right)&lt;br /&gt;
\\&amp;amp;=\frac{1}{\sqrt{2}\sqrt{x^2+y^2}}\left(x\frac{1}{\sqrt{2}}+\sqrt{x^2+y^2}\frac{1}{\sqrt{2}}\right)&lt;br /&gt;
\\&amp;amp;=\frac{x}{2\sqrt{x^2+y^2}}+\frac{1}{2}&lt;br /&gt;
\end{align}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a perfect result it should now be taken into account that we have a cosine and not an angle, but the difference is not very big and it may not always be an issue.&lt;br /&gt;
&lt;br /&gt;
==Spiral gradient==&lt;br /&gt;
Here defined as similar to a conical gradient, but with the mapping &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; also depending on the distance to the center. Specifically &amp;lt;math&amp;gt;f(x,y)=\frac{1}{2\pi}\arctan(y-cy,x-cx)+\sqrt{(x-cx)^2+(y-cy)^2}\mod 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a conical gradient can be created then this can be created by simply adding the distance to the center. If needed use can be made of the fact that modular arithmetic is used (that is, a long steep gradient is equivalent to many small, equally steep, gradients).&lt;br /&gt;
&lt;br /&gt;
To avoid overflow in the mapping it can be scaled by 0.5, allowing two &amp;quot;periods&amp;quot; in the [0,1] range. In this case the mapping to colors should be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
==More==&lt;br /&gt;
Diffusion curves? See [[http://artis.imag.fr/Publications/2008/OBWBTS08/]].&lt;/div&gt;</summary>
		<author><name>Jaspervdg</name></author>
	</entry>
</feed>