UNPKG

generator-gsndnn

Version:

Scaffolds DNN extensions, including Modules (Webforms, SPA, and MVC), Persona Bar, Skin Object, Library, Scheduler, and Hotcakes Commerce projects (based on the generator built by Matt Rutledge).

52 lines (38 loc) 7.32 kB
/* This Snippet is using a modified Stack Blur js lib for blurring the header images. I could not use hosted images because Canvas cannot work with cross domain images. If you want to use hosted images make sure they are on the same domain. Have fun! */ /* StackBlur - a fast almost Gaussian Blur For Canvas Version: 0.5 Author: Mario Klingemann Contact: mario@quasimondo.com Website: http://www.quasimondo.com/StackBlurForCanvas Twitter: @quasimondo In case you find this class useful - especially in commercial projects - I am not totally unhappy for a small donation to my PayPal account mario@quasimondo.de Or support me on flattr: https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript Copyright (c) 2010 Mario Klingemann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function stackBlurCanvasRGBA(a, b, c, d, e, f) { if (!(isNaN(f) || f < 1)) { f |= 0; var h, g = a.getContext("2d"); try { try { h = g.getImageData(b, c, d, e) } catch (i) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"), h = g.getImageData(b, c, d, e) } catch (i) { throw alert("Cannot access local image"), new Error("unable to access local image data: " + i) } } } catch (i) { throw alert("Cannot access image"), new Error("unable to access image data: " + i) } var k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, j = h.data, I = f + f + 1, K = d - 1, L = e - 1, M = f + 1, N = M * (M + 1) / 2, O = new BlurStack, P = O; for (m = 1; m < I; m++) if (P = P.next = new BlurStack, m == M) var Q = P; P.next = O; var R = null, S = null; q = p = 0; var T = mul_table[f], U = shg_table[f]; for (l = 0; l < e; l++) { for (z = A = B = C = r = s = t = u = 0, v = M * (D = j[p]), w = M * (E = j[p + 1]), x = M * (F = j[p + 2]), y = M * (G = j[p + 3]), r += N * D, s += N * E, t += N * F, u += N * G, P = O, m = 0; m < M; m++) P.r = D, P.g = E, P.b = F, P.a = G, P = P.next; for (m = 1; m < M; m++) n = p + ((K < m ? K : m) << 2), r += (P.r = D = j[n]) * (H = M - m), s += (P.g = E = j[n + 1]) * H, t += (P.b = F = j[n + 2]) * H, u += (P.a = G = j[n + 3]) * H, z += D, A += E, B += F, C += G, P = P.next; for (R = O, S = Q, k = 0; k < d; k++) j[p + 3] = G = u * T >> U, 0 != G ? (G = 255 / G, j[p] = (r * T >> U) * G, j[p + 1] = (s * T >> U) * G, j[p + 2] = (t * T >> U) * G) : j[p] = j[p + 1] = j[p + 2] = 0, r -= v, s -= w, t -= x, u -= y, v -= R.r, w -= R.g, x -= R.b, y -= R.a, n = q + ((n = k + f + 1) < K ? n : K) << 2, z += R.r = j[n], A += R.g = j[n + 1], B += R.b = j[n + 2], C += R.a = j[n + 3], r += z, s += A, t += B, u += C, R = R.next, v += D = S.r, w += E = S.g, x += F = S.b, y += G = S.a, z -= D, A -= E, B -= F, C -= G, S = S.next, p += 4; q += d } for (k = 0; k < d; k++) { for (A = B = C = z = s = t = u = r = 0, p = k << 2, v = M * (D = j[p]), w = M * (E = j[p + 1]), x = M * (F = j[p + 2]), y = M * (G = j[p + 3]), r += N * D, s += N * E, t += N * F, u += N * G, P = O, m = 0; m < M; m++) P.r = D, P.g = E, P.b = F, P.a = G, P = P.next; for (o = d, m = 1; m <= f; m++) p = o + k << 2, r += (P.r = D = j[p]) * (H = M - m), s += (P.g = E = j[p + 1]) * H, t += (P.b = F = j[p + 2]) * H, u += (P.a = G = j[p + 3]) * H, z += D, A += E, B += F, C += G, P = P.next, m < L && (o += d); for (p = k, R = O, S = Q, l = 0; l < e; l++) n = p << 2, j[n + 3] = G = u * T >> U, G > 0 ? (G = 255 / G, j[n] = (r * T >> U) * G, j[n + 1] = (s * T >> U) * G, j[n + 2] = (t * T >> U) * G) : j[n] = j[n + 1] = j[n + 2] = 0, r -= v, s -= w, t -= x, u -= y, v -= R.r, w -= R.g, x -= R.b, y -= R.a, n = k + ((n = l + M) < L ? n : L) * d << 2, r += z += R.r = j[n], s += A += R.g = j[n + 1], t += B += R.b = j[n + 2], u += C += R.a = j[n + 3], R = R.next, v += D = S.r, w += E = S.g, x += F = S.b, y += G = S.a, z -= D, A -= E, B -= F, C -= G, S = S.next, p += d } g.putImageData(h, b, c) } } function BlurStack() { this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null } var mul_table = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259], shg_table = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];