That's EXACTLY what PDF does with an Axial Shading (ISO 32000-1:2008,
8.7.4.5.3). You define a color "range" (with stop points along the way, if you
wish) and then you apply it to a shape.
Why Java2D doesn't give you that is beyond me? I can't speak to iText's APIs
either.
Leonard
From: Jarrod Smith [mailto:[email protected]]
Sent: Sunday, February 26, 2012 11:38 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] How to smoothly interpolate color along a path?
Thanks Leonard,
GradientPaint is a pretty terrible way of doing it though. I have long,
complicated paths made up of thousands of curveTo() commands. Say I want one
end of one of these paths to be RGB(255, 0, 0) and the other end to be RGB(0,
0, 0).
That means I have to:
* Construct many GradientPaints - using some heuristic to decide when the
curvature of the path is "straight" enough for the color change along the curve
to be approximated by a linear gradient for that section.
* Split up the path into a segment per GradientPaint. This makes the PDF far
bigger than it otherwise would be.
What would be simpler is to just specify a colour per "vertex" on the paths
(i.e. curveTo(x, y, color)), and have the PDF renderer interpolate between
these colours when it draws. It's odd that a vector format doesn't support this
since the whole point is to parametrise the information needed to render the
vector image - in my case I'm forced to artificially quantize the information
to get a poor approximation of the desired result.
On Thu, Feb 23, 2012 at 11:35 PM, Leonard Rosenthol
<[email protected]<mailto:[email protected]>> wrote:
I can't speak to Java2D, but a linear gradient is indeed the correct way to do
this with PDF.
And performance is certainly going to related to the rendering system - of
which Acrobat/Reader do just fine :).
Leonard
From: Jarrod Smith
[mailto:[email protected]<mailto:[email protected]>]
Sent: Thursday, February 23, 2012 4:24 AM
To:
[email protected]<mailto:[email protected]>
Subject: [iText-questions] How to smoothly interpolate color along a path?
I'm from a 3D rendering background where this is trivial to do, but I can't
find how to do this in iText (or Java2D for that matter):
Say I have points A, B and colors cA, cB.
The points are joined together by a curveTo() command. I want the colors to
smoothly interpolate between each point. i.e. point A is color cA, point B is
color cB, and the color of the line between A and B linearly interpolates
between cA and cB.
I've tried stroking with a gradient fill but for my purposes it is far too
slow, and also produces inaccurate results since I am actually joining up
thousands of these curve segments into long continuous curves.
It seems like good 'ole point to point linear color interpolation isn't
supported in either Java2D or iText?
Thanks for any help,
Jarrod
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php