Skip to content

Commit

Permalink
preparing for algofive
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwilk committed Mar 13, 2017
1 parent 09c5fd0 commit 3b46178
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 15 deletions.
141 changes: 141 additions & 0 deletions animations/algo.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
;;algo by Joseph Wilk
(defvar start-total-count 0)


(defun post-zone-algo-animate (c col wend)
(let ((fall-p nil) ; todo: move outward
(o (point)) ; for terminals w/o cursor hiding
(p (point))
(insert-char (nth 0 `("")))
(halt-char " ")
(counter 0))

(while (< counter 10)
(let ((next-char (char-after p))
(previous-char (char-after (- p 1))))

;;(progn (forward-line 1) (move-to-column col) (looking-at halt-char))
;; (when (< counter 50) (move-to-column (mod counter 150)))

(when (< (random 100) 50) (move-to-column counter))

(setq counter (+ 1 counter))
(setq total-count (+ 1 total-count))

(if (and
;;(not (looking-at ")"))
;; (not (looking-at "("))
;; (not (looking-at "\W"))
(not (looking-at insert-char))
;; (not (looking-at "\s"))
;; (not (looking-at "\w"))


)
(progn
(save-excursion
(dotimes (_ 1)
(delete-char 1)
(insert insert-char)
)
;;(goto-char o)
(sit-for 0))
(if (<= 5 (mod counter 10))
(setq p (- (point) 1))
(setq p (+ (point) 1)))))))
fall-p))


(defun zone-algo-animate (c col wend)
(let ((fall-p nil) ; todo: move outward
(o (point)) ; for terminals w/o cursor hiding
(p (point))
(insert-char (nth 0 `("")))
(halt-char " ")
(counter 0))

(while (< counter 10)
(let ((next-char (char-after p))
(previous-char (char-after (- p 1))))

;;(progn (forward-line 1) (move-to-column col) (looking-at halt-char))
;; (when (< counter 50) (move-to-column (mod counter 150)))

(when (< (random 100) 50) (move-to-column counter))

(setq counter (+ 1 counter))
(setq total-count (+ 1 total-count))

(if (and
;;(not (looking-at ")"))
;; (not (looking-at "("))
;; (not (looking-at "\W"))
(not (looking-at insert-char))
;; (not (looking-at "\s"))
;; (not (looking-at "\w"))


)
(progn
(save-excursion
(dotimes (_ 1)
(delete-char 1)
(insert insert-char)
)
;;(goto-char o)
(sit-for 0))
(if (<= 5 (mod counter 10))
(setq p (- (point) 1))
(setq p (+ (point) 1)))))))
fall-p))

(defun zone-algo ()
(set 'truncate-lines nil)
(setq total-count 0)
(let* ((ww (1- (window-width)))
(wh (window-height))
(mc 0) ; miss count
(total (* ww wh))
(fall-p nil)
(wend 100)
(wbeg 1)
(counter 0))
(goto-char (point-min))


(let ((nl (- wh (count-lines (point-min) (point)))))
(when (> nl 0)
(let ((line (concat (make-string (1- ww) ? ) "\n")))
(do ((i 0 (1+ i)))
((= i nl))
;;(insert line)
))))

(catch 'done; ugh
(while (not (input-pending-p))
(goto-char (point-min))
(let ((wbeg (window-start))
(wend (window-end)))
(setq mc 0)

(goto-char (+ wbeg (random (- wend wbeg))))
(while (or (looking-at "[\t\n]")) (goto-char (+ wbeg (random (- wend wbeg)))))
;; character animation sequence

(setq counter (+ 1 counter))

(let ((p (point)))
(goto-char p)
(when (< counter 10000) (zone-algo-animate (zone-cpos p) (current-column) wend))
(when (and (> counter 4500) (< counter 10000))
;;(delete-char 1)
(while (re-search-forward "\\(\s+\\)" nil t 1)
(when (< (random 100) 50) (replace-match "\\1 ")))
)

))
))))

(eval-after-load "zone"
'(unless (memq 'zone-algo (append zone-programs nil))
(setq zone-programs [zone-algo])))
2 changes: 1 addition & 1 deletion animations/end-of-buffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@

(eval-after-load "zone"
'(unless (memq 'zone-end-of-buffer (append zone-programs nil))
(setq zone-programs [zone-end-of-buffer])))
(setq zone-programs [zone-end-of-buffer])))
14 changes: 13 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'("~/.live-packs/josephwilk-pack/snippets")))
(yas-reload-all)

(load "~/.live-packs/josephwilk-pack/animations/end-of-buffer.el")
(load "~/.live-packs/josephwilk-pack/animations/algo.el")
;;(load "~/.live-packs/josephwilk-pack/animations/end-of-buffer.el")
;;(load "~/.live-packs/josephwilk-pack/animations/the-stars.el")
;;(load "~/.live-packs/josephwilk-pack/animations/waves.el")
;;(load "~/.live-packs/josephwilk-pack/animations/upcase.el")
Expand Down Expand Up @@ -169,3 +170,14 @@ middle"
;;Sane reg-builder
(require 're-builder)
(setq reb-re-syntax 'string)

(require 'unicode-fonts)
(unicode-fonts-setup)


(setq-default show-trailing-whitespace nil)
(setq-default mode-require-final-newline nil)

(require 'emojify)
(setq emojify-set-emoji-styles 'unicode)
(setq emojify-display-style 'unicode)
8 changes: 8 additions & 0 deletions snippets/sonic-pi-mode/at
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#name: at
# --
if spread(1,64).look
at do
sleep 1/8.0*2
$0
end
end
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/berry
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# name: stb
# --
Berry[/sus_oh_p_0$0_rel/,0]
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: chip
# --
🐿$0
5 changes: 5 additions & 0 deletions snippets/sonic-pi-mode/fxsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#name: fxsp
# --
with_fx(spread(${1:in}, ${2:over}).map{|s| s ? ${3:hit} : ${4:miss}}.look) do
$0
end
5 changes: 5 additions & 0 deletions snippets/sonic-pi-mode/gpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#name: gpa
# --
synth :gpa, note: knit( :Fs4,64, :Cs5,64,
:b4,64, :fs4,64/2.0, :a4, 64/2.0
).look, amp: 0.0, attack: 0.001, decay: fslice[:length], release: 0.001
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/hrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: hrt
# --
♥️$0
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/knit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: knit
# --
(knit $1,$0).look
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/line
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: line
# --
(line $1, $2, $3).look
10 changes: 7 additions & 3 deletions snippets/sonic-pi-mode/ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#name: ll
# --
live_loop :${1:name} do
tick
$0
end
with_fx :none, mix: 0 do
tick
forever = (knit 1/8.0, 32, 0, 0).look
$0
sleep forever
end
end
11 changes: 7 additions & 4 deletions snippets/sonic-pi-mode/lls
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#name: lls
# --
live_loop :${1:name}, sync: :${2:sname} do
tick
$0
end
live_loop :${1:name}, sync: algo do
with_fx :none, mix: 0 do
tick
$0
sleep (1/2.0)*6
end
end
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/ring
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: ring
# --
(ring $0).look
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/rmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: rmp
# --
(ramp $1, $2, $3).tick(:fire)
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/skull
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: skull
# --
☠️$0
2 changes: 1 addition & 1 deletion snippets/sonic-pi-mode/smp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#name: smp
# --
smp ${1:mod}[/:${2:pat}/,[0,0]].tick(:sample), cutoff: 135, amp: 1.0
smp ${1:mod}[/${2:pat}/,[0,0]].tick(:sample), cutoff: 135, amp: 1.0, rpitch: (ring 0).look
3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/smppan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# name: smppan
# --
sample ${1:lib}[[$0]].look, amp: 0.05*1.0, pan: line(-0.25,0.25,256).look
5 changes: 5 additions & 0 deletions snippets/sonic-pi-mode/spd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#name: spd
# --
if spread($1).look
$0
end
5 changes: 0 additions & 5 deletions snippets/sonic-pi-mode/spread

This file was deleted.

3 changes: 3 additions & 0 deletions snippets/sonic-pi-mode/spreadw
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#name: spreadw
# --
$0 = spread(7,11).map{|s| s ? :hit : :miss}

0 comments on commit 3b46178

Please sign in to comment.