- Jump To … +
  ./source/core/animation-loop.js ./source/core/display-cycle.js ./source/core/document-root-elements.js ./source/core/document.js ./source/core/events.js ./source/core/init.js ./source/core/library.js ./source/core/random-seed.js ./source/core/shared-vars.js ./source/core/snippets.js ./source/core/system-flags.js ./source/core/user-interaction.js ./source/core/utilities.js ./source/factory/action.js ./source/factory/anchor.js ./source/factory/animation.js ./source/factory/array-pool.js ./source/factory/bezier.js ./source/factory/block.js ./source/factory/canvas.js ./source/factory/cell-fragment.js ./source/factory/cell.js ./source/factory/cog.js ./source/factory/color.js ./source/factory/conic-gradient.js ./source/factory/coordinate.js ./source/factory/crescent.js ./source/factory/drag-zone.js ./source/factory/element.js ./source/factory/emitter.js ./source/factory/filter-engine-bluenoise-data.js ./source/factory/filter-engine.js ./source/factory/filter.js ./source/factory/font-attributes.js ./source/factory/gradient.js ./source/factory/grid.js ./source/factory/group.js ./source/factory/image-asset.js ./source/factory/keyboard-zone.js ./source/factory/line-spiral.js ./source/factory/line.js ./source/factory/loom.js ./source/factory/mesh.js ./source/factory/net.js ./source/factory/noise-asset.js ./source/factory/observe-update.js ./source/factory/oval.js ./source/factory/palette.js ./source/factory/particle-force.js ./source/factory/particle-history.js ./source/factory/particle-spring.js ./source/factory/particle-world.js ./source/factory/particle.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/radial-gradient.js ./source/factory/raw-asset.js ./source/factory/reaction-diffusion-asset.js ./source/factory/rectangle.js ./source/factory/render-animation.js ./source/factory/shape.js ./source/factory/spiral.js ./source/factory/sprite-asset.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/unstacked-element.js ./source/factory/vector.js ./source/factory/video-asset.js ./source/factory/wheel.js ./source/mixin/anchor.js ./source/mixin/asset-advanced-functionality.js ./source/mixin/asset-consumer.js ./source/mixin/asset.js ./source/mixin/base.js ./source/mixin/cascade.js ./source/mixin/cell-key-functions.js ./source/mixin/delta.js ./source/mixin/display-shape.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/shape-basic.js ./source/mixin/shape-curve.js ./source/mixin/shape-path-calculation.js ./source/mixin/styles.js ./source/mixin/tween.js

- §

  # Core library

  Scrawl-canvas stores most of the objects it creates in a centralized space, so that they can be referenced from other places in the code base, and from user-written code.

  While some sections are dedicated to a single type of object, other sections are aggregations - this may lead to name conflicts if coders are not rigorous in their naming conventions when creating objects (through the make factory functions).

  `Exported object` (to modules and scrawl object). Scrawl-canvas exposes the library, and its sections, for import into other script files

- §

  No imports required

- §

  Current version

      export const version = '8.10.4';

- §

  Objects created using the makeAnchor factory

      export const anchor = {};
      export const anchornames = [];

- §

  Objects created using the makeAnimation and makeRender factories

      export const animation = {};
      export const animationnames = [];

- §

  Objects - specifically tickers - created using the makeTicker and makeTween factories

      export const animationtickers = {};
      export const animationtickersnames = [];

- §

  An aggregate of all contents in the canvas, element, entity and stack sections of the library.

      export const artefact = {};
      export const artefactnames = [];

- §

  Scrawl-canvas wrappers for visual media (images, videos, sprites). Anything that a Picture entity or Pattern style can use as their asset source needs to be included in this section of the library

      export const asset = {};
      export const assetnames = [];

- §

  Canvas element wrappers created during Scrawl-canvas initialization, and the makeCanvas, getCanvas and addCanvas factories

      export const canvas = {};
      export const canvasnames = [];

- §

  Objects created using the makeCell and canvas.buildCell factories

      export const cell = {};
      export const cellnames = [];

- §

  DOM element wrappers created during Scrawl-canvas initialization, and created using the makeElement, Stack.addExistingDomElement and Stack.addNewElement factories

      export const element = {};
      export const elementnames = [];

- §

  All canvas-related artefacts (Blocks, Wheels, etc) get stored in the entity section of the library.

      export const entity = {};
      export const entitynames = [];

- §

  Objects created using the makeFilter factory

      export const filter = {};
      export const filternames = [];

- §

  Used internally by Phrase artefacts

      export const fontattribute = {};
      export const fontattributenames = [];

- §

  Objects created using the makeGroup factory, and generated as part of the process of creating Stack and Canvas artefacts, and Cell assets.

      export const group = {};
      export const groupnames = [];

- §

  Used internally by Gradient and RadialGradient styles

      export const palette = {};
      export const palettenames = [];

- §

  Physics-related objects

      export const particle = {};
      export const particlenames = [];

      export const force = {};
      export const forcenames = [];

      export const spring = {};
      export const springnames = [];

      export const world = {};
      export const worldnames = [];

- §

  Stack element wrappers created during Scrawl-canvas initialization, and created using the makeStack and addStack factories

      export const stack = {};
      export const stacknames = [];

- §

  Objects created using the makeTween and makeAction factories

      export const tween = {};
      export const tweennames = [];

- §

  Objects created using the makeGradient, makeRadialGradient, makePattern and makeColor factories

      export const styles = {};
      export const stylesnames = [];

- §

  DOM unstackedElement wrappers created using the makeUnstackedElement and makeSnippet factories

      export const unstackedelement = {};
      export const unstackedelementnames = [];

- §

  Given a `namespace` string, kill all objects created with that namespace

  - Function assumes that the namespace string appears as the first part of the object’s `name` attribute

      export function purge (namespace = '') {

          const remove = function (candidates, target, flag = false) {

              candidates.forEach(c => {

                  const obj = target[c];

                  if (obj && obj.kill) obj.kill(flag);
              });
          };

          if (namespace) {

              const candidateArtefacts = artefactnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateArtefacts, artefact);

              const candidateAssets = assetnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateAssets, asset);

              const candidateGroups = groupnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateGroups, group, true);

              const candidateStyles = stylesnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateStyles, styles);

              const candidateTweens = tweennames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateTweens, tween);

              const candidateAnimations = animationnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateAnimations, animation);

              const candidateAnimationTickers = animationtickersnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateAnimationTickers, animationtickers);

              const candidateFilters = filternames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateFilters, filter);

              const candidateAnchors = anchornames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateAnchors, anchor);

              const candidateForces = forcenames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateForces, force);

              const candidateSprings = springnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateSprings, spring);

              const candidateWorlds = worldnames.filter(c => c.indexOf(namespace) === 0);
              remove(candidateWorlds, world);
          }
      }

- §

  Section classes are used with Phrase entitys - we store the class definitions in the library so that they can be easily shared between Phrases

      export const sectionClasses = {
          'DEFAULTS': { defaults: true },

          'b': { weight: 'bold' },
          '/b': { weight: 'normal' },
          'strong': { weight: 'bold' },
          '/strong': { weight: 'normal' },
          'BOLD': { weight: 'bold' },
          '/BOLD': { weight: 'normal' },

          'i': { style: 'italic' },
          '/i': { style: 'normal' },
          'em': { style: 'italic' },
          '/em': { style: 'normal' },
          'ITALIC': { style: 'italic' },
          '/ITALIC': { style: 'normal' },

          'u': { underline: true },
          '/u': { underline: false },
          'UNDERLINE': { underline: true },
          '/UNDERLINE': { underline: false },

          'OVERLINE': { overline: true },
          '/OVERLINE': { overline: false },

          'SMALL-CAPS': { variant: 'small-caps' },
          '/SMALL-CAPS': { variant: 'normal' },

          'HIGHLIGHT': { highlight: true },
          '/HIGHLIGHT': { highlight: false },
      };

- §

  All makeXXX factory functions get added as references to the constructors section of the library - used mainly as part of Scrawl-canvas cloning functionality.

      export const constructors = {};