> Of course - you can have as many colors as you want (provided they
> are all in the same colorspace).
Just making sure. :)
> You will definitely need to read the PDF Reference/ISO 32000-1 in
> order to understand how to encode such things, since it is more
> complex than a simple gradiants.
Thanks for the reference. I started by exploring section 8.7.4.5.3:
"Type 2 (Axial) Shadings".
However I couldn't find a way to support more than 2 colors. When two
colors are used, you use "C0" and "C1" to define the color at t=0 and
t=1, but I couldn't figure out how to to introduce n-many colors with
a type 2 function. (I tried using floating points, and also
increasing my domain by a factor of 10 so my dictionary included "C0",
"C5", and "C10" (for example).
I gave up on this approach, and then turned to section 7.10.4: "Type 3
(Stitching) Functions". (I'm trying to use a type 2 shading with a
type 3 function.)
My current new PdfShading method is included below.
When I fill a rectangle with this shading... the resulting PDF appears
blank. (Based on previous results, I assume this basically means
there is an error parsing it?)
Soooo... at this point I'm feeling pretty stuck. I don't suppose
anyone has any pointers on what I'm doing wrong? I tried to be
concise in this email, but I could discuss in more detail exactly what
I'm doing if anything is too vague.
Regards,
- Jeremy
The following method I added to PdfShading.java to complement the
"simpleAxial" methods:
public static PdfShading complexAxial(PdfWriter writer, float x0,
float y0, float x1, float y1, Color[] colors,float[] times, boolean
extendStart, boolean extendEnd) {
if(colors.length!=times.length) {
System.err.println("colors.length = "+colors.length);
System.err.println("times.length = "+times.length);
throw new IllegalArgumentException("colors.length must equal
times.length");
}
for(int a = 1; a<colors.length; a++) {
checkCompatibleColors(colors[0], colors[a]);
}
float[][] colorArrays = new float[colors.length][];
for(int a = 0; a<colors.length; a++) {
colorArrays[a] = getColorArray(colors[a]);
}
normalize(times);
PdfFunction[] functions = new PdfFunction[times.length-1];
float[] encode = new float[functions.length*2];
for(int a = 0; a<functions.length; a++) {
functions[a] = PdfFunction.type2(writer,
new float[] {0,1},
null,
colorArrays[a],
colorArrays[a+1],
1);
encode[2*a+0] = 0;
encode[2*a+1] = 1;
}
float[] bounds = new float[functions.length-1];
for(int a = 0; a<bounds.length; a++) {
bounds[a] = times[a+1];
}
PdfFunction function = PdfFunction.type3(writer,
new float[] {0,1},
null,
functions,
bounds,
encode);
return type2(writer, colors[0], new float[]{x0, y0, x1, y1},
null, function, new boolean[]{extendStart, extendEnd});
}
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/