Gnome-print colors, gradients proposal


I will extend gnome-print painter model a bit, and would like to
hear your opinion about the following infrastructure:


  typedef void


  struct G2DColorDeviceRGBA {
    gdouble c[4];

As much as I do not like the idea of including opacity into
colorspace, there seems to be no way to avoid it.

We also need some way to specify 'packed color' of bitmap images.

Object G2DColorSpace
Is placeholder for real colorspace support. Initially will have
single virtual method

  void (* get_device_rgba) (G2DColorSpace *cs,
                            G2DColor *color,
                            gdouble overall_opacity,
                            G2DColorDeviceRGBA *rgbacolor)

Well, that sucks in many ways, but I'd like to have upward compatible
way for setting colors for what follows.

Specifies gradient span blending mode

  enum {

Specifies single span inside gradient vector

  struct G2DGradientSpan {
    G2DColorSpanType type;
    gdouble length;

Specifies 1D gradient vector. There should be num_spans spans and
num_spans + 1 stops. Stops are colorspace-specific color structs.
Zero-length spans are allowed - to specify color jumps in gradient.

  struct G2DGradientVector {
    G2DColorSpace colorspace;
    gint num_spans;
    G2DGradientSpan *spans;
    G2DColor *stops;

Spread type - i.e. what to at the end of gradient vector

  enum {

Abstract base (class? - I am not sure, whether to do these
G(tk)Objects) of gradients.

  struct G2DGradient {
    G2DGradientVector vector;
    G2DGradientSpread spread_type;
    gdouble transform[6];

Transform specifies affine transformation from gradient coordinate
system to current (object) user coordinate system.
All gradients are painted relative to (0,0 - 1,1) box in gradient
coordinates. Vector is scaled, so the sum of all spans is equal to 1.

Linear gradient

  struct G2DLinearGradient {
    G2DGradient gradient;

Linear gradients are painted along (0,0 - 1,0) vector in gradient
coordinate system.


  struct G2DRadialGradient {
    G2DGradient gradient;
    gdouble fx, fy;

Radial gradient is painted as circle, touching the inside of
(0,0 - 1,1) box, with focal point (starting color) at fx, fy.


  struct G2DRasterImage {
    G2DColorSpace colorspace;
    gint width, height, rowstride;
    G2DColor *pixels;

Rowstride is given in real color units (i.e. bytes/sizeof (color))

Specifies filling by tiled raster images

  struct G2DRasterFill {
    gdouble transform[6];
    G2DRasterImage *image;

Each raster image is painted to (0,0 - 1,1) box in fill coordinate
system, transform specifies transformation from fill coordinates to
user coordinates.

What is missing, is vector fill, but I do not like to touch these,
before I have some internal infrastructure thought out.
I have used G2D as namespace. If this sounds too prentensious, I can
go with gp too ;)

The model does not have to be complete, but I'd like to have it to
be extensible enough to cover most needs. So feel free to critisize

Best wishes,
Lauris Kaplinski

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]