Comments (5)
PDF export functionality has been implemented and merged into master (#28). However, the PDF rendering routines lack support for use of transparent colors since they do not take color alpha into account yet.
For example the helper method for creating a linear color gradient currently ignores alpha.
Support for transparent colors in PDF export is pending.
from jplotter.
I think most renderers are now alpha capable, except for triangles due to some complication with gouraud shading (not allowing for alpha specification of vertex colors?).
I skimmed through the PDF specification and found a section on transparency (section 7). I think we could try and use a softmask as described in section 7.4 to specify transparency for triangles. From what I understood from section 7.4.2 (Deriving a Soft Mask from Group Luminosity), we can create a softmask that will use the luminosity of things drawn into it as alpha. So basically we can draw the triangles in greyscale with their alpha value as grey, and then use this softmask with the actual colored triangles.
@lvcarx what do you think? Maybe there is also a better way
from jplotter.
Yep that solved the issue. Should be working now as expected and i will push it after some more testing. Thank you!
from jplotter.
Since we are currently having some problems with triangle mesh creation for PDF, I had a look again at the specification. Currently we are creating a new PDShadingType4 object including the decode array for every single triangle.
It is however possible to provide a whole stream of triangles for the same shading object, which allows us to save memory and should also improve render performance in PDF readers. This is described in the PDF reference for type 4 shading.
Basically the stream of triangles consists of tuples
f x y c1 .. cn
or in our case f x y r g b
, where each such tuple is a vertex.
f
is a flag with possible values0,1,2
. It specifies how to use the vertices in the stream.0
= start a new triangle. This vertex and the next two vertices will form the triangle. Flags on the next two triangles will be ignored.1
= form a triangle with the second edge of the previous triangle (prev. triangle with vertices {A,B,C}, new triangle with vertices {B,C,D} where D is the current vertex)2
= form a triangle with the third edge of the previous triangle (prev. triangle with vertices {A,B,C}, new triangle with vertices {C,A,D} where D is the current vertex)- Note: In our case we can only use
f=0
because we don't have this implicit triangle mesh structure in theTriangles
class.
x, y
coordinates of the vertex. Integer valued in range0 .. 2^n -1
, wheren
is the number of bits per coordinate.- these coordinates are not used as they are, but transformed to another range of values specified in the decode array of the shading.
- The decode array consists of min,max tuples
[Xmin Xmax Ymin Ymax Rmin Rmax Gmin Gmax Bmin Bmax]
- The
x
coordinate will be transformed tox_new
as follows:
x_normalized := x/(2^n -1)
wheren
is the number of bits per coordinate (fromsetBitsPerCoordinate(16)
)
x_new := x_normalized*(Xmax-Xmin)+Xmin
- Decode arrays in the specification
- Note: In the current code
Xmax
andYmax
are set to(2^n -1) = (2^16 -1) = 0xFFFF
, andXmin=Ymin=0
,
so that the transformation effectively results inx_new := x
.
I think we can consider to do a more sophisticated transform to allow for higher precision ofx_new
than integer values. (later)
r, g, b
color of the vertex. Integer valued in range0 .. 2^m -1
, wherem
is the number of bits per component.- These values are also transformed to a new value range, like the coordinates
x, y
are. - Note: In the current code
m=8
andRmax=Gmax=Bmax=1
so that we transform to normalized color values [0,1]. That's alright.
- These values are also transformed to a new value range, like the coordinates
from jplotter.
released as of bd7cf5c
from jplotter.
Related Issues (20)
- Ready-to-use line chart class
- 64 bit vertex support HOT 8
- Glyph associated with a Points objects does not have to be final
- Global saturation change of basic renderables (Points,Lines, Triangles...)
- Triangle Glyphs broken in GL
- PDF Rendering: rendering issues in various renderers HOT 2
- GUI for exploring/debugging renderers of a canvas HOT 2
- Enhancement - log axes? HOT 3
- Key Masking HOT 2
- make Legend more interactive
- possibility to adapt view to aspect ratio of coordinate system HOT 1
- Line drawing stalls on small ranges HOT 2
- Isolines not rendering the entire view HOT 5
- SVG rendering inconsistency HOT 1
- Overview of the branches' progress currently being developed
- Issue with text rendering in SVG
- BarycentricGradientPaint triangle does not overlap with a triangle painted using drawPolygon HOT 14
- Please help with java.util.ConcurrentModificationException HOT 2
- HiDPI scaling creates flickering and scaling artifacts HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jplotter.