# HG changeset patch # User drewp@bigasterisk.com # Date 2016-06-11 17:16:55 # Node ID e3de5d1208ca19d67ad206f2b1b6b1e1f49cc961 # Parent 185f3e2208c315aa8153ed849fd55b73eada9229 refactor makeNewNote Ignore-this: b1f934761ccb6359f9625cf4cc5969f8 diff --git a/light9/web/timeline/timeline.coffee b/light9/web/timeline/timeline.coffee --- a/light9/web/timeline/timeline.coffee +++ b/light9/web/timeline/timeline.coffee @@ -221,9 +221,7 @@ Polymer attached: -> root = @closest('light9-timeline-editor') setupDrop @, @$.rows, root, (effect, pos) => - U = (x) -> @graph.Uri(x) - quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song} # we could probably accept some initial overrides right on the # effect uri, maybe as query params @@ -233,33 +231,37 @@ Polymer return dropTime = @zoomInX.invert(pos.e(1)) + @makeNewNote(effect, dropTime) - newNote = graph.nextNumberedResource("#{@song}/n") - newCurve = graph.nextNumberedResource("#{newNote}c") - points = graph.nextNumberedResources("#{newCurve}p", 4) + makeNewNote: (effect, dropTime) -> + U = (x) -> @graph.Uri(x) + quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song} - curveQuads = [ - quad(@song, U(':note'), newNote) - quad(newNote, RDF + 'type', U(':Note')) - quad(newNote, U(':originTime'), @graph.LiteralRoundedFloat(dropTime)) - quad(newNote, U(':effectClass'), effect) - quad(newNote, U(':curve'), newCurve) - quad(newCurve, RDF + 'type', U(':Curve')) - quad(newCurve, U(':attr'), U(':strength')) - ] - pointQuads = [] - for i in [0...4] - pt = points[i] - pointQuads.push(quad(newCurve, U(':point'), pt)) - pointQuads.push(quad(pt, U(':time'), @graph.LiteralRoundedFloat(i))) - pointQuads.push(quad(pt, U(':value'), @graph.LiteralRoundedFloat(i == 1 or i == 2))) - - patch = { - delQuads: [] - addQuads: curveQuads.concat(pointQuads) - } - @graph.applyAndSendPatch(patch) - + newNote = @graph.nextNumberedResource("#{@song}/n") + newCurve = @graph.nextNumberedResource("#{newNote}c") + points = @graph.nextNumberedResources("#{newCurve}p", 4) + + curveQuads = [ + quad(@song, U(':note'), newNote) + quad(newNote, RDF + 'type', U(':Note')) + quad(newNote, U(':originTime'), @graph.LiteralRoundedFloat(dropTime)) + quad(newNote, U(':effectClass'), effect) + quad(newNote, U(':curve'), newCurve) + quad(newCurve, RDF + 'type', U(':Curve')) + quad(newCurve, U(':attr'), U(':strength')) + ] + pointQuads = [] + for i in [0...4] + pt = points[i] + pointQuads.push(quad(newCurve, U(':point'), pt)) + pointQuads.push(quad(pt, U(':time'), @graph.LiteralRoundedFloat(i))) + pointQuads.push(quad(pt, U(':value'), @graph.LiteralRoundedFloat(i == 1 or i == 2))) + + patch = { + delQuads: [] + addQuads: curveQuads.concat(pointQuads) + } + @graph.applyAndSendPatch(patch) Polymer is: "light9-timeline-time-axis",