Laxkit
0.0.7.1
|
Handled by GradientInterface. More...
Public Member Functions | |
GradientData () | |
Default constructor, makes a filled circle radius 10. | |
GradientData (flatpoint pp1, flatpoint pp2, double rr1, double rr2, Laxkit::ScreenColor *col1, Laxkit::ScreenColor *col2, unsigned int stle) | |
Create new basic gradient pp1 to pp2. Sets col1 at 0 and col2 at 1. | |
virtual | ~GradientData () |
Empty virtual destructor. | |
virtual void | Set (flatpoint pp1, flatpoint pp2, double rr1, double rr2, Laxkit::ScreenColor *col1, Laxkit::ScreenColor *col2, unsigned int stle) |
Set so gradient is pp1 to pp2. Sets col1 at 0 and col2 at 1. | |
virtual const char * | whattype () |
virtual SomeData * | duplicate (SomeData *dup) |
virtual void | FindBBox () |
Find bounding box of a rectangle for linear, or the circles for radial. | |
virtual int | pointin (flatpoint pp, int pin=1) |
Return if pp transformed to data coords is within the bounds. | |
virtual int | ShiftPoint (int which, double dt) |
Move the color which to a new t position. | |
virtual int | AddColor (double t, int red, int green, int blue, int alpha) |
Place new color in right spot in list. | |
virtual int | AddColor (double t, Laxkit::ScreenColor *col) |
Add a spot with the given color, or interpolated, if col==NULL. | |
virtual int | WhatColor (double t, Laxkit::ScreenColor *col) |
Figure out what color lays at coordinate t. | |
virtual int | WhatColor (double t, double *col) |
Figure out what color lays at coordinate t. | |
virtual int | AddColor (GradientDataSpot *spot) |
Takes pointer, does not make duplicate. | |
virtual void | FlipColors () |
Flip the order of the colors. | |
virtual int | renderToBuffer (unsigned char *buffer, int bufw, int bufh, int bufstride, int bufdepth, int bufchannels) |
Render the whole gradient to a buffer. | |
virtual void | dump_out (FILE *f, int indent, int what, Laxkit::anObject *context) |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *context) |
Public Member Functions inherited from LaxInterfaces::SomeData | |
virtual void | touchContents () |
virtual Laxkit::LaxImage * | GetPreview () |
If usepreview==1 and preview, then return preview. | |
virtual void | GeneratePreview (int w, int h) |
Create a preview image with transparency for a cached screen preview. | |
virtual const char * | Id () |
virtual const char * | Id (const char *newid) |
SomeData () | |
SomeData (double nminx, double nmaxx, double nminy, double nmaxy) | |
Constructor, setting the bounds. | |
virtual flatpoint | BBoxPoint (double x, double y, bool transform_to_parent) |
virtual flatpoint | ReferencePoint (int which, bool transform_to_parent) |
virtual int | fitto (double *boxm, DoubleBBox *box, double alignx, double aligny, int whentoscale=2) |
Fit this data to box. | |
virtual SomeData * | GetParent () |
virtual void | dump_in (FILE *f, int indent, Laxkit::anObject *context, LaxFiles::Attribute **Att=NULL) |
Dump in an attribute, then call dump_in_atts(thatatt,0). | |
virtual LaxFiles::Attribute * | dump_out_atts (LaxFiles::Attribute *att, int what, Laxkit::anObject *savecontext) |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Member Functions inherited from Laxkit::Affine | |
Affine (const double *m) | |
If mm==NULL, set identity. | |
Affine (const Affine &m) | |
Affine (double xx, double xy, double yx, double yy, double tx, double ty) | |
Affine & | operator= (Affine const &m) |
Affine & | operator*= (Affine const &m) |
Affine | operator* (Affine const m) |
virtual void | set (Affine a) |
virtual void | setIdentity () |
virtual bool | isIdentity () |
virtual void | setRotation (double angle) |
virtual void | setScale (double sx, double sy) |
virtual void | setBasis (flatpoint o, flatpoint x, flatpoint y) |
virtual void | setBasics (double x, double y, double sx, double sy, double angle, double shear) |
virtual void | getBasics (double *x, double *y, double *sx, double *sy, double *angle, double *shear) |
virtual void | Translate (flatvector d) |
virtual void | Rotate (double angle) |
virtual void | Rotate (double angle, flatpoint around_point) |
virtual void | RotatePointed (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
virtual void | RotateScale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
Rotate and scale so that anchor1 stays fixed, but anchor2 is shifted to newanchor2. | |
virtual void | Stretch (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
virtual void | AnchorShear (flatpoint anchor1, flatpoint anchor2, flatpoint anchor3, flatpoint newanchor3) |
Transform so that anchor1 and 2 stay fixed, but anchor3 is shifted to newanchor3. | |
virtual void | Scale (double s) |
virtual void | Scale (flatpoint o, double s) |
Scale around point o. | |
virtual void | Scale (flatpoint o, double sx, double sy) |
virtual void | Scale (flatpoint anchor1, flatpoint anchor2, flatpoint newanchor2) |
Scale as if you move anchor2 to newanchor2, while anchor1 stays the same. | |
virtual void | FlipH () |
virtual void | FlipV () |
virtual void | Flip (flatpoint f1, flatpoint f2) |
Flip across the axis of f1 to f2. | |
virtual void | Multiply (Affine &m) |
this=this*m | |
virtual void | PreMultiply (Affine &m) |
this=m*this | |
virtual Affine | Inversion () |
Return a new matrix that is the inverse of this, if possible. | |
virtual void | Invert () |
Make this the inverse of whatever it is. | |
virtual flatpoint | transformPoint (flatpoint p) |
virtual flatpoint | transformPointInverse (flatpoint p) |
virtual flatpoint | transformVector (flatpoint p) |
Apply the transfrom, but ignore this's translation component. | |
virtual const double * | m () const |
virtual void | m (const double *mm) |
virtual void | m (double xx, double xy, double yx, double yy, double tx, double ty) |
virtual double | m (int c) |
virtual void | m (int c, double v) |
virtual void | Unshear (int preserve_x, int normalize) |
Clear shearing and unequal scaling. Null vectors stay null vectors. | |
virtual void | Normalize () |
Make x and y both be unit vectors, but point in the same direction as before. | |
virtual flatpoint | origin () |
virtual void | origin (flatpoint o) |
virtual flatpoint | xaxis () |
virtual void | xaxis (flatpoint x) |
virtual flatpoint | yaxis () |
virtual void | yaxis (flatpoint y) |
Public Member Functions inherited from Laxkit::DoubleBBox | |
DoubleBBox () | |
Create empty invalid bbox (maxx<minx and maxy<miny). | |
DoubleBBox (flatpoint p) | |
Create box whose bounds are p. | |
DoubleBBox (double mix, double max, double miy, double may) | |
Create box whose bounds are as given. | |
virtual void | clear () |
Make box invalid: set minx=miny=0 and maxx=maxy=-1. | |
virtual void | addtobounds (double x, double y) |
virtual void | addtobounds (flatpoint p) |
Expand bounds to contain p. Set the bounds to p if current bounds are invalid. | |
virtual void | addtobounds (DoubleBBox *bbox) |
Add the bbox to the bounds. Set the bounds if current bounds are invalid. | |
virtual void | addtobounds (const double *m, DoubleBBox *bbox) |
Add bbox to bounds, first transforming it by 6 element transform matrix m. | |
virtual void | setbounds (DoubleBBox *bbox) |
Just copy over the bounds. | |
virtual void | setbounds (flatpoint *pts, int n) |
Make this bbox be the bounds for the given n points. (does not add to previous bounds) | |
virtual void | setbounds (double mix, double max, double miy, double may) |
Set the bounds to the specified values. | |
virtual int | validbounds () |
Returns maxx>=minx && maxy>=miny. | |
virtual int | intersect (double mix, double max, double miy, double may, int settointersection=0) |
Intersect the given bounds with this's bounds. Return 1 for non-empty intersection. | |
virtual int | intersect (DoubleBBox *bbox, int settointersection=0) |
Just return intersect(bbox.minx,...,settointersection). | |
virtual int | intersect (double *m, DoubleBBox *bbox, int touching, int settointersection) |
Does the transformed box touch. **** incomplete implementation. | |
virtual int | boxcontains (double x, double y) |
Return whether the given point is contained within or on the bounds. | |
virtual flatpoint | BBoxPoint (double x, double y) |
Public Attributes | |
unsigned int | style |
double | p1 |
double | p2 |
double | r1 |
double | r2 |
double | a |
A displacement to place the color spot line when drawing on screen. | |
Laxkit::PtrStack < GradientDataSpot > | colors |
Public Attributes inherited from LaxInterfaces::SomeData | |
Laxkit::LaxImage * | preview |
A preview image potentially to be used to not have to rerender on each refresh. | |
int | usepreview |
Flag for whether to use SomeData::preview rather than rendering. | |
std::time_t | previewtime |
The time the preview was generated, if at all, as returned by time(). | |
std::time_t | modtime |
The time of last modification through a SomeData function. | |
int | bboxstyle |
flatpoint | centerpoint |
unsigned int | flags |
int | iid |
Id of the interface that should handle this data. | |
char * | nameid |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Public Attributes inherited from Laxkit::DoubleBBox | |
double | minx |
double | maxx |
double | miny |
double | maxy |
Handled by GradientInterface.
Can be a linear or a radial gradient. It is not advisable to move around the color spots manually. Call ShiftPoint(). This is to ensure that the colors.e[] array is ordered from lowest t value to highest. GradientInterfaces places the color spots along the xaxis.
For GRADIENT_RADIAL, the center of the start circle is at (p1,0) with radius r1 The center of the ending circle is at (p2,0) with radius r2. The spots' t values are distributed as appropriate along the circles.
For GRADIENT_LINEAR, the spots are distributed according to the color[]->t values as mapped to the segment (p1,0) to (p2,0). The color extends in the y direction from r1 down to -r2. Derived classes should remember that r1 and r2 can be negative.
*** move the change between radial and linear to here from GradientInterface? or separate linear from radial.. editing radial is really obnoxious right now..
*** perhaps have the colors array be potentially read only (or make new on change), and be able to be stored elsewhere, thus be able to read stand alone gradient files....
*** care must be taken that final t != initial t (esp is ShiftPoint())!!
it is assumed here that p1<p2, maybe should make that explicit somehow?
LaxInterfaces::GradientData::GradientData | ( | flatpoint | pp1, |
flatpoint | pp2, | ||
double | rr1, | ||
double | rr2, | ||
Laxkit::ScreenColor * | col1, | ||
Laxkit::ScreenColor * | col2, | ||
unsigned int | stle | ||
) |
Create new basic gradient pp1 to pp2. Sets col1 at 0 and col2 at 1.
This just passes everything to Set().
|
virtual |
Place new color in right spot in list.
The color components are in range [0,0xffff].
Referenced by LaxInterfaces::GradientInterface::LBDown().
|
virtual |
Reads in from something like:
matrix 1 0 0 1 0 0 p1 0 p2 1 r1 0 r2 10 spot t 0 rgba 255 100 50 255 spot t 1 rgba 0 0 0 0 radial
Reimplemented from LaxInterfaces::SomeData.
References LaxFiles::BooleanAttribute(), LaxFiles::DoubleAttribute(), LaxInterfaces::GradientDataSpot::dump_in_atts(), Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
Return if pp transformed to data coords is within the bounds.
unimplemented: in=1 | on=2 | out=0
Reimplemented from LaxInterfaces::SomeData.
References Laxkit::transform_invert(), and Laxkit::transform_point().
Referenced by LaxInterfaces::GradientInterface::scan().
|
virtual |
Render the whole gradient to a buffer.
The entire buffer maps to the gradient's bounding box.
bufchannels must be the same number of channels as the number of channels of the colors of the gradient. The last channel is assumed to be the alpha channel. bufstride is the number of bytes each row takes. bufdepth can be either 8 or 16.
Currently not antialiased. Please note this is mainly for generating preview images for use on screen. 16 bit stuff should really be implented with a Displayer capable of 16 bit buffers and transforms.
Return 0 for success, or nonzero for error at some point.
must rethink about rendering to buffers! must be able to handle 16 bit per channel buffers, but to be effective, this really means being able to handle arbitrary transformations, which in turn says what actually has to be rendered...
*** rendering radial gradients VERY inefficient here..
radial draw assumes argb
Reimplemented from LaxInterfaces::SomeData.
References Laxkit::coloravg().
Move the color which to a new t position.
Note this is the GradientData independent t value.
|
virtual |
Figure out what color lays at coordinate t.
If t is before the earliest point then the earliest point is used for the color, and -1 is returned. Similarly for beyond the final point, but 1 is returned. Otherwise, the color is linearly interpolated between the nearest points, and 0 is returned.
|
virtual |
Figure out what color lays at coordinate t.
If t is before the earliest point then the earliest point is used for the color, and -1 is returned. Similarly for beyond the final point, but 1 is returned. Otherwise, the color is linearly interpolated between the nearest points, and 0 is returned.
The colors are returned as doubles in range [0..1]. It is assumed that col has as many channels as needed for color (with alpha). For most cases, rgba (4 channels, so a double[4]) is sufficient.
int LaxInterfaces::GradientData::a |
A displacement to place the color spot line when drawing on screen.
This is automatically determined by GradientInterface.
Referenced by LaxInterfaces::GradientInterface::getpoint().