Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="G2Vk3A" style="width: 600; height: 160028; transform: translate(0px) rotate(0deg);">
- <svg class="UM3_lA" viewBox="0 0 600 600" preserveAspectRatio="none">
- <defs>
- <filter id="filter" color-interpolation-filters="sRGB">
- <feComponentTransfer></feComponentTransfer>
- </filter>
- </defs>
- <image crossorigin="anonymous" xlink:href="https://i.imgur.com/p2B0TrF.jpg" width="600" height="600"
- filter="url(#filter)"></image>
- </svg>
- <div id="filterPanel">
- FILTER PANEL
- url(#filter1)
- </div>
- </div>
- <script>
- const filtersArray = [{
- "name": "epic",
- "params": [
- {
- "name": "brightness",
- "val": 12,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -40,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -28,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "festive",
- "params": [
- {
- "name": "brightness",
- "val": 20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 42,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 48,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -14,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 80,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "summer",
- "params": [
- {
- "name": "brightness",
- "val": 20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 28,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 36,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": -46,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 60,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "afterglow",
- "params": [
- {
- "name": "brightness",
- "val": 30,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 38,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -24,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -46,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "solar",
- "params": [
- {
- "name": "brightness",
- "val": 36,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 30,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 84,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "selfie",
- "params": [
- {
- "name": "brightness",
- "val": 60,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": -52,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "cali",
- "params": [
- {
- "name": "brightness",
- "val": 44,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -92,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 76,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 54,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "the blues",
- "params": [
- {
- "name": "brightness",
- "val": 88,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -76,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -52,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -28,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": -46,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "nordic",
- "params": [
- {
- "name": "brightness",
- "val": 30,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -32,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "whimsical",
- "params": [
- {
- "name": "brightness",
- "val": 86,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": -79,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -38,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "retro",
- "params": [
- {
- "name": "brightness",
- "val": 20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -30,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -36,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": 14,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "edge",
- "params": [
- {
- "name": "brightness",
- "val": 20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -48,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 52,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": 49,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 58,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "dalliance",
- "params": [
- {
- "name": "brightness",
- "val": 36,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -44,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": 75,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -46,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "peoni",
- "params": [
- {
- "name": "brightness",
- "val": 20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 42,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -20,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "dare",
- "params": [
- {
- "name": "contrast",
- "val": 88,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": 96,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": -46,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -20,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "rosie",
- "params": [
- {
- "name": "contrast",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -56,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": -73,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -28,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 54,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "drama",
- "params": [
- {
- "name": "brightness",
- "val": -20,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 42,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -68,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "hue",
- "val": 60,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "crossProcess",
- "val": 100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "grayscale",
- "params": [
- {
- "name": "brightness",
- "val": 30,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": -40,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -100,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- },
- {
- "name": "street",
- "params": [
- {
- "name": "brightness",
- "val": -14,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "contrast",
- "val": 42,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "saturation",
- "val": -100,
- "wh": {
- "w": 600,
- "h": 600
- }
- },
- {
- "name": "blur",
- "val": -14,
- "wh": {
- "w": 600,
- "h": 600
- }
- }
- ]
- }
- ];
- var filters = {
- getFilters(filters = []) {
- var res = [];
- filters.forEach((f, i) => {
- if (typeof this[f.name] != 'undefined') {
- const str = this[f.name](f);
- console.log(f.name, f.val);
- if (str) {
- res.push(str);
- }
- }
- });
- return (res.length ? res : ['<feComponentTransfer></feComponentTransfer>']).join('');
- },
- hue(params) {
- if (params.val === 0) return;
- var b = { rf: params.val, lh: 50 };
- function Yr(a, b, c) {
- 0 > c && (c += 1);
- 1 < c && --c;
- return c < 1 / 6 ? a + 6 * (b - a) * c : .5 > c ? b : c < 2 / 3 ? a + (b - a) * (2 / 3 - c) * 6 : a;
- }
- let a = b.lh / 500;
- if (a == 0) return;
- b = ((b.rf / 200 + .5 - 1 / 7) % 1 + 1) % 1;
- let c = 1, d = 1 - c;
- b = {
- r: Yr(d, c, b + 1 / 3),
- g: Yr(d, c, b),
- b: Yr(d, c, b - 1 / 3)
- };
- c = b.g;
- d = b.b;
- return `<feComponentTransfer>
- <feFuncR type="linear" slope="${1 - a}" intercept="${b.r * a}"></feFuncR>
- <feFuncG type="linear" slope="${1 - a}" intercept="${c * a}"></feFuncG>
- <feFuncB type="linear" slope="${1 - a}" intercept="${d * a}"></feFuncB>
- </feComponentTransfer>`;
- },
- brightness: function (params) { //-100-100
- if (params.val === 0) return;
- var val = params.val / 200 /* (0.5 * params.val / 100).toFixed(3) */;
- console.log(val);
- return `<feComponentTransfer>
- <feFuncR type="linear" slope="1" intercept="${val}"></feFuncR>
- <feFuncG type="linear" slope="1" intercept="${val}"></feFuncG>
- <feFuncB type="linear" slope="1" intercept="${val}"></feFuncB>
- </feComponentTransfer>`;
- },
- contrast: function (params) {
- if (params.val === 0) return;
- /* var slope = this.conv(params.val, 0.4, 2.5);
- var intercept = this.conv(params.val, 0.3, -0.75); */
- let a = params.val / 100 * .6;
- if (0 === a) return;
- a = 0 < a ? 1 / (1 - a) : 1 + a;
- const b = -(.5 * a) + .5;
- var res = `<feComponentTransfer>
- <feFuncR type="linear" slope="${a}" intercept="${b}"></feFuncR>
- <feFuncG type="linear" slope="${a}" intercept="${b}"></feFuncG>
- <feFuncB type="linear" slope="${a}" intercept="${b}"></feFuncB>
- </feComponentTransfer>`
- return res;
- },
- saturation: function (params) {
- if (params.val === 0) return;
- /* var pairs = [[0.3086, 1.6914], [0.6094, -0.6094], [0.082, -0.082], [0, 0], [0, 0], [0.3086, -0.3086], [0.6094, 1.3906], [0.082, -0.082], [0, 0], [0, 0], [0.3086, -0.3086], [0.6094, -0.6094], [0.082, 1.918],];
- var matrix = [];
- pairs.forEach((v) => {
- matrix.push(this.conv(params.val, v[0], v[1]));
- });
- matrix.push("0 0 0 0 0 1 0"); */
- let a = params.val / 100 + 1;
- if (1 === a) return;
- const b = .3086 * (1 - a);
- const c = .6094 * (1 - a);
- const d = .082 * (1 - a);
- return `<feColorMatrix type="matrix"
- values="${[b + a, c, d, 0, 0, b, c + a, d, 0, 0, b, c, d + a, 0, 0, 0, 0, 0, 1, 0].join(' ')}">
- </feColorMatrix>`;
- },
- //var ff = filters.getFilters([{name: "blur", val: -100, wh: {w: 128, h: 128} } ]);
- blur: function (params) {
- if (params.val === 0) return;
- if (params.val > 0) {
- var max = params.wh.w * 0.05;
- var vv = this.conv(params.val, 0, max);
- return `<feGaussianBlur stdDeviation="${vv}"></feGaussianBlur>`;
- } else if (params.val < 0) {
- var blur = params.wh.w * 0.0015;
- var k1 = this.conv(params.val, 0, 0);
- var k2 = this.conv(params.val, -0.06, 6);
- var k3 = this.conv(params.val * -1, 1.06, 7);
- var k4 = 0;
- return `
- <feComponentTransfer result="preblur"></feComponentTransfer>
- <feGaussianBlur stdDeviation="${blur}"></feGaussianBlur>
- <feComponentTransfer><feFuncA type="table" tableValues="0 1 1 1"></feFuncA></feComponentTransfer>
- <feComposite operator="arithmetic" k1="${k1}" k2="${k2}" k3="${k3}" k4="${k4}" in2="preblur"></feComposite>`;
- }
- },
- crossProcess: function (params) {
- if (params.val === 0) return;
- /* var pairs_r = [["0", "0"], ["0.018546631163103112", "0"], ["0.036563090132369254", "0"], ["0.05351920471396142", "0"], ["0.06888480271404268", "0.001201887041747698"], ["0.08212971193877604", "0.00815699822491688"], ["0.09272376019432449", "0.019548535689907564"], ["0.10013677528685111", "0.03626378469308406"], ["0.10383858502251889", "0.05919003049081066"], ["0.10329901720749086", "0.08921455833945166"], ["0.09808447604792396", "0.1271316565773867"], ["0.08900374495505535", "0.17253928155041756"], ["0.07772789187743862", "0.22420506455183506"], ["0.06594534963942325", "0.28087991560627334"], ["0.05534455106535869", "0.34131474473836626"], ["0.047613928979594544", "0.4042604619727479"], ["0.044441916206480234", "0.46846797733405227"], ["0.04751694557036534", "0.5326882008469132"], ["0.05852744989559917", "0.5956720425359648"], ["0.07916186200653139", "0.6561704124258413"], ["0.11110861472751156", "0.7129342205411767"], ["0.15605614088288894", "0.7647143769066046"], ["0.21568426274775512", "0.8102664150687151"], ["0.2905102215098147", "0.8489701283073448"], ["0.37872533106876044", "0.8814542402041557"], ["0.47824392651731956", "0.908496200926875"], ["0.5869803429482184", "0.93087346064323"], ["0.7028489154541844", "0.9493634695209482"], ["0.8237639791279442", "0.9647436777277569"], ["0.9476398690622253", "0.9777915354313835"], ["1", "0.9892844927995555"], ["1", "1"]];
- var pairs_g = [["0", "0"], ["0.01265830762650567", "0.05938442699171673"], ["0.025971185421494163", "0.11796530615292077"], ["0.04059320355344828", "0.17493908965309943"], ["0.05717893219085087", "0.22950222966174008"], ["0.07638294150218472", "0.28085117834833"], ["0.09885980165593265", "0.32818238788235643"], ["0.12526408282057752", "0.37069231043330686"], ["0.15624803518077382", "0.407580364535447"], ["0.1920758124814897", "0.4385421944274188"], ["0.23219179750014032", "0.4643216153285879"], ["0.27593626597242793", "0.4857955552231419"], ["0.3226494936340549", "0.5038409420952686"], ["0.3716717562207237", "0.5193347039291559"], ["0.4223433294681365", "0.5331537687089917"], ["0.4740044891119959", "0.546175064418964"], ["0.5259955108880041", "0.5592755190432603"], ["0.5776566705318634", "0.5733320605660687"], ["0.6283282437792762", "0.5892216169715769"], ["0.6773505063659451", "0.607808978603834"], ["0.7240637340275722", "0.6294870850464945"], ["0.7678082024998597", "0.6540359250562033"], ["0.8079241875185104", "0.6811945228541384"], ["0.8437519648192263", "0.7107019026614771"], ["0.8747359171794225", "0.7422970886993968"], ["0.9011401983440674", "0.7757191051890745"], ["0.9236170584978154", "0.8107069763516883"], ["0.9428210678091492", "0.8469997264084148"], ["0.9594067964465517", "0.8843363795804319"], ["0.9740288145785059", "0.9224559600889171"], ["0.9873416923734943", "0.9610974921550473"], ["1", "1"]];
- var pairs_b = [["0", "0"], ["0.04382263099593838", "0.0335866406453361"], ["0.08735524151589408", "0.06713929283107775"], ["0.13030781108388437", "0.10062396809763045"], ["0.17239031922392672", "0.1340066779853998"], ["0.21331274546003828", "0.16725343403479132"], ["0.2527850693162364", "0.2003302477862105"], ["0.29051727031653857", "0.23320313078006294"], ["0.32621932798496195", "0.2658380945567542"], ["0.35960122184552384", "0.29820115065668973"], ["0.3903729314222416", "0.33026216363453476"], ["0.418276660736464", "0.3620405640340923"], ["0.4434292235910174", "0.3935901841227579"], ["0.46618911751871367", "0.42496554895740846"], ["0.4869188681145312", "0.4562211835949208"], ["0.5059810009734483", "0.4874116130921718"], ["0.5237380416904436", "0.5185913625060383"], ["0.5405525158604948", "0.549814956893397"], ["0.5567869490785807", "0.5811369213111252"], ["0.5728038669396799", "0.6126110395508719"], ["0.5889657950387701", "0.6442622787185796"], ["0.6056325735960525", "0.6760781720262137"], ["0.6230029203450707", "0.7080437509155997"], ["0.6410258131650498", "0.7401440468285623"], ["0.6596287469369944", "0.7723640912069264"], ["0.6787392165419087", "0.8046889154925165"], ["0.698284716860797", "0.8371035511271582"], ["0.7181927427746635", "0.8695930295526753"], ["0.7383907891645128", "0.9021423822108934"], ["0.7588063509113492", "0.934736640543637"], ["0.7793669228961767", "0.967360835992731"], ["0.8", "1"]]
- var matrix_r = [];
- var matrix_g = [];
- var matrix_b = [];
- pairs_r.forEach((v, i) => {
- matrix_r.push(this.conv(params.val, v[0], v[1]));
- });
- pairs_g.forEach((v, i) => {
- matrix_g.push(this.conv(params.val, v[1], v[0]));
- });
- pairs_b.forEach((v, i) => {
- matrix_b.push(this.conv(params.val, v[1], v[0]));
- }); */
- const Aya = 0 <= params.val ? {
- r: [{ x: 0, y: 0 }, { x: 77, y: 26 }, { x: 179, y: 204 }, { x: 255, y: 255 }],
- g: [{ x: 0, y: 0 }, { x: 64, y: 38 }, { x: 191, y: 217 }, { x: 255, y: 255 }],
- b: [{ x: 0, y: 0 }, { x: 85, y: 102 }, { x: 170, y: 153 }, { x: 255, y: 204 }]
- } : {
- r: [{ x: 0, y: 0 }, { x: 77, y: 26 }, { x: 179, y: 51 }, { x: 242, y: 255 }],
- g: [{ x: 0, y: 0 }, { x: 64, y: 102 }, { x: 153, y: 153 }, { x: 255, y: 255 }],
- b: [{ x: 0, y: 0 }, { x: 77, y: 79 }, { x: 153, y: 153 }, { x: 255, y: 255 }]
- };
- params.val = Math.abs(params.val);
- var b = {
- mh: 70,
- Aya
- };
- const c = params.val / 100;
- var d = h => {
- let l = h.x;
- return { x: l, y: (1 - c) * l + h.y * c };
- };
- class nza {
- constructor(a, b) {
- this.J3b = a;
- this.xs = b
- }
- interpolate(a) {
- var b = this.J3b;
- const c = this.xs;
- let d = 0, e = this.J3b.length - 1;
- for (; 1 < e - d;) {
- var f = e + d >> 1;
- b[f].x > a ? e = f : d = f
- }
- f = b[e];
- b = b[d];
- const g = f.x - b.x, h = (f.x - a) / g;
- a = (a - b.x) / g;
- return h * b.y + a * f.y + (c[d] * (h ** 3 - h) + c[e] * (a ** 3 - a)) * g ** 2 / 6;
- }
- }
- function Xr(a) {
- var b = a.length;
- const c = new Float64Array(b),
- d = new Float64Array(b);
- for (let e = 1; e < b - 1; e++) {
- const f = a[e - 1],
- g = a[e],
- h = a[e + 1],
- l = h.x - f.x,
- p = (g.x - f.x) / l,
- q = p * d[e - 1] + 2;
- c[e] = (6 * ((h.y - g.y) / (h.x - g.x) - (g.y - f.y) / (g.x - f.x)) / l - p * c[e - 1]) / q;
- d[e] = (p - 1) / q
- }
- for (b -= 2; 0 <= b; --b) d[b] = d[b] * d[b + 1] + c[b];
- return new nza(a, d);
- };
- a = Xr(Aya.r.map(d));
- const e = Xr(Aya.g.map(d));
- b = Xr(Aya.b.map(d));
- d = Array(32);
- const f = Array(32), g = Array(32);
- for (let h = 0; 32 > h; h++) {
- const l = 255 * h / 31;
- d[h] = Math.max(0, Math.min(255, a.interpolate(l))) / 255;
- f[h] = Math.max(0, Math.min(255, e.interpolate(l))) / 255;
- g[h] = Math.max(0, Math.min(255, b.interpolate(l))) / 255;
- }
- return `<feComponentTransfer>
- <feFuncR type="table" tableValues="${d.join(" ")}"></feFuncR>
- <feFuncG type="table" tableValues="${f.join(" ")}"></feFuncG>
- <feFuncB type="table" tableValues="${g.join(" ")}"></feFuncB>
- </feComponentTransfer> `
- },
- //var ff = filters.getFilters([{name: "viggnete", val: 44, wh: {w: 600, h: 600} } ]);
- viggnete: function (params) {
- if (params.val === 0) return;
- var x = params.wh.w / 2;
- var y = params.wh.h / 2;
- var z = this.conv(params.val, (params.wh.w + params.wh.h) * 2, ((params.wh.w + params.wh.h) * 2) * .5);
- return `
- <feFlood id="vignette-flood" x="0" y="0" result="blackfield" flood-color="#000000" flood-opacity="1"></feFlood>
- <feSpecularLighting id="vignette-specular" result="spotlight" lighting-color="#FFFFFF" surfaceScale="1" specularConstant="1" specularExponent="120">
- <fePointLight id="vignette-pointlight" x="${x}" y="${y}" z="${z}"></fePointLight>
- </feSpecularLighting>
- <feBlend id="vignette-mask" result="mask" in="blackfield" in2="spotlight" mode="lighten"></feBlend>
- <feBlend id="vignette-mask-multiply" in="mask" in2="SourceGraphic" mode="multiply" result="vignette-result"></feBlend>
- `;
- },
- epic: function (params = {}) {
- // console.log(params);
- return '';
- },
- conv(val, slope_min = 0, slope_max = 1) {
- var val = val / 100;
- var r = ((slope_max * (val)) - (slope_min * (val)) - (slope_min * -1)).toFixed(8);
- return r;
- },
- convertValue(originalMaxValue, rangeValue) {
- return originalMaxValue * (Number(rangeValue) / 100);
- },
- generateFilter(filterName, rangeValue, { width, height }) {
- const filter = filtersArray.find(({ name }) => name == filterName);
- if (!filter) return;
- const cloneParams = [];
- filter.params.forEach(param => {
- cloneParams.push({
- ...param, val: filters.convertValue(param.val, rangeValue),
- wh: { w: width, h: height }
- });
- });
- console.log(filter.name);
- return filters.getFilters(cloneParams);
- },
- // for test
- getFiltersString(id, value, params = {}) {
- return filters.generateFilter(filtersArray[id].name, value, params);
- }
- }
- const filterElement = document.getElementById('filter');
- // filterElement.innerHTML = filters.generateFilter('default');
- /* var ff = filters.getFilters([
- // {name: "viggnete", val: 44, wh: {w: 600, h: 600} },
- { name: "blur", val: 22, wh: { w: 600, h: 600 } },
- { name: "crossProcess", val: 1, wh: { w: 600, h: 600 } },
- // {name: "contrast", val: 11, wh: {w: 600, h: 600} },
- ]); */
- // document.getElementById("filter1").innerHTML = ff.join("");
- /* const selectFilter = document.getElementById('selectFilter');
- selectFilter.innerHTML = '';
- for(const filter of filtersArray) {
- selectFilter.innerHTML += `<option value="${filter.name}">${filter.name}</option>`;
- } */
- /* let html = '';
- for (const filter of filtersArray) {
- html += `<filter id="${filter.name}" color-interpolation-filters="sRGB">
- ${filters.getFilters(filter.params).join('')}
- </filter>`;
- }
- document.getElementById('canvasFilters').innerHTML = html; */
- /* brightness: 12,
- contrast: -40,
- saturation: -28,
- hue: 0,
- blur: 0,
- crossProcess: 100,
- vignette: 0 */
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement