• Jump To … +
    ./source/core/animationloop.js ./source/core/document.js ./source/core/events.js ./source/core/init.js ./source/core/library.js ./source/core/random-seed.js ./source/core/snippets.js ./source/core/userInteraction.js ./source/core/utilities.js ./source/factory/action.js ./source/factory/anchor.js ./source/factory/animation.js ./source/factory/bezier.js ./source/factory/block.js ./source/factory/canvas.js ./source/factory/cell.js ./source/factory/cog.js ./source/factory/color.js ./source/factory/conicGradient.js ./source/factory/coordinate.js ./source/factory/crescent.js ./source/factory/element.js ./source/factory/emitter.js ./source/factory/filter.js ./source/factory/filterEngine-bluenoiseData.js ./source/factory/filterEngine.js ./source/factory/fontAttributes.js ./source/factory/gradient.js ./source/factory/grid.js ./source/factory/group.js ./source/factory/imageAsset.js ./source/factory/line.js ./source/factory/lineSpiral.js ./source/factory/loom.js ./source/factory/mesh.js ./source/factory/net.js ./source/factory/noiseAsset.js ./source/factory/oval.js ./source/factory/palette.js ./source/factory/particle.js ./source/factory/particleForce.js ./source/factory/particleHistory.js ./source/factory/particleSpring.js ./source/factory/particleWorld.js ./source/factory/pattern.js ./source/factory/phrase.js ./source/factory/picture.js ./source/factory/polygon.js ./source/factory/polyline.js ./source/factory/quadratic.js ./source/factory/quaternion.js ./source/factory/radialGradient.js ./source/factory/rawAsset.js ./source/factory/rdAsset.js ./source/factory/rectangle.js ./source/factory/renderAnimation.js ./source/factory/shape.js ./source/factory/spiral.js ./source/factory/spriteAsset.js ./source/factory/stack.js ./source/factory/star.js ./source/factory/state.js ./source/factory/tetragon.js ./source/factory/ticker.js ./source/factory/tracer.js ./source/factory/tween.js ./source/factory/unstackedElement.js ./source/factory/vector.js ./source/factory/videoAsset.js ./source/factory/wheel.js ./source/mixin/anchor.js ./source/mixin/asset.js ./source/mixin/assetAdvancedFunctionality.js ./source/mixin/assetConsumer.js ./source/mixin/base.js ./source/mixin/cascade.js ./source/mixin/delta.js ./source/mixin/displayShape.js ./source/mixin/dom.js ./source/mixin/entity.js ./source/mixin/filter.js ./source/mixin/mimic.js ./source/mixin/path.js ./source/mixin/pattern.js ./source/mixin/pivot.js ./source/mixin/position.js ./source/mixin/shapeBasic.js ./source/mixin/shapeCurve.js ./source/mixin/shapePathCalculation.js ./source/mixin/styles.js ./source/mixin/tween.js
  • §

    Core initialization

    A single, exported function (to modules). This needs to run once after the scrawl.js module (or equivalent) loads

  • §

    Imports

    import { startCoreAnimationLoop } from './animationloop.js';
    import { getCanvases, getStacks } from './document.js';
    import { startCoreListeners, applyCoreResizeListener, applyCoreScrollListener } from './userInteraction.js';
    
    import { makeColor } from '../factory/color.js';
    
    
    const init = function () {
  • §

    Environment checks

  • §

    Flags to indicate if Scrawl-canvas is running in a touch-enabled environment. We lodge the results in the window object so other parts of the Scrawl-canvas code base can quickly check them

  • §

    Flag to indicate whether the device is touch-enabled

        window.scrawlEnvironmentTouchSupported = ('ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch)) ? true : false;
  • §

    Initialization

  • §

    Discovery phase - collect all canvas elements present in the DOM, and any other elements with a ‘data-stack’ attribute

        getStacks();
        getCanvases();
  • §

    Start the core animation loop

        startCoreAnimationLoop();
  • §

    Start the core listeners on the window object

        applyCoreResizeListener();
        applyCoreScrollListener();
        startCoreListeners();
  • §

    Dedicated entity state color engine - this allows the user to set a fillStyle, strokeStyle or shadowColor attribute to any CSS color string

    • Can’t set this as part of the State factory initialization as it appears to run before the Color factory initializes
    	window.scrawlEnvironmentColorChecker = makeColor({
    	    name: 'entity-colorEngine-do-not-overwrite',
    	});
    
    };
  • §

    Exports

    export {
        init,
    };