Changeset - 717a971132eb
[Not reviewed]
default
0 3 0
Drew Perttula - 7 years ago 2018-06-05 06:55:45
drewp@bigasterisk.com
float vs str values on live
Ignore-this: 9eb228a2a3b2e9cdb4fe821251703268
3 files changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -276,25 +276,28 @@ class window.SyncedGraph
 
      when 1
 
        obj = objs.values().next().value
 
        return obj
 
      else
 
        throw new Error("too many different values: " + JSON.stringify(quads))
 

	
 
  floatValue: (s, p) ->
 
    key = s.value + '|' + p.value
 
    hit = @cachedFloatValues.get(key)
 
    return hit if hit != undefined
 
    #log('float miss', s, p)
 

	
 
    ret = parseFloat(@_singleValue(s, p).value)
 
    v = @_singleValue(s, p).value
 
    ret = parseFloat(v)
 
    if isNaN(ret)
 
      throw new Error("#{s.value} #{p.value} -> #{v} not a float")
 
    @cachedFloatValues.set(key, ret)
 
    return ret
 
    
 
  stringValue: (s, p) ->
 
    @_singleValue(s, p).value
 
    
 
  uriValue: (s, p) ->
 
    key = s.value + '|' + p.value
 
    hit = @cachedUriValues.get(key)
 
    return hit if hit != undefined
 

	
 
    ret = @_singleValue(s, p)
light9/web/light9-color-picker.html
Show inline comments
 
@@ -298,25 +298,27 @@
 
         this.moveLargeCrosshair(pos);
 
         this.$.large.style.left = (x - Math.max(20, Math.min(380, pos[0]))) + 'px';
 
         this.$.large.style.top = (y - Math.max(20, Math.min(180, pos[1]))) + 'px';
 
       } catch(e) {
 
         this.moveLargeCrosshair([-999, -999]);
 
         this.$.large.style.left = (400 / 2) + 'px';
 
         this.$.large.style.top = (200 / 2) + 'px';
 
         return;
 
       }
 
     }
 
     hideLarge() {
 
       this.$.large.style.display = 'none';
 
       this.readColor(this.color);
 
       if (this.color !== undefined) {
 
         this.readColor(this.color);
 
       }
 
       this.closeTime = Date.now();
 
     }
 
     onEnterSmall(ev) {
 
       if (this.closeTime && this.closeTime > Date.now() - 500) {
 
         return;
 
       }
 

	
 
       // if scrolling put us here, don't open large. require deliberate entering motion.
 
       
 
       this.showLarge(ev.pageX, ev.pageY);
 
     }
 
     moveLargeCrosshair(pos, _elem) {
light9/web/live/live.coffee
Show inline comments
 
@@ -123,41 +123,42 @@ coffeeElementSetup(class Light9LiveContr
 
      @effectPreview = JSON.stringify(v for k,v of @currentSettings)
 

	
 
      @sendAllThrottled()
 

	
 
  currentSettingsList: -> (v for k,v of @currentSettings)
 
      
 
  sendAll: ->
 
    @client.send(@currentSettingsList())
 

	
 
  valuePred: (attr) ->
 
    U = (x) => @graph.Uri(x)
 
    scaledAttributeTypes = [U(':color'), U(':brightness'), U(':uv')]
 
    if attr in scaledAttributeTypes then U(':scaledValue') else U(':value')
 
    if [attr.equals(x) for x in scaledAttributeTypes].length then U(':scaledValue') else U(':value')
 

	
 
  onEffect: ->
 
    U = (x) => @graph.Uri(x)
 
    return unless @effect
 
    log('load', @effect)
 
    for s in @graph.objects(@effect, U(':setting'))
 
      dev = @graph.uriValue(s, U(':device'))
 
      devAttr = @graph.uriValue(s, U(':deviceAttr'))
 

	
 
      pred = @valuePred(devAttr)
 
      try
 
        value = @graph.floatValue(s, pred)
 
      catch
 
        value = @graph.stringValue(s, pred)
 
      log('got', devAttr, value)
 
      window.gather([[dev, devAttr, value]])
 
      # there's nothing here to set the widgets to these values.
 
            
 
  saveNewEffect: ->
 
    uriName = @newEffectName.replace(/[^a-zA-Z0-9_]/g, '')
 
    return if not uriName.length
 

	
 
    U = (x) => @graph.Uri(x)
 

	
 
    @effect = U(U(":effect").value + "/#{uriName}")
 
    ctx = U("http://light9.bigasterisk.com/show/dance2017/effect/#{uriName}")
 
    quad = (s, p, o) => @graph.Quad(s, p, o, ctx)
 

	
 
    addQuads = [
0 comments (0 inline, 0 general)