UNPKG

scrawl-canvas

Version:
119 lines (96 loc) 4.42 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Demo Filters 101</title> <link href="css/normalize.css" rel="stylesheet" /> <link href="css/tests.css" rel="stylesheet" /> <style> #my-image-store { display: none; } .controls { grid-template-columns: 1fr 2fr 1fr 2fr; } </style> </head> <body> <h1><a href="index.html">Scrawl-canvas v8</a> - Filters test 101</h1> <h2>Using assets in the filter stream; filter compositing</h2> <h3>To change image, drag-and-drop an image file over the canvas</h3> <div class="controls"> <div class="yellow label">Line IN</div> <div class="yellow"> <select class="controlItem" id="source"> <option value="source">source</option> <option value="source-alpha">source-alpha</option> <option value="star">star</option> <option value="wheel">wheel</option> <option value="flower">flower</option> </select> </div> <div class="yellow label">Line MIX</div> <div class="yellow"> <select class="controlItem" id="destination"> <option value="source">source</option> <option value="source-alpha">source-alpha</option> <option value="star">star</option> <option value="wheel">wheel</option> <option value="flower">flower</option> </select> </div> <div class="yellow label">Composite operation</div> <div class="yellow"> <select class="controlItem" id="composite"> <option value="source-over">source-over</option> <option value="source-in">source-in</option> <option value="source-out">source-out</option> <option value="source-atop">source-atop</option> <option value="source-only">source-only</option> <option value="destination-over">destination-over</option> <option value="destination-in">destination-in</option> <option value="destination-out">destination-out</option> <option value="destination-atop">destination-atop</option> <option value="destination-only">destination-only</option> <option value="xor">xor</option> <option value="clear">clear</option> </select> </div> <div class="lavender label">Opacity</div> <div class="lavender"><input class="controlItem" id="opacity" type="range" value="1" min="0" max="1" step="0.01" /></div> <div class="pink label">Offset - X</div> <div class="pink"><input class="controlItem" id="offset-x" type="range" value="30" min="-250" max="250" step="1" /></div> <div class="pink label">Offset - Y</div> <div class="pink"><input class="controlItem" id="offset-y" type="range" value="30" min="-250" max="250" step="1" /></div> </div> <canvas id="mycanvas" width="400" height="400" data-scrawl-canvas ></canvas> <p id="reportmessage"></p> <div class="testinfo"> <h4>Test purpose</h4> <ul> <li>Create two Cells which we can use to generate images for the filter</li> <li>Load an additional image from the DOM</li> <li>For each of our assets, create an image filter to load the assets into the filter pipeline</li> <li>Create a compositing filter</li> <li>Create a Block entity, using a gradient for its fill, and apply the compositing filter to it</li> <li>Update the filter's lineIn and lineMix attributes and note the effect</li> <li>Update the composite operation, check that the choice changes the display appropriately</li> <li>In particular make sure the lineMix asset moves when the filter offset values are updated</li> </ul> <p>Note that filter memoization would provide no benefit in this demo because of the way we include the (rotating) cell-based wheel image filter in the display block filters array, even though that filter will only be displayed (as part of the compositing filter) if selected. Moral: only load process-image filters into a filter array if you intend to use them!</p> <p><b>Touch test:</b> not required</p> <p><a href="../docs/demo/filters-101.html">Annotated code</a></p> </div> <div id="my-image-store"> <img id="iris" src="img/iris.png" class="flowers" /> </div> <script src="filters-101.js" type="module"></script> </body> </html>