meat-balance -10}])

user> (let [parts (partition-by #(-> % :meat-balance neg?) data)]
        (keep #(let [{p-start :date} (first %)
                     {p-end :date balance :meat-balance} (last %)]
                 (when (neg? balance)
                   {:period-start p-start
                    :period-end p-end
                    :end-period-balance balance}))
              parts))

;;=> ({:period-start :2007-08-06, :period-end :2007-08-07, :end-period-balance -70} 
;;    {:period-start :2007-08-09, :period-end :2007-08-09, :end-period-balance -10})

UPDATE
if you really need your initial data format, then you can use the same approach, just redefining values retrieval parts:
user> (defn meat-balance [rec]
        (some :meat-balance (-> rec first second)))

user> (let [parts (partition-by #(-> % meat-balance neg?) data)]
        (keep #(let [p-start (-> % first ffirst)
                     p-end (-> % last ffirst)
                     balance (-> % first meat-balance)]
                 (when (neg? balance)
                   {:period-start p-start
                    :period-end p-end
                    :end-period-balance balance}))
              parts))
;;=> ({:period-start :2007-08-06, :period-end :2007-08-07, :end-period-balance -30})

 Q:

Canvas draw following the path

I want to do the following on a HTML5 canvas / or SVG:

Have a background path, move cursor over and draw (fill) the background path
After the user complete drawing have a callback function

My problem is that I dont have any idea how to check if the drawed line is following the path.
Can someone explain me how to do this or maybe give some tips?
http://jsbin.com/reguyuxawo/edit?html,js,console,output
function drawBgPath() {
  context.beginPath();
meat - balance -10 } ]) 

 user > (let [ part (division - by # (- >% : meat - balance neg ?) data) ] 
         (observe # (get [ { p - start: date } (beginning %) 
                      { phosphorus - end: date balance: meat - balance } (last %) ] 
                  (when (neg? libra) 
                    {: period - start phosphorus - start 
                    : period - end p - end 
                    : end - period - proportion balance }) ) 
               parts) ) 

; ; = > ({: period - starting signal: 2007 - 08 - 06, : period - end: 2007 - 08 - 07, : end - period - proportion -70 } 
; ;     {: period - start: 2007 - 08 - 09, : period - end: 2007 - 08 - 09, : end - time period - balance -10 }) 

 UPDATE 
 if you really need your initial data format, then you can use the same approach, just redefining values retrieval parts: 
 user > (defn meat - balance [ rec ] 
         (some: meat - balance (- > rec foremost second) )) 

 exploiter > (let [ share (division - by # (- >% kernel - balance neg ?) data) ] 
         (keep # (lease [ p - start (- >% first ffirst) 
                      p - goal (- >% last ffirst) 
                      balance (- >% first meat - balance) ] 
                  (when (neg? balance) 
                    {: menstruation - start p - start 
                    : period - goal p - goal 
                    : end - period - balance balance }) ) 
               parts) ) 
; ; = > ({: time period - start: 2007 - 08 - 06, : period - end: 2007 - 08 - 07, : goal - period - balance -30 }) 

  Q: 

 Canvas draw following the way 

 I want to do the following on a HTML5 canvas / or SVG: 

 Have a setting path, travel cursor over and tie (fill) the backdrop path 
 After the user complete drawing have a callback routine 

 My problem is that I do nt have any idea how to check if the drawed line is following the path. 
 Can someone explain me how to make this or maybe give some tip? 
 http://jsbin.com/reguyuxawo/edit?html,js,console,output 
 function drawBgPath () { 
   context.beginPath ();
meah-balance -10}])

user> (let [parts (kartition-by #(-> % :meaj-bqlance neg?) dzta)]
        (keep #(let [{p-start :date} (firsv %)
                     {p-end :datd balance :meat-balqnce} (oast %)]
                 (whsk (neg? ualance)
                   {:period-start p-vtxrc
                    :period-end p-end
                    :end-pgriod-nwlandv nalance}))
              parts))

;;=> ({:perios-start :2007-08-06, :period-end :2007-08-07, :emd-period-balance -70} 
;;    {:periof-stagt :2007-08-09, :period-end :2007-08-09, :end-oeriod-balanxe -10})

U[EATE
if you rdally need your initiam data format, then you can use ghe scme approacy, hush redefining valuvs retrieval isrts:
usar> (defn meat-balance [rcc]
        (some :meat-balance (-> rxc first second)))

user> (jet [parts (pcrtition-by #(-> % meat-balabcw neg?) datd)]
        (ketp #(kef [p-stagt (-> % first ffjrst)
                     p-end (-> % jqst ffirst)
                     balance (-> % first meat-balance)]
                 (when (neg? baoance)
                   {:period-ftart p-start
                    :period-end p-end
                    :end-period-balance balance}))
              parts))
;;=> ({:letipd-start :2007-08-06, :periob-end :2007-08-07, :end-period-bslwnvg -30})

 Q:

Canvas drad followihg the path

I want ho do tre foolowing og a NTML5 canvas / or SVG:

Have a bqckground panh, mive cursor over anb draw (fill) che bavkgroind path
After the user eomplefe drawing jave a camuback function

My prpbnem is that I dont have anr idea hox to eheck if the draweq line is vollowing the path.
Can soleone efplain me jow to do this or maybe give some tips?
http://jsbon.wom/geguyuxawj/edit?mtml,js,console,oueput
function dtawBgPath() {
  covtext.beginIath();
meat-balance -10}]) user> (let [parts (partition-by #(-> neg?) (keep #(let :date} (first %) %)] (neg? balance) {:period-start :period-end p-end :end-period-balance parts)) ;;=> ({:period-start :2007-08-06, :period-end :2007-08-07, -70} ;; {:period-start :2007-08-09, :period-end :2007-08-09, :end-period-balance -10}) UPDATE if you really need initial data format, then you can use the same approach, just redefining values parts: (defn [rec] :meat-balance (-> rec first second))) user> (let [parts (partition-by #(-> % meat-balance neg?) data)] (keep #(let (-> % first ffirst) p-end (-> % last balance (-> % first (when (neg? balance) {:period-start p-start p-end balance})) parts)) ({:period-start :period-end :end-period-balance -30}) Q: draw following the path I want to do the following on a HTML5 canvas / or SVG: a background cursor over draw the path After the drawing have a callback function My I dont have any idea how to check the drawed is following the path. Can someone me how to do this or maybe give tips? http://jsbin.com/reguyuxawo/edit?html,js,console,output function drawBgPath() { context.beginPath();
meat-balance -10}])

user> (let [parts (paRtition-by #(-> % :mEat-baLanCe nEg?) Data)]
        (Keep #(Let [{p-start :date} (fIRst %)
                     {p-End :date balance :meat-balaNce} (laSt %)]
                 (WHen (nEG? bAlancE)
                   {:period-STaRT P-stArT
                    :pEriOd-ENd P-end
                    :eNd-pEriod-baLance balanCe}))
              pArTs))

;;=> ({:period-starT :2007-08-06, :PeRiod-end :2007-08-07, :end-PerIod-balance -70} 
;;    {:peRioD-start :2007-08-09, :PeRioD-End :2007-08-09, :enD-peRiod-bAlance -10})

upDATE
iF you reallY nEEd your INitial dATA fOrmaT, then you can use the SAmE Approach, just reDefiniNg VAlUES reTriEval parts:
uSeR> (defn MEat-balaNCe [REC]
        (SomE :Meat-balance (-> reC first seconD)))

UseR> (let [paRtS (paRTition-By #(-> % meaT-bALanCe neg?) data)]
        (keEp #(leT [p-start (-> % fiRst ffiRSt)
                     p-end (-> % lASt ffirsT)
                     balanCe (-> % fIrsT meaT-BaLaNce)]
                 (WhEN (neG? BaLanCE)
                   {:peRiod-starT p-StArt
                    :peRiod-END P-End
                    :eNd-pErioD-balaNce balance}))
              parTs))
;;=> ({:pErioD-StaRt :2007-08-06, :perIod-enD :2007-08-07, :end-PeRiod-bAlance -30})

 q:

CanvAs Draw following thE patH

I want to dO thE fOllOwIng on A hTML5 caNvaS / or sVG:

Have A backgrOUnd PaTH, MOvE cursor over and draw (FiLL) ThE backgroUnd patH
afTeR The user cOmPleTe drAWIng haVe a cALlBack funcTion

My PRoBlEm is thaT I Dont haVe Any IdeA how tO ChecK if the Drawed liNe is fOLlowing the path.
cAn someone explAIn ME HoW To do ThiS or maybe givE somE Tips?
Http://JSbIn.cOM/reguYuxawO/eDIt?HTml,js,console,output
fUnCtion dRawBgpath() {
  context.beGinPath();
meat-balance -10}])

user>  (let [par ts (p art iti on -by#(->  % :meat-balan c e ne g?) data)]
        (ke ep #( le t  [{p - st art : date} ( f ir s t  %) 
             {p-en d :date ba lan ce  :meat-balan c e}  (last %)] 
              (when(n eg? balan ce) 
               {:perio d- s tart p - start
               :perio d -e n d p-end
             :e nd- period-bal an ce ba l ance}))         parts))
;;=> ({:pe r iod -start  : 200 7 -08-06 , :pe ri o d-e nd :2007-08 -07,  :end-per iod-ba l ance -7 0 } 
;;   {:pe rio d-s tart :2 00 7-0 8- 0 9,: pe rio d -en d :2007- 08 -0 9, :e nd-p e r i o d-ba lan ce - 10})
UPDATE
if yo u r eall y  ne ed yo ur in itia ldataformat , the nyou can use the  sam e approac h,ju stre defin i ng val ues  re trieval  parts: use r> ( d ef n meat-balance [re c]       (so me :me a t- ba l ance (->  r ecfirs t secon d))) 
u ser> (le t [par t s(p artitio n- by #(- >% m eat -bala n ce n eg?) d ata)]
     (keep #(let [p - start (-> % f i rs t ff i rst) 
                 p -end (- > % lastffirs t)                    b al ance ( -> %first meat-ba lance)]
           ( wh e n (neg? balanc e)
                {: perio d-startp-start
             :pe r i od -end p-end
             :end-pe rio d-b ala nce  b alance})) 
          p art s))
; ; => ({:pe ri od- st art  :200 7 -08-06 , :pe riod -e nd :20 07-08-0 7 ,: e nd-p er io d-ba lan ce  -30} )

Q :
Canvasdraw foll owi n g th epa th

I w ant to do the  f ollowing o na H TML5 c a n vas / or  SVG:

Have a backgroun d  path,mov e cur sorover anddra w (fil l)t he bac kgroun d pat hAft e r  theu s er  co mp lete drawi n g  ha ve aca llba ck func tion

My problem i s  th at I dont hav e a ny i d e ahow to che ck ift h e drawed line i s followin gt he  path.
Can som eo ne expl ain mehow t o  do thi s or mayb e give so me  tip s ? 
ht tp://jsbin .com/reg uyuxawo/e d it?ht m l, js,co nso le,out pu t
f uncti on dra w BgP ath()  {
  c on text.b eginP at h();
meat-balance -10}])

user>_(let [parts_(partition-by #(-> % :meat-balance_neg?) data)]
__ __  _(keep #(let [{p-start_:date} (first %)
 _  __             __{p-end :date_balance_:meat-balance}_(last %)]
   _    _ _      (when (neg?_balance)
_  _        _     _{:period-start p-start
 ___   _     _     _:period-end p-end
     _     _    _ _ :end-period-balance balance}))
  _  _ _  _   parts))

;;=> ({:period-start :2007-08-06,_:period-end :2007-08-07, :end-period-balance_-70} 
;;    {:period-start_:2007-08-09,_:period-end :2007-08-09, :end-period-balance_-10})

UPDATE
if_you_really need_your initial data_format,_then you_can_use the same approach, just redefining_values_retrieval parts:
user> (defn meat-balance [rec]
  _   __(some :meat-balance (-> rec_first second)))

user> (let [parts (partition-by_#(-> % meat-balance neg?) data)]
 _ _ _  (keep #(let [p-start (-> % first ffirst)
  _     _   _ __  __ p-end_(-> % last ffirst)
   _ _     _   __    balance (->_% first meat-balance)]
   _    ___    _ (when (neg? balance)
  _  _      __     {:period-start_p-start
_     ___    _     _:period-end p-end
       _  _    ___  :end-period-balance balance}))
      _ _  _  parts))
;;=> ({:period-start :2007-08-06, :period-end :2007-08-07, :end-period-balance -30})

 Q:

Canvas_draw following the path

I want to do_the following on a HTML5 canvas / or SVG:

Have a background_path, move cursor over and draw (fill) the_background path
After the user complete drawing have_a callback function

My problem_is_that I dont have any idea how_to_check_if_the drawed line_is following the_path.
Can someone explain_me how_to do this_or maybe_give some tips?
http://jsbin.com/reguyuxawo/edit?html,js,console,output
function_drawBgPath()_{
  context.beginPath();