UNPKG

scrawl-canvas

Version:
1,127 lines (720 loc) 77.8 kB
<!DOCTYPE html> <html> <head> <title>Display shape mixin</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <ul id="jump_to"> <li> <a class="large" href="javascript:void(0);">Jump To &hellip;</a> <a class="small" href="javascript:void(0);">+</a> <div id="jump_wrapper"> <div id="jump_page_wrapper"> <div id="jump_page"> <a class="source" href="../core/animationloop.html"> ./source/core/animationloop.js </a> <a class="source" href="../core/document.html"> ./source/core/document.js </a> <a class="source" href="../core/events.html"> ./source/core/events.js </a> <a class="source" href="../core/init.html"> ./source/core/init.js </a> <a class="source" href="../core/library.html"> ./source/core/library.js </a> <a class="source" href="../core/random-seed.html"> ./source/core/random-seed.js </a> <a class="source" href="../core/snippets.html"> ./source/core/snippets.js </a> <a class="source" href="../core/userInteraction.html"> ./source/core/userInteraction.js </a> <a class="source" href="../core/utilities.html"> ./source/core/utilities.js </a> <a class="source" href="../factory/action.html"> ./source/factory/action.js </a> <a class="source" href="../factory/anchor.html"> ./source/factory/anchor.js </a> <a class="source" href="../factory/animation.html"> ./source/factory/animation.js </a> <a class="source" href="../factory/bezier.html"> ./source/factory/bezier.js </a> <a class="source" href="../factory/block.html"> ./source/factory/block.js </a> <a class="source" href="../factory/canvas.html"> ./source/factory/canvas.js </a> <a class="source" href="../factory/cell.html"> ./source/factory/cell.js </a> <a class="source" href="../factory/cog.html"> ./source/factory/cog.js </a> <a class="source" href="../factory/color.html"> ./source/factory/color.js </a> <a class="source" href="../factory/conicGradient.html"> ./source/factory/conicGradient.js </a> <a class="source" href="../factory/coordinate.html"> ./source/factory/coordinate.js </a> <a class="source" href="../factory/crescent.html"> ./source/factory/crescent.js </a> <a class="source" href="../factory/element.html"> ./source/factory/element.js </a> <a class="source" href="../factory/emitter.html"> ./source/factory/emitter.js </a> <a class="source" href="../factory/filter.html"> ./source/factory/filter.js </a> <a class="source" href="../factory/filterEngine-bluenoiseData.html"> ./source/factory/filterEngine-bluenoiseData.js </a> <a class="source" href="../factory/filterEngine.html"> ./source/factory/filterEngine.js </a> <a class="source" href="../factory/fontAttributes.html"> ./source/factory/fontAttributes.js </a> <a class="source" href="../factory/gradient.html"> ./source/factory/gradient.js </a> <a class="source" href="../factory/grid.html"> ./source/factory/grid.js </a> <a class="source" href="../factory/group.html"> ./source/factory/group.js </a> <a class="source" href="../factory/imageAsset.html"> ./source/factory/imageAsset.js </a> <a class="source" href="../factory/line.html"> ./source/factory/line.js </a> <a class="source" href="../factory/lineSpiral.html"> ./source/factory/lineSpiral.js </a> <a class="source" href="../factory/loom.html"> ./source/factory/loom.js </a> <a class="source" href="../factory/mesh.html"> ./source/factory/mesh.js </a> <a class="source" href="../factory/net.html"> ./source/factory/net.js </a> <a class="source" href="../factory/noiseAsset.html"> ./source/factory/noiseAsset.js </a> <a class="source" href="../factory/oval.html"> ./source/factory/oval.js </a> <a class="source" href="../factory/palette.html"> ./source/factory/palette.js </a> <a class="source" href="../factory/particle.html"> ./source/factory/particle.js </a> <a class="source" href="../factory/particleForce.html"> ./source/factory/particleForce.js </a> <a class="source" href="../factory/particleHistory.html"> ./source/factory/particleHistory.js </a> <a class="source" href="../factory/particleSpring.html"> ./source/factory/particleSpring.js </a> <a class="source" href="../factory/particleWorld.html"> ./source/factory/particleWorld.js </a> <a class="source" href="../factory/pattern.html"> ./source/factory/pattern.js </a> <a class="source" href="../factory/phrase.html"> ./source/factory/phrase.js </a> <a class="source" href="../factory/picture.html"> ./source/factory/picture.js </a> <a class="source" href="../factory/polygon.html"> ./source/factory/polygon.js </a> <a class="source" href="../factory/polyline.html"> ./source/factory/polyline.js </a> <a class="source" href="../factory/quadratic.html"> ./source/factory/quadratic.js </a> <a class="source" href="../factory/quaternion.html"> ./source/factory/quaternion.js </a> <a class="source" href="../factory/radialGradient.html"> ./source/factory/radialGradient.js </a> <a class="source" href="../factory/rawAsset.html"> ./source/factory/rawAsset.js </a> <a class="source" href="../factory/rdAsset.html"> ./source/factory/rdAsset.js </a> <a class="source" href="../factory/rectangle.html"> ./source/factory/rectangle.js </a> <a class="source" href="../factory/renderAnimation.html"> ./source/factory/renderAnimation.js </a> <a class="source" href="../factory/shape.html"> ./source/factory/shape.js </a> <a class="source" href="../factory/spiral.html"> ./source/factory/spiral.js </a> <a class="source" href="../factory/spriteAsset.html"> ./source/factory/spriteAsset.js </a> <a class="source" href="../factory/stack.html"> ./source/factory/stack.js </a> <a class="source" href="../factory/star.html"> ./source/factory/star.js </a> <a class="source" href="../factory/state.html"> ./source/factory/state.js </a> <a class="source" href="../factory/tetragon.html"> ./source/factory/tetragon.js </a> <a class="source" href="../factory/ticker.html"> ./source/factory/ticker.js </a> <a class="source" href="../factory/tracer.html"> ./source/factory/tracer.js </a> <a class="source" href="../factory/tween.html"> ./source/factory/tween.js </a> <a class="source" href="../factory/unstackedElement.html"> ./source/factory/unstackedElement.js </a> <a class="source" href="../factory/vector.html"> ./source/factory/vector.js </a> <a class="source" href="../factory/videoAsset.html"> ./source/factory/videoAsset.js </a> <a class="source" href="../factory/wheel.html"> ./source/factory/wheel.js </a> <a class="source" href="anchor.html"> ./source/mixin/anchor.js </a> <a class="source" href="asset.html"> ./source/mixin/asset.js </a> <a class="source" href="assetAdvancedFunctionality.html"> ./source/mixin/assetAdvancedFunctionality.js </a> <a class="source" href="assetConsumer.html"> ./source/mixin/assetConsumer.js </a> <a class="source" href="base.html"> ./source/mixin/base.js </a> <a class="source" href="cascade.html"> ./source/mixin/cascade.js </a> <a class="source" href="delta.html"> ./source/mixin/delta.js </a> <a class="source" href="displayShape.html"> ./source/mixin/displayShape.js </a> <a class="source" href="dom.html"> ./source/mixin/dom.js </a> <a class="source" href="entity.html"> ./source/mixin/entity.js </a> <a class="source" href="filter.html"> ./source/mixin/filter.js </a> <a class="source" href="mimic.html"> ./source/mixin/mimic.js </a> <a class="source" href="path.html"> ./source/mixin/path.js </a> <a class="source" href="pattern.html"> ./source/mixin/pattern.js </a> <a class="source" href="pivot.html"> ./source/mixin/pivot.js </a> <a class="source" href="position.html"> ./source/mixin/position.js </a> <a class="source" href="shapeBasic.html"> ./source/mixin/shapeBasic.js </a> <a class="source" href="shapeCurve.html"> ./source/mixin/shapeCurve.js </a> <a class="source" href="shapePathCalculation.html"> ./source/mixin/shapePathCalculation.js </a> <a class="source" href="styles.html"> ./source/mixin/styles.js </a> <a class="source" href="tween.html"> ./source/mixin/tween.js </a> </div> </div> </li> </ul> <ul class="sections"> <li id="section-1"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-1">&#x00a7;</a> </div> <h1 id="display-shape-mixin">Display shape mixin</h1> <p>This mixin defines additional attributes and functions for Stack and Canvas artefacts, in particular adding hooks for functions that will be automatically invoked when the artefact’s dimensions update.</p> </div> </li> <li id="section-2"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-2">&#x00a7;</a> </div> <h4 id="demos">Demos:</h4> <ul> <li><a href="../../demo/canvas-034.html">Canvas-034</a> - Determine the displayed shape of the visible canvas; react to changes in the displayed shape</li> <li><a href="../../demo/dom-016.html">DOM-016</a> - Determine the displayed shape of the visible stack; react to changes in the displayed shape</li> </ul> </div> </li> <li id="section-3"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-3">&#x00a7;</a> </div> <h4 id="imports">Imports</h4> </div> <div class="content"><div class='highlight'><pre><span class="hljs-keyword">import</span> { mergeOver, pushUnique, λ<span class="hljs-literal">null</span>, isa_obj, isa_number, isa_fn, Ωempty } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;../core/utilities.js&#x27;</span>;</pre></div></div> </li> <li id="section-4"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-4">&#x00a7;</a> </div> <h4 id="export-function">Export function</h4> </div> <div class="content"><div class='highlight'><pre><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">function</span> (<span class="hljs-params">P = Ωempty</span>) {</pre></div></div> </li> <li id="section-5"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-5">&#x00a7;</a> </div> <h4 id="shared-attributes">Shared attributes</h4> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">let</span> defaultAttributes = {</pre></div></div> </li> <li id="section-6"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-6">&#x00a7;</a> </div> <p>Scrawl-canvas recognises five shapes, separated by four breakpoints: </p> <ul> <li><code>banner</code></li> <li><code>landscape</code></li> <li><code>rectangle</code></li> <li><code>portrait</code></li> <li><code>skyscraper</code></li> </ul> <p>The values assigned to the breakpoints are Float numbers for the displayed Canvas element’s width/height ratio - the value <code>3</code> represents the case where the width value is three times <strong>more</strong> than the height value, while <code>0.35</code> represents a width (roughly) 3 times <strong>less</strong> than the height.</p> <p>We can set a Canvas artefact’s breakpoints in one go using the dedicated <code>setDisplayShapeBreakpoints()</code> function, as below. Alternatively we can use the regular <code>set()</code> function, supplying the attributes <code>breakToBanner</code>, <code>breakToLandscape</code>, <code>breakToPortrait</code> and <code>breakToSkyscraper</code> as required. The values given here are the default values for Canvas artefacts.</p> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attr">breakToBanner</span>: <span class="hljs-number">3</span>, <span class="hljs-attr">breakToLandscape</span>: <span class="hljs-number">1.5</span>, <span class="hljs-attr">breakToPortrait</span>: <span class="hljs-number">0.65</span>, <span class="hljs-attr">breakToSkyscraper</span>: <span class="hljs-number">0.35</span>, <span class="hljs-attr">actionBannerShape</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionLandscapeShape</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionRectangleShape</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionPortraitShape</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionSkyscraperShape</span>: <span class="hljs-literal">null</span>,</pre></div></div> </li> <li id="section-7"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-7">&#x00a7;</a> </div> <p>Scrawl-canvas also recognises five areas, again separated by four breakpoints: </p> <ul> <li><code>smallest</code></li> <li><code>smaller</code></li> <li><code>regular</code></li> <li><code>larger</code></li> <li><code>largest</code></li> </ul> <p>The values assigned to the breakpoints are Float numbers for the displayed Canvas element’s pixel area (<code>width * height</code>).</p> <ul> <li>Useful for dynamic Cells - for example Canvas base Cells, where the canvas <code>baseMatchesCanvasDimensions</code> flag has been set to <code>true</code>; in these situations we can use the area breakpoints to adjust entity dimensions and scales, and text font sizes, to better match the changed environment.</li> <li>The other option - to set the base Cell’s dimensions to known, static values and set the canvas’s <code>fit</code> attribute - suffers from image degredation when the canvas and its base cell’s dimensions are excessively different.</li> </ul> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-attr">breakToSmallest</span>: <span class="hljs-number">20000</span>, <span class="hljs-attr">breakToSmaller</span>: <span class="hljs-number">80000</span>, <span class="hljs-attr">breakToLarger</span>: <span class="hljs-number">180000</span>, <span class="hljs-attr">breakToLargest</span>: <span class="hljs-number">320000</span>, <span class="hljs-attr">actionSmallestArea</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionSmallerArea</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionRegularArea</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionLargerArea</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">actionLargestArea</span>: <span class="hljs-literal">null</span>, }; P.<span class="hljs-property">defs</span> = <span class="hljs-title function_">mergeOver</span>(P.<span class="hljs-property">defs</span>, defaultAttributes); <span class="hljs-title function_">mergeOver</span>(P, defaultAttributes);</pre></div></div> </li> <li id="section-8"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-8">&#x00a7;</a> </div> <h4 id="packet-management">Packet management</h4> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">packetFunctions</span> = <span class="hljs-title function_">pushUnique</span>(P.<span class="hljs-property">packetFunctions</span>, [<span class="hljs-string">&#x27;actionBannerShape&#x27;</span>, <span class="hljs-string">&#x27;actionLandscapeShape&#x27;</span>, <span class="hljs-string">&#x27;actionRectangleShape&#x27;</span>, <span class="hljs-string">&#x27;actionPortraitShape&#x27;</span>, <span class="hljs-string">&#x27;actionSkyscraperShape&#x27;</span>]);</pre></div></div> </li> <li id="section-9"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-9">&#x00a7;</a> </div> <h4 id="clone-management">Clone management</h4> <p>No additional clone functionality defined here</p> </div> </li> <li id="section-10"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-10">&#x00a7;</a> </div> <h4 id="kill-management">Kill management</h4> <p>No additional kill functionality defined here</p> </div> </li> <li id="section-11"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-11">&#x00a7;</a> </div> <h4 id="get-set-deltaset">Get, Set, deltaSet</h4> </div> <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">let</span> G = P.<span class="hljs-property">getters</span>, S = P.<span class="hljs-property">setters</span>;</pre></div></div> </li> <li id="section-12"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-12">&#x00a7;</a> </div> <p>Get <strong>displayShape</strong> - returns the current display shape for the Canvas or Stack artefact. Returns a string whose value can be one of <code>banner</code>, <code>landscape</code>, <code>rectangle</code>, <code>portrait</code>, or <code>skyscraper</code>.</p> </div> <div class="content"><div class='highlight'><pre> G.<span class="hljs-property">displayShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) { <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">currentDisplayShape</span>; };</pre></div></div> </li> <li id="section-13"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-13">&#x00a7;</a> </div> <p>Get <strong>displayShapeBreakpoints</strong> - returns an object with the current Number values for each of the breakpoint attributes.</p> </div> <div class="content"><div class='highlight'><pre> G.<span class="hljs-property">displayShapeBreakpoints</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) { <span class="hljs-keyword">return</span> { <span class="hljs-attr">breakToBanner</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToBanner</span>, <span class="hljs-attr">breakToLandscape</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLandscape</span>, <span class="hljs-attr">breakToPortrait</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToPortrait</span>, <span class="hljs-attr">breakToSkyscraper</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSkyscraper</span>, <span class="hljs-attr">breakToSmallest</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmallest</span>, <span class="hljs-attr">breakToSmaller</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmaller</span>, <span class="hljs-attr">breakToLarger</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLarger</span>, <span class="hljs-attr">breakToLargest</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLargest</span>, }; };</pre></div></div> </li> <li id="section-14"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-14">&#x00a7;</a> </div> <p>Set <strong>displayShapeBreakpoints</strong> - breakpoints can be set individually, or alternatively they can be supplied in an object keyed to this attribute</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">displayShapeBreakpoints</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">items = Ωempty</span>) { <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> [key, val] <span class="hljs-keyword">of</span> <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">entries</span>(items)) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(val)) { <span class="hljs-keyword">switch</span> (key) { <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToBanner&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToBanner</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToLandscape&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLandscape</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToPortrait&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToPortrait</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToSkyscraper&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSkyscraper</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToSmallest&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmallest</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToSmaller&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmaller</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToLarger&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLarger</span> = val; <span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-string">&#x27;breakToLargest&#x27;</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLargest</span> = val; <span class="hljs-keyword">break</span>; } } } <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayArea</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-15"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-15">&#x00a7;</a> </div> <p><code>setDisplayShapeBreakpoints</code> - an alternative mechanism to set breakpoints beyond the normal <code>set</code> function</p> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">setDisplayShapeBreakpoints</span> = S.<span class="hljs-property">displayShapeBreakpoints</span>;</pre></div></div> </li> <li id="section-16"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-16">&#x00a7;</a> </div> <p>Set <strong>breakToBanner</strong> - the breakpoint between <code>landscape</code> and <code>banner</code> display shapes; value will generally be a number greater than <code>1</code></p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToBanner</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToBanner</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-17"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-17">&#x00a7;</a> </div> <p>Set <strong>breakToLandscape</strong> - the breakpoint between <code>landscape</code> and <code>rectangle</code> display shapes; value will generally be a number greater than <code>1</code></p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToLandscape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLandscape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-18"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-18">&#x00a7;</a> </div> <p>Set <strong>breakToPortrait</strong> - the breakpoint between <code>portrait</code> and <code>rectangle</code> display shapes; value will generally be a number greater than <code>0</code> and less than <code>1</code></p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToPortrait</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToPortrait</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-19"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-19">&#x00a7;</a> </div> <p>Set <strong>breakToSkyscraper</strong> - the breakpoint between <code>portrait</code> and <code>skyscraper</code> display shapes; value will generally be a number greater than <code>0</code> and less than <code>1</code></p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToSkyscraper</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSkyscraper</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-20"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-20">&#x00a7;</a> </div> <p>Set <strong>breakToSmallest</strong> - the breakpoint between <code>smaller</code> and <code>smallest</code> display shapes</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToSmallest</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmallest</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayArea</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-21"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-21">&#x00a7;</a> </div> <p>Set <strong>breakToSmaller</strong> - the breakpoint between <code>regular</code> and <code>smaller</code> display shapes</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToSmaller</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToSmaller</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayArea</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-22"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-22">&#x00a7;</a> </div> <p>Set <strong>breakToLarger</strong> - the breakpoint between <code>regular</code> and <code>larger</code> display shapes</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToLarger</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLarger</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayArea</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-23"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-23">&#x00a7;</a> </div> <p>Set <strong>breakToLargest</strong> - the breakpoint between <code>larger</code> and <code>largest</code> display shapes</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">breakToLargest</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_number</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">breakToLargest</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayArea</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-24"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-24">&#x00a7;</a> </div> <p>Each display shape has an associated hook function (by default a function that does nothing) which Scrawl-canvas will run each time it detects that the Canvas display shape has changed to that shape. We can replace these null-functions with our own; this allows us to configure the scene/animation to accommodate different display shapes, thus making the code reusable in a range of different web page environments.</p> <p>We can set/update these functions at any time using the normal <code>set()</code> function. We can also set/update the functions using dedicated <code>setAction???Shape()</code> functions:</p> </div> </li> <li id="section-25"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-25">&#x00a7;</a> </div> <p>Set <strong>actionBannerShape</strong> - must be a Function</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">actionBannerShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_fn</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">actionBannerShape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-26"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-26">&#x00a7;</a> </div> <p><code>setActionBannerShape</code> - an alternative mechanism to set the <strong>actionBannerShape</strong> function, beyond the normal <code>set</code> functionality</p> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">setActionBannerShape</span> = S.<span class="hljs-property">actionBannerShape</span>;</pre></div></div> </li> <li id="section-27"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-27">&#x00a7;</a> </div> <p>Set <strong>actionLandscapeShape</strong> - must be a Function</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">actionLandscapeShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_fn</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">actionLandscapeShape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-28"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-28">&#x00a7;</a> </div> <p><code>setActionLandscapeShape</code> - an alternative mechanism to set the <strong>actionLandscapeShape</strong> function, beyond the normal <code>set</code> functionality</p> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">setActionLandscapeShape</span> = S.<span class="hljs-property">actionLandscapeShape</span>;</pre></div></div> </li> <li id="section-29"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-29">&#x00a7;</a> </div> <p>Set <strong>actionRectangleShape</strong> - must be a Function</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">actionRectangleShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_fn</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">actionRectangleShape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-30"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-30">&#x00a7;</a> </div> <p><code>setActionRectangleShape</code> - an alternative mechanism to set the <strong>actionRectangleShape</strong> function, beyond the normal <code>set</code> functionality</p> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">setActionRectangleShape</span> = S.<span class="hljs-property">actionRectangleShape</span>;</pre></div></div> </li> <li id="section-31"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-31">&#x00a7;</a> </div> <p>Set <strong>actionPortraitShape</strong> - must be a Function</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">actionPortraitShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_fn</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">actionPortraitShape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <span class="hljs-literal">true</span>; };</pre></div></div> </li> <li id="section-32"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-32">&#x00a7;</a> </div> <p><code>setActionPortraitShape</code> - an alternative mechanism to set the <strong>actionPortraitShape</strong> function, beyond the normal <code>set</code> functionality</p> </div> <div class="content"><div class='highlight'><pre> P.<span class="hljs-property">setActionPortraitShape</span> = S.<span class="hljs-property">actionPortraitShape</span>;</pre></div></div> </li> <li id="section-33"> <div class="annotation"> <div class="sswrap "> <a class="ss" href="#section-33">&#x00a7;</a> </div> <p>Set <strong>actionSkyscraperShape</strong> - must be a Function</p> </div> <div class="content"><div class='highlight'><pre> S.<span class="hljs-property">actionSkyscraperShape</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) { <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_fn</span>(item)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">actionSkyscraperShape</span> = item; <span class="hljs-variable language_">this</span>.<span class="hljs-property">dirtyDisplayShape</span> = <s