diff options
author | Jens Ole Wund <bjornmose@gmx.net> | 2006-02-01 00:43:59 +0300 |
---|---|---|
committer | Jens Ole Wund <bjornmose@gmx.net> | 2006-02-01 00:43:59 +0300 |
commit | 397ee6768dca9e4696c608c7731f050ce4440802 (patch) | |
tree | ebe446d2a7407e9eeb1eb480da0bec2c7b143530 /source/blender/img/intern | |
parent | e377e5407fcc42c4b33e86e43d5210a4eca0fc08 (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/blender/img/intern')
-rw-r--r-- | source/blender/img/intern/IMG_Api.cpp | 2 | ||||
-rw-r--r-- | source/blender/img/intern/IMG_BrushRGBA32.cpp | 41 | ||||
-rw-r--r-- | source/blender/img/intern/IMG_BrushRGBA32.h | 4 |
3 files changed, 23 insertions, 24 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; |