René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Gradient [Ming wrapper class]

The source

Gradient.h
#ifndef GRADIENT_H
#define GRADIENT_H

#include "ming.h"

/* Gradients are smooth transitions between colors. 
   
   Gradients can be linear or radial. (Shape::FillLinear and Shape::FillRadial)
   
   They can contain up to eight colors and can have transparency.
*/
class Gradient {
  friend class Shape;

  public:
    Gradient();

    /*
        ratio: number between 0..1. Components must be added in order of
        increasing ration
    */
    void Add(float ratio, byte r, byte g, byte b, byte a = 0xff);

  private:
    SWFGradient gradient_;
};

#endif
Gradient.cpp
#include "Gradient.h"

Gradient::Gradient() {
  gradient_ = newSWFGradient();
}

void Gradient::Add(float ratio, byte r, byte g, byte b, byte a) {
  SWFGradient_addEntry(gradient_, ratio, r, g, b, a);
}

Examples

The following examples demonstrate this class: