[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jul 11 05:42:01 PDT 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/9b584c637f09/
Changeset:   9b584c637f09
Branch:      yt
User:        samskillman
Date:        2013-07-10 18:18:40
Summary:     Fix alpha blending in line drawing for grey_opacity=True.  This now correctly
blends and renormalizes the RGB channels based on the alpha channel. Before
the color of the lines were completely over-powering the underlying rendering.
Affected #:  1 file

diff -r 577bb3ce6fc3e6d71130be84d03f46201f8cac7b -r 9b584c637f0906e6bce1a52dca7c439495a75235 yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -127,7 +127,7 @@
     cdef int nx = image.shape[0]
     cdef int ny = image.shape[1]
     cdef int nl = xs.shape[0]
-    cdef np.float64_t alpha[4]
+    cdef np.float64_t alpha[4], outa
     cdef int i, j
     cdef int dx, dy, sx, sy, e2, err
     cdef np.int64_t x0, x1, y0, y1
@@ -158,17 +158,22 @@
             elif (x0 >= nx-thick+1 and sx == 1): break
             elif (y0 < thick and sy == -1): break
             elif (y0 >= ny-thick+1 and sy == 1): break
-            if (x0 >=thick and x0 < nx-thick and y0 >= thick and y0 < ny-thick):
-                if has_alpha:
-                    for i in range(4):
-                        image[x0-thick/2:x0+(1+thick)/2, 
-                              y0-thick/2:y0+(1+thick)/2,i] = \
-                                (1.-alpha[3])*image[x0,y0,i] + alpha[i]
-                else:
-                    for i in range(3):
-                        image[x0-thick/2:x0+(1+thick)/2, 
-                              y0-thick/2:y0+(1+thick)/2,i] = \
-                                (1.-alpha[i])*image[x0,y0,i] + alpha[i]
+            if (x0 < thick or x0 >= nx-thick or y0 < thick or y0 >= ny-thick):
+                break
+            for xi in range(x0-thick/2, x0+(1+thick)/2):
+                for yi in range(y0-thick/2, y0+(1+thick)/2):
+                    if has_alpha:
+                        image[xi, yi, 3] = outa = alpha[3] + image[xi, yi, 3]*(1-alpha[3]) 
+                        if outa != 0.0:
+                            outa = 1.0/outa
+                        for i in range(3):
+                            image[xi, yi, i] = \
+                                    ((1.-alpha[3])*image[xi, yi, i]*image[xi, yi, 3] 
+                                     + alpha[3]*alpha[i])*outa
+                    else:
+                        for i in range(3):
+                            image[xi, yi, i] = \
+                                    (1.-alpha[i])*image[xi,yi,i] + alpha[i]
 
             if (x0 == x1 and y0 == y1):
                 break


https://bitbucket.org/yt_analysis/yt/commits/ad11ffa1a7b5/
Changeset:   ad11ffa1a7b5
Branch:      yt
User:        samskillman
Date:        2013-07-10 18:48:37
Summary:     Can't just break out or else you won't draw lines that begin outside of the image.
Affected #:  1 file

diff -r 9b584c637f0906e6bce1a52dca7c439495a75235 -r ad11ffa1a7b5b7665f8e3269e1b3d1e875c04743 yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -158,22 +158,21 @@
             elif (x0 >= nx-thick+1 and sx == 1): break
             elif (y0 < thick and sy == -1): break
             elif (y0 >= ny-thick+1 and sy == 1): break
-            if (x0 < thick or x0 >= nx-thick or y0 < thick or y0 >= ny-thick):
-                break
-            for xi in range(x0-thick/2, x0+(1+thick)/2):
-                for yi in range(y0-thick/2, y0+(1+thick)/2):
-                    if has_alpha:
-                        image[xi, yi, 3] = outa = alpha[3] + image[xi, yi, 3]*(1-alpha[3]) 
-                        if outa != 0.0:
-                            outa = 1.0/outa
-                        for i in range(3):
-                            image[xi, yi, i] = \
-                                    ((1.-alpha[3])*image[xi, yi, i]*image[xi, yi, 3] 
-                                     + alpha[3]*alpha[i])*outa
-                    else:
-                        for i in range(3):
-                            image[xi, yi, i] = \
-                                    (1.-alpha[i])*image[xi,yi,i] + alpha[i]
+            if x0 >= thick and x0 < nx-thick and y0 >= thick and y0 < ny-thick:
+                for xi in range(x0-thick/2, x0+(1+thick)/2):
+                    for yi in range(y0-thick/2, y0+(1+thick)/2):
+                        if has_alpha:
+                            image[xi, yi, 3] = outa = alpha[3] + image[xi, yi, 3]*(1-alpha[3])
+                            if outa != 0.0:
+                                outa = 1.0/outa
+                            for i in range(3):
+                                image[xi, yi, i] = \
+                                        ((1.-alpha[3])*image[xi, yi, i]*image[xi, yi, 3]
+                                         + alpha[3]*alpha[i])*outa
+                        else:
+                            for i in range(3):
+                                image[xi, yi, i] = \
+                                        (1.-alpha[i])*image[xi,yi,i] + alpha[i]
 
             if (x0 == x1 and y0 == y1):
                 break


https://bitbucket.org/yt_analysis/yt/commits/f1da09f71bbb/
Changeset:   f1da09f71bbb
Branch:      yt
User:        MatthewTurk
Date:        2013-07-11 14:41:56
Summary:     Merged in samskillman/yt (pull request #553)

Fix for grey_opacity grid line drawing
Affected #:  1 file

diff -r a745781d8c7dde89973c1e8cac7da07aa564036e -r f1da09f71bbb45215639285c3071695b55e2e6bf yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -127,7 +127,7 @@
     cdef int nx = image.shape[0]
     cdef int ny = image.shape[1]
     cdef int nl = xs.shape[0]
-    cdef np.float64_t alpha[4]
+    cdef np.float64_t alpha[4], outa
     cdef int i, j
     cdef int dx, dy, sx, sy, e2, err
     cdef np.int64_t x0, x1, y0, y1
@@ -158,17 +158,21 @@
             elif (x0 >= nx-thick+1 and sx == 1): break
             elif (y0 < thick and sy == -1): break
             elif (y0 >= ny-thick+1 and sy == 1): break
-            if (x0 >=thick and x0 < nx-thick and y0 >= thick and y0 < ny-thick):
-                if has_alpha:
-                    for i in range(4):
-                        image[x0-thick/2:x0+(1+thick)/2, 
-                              y0-thick/2:y0+(1+thick)/2,i] = \
-                                (1.-alpha[3])*image[x0,y0,i] + alpha[i]
-                else:
-                    for i in range(3):
-                        image[x0-thick/2:x0+(1+thick)/2, 
-                              y0-thick/2:y0+(1+thick)/2,i] = \
-                                (1.-alpha[i])*image[x0,y0,i] + alpha[i]
+            if x0 >= thick and x0 < nx-thick and y0 >= thick and y0 < ny-thick:
+                for xi in range(x0-thick/2, x0+(1+thick)/2):
+                    for yi in range(y0-thick/2, y0+(1+thick)/2):
+                        if has_alpha:
+                            image[xi, yi, 3] = outa = alpha[3] + image[xi, yi, 3]*(1-alpha[3])
+                            if outa != 0.0:
+                                outa = 1.0/outa
+                            for i in range(3):
+                                image[xi, yi, i] = \
+                                        ((1.-alpha[3])*image[xi, yi, i]*image[xi, yi, 3]
+                                         + alpha[3]*alpha[i])*outa
+                        else:
+                            for i in range(3):
+                                image[xi, yi, i] = \
+                                        (1.-alpha[i])*image[xi,yi,i] + alpha[i]
 
             if (x0 == x1 and y0 == y1):
                 break

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list