19#include "kis_autobrush_resource.h"
22void KisAutobrushShape::createBrush( TQImage* img)
24 img->create(m_w, m_h, 32);
25 for(
int j = 0; j < m_h; j++)
27 for(
int i = 0; i < m_w; i++)
29 TQ_INT8 v = valueAt(i,j);
30 img->setPixel( i, j, tqRgb(v,v,v));
35KisAutobrushCircleShape::KisAutobrushCircleShape(TQ_INT32 w, TQ_INT32 h,
double fh,
double fv)
36 : KisAutobrushShape( w, h, w / 2.0 - fh, h / 2.0 - fv),
37 m_xcentre ( w / 2.0 ),
38 m_ycentre ( h / 2.0 ),
41 m_xfadecoef ( (m_fh == 0) ? 1 : ( 1.0 / m_fh)),
42 m_yfadecoef ( (m_fv == 0) ? 1 : ( 1.0 / m_fv))
45TQ_INT8 KisAutobrushCircleShape::valueAt(TQ_INT32 x, TQ_INT32 y)
47 double xr = (x - m_xcentre) + 0.5;
48 double yr = (y - m_ycentre) + 0.5;
49 double n = norme( xr * m_xcoef, yr * m_ycoef);
56 double normeFade = norme( xr * m_xfadecoef, yr * m_yfadecoef );
67 yle = yr > 0 ? 1/m_ycoef : -1/m_ycoef;
69 double c = yr / (double)xr;
70 xle = sqrt(1 / norme( m_xcoef, c * m_ycoef ));
71 xle = xr > 0 ? xle : -xle;
75 double normeFadeLimitE = norme( xle * m_xfadecoef, yle * m_yfadecoef );
76 return (uchar)(255 * ( normeFade - 1 ) / ( normeFadeLimitE - 1 ));
83KisAutobrushRectShape::KisAutobrushRectShape(TQ_INT32 w, TQ_INT32 h,
double fh,
double fv)
84 : KisAutobrushShape( w, h, w / 2.0 - fh, h / 2.0 - fv),
85 m_xcentre ( w / 2.0 ),
86 m_ycentre ( h / 2.0 ),
90TQ_INT8 KisAutobrushRectShape::valueAt(TQ_INT32 x, TQ_INT32 y)
92 double xr = TQABS(x - m_xcentre);
93 double yr = TQABS(y - m_ycentre);
94 if( xr > m_fh || yr > m_fv )
96 if( yr <= ((xr - m_fh) * m_c + m_fv ) )
98 return (uchar)(255 * (xr - m_fh) / (m_w - m_fh));
100 return (uchar)(255 * (yr - m_fv) / (m_w - m_fv));