Gnome-print colors, gradients proposal



Hello!

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

G2DColor
=========================

  typedef void

G2DColorDeviceRGBA
=========================

  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.

G2DColorSpanType
==========================
Specifies gradient span blending mode

  enum {
    G2D_COLOR_SPAN_LINEAR,
    G2D_COLOR_SPAN_SINUSOIDAL
  };

G2DGradientSpan
==========================
Specifies single span inside gradient vector

  struct G2DGradientSpan {
    G2DColorSpanType type;
    gdouble length;
  };

G2DGradientVector
===========================
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;
  };

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

  enum {
    G2D_GRADIENT_SPREAD_PAD,
    G2D_GRADIENT_SPREAD_REFLECT,
    G2D_GRADIENT_SPREAD_REPEAT
  };

G2DGradient
===========================
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.

G2DLinearGradient
===========================
Linear gradient

  struct G2DLinearGradient {
    G2DGradient gradient;
  };

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

G2DRadialGradient
===========================

  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.

G2DRasterImage
===========================

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

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

G2DRasterFill
===========================
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
it.

Best wishes,
Lauris Kaplinski







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