setunset

<script src="./point_src/setunset"></script>

The "Set Unset" tool acts similar to the ctx.save() method, by applying changes to the context, and then unsetting after usage.

This allows the switching of a property of the context with set and unset values previously assigned to changed properties are reapplied - essentially wrapping some drawing with context changes.

su = new SetUnset({
    lineWidth: 10
})

// lineWidth == ...
su.set(ctx)
// lineWidth == 10
su.unset(ctx)
// lineWidth == ...

Implement shortcuts:

class Stroke extends SetUnset {
    getOpts() {
        let supported = new Set([
            , "lineWidth"
        ])

        let map = {
            color: 'strokeStyle'
        }
        let functional = {
            dash: 'lineDashKeyApply'
        }
        return [supported, map, functional]
    }
}

st = new Stroke({
    color: 'red'
})
Meta Data
filepath_exists True
path setunset
filepath setunset.js
clean_files ()

  • ClassDeclaration
    class comments:
    The "Set Unset" tool acts similar to the _ctx.save()_ method, by applying changes to the context, and then _unsetting_ after usage. This allows the _switching_ of a property of the context with `set` and `unset` values previously assigned to changed properties are reapplied - essentially _wrapping_ some drawing with context changes. su = new SetUnset({ lineWidth: 10 }) // lineWidth == ... su.set(ctx) // lineWidth == 10 su.unset(ctx) // lineWidth == ... Implement shortcuts: class Stroke extends SetUnset { getOpts() { let supported = new Set([ , "lineWidth" ]) let map = { color: 'strokeStyle' } let functional = { dash: 'lineDashKeyApply' } return [supported, map, functional] } } st = new Stroke({ color: 'red' })
    Perform _stroke_ with styling and stoking; but with a convenient on/off without using the context switcher.
    • constructor

      constructor

      (
      settings = {}
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Perform _stroke_ with styling and stoking; but with a convenient on/off without using the context switcher.
    • method

      onCreate

      (
      cachedData
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    • method

      update

      (
      settings
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Apply changes for the persistent info
    • method

      getOpts

      (
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    • method

      prepare

      (
      settings
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      when _settings_ to the ctx + first check if its a raw prop, + else then resolve from the map. + keep the last value + Apply through the given function + accept a optional return function, to call during unset. Therefore the stroker has a _state_ This should occur _early_ such that the _set_ here runs a chain of on/off functions in a map. Which means: 1. for each key resolve ctx (real prop map key), on method, off method 2. store those until _set_ 3. iter on map; calling each func with the ctx and the value 4. iter off map, calling each with the stored value, reapplying in the func.
    • method

      genericKeyApply

      (
      ctx , key , newValue
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Receive a ctx key property (e.g. lineWidth) and apply the newValue Return the previously applied value and a function to remove reverse change.
    • method

      genericKeyRemove

      (
      ctx , key , newValue
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      the newValue given is the original value applied to this key, before the change occured (the cached value). Therefore the _remove_ is identical to the _apply_.
    • method

      functionKeyApply

      (
      ctx , assignment , newValue , key
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Call upon the `aasignment` function, with the key and value. This expects a {f: function,v: value} response
    • method

      set

      (
      ctx , settings
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Iter all the assignments, functionally calling each
    • method

      getCacheBeforeApply

      (
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    • method

      unset

      (
      ctx , settings
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Remove any currently applied styles, by reading the cache and performing the reverse.
    • method

      draw

      (
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      a start but probably more dynamic.
    • method

      wrap

      (
      ctx , settings , func
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      Wrap the call with a start stop wrap(ctx, ()=>{}) wrap(ctx, settings, ()=>{})
    • method

      step

      (
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      A _step_ is required when integrating moving values, such as the dash offset animation.
    • method

      off

      (
      setDisable = True
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
      undo any _on_ and _pause_ the _on_ function
    • method

      on

      (
      setEnable = True
      )
      from class_name
      dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])
    dict_keys(['kind', 'word', 'parentName', 'type', 'body', 'comments', 'pos'])