1/* global define, require */ 2(function (root, factory) { 3 'use strict'; 4 5 if (typeof define === 'function' && define.amd) { 6 // AMD. Register as an anonymous module. 7 define(['seriously'], factory); 8 } else if (typeof exports === 'object') { 9 // Node/CommonJS 10 factory(require('seriously')); 11 } else { 12 if (!root.Seriously) { 13 root.Seriously = { plugin: function (name, opt) { this[name] = opt; } }; 14 } 15 factory(root.Seriously); 16 } 17}(window, function (Seriously) { 18 'use strict'; 19 20 Seriously.plugin('tone', { 21 commonShader: true, 22 shader: function (inputs, shaderSource) { 23 shaderSource.fragment = [ 24 'precision mediump float;', 25 26 'varying vec2 vTexCoord;', 27 28 'uniform sampler2D source;', 29 'uniform vec4 light;', 30 'uniform vec4 dark;', 31 'uniform float desat;', 32 'uniform float toned;', 33 34 'const vec3 lumcoeff = vec3(0.2125,0.7154,0.0721);', 35 36 'void main(void) {', 37 ' vec4 sourcePixel = texture2D(source, vTexCoord);', 38 ' vec3 sceneColor = light.rgb * sourcePixel.rgb;', 39 ' vec3 gray = vec3(dot(lumcoeff, sceneColor));', 40 ' vec3 muted = mix(sceneColor, gray, desat);', 41 ' vec3 tonedColor = mix(dark.rgb, light.rgb, gray);', 42 ' gl_FragColor = vec4(mix(muted, tonedColor, toned), sourcePixel.a);', 43 '}' 44 ].join('\n'); 45 return shaderSource; 46 }, 47 inPlace: true, 48 inputs: { 49 source: { 50 type: 'image', 51 uniform: 'source' 52 }, 53 light: { 54 type: 'color', 55 uniform: 'light', 56 defaultValue: [1, 0.9, 0.5, 1] 57 }, 58 dark: { 59 type: 'color', 60 uniform: 'dark', 61 defaultValue: [0.2, 0.05, 0, 1] 62 }, 63 toned: { 64 type: 'number', 65 uniform: 'toned', 66 defaultValue: 1, 67 minimumRange: 0, 68 maximumRange: 1 69 }, 70 desat: { 71 type: 'number', 72 uniform: 'desat', 73 defaultValue: 0.5, 74 minimumRange: 0, 75 maximumRange: 1 76 } 77 }, 78 title: 'Tone', 79 description: '' 80 }); 81}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.