Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJens Ole Wund <bjornmose@gmx.net>2006-02-01 00:43:59 +0300
committerJens Ole Wund <bjornmose@gmx.net>2006-02-01 00:43:59 +0300
commit397ee6768dca9e4696c608c7731f050ce4440802 (patch)
treeebe446d2a7407e9eeb1eb480da0bec2c7b143530 /source
parente377e5407fcc42c4b33e86e43d5210a4eca0fc08 (diff)
-some knitpicking on low scale brushes
-- should do 'alpha' right now .. down to brushes of 2 pixel size -making AUX1/2 real air brushes .. must have been lost by brechts 'cleaning'
Diffstat (limited to 'source')
-rw-r--r--source/blender/img/intern/IMG_Api.cpp2
-rw-r--r--source/blender/img/intern/IMG_BrushRGBA32.cpp41
-rw-r--r--source/blender/img/intern/IMG_BrushRGBA32.h4
-rw-r--r--source/blender/src/imagepaint.c12
4 files changed, 32 insertions, 27 deletions
diff --git a/source/blender/img/intern/IMG_Api.cpp b/source/blender/img/intern/IMG_Api.cpp
index c57e5e7c5a1..e59d5bfa586 100644
--- a/source/blender/img/intern/IMG_Api.cpp
+++ b/source/blender/img/intern/IMG_Api.cpp
@@ -67,7 +67,7 @@ void IMG_BrushSetInnerRaduisRatio(IMG_BrushPtr brush,float aspect)
if (he > si) si = we;
he = si/2;
we = (TUns32)(aspect*si/2);
- if (we < 2) we = 2;
+// if (we < 2) we = 2;
((IMG_BrushRGBA32*)brush)->setRadii(we,he);
diff --git a/source/blender/img/intern/IMG_BrushRGBA32.cpp b/source/blender/img/intern/IMG_BrushRGBA32.cpp
index 72e1c57ef63..6678365d6da 100644
--- a/source/blender/img/intern/IMG_BrushRGBA32.cpp
+++ b/source/blender/img/intern/IMG_BrushRGBA32.cpp
@@ -63,7 +63,6 @@ void IMG_BrushRGBA32::setTransparency(float a)
void IMG_BrushRGBA32::setRadii(TUns32 rI, TUns32 rO)
{
- if ((rI < 2) || (rO < 2)) return;
m_ri = rI;
m_ro = rO;
@@ -85,8 +84,9 @@ void IMG_BrushRGBA32::setRadii(TUns32 rI, TUns32 rO)
void IMG_BrushRGBA32::updateImage()
{
- TUns32 cx = m_width >> 1;
- TUns32 cy = m_height >> 1;
+ float fcx = m_width / 2.0f;
+ float fcy = m_height/ 2.0f ;
+
// Prepare pixel values for this pixmap
IMG_ColorRGBA c (m_color.m_r, m_color.m_g, m_color.m_b, 0.f);
@@ -102,30 +102,29 @@ void IMG_BrushRGBA32::updateImage()
TPixelPtr desPtr = getPixelPtr(0, y);
for (TUns32 x = 0; x < m_width; x++) {
// Calculate the distance between current pixel and center
- float dX = (float)((TInt32)x) - ((TInt32)cx);
- float dY = (float)((TInt32)y) - ((TInt32)cy);
+ float dX = (float)((TInt32)x - fcx);
+ float dY = (float)((TInt32)y - fcy);
float d = (float) ::sqrt(dX*dX + dY*dY);
float a;
if (d <= m_ri) {
*desPtr = pIn;
}
- else if ((d < m_ro) && (m_ri < m_ro)) {
- // Calculate alpha, linear
- a = (d - m_ri) / (m_ro - m_ri);
- // Now: 0 <= a <= 1
- //a = m_alpha + a * (1.f - m_alpha);
- a = (1.f - a) * m_alpha;
- // Now: m_alpha <= a <= 1
-#if 0
- a = (float)::pow(a, 0.2);
-#endif
- // Store pixel
- *pa = (TUns8)(a * ((float)0xFF));
- *desPtr = p;
- }
- else {
- *desPtr = pOut;
+ else {
+ if ((d < m_ro) && (m_ri < m_ro)) {
+ // Calculate alpha, linear
+ a = (d - m_ri) / (m_ro - m_ri);
+ // Now: 0 <= a <= 1
+ a = (float)::pow(a, 0.5f);
+ a = (1.f - a) * m_alpha;
+ // Now: m_alpha <= a <= 1
+ // Store pixel
+ *pa = (TUns8)(a * ((float)0xFF));
+ *desPtr = p;
+ }
+ else {
+ *desPtr = pOut;
+ }
}
desPtr++;
}
diff --git a/source/blender/img/intern/IMG_BrushRGBA32.h b/source/blender/img/intern/IMG_BrushRGBA32.h
index 4c94131f52a..90d4e124892 100644
--- a/source/blender/img/intern/IMG_BrushRGBA32.h
+++ b/source/blender/img/intern/IMG_BrushRGBA32.h
@@ -97,7 +97,7 @@ public:
* @param rI inner radius
* @param rO outer radius
*/
- inline virtual void setRadii(TUns32& rI, TUns32& rO) const;
+ inline virtual void getRadii(TUns32& rI, TUns32& rO) const;
protected:
/**
@@ -113,7 +113,7 @@ protected:
};
-inline void IMG_BrushRGBA32::setRadii(TUns32& rI, TUns32& rO) const
+inline void IMG_BrushRGBA32::getRadii(TUns32& rI, TUns32& rO) const
{
rI = m_ri;
rO = m_ro;
diff --git a/source/blender/src/imagepaint.c b/source/blender/src/imagepaint.c
index 7fa2f9c3cca..23cd624703e 100644
--- a/source/blender/src/imagepaint.c
+++ b/source/blender/src/imagepaint.c
@@ -120,7 +120,9 @@ static int imagepaint_init(IMG_BrushPtr **brush, IMG_CanvasPtr **canvas, IMG_Can
*clonecanvas= NULL;
/* initialize paint settings */
- if(Gip.current >= IMAGEPAINT_AIRBRUSH && Gip.current <= IMAGEPAINT_SOFTEN)
+ if((Gip.current == IMAGEPAINT_AIRBRUSH) ||
+ (Gip.current == IMAGEPAINT_AUX1) ||
+ (Gip.current == IMAGEPAINT_AUX2))
Gip.flag |= IMAGEPAINT_TIMED;
else
Gip.flag &= ~IMAGEPAINT_TIMED;
@@ -184,6 +186,8 @@ static void imagepaint_paint_tool(IMG_BrushPtr *brush, IMG_CanvasPtr *canvas, IM
IMG_CanvasCloneAt(canvas, clonecanvas, prevuv[0], prevuv[1], offx, offy, tool->size, tool->rgba[3], tool->innerradius);
}
+ else if(Gip.flag & IMAGEPAINT_TIMED)
+ IMG_CanvasDrawLineUVEX(canvas, brush, uv[0], uv[1],uv[0], uv[1], torus);
else
IMG_CanvasDrawLineUVEX(canvas, brush, prevuv[0], prevuv[1], uv[0], uv[1], torus);
}
@@ -195,7 +199,7 @@ void imagepaint_paint(short mousebutton)
short prevmval[2], mval[2];
double prevtime, curtime;
float prevuv[2], uv[2];
- int paint= 0, moved= 0;
+ int paint= 0, moved= 0, firsttouch=1 ;
ImagePaintTool *tool= &Gip.tool[Gip.current];
if(!imagepaint_init(&brush, &canvas, &clonecanvas))
@@ -215,10 +219,11 @@ void imagepaint_paint(short mousebutton)
/* see if need to draw because of timer */
curtime = PIL_check_seconds_timer();
- if((curtime - prevtime) > (5.0/tool->timing)) {
+ if(((curtime - prevtime) > (5.0/tool->timing)) || firsttouch) {
prevtime= curtime;
paint= 1;
}
+ else paint= 0;
}
else if(paint) {
/* check if we moved enough to draw */
@@ -244,6 +249,7 @@ void imagepaint_paint(short mousebutton)
prevmval[0]= mval[0];
prevmval[1]= mval[1];
}
+ firsttouch = 0;
if(paint)
imagepaint_redraw(0, paint);