diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-10-04 14:13:31 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2021-10-04 14:48:31 +0000 |
| commit | e7b84a65084e17d5da64fe1fa716d7a186ed701c (patch) | |
| tree | 61b2c6b140c644c0544b3255aae0069550d963aa /root/experiments | |
| parent | add mmmfs pdf (diff) | |
| download | mmm-e7b84a65084e17d5da64fe1fa716d7a186ed701c.tar.gz mmm-e7b84a65084e17d5da64fe1fa716d7a186ed701c.zip | |
Split root out of mmm repo
Diffstat (limited to 'root/experiments')
22 files changed, 0 insertions, 457 deletions
diff --git a/root/experiments/$order b/root/experiments/$order deleted file mode 100644 index 6eca172..0000000 --- a/root/experiments/$order +++ /dev/null @@ -1,5 +0,0 @@ -tags -glitch_cube -torus4d -center_of_mass -parallax_panels diff --git a/root/experiments/center_of_mass/_web_view: type b/root/experiments/center_of_mass/_web_view: type deleted file mode 100644 index bde5644..0000000 --- a/root/experiments/center_of_mass/_web_view: type +++ /dev/null @@ -1 +0,0 @@ -text/html+interactive diff --git a/root/experiments/center_of_mass/description: text$plain b/root/experiments/center_of_mass/description: text$plain deleted file mode 100644 index 256df66..0000000 --- a/root/experiments/center_of_mass/description: text$plain +++ /dev/null @@ -1 +0,0 @@ -Fonts aligned by Center-of-Mass diff --git a/root/experiments/center_of_mass/text$moonscript -> mmm$dom.moon b/root/experiments/center_of_mass/text$moonscript -> mmm$dom.moon deleted file mode 100644 index a43ea69..0000000 --- a/root/experiments/center_of_mass/text$moonscript -> mmm$dom.moon +++ /dev/null @@ -1,171 +0,0 @@ -assert MODE == 'CLIENT', '[nossr]' - -import CanvasApp from require 'mmm.canvasapp' -import rgb from require 'mmm.color' -import article, h1, p, div, span, input, button from require 'mmm.dom' - -fast = true -center = true -center_char = do - canvas = document\createElement 'canvas' - ctx = canvas\getContext '2d' - - cache = {} - - (char, font, height) -> - name = "#{char} #{height} #{font}" - return table.unpack cache[name] if cache[name] - - ctx\resetTransform! - ctx.font = "#{height}px #{font}" - width = (ctx\measureText char).width - canvas.width, canvas.height = width, height * 1.2 - - ctx.font = "#{height}px #{font}" - ctx.textBaseline = 'top' - ctx.fillStyle = rgb 0, 0, 0 - ctx\fillText char, 0, 0 - - data = ctx\getImageData 0, 0, width, height * 1.2 - - local xx, yy - if fast - loop = window\eval '(function(data) { - var xx = 0, yy = 0, n = 0; - for (var x = 0; x < data.width - 1; x++) { - for (var y = 0; y < data.height - 1; y++) { - var i = y * (data.width * 4) + x * 4; - var alpha = data.data[i + 3] / 255; - xx += x * alpha; - yy += y * alpha; - n += alpha; - } - } - - xx /= n; - yy /= n; - return [xx, yy]; - })' - res = loop nil, data - xx, yy = res[0], res[1] - else - xx, yy, n = 0, 0, 0 - for x = 0, data.width - 1 - for y = 0, data.height - 1 - i = y * (data.width * 4) + x * 4 - alpha = data.data[i + 3] / 255 - xx += x * alpha - yy += y * alpha - n += alpha - - xx /= n - yy /= n - cache[name] = { xx, yy, width } - xx, yy, width - -class CenterOfMass extends CanvasApp - width: window.innerWidth - 20 - height: 300 - new: (text, @font, @size) => - super! - @text = {} - for i = 1,#text - @add text\sub i, i - - add: (char) => - rcx, rcy, w = center_char char, @font, @size - cx, cy = w/2, @size/2 - vx, vy = 0, 0 - table.insert @text, { - :char, :rcx, :rcy, :w - :cx, :cy, :vx, :vy - } - - refresh: => - for char in *@text - char.rcx, char.rcy, char.w = center_char char.char, @font, @size - - keydown: (key) => - if key == "Backspace" or key == "Delete" - table.remove @text - elseif string.len(key) == 1 - @add key - - update: (dt) => - super dt - - ACCEL = 4 * dt - DAMPING = 8 * dt - - for char in *@text - { :rcx, :rcy, :cx, :cy, :w } = char - if not center - rcx, rcy = w/2, @size/2 - dx, dy = rcx - cx, rcy - cy - char.vx += dx * ACCEL - char.vy += dy * ACCEL - char.cx += char.vx - char.cy += char.vy - char.vx *= DAMPING - char.vy *= DAMPING - - draw: => - @ctx\clearRect 0, 0, @width, @height - - @ctx.font = "#{@size}px #{@font}" - @ctx.textBaseline = 'top' - - x, y = @size * .1, @size - for { :char, :cx, :cy, :w } in *@text - if x + w > @width - x = 0 - y += @size * 1.2 - - @ctx\fillText char, x + w/2 - cx, y - cy - x += w - -_content = {} -append = (x) -> table.insert _content, x - -append h1 'Fonts aligned by Center-of-Mass' -app = CenterOfMass "Click here and type Away!", "Times New Roman", 40 -append app.canvas -app.canvas.style.backgroundColor = '#eee' - -add = => - append div { - span 'font: ', - with @font_input = input! - .type = 'text' - .value = 'Times New Roman' - with button 'set' - .onclick = (_, e) -> - app.font = @font_input.value - app\refresh! - } - - append div { - span 'size: ', - input type: 'range', min: 2, max: 120, value: 40, onchange: (_, e) -> - size = e.target.value - @size_label.innerText = size - app.size = size - app\refresh! - with @size_label = span '40' - '' - } - - append div { - span 'center characters by weight: ', - input type: 'checkbox', checked: center, onchange: (_, e) -> - center = e.target.checked - } - - append div { - span 'optimize inner loop: ', - input type: 'checkbox', checked: fast, onchange: (_, e) -> - fast = e.target.checked - } -add {} - -article _content diff --git a/root/experiments/glitch_cube/description: text$plain b/root/experiments/glitch_cube/description: text$plain deleted file mode 100644 index b38c873..0000000 --- a/root/experiments/glitch_cube/description: text$plain +++ /dev/null @@ -1 +0,0 @@ -program interpreting random parts of itself as textures for a cube. diff --git a/root/experiments/glitch_cube/link: URL -> tweet b/root/experiments/glitch_cube/link: URL -> tweet deleted file mode 100644 index 3625985..0000000 --- a/root/experiments/glitch_cube/link: URL -> tweet +++ /dev/null @@ -1 +0,0 @@ -https://twitter.com/S0lll0s/status/984465155445678080 diff --git a/root/experiments/parallax_panels/$order b/root/experiments/parallax_panels/$order deleted file mode 100644 index c4fca74..0000000 --- a/root/experiments/parallax_panels/$order +++ /dev/null @@ -1,2 +0,0 @@ -picture -viewer diff --git a/root/experiments/parallax_panels/description: text$plain b/root/experiments/parallax_panels/description: text$plain deleted file mode 100644 index 0eed9db..0000000 --- a/root/experiments/parallax_panels/description: text$plain +++ /dev/null @@ -1 +0,0 @@ -A Parallax SVG Viewer, for Prototyping (Eurorack) Panels diff --git a/root/experiments/parallax_panels/picture/URL -> twitter$tweet b/root/experiments/parallax_panels/picture/URL -> twitter$tweet deleted file mode 100644 index 8d5bce2..0000000 --- a/root/experiments/parallax_panels/picture/URL -> twitter$tweet +++ /dev/null @@ -1 +0,0 @@ -https://twitter.com/S0lll0s/status/1141006444793405440 diff --git a/root/experiments/parallax_panels/text$markdown.md b/root/experiments/parallax_panels/text$markdown.md deleted file mode 100644 index 7453762..0000000 --- a/root/experiments/parallax_panels/text$markdown.md +++ /dev/null @@ -1,16 +0,0 @@ -parallax-panels -=============== - -I'm prototyping an aesthetic for (eurorack) panels that relies on multiple layers of parallax visuals for dramatic effect. - -<mmm-embed path="picture" nolink></mmm-embed> - -parallax-viewer -=============== - -I built a little SVG viewer that stacks the layers and lets you view them in parallax. -You can find it <mmm-link path="viewer">here</mmm-link>. - -And here's a little demonstration: - -<mmm-embed path="viewer/demo" nolink></mmm-embed> diff --git a/root/experiments/parallax_panels/viewer/$order b/root/experiments/parallax_panels/viewer/$order deleted file mode 100644 index 1549b67..0000000 --- a/root/experiments/parallax_panels/viewer/$order +++ /dev/null @@ -1 +0,0 @@ -demo diff --git a/root/experiments/parallax_panels/viewer/demo/video$mp4.mp4 b/root/experiments/parallax_panels/viewer/demo/video$mp4.mp4 Binary files differdeleted file mode 100755 index f3600cc..0000000 --- a/root/experiments/parallax_panels/viewer/demo/video$mp4.mp4 +++ /dev/null diff --git a/root/experiments/parallax_panels/viewer/link: URL b/root/experiments/parallax_panels/viewer/link: URL deleted file mode 100644 index f1bc92e..0000000 --- a/root/experiments/parallax_panels/viewer/link: URL +++ /dev/null @@ -1 +0,0 @@ -https://codepen.io/s-ol/full/rExrey diff --git a/root/experiments/tags/_web_view: type b/root/experiments/tags/_web_view: type deleted file mode 100644 index bde5644..0000000 --- a/root/experiments/tags/_web_view: type +++ /dev/null @@ -1 +0,0 @@ -text/html+interactive diff --git a/root/experiments/tags/description: text$plain b/root/experiments/tags/description: text$plain deleted file mode 100644 index e585bb8..0000000 --- a/root/experiments/tags/description: text$plain +++ /dev/null @@ -1 +0,0 @@ -defining toggles, categories etc. with tags and functional hooks diff --git a/root/experiments/tags/hidden: text$lua -> bool b/root/experiments/tags/hidden: text$lua -> bool deleted file mode 100644 index b30e187..0000000 --- a/root/experiments/tags/hidden: text$lua -> bool +++ /dev/null @@ -1 +0,0 @@ -return true diff --git a/root/experiments/tags/tags: text$moonscript -> table.moon b/root/experiments/tags/tags: text$moonscript -> table.moon deleted file mode 100644 index 198392e..0000000 --- a/root/experiments/tags/tags: text$moonscript -> table.moon +++ /dev/null @@ -1,146 +0,0 @@ -join = (tbl, sep) -> - ret = '' - for tag in pairs tbl - ret ..= (tostring tag) .. sep - ret - -handlers = { - add: {} - rmv: {} -} - -class Node - new: (@name) => - @tags = {} - - inspect: => - "#{@name}: [#{join @tags, ' '}]" - - has: (tag) => @tags[tag] - add: (tag) => @tags[tag] = tag - rmv: (tag) => @tags[tag] = nil - -any = -> true -literal = (def) -> (val) -> def == val -oneof = (defs) -> (val) -> - for def in *defs - return true if def == val - false -has = (tag) -> (node) -> node\has tag - -add_tag = (node, tag) -> - return if node\has tag - node\add tag - for hand, _ in pairs handlers.add - hand\match node, tag - -rmv_tag = (node, tag) -> - return if not node\has tag - node\rmv tag - for hand, _ in pairs handlers.rmv - hand\match node, tag - -class Handler - new: (@rule, @action, match, @func) => - @args = for arg in *match - if 'string' == type arg - literal arg - elseif 'table' == type arg - oneof arg - else - arg - - match: (...) => - supplied = { ... } - assert #supplied == #@args, 'length of arguments doesnt match' - for i = 1, #supplied - return false if not @args[i] supplied[i] - - @.func @rule, ... - - name: => "#{@rule.name}:#{@action}" - -class Rule - new: (@name="#{@@__name}") => - @owned_handlers = {} - - hook: (action, ...) => - handler = Handler @, action, ... - table.insert @owned_handlers, handler - handlers[action][handler] = handler - - destroy: => - for hand in *@owned_handlers - handlers[hand.action][hand] = nil - -class Hierarchy extends Rule - new: (@parent, @child) => - super! - - -- when something is tagged with the child-tag, apply the parent tag - @hook 'add', { any, @child }, (node) => - add_tag node, @parent - - -- when child tag is removed, remove parent tag - @hook 'rmv', { any, @child }, (node) => - rmv_tag node, @parent - - -- when parent tag is removed, remove child tag - @hook 'rmv', { any, @parent }, (node) => - rmv_tag node, @child - -class Toggle extends Rule - new: (@a, @b) => - super! - - either = { @a, @b } - opposite = (tag) -> if tag == @a then @b else @a - - -- when a is added, remove b and vice-versa - @hook 'add', { any, either }, (node, tag) => - rmv_tag node, opposite tag - - -- when a is removed, add b and vice-versa - @hook 'rmv', { any, either }, (node, tag) => - add_tag node, opposite tag - -class NamespacedToggle extends Rule - new: (@ns, @a, @b) => - super! - - namespaced = has @ns - either = { @a, @b } - opposite = (tag) -> if tag == @a then @b else @a - - -- when node enters namespace, add default tag - @hook 'add', { any, @ns }, (node) => - add_tag node, @a - - -- when node leaves namespace, remove tags - @hook 'rmv', { any, @ns }, (node) => - rmv_tag node, @a - rmv_tag node, @b - - -- when a is added, remove b and vice-versa - @hook 'add', { namespaced, either }, (node, tag) => - rmv_tag node, opposite tag - - -- when a is removed, add b and vice-versa - @hook 'rmv', { namespaced, either }, (node, tag) => - add_tag node, opposite tag - -{ - :Node, - :Rule, - - :any, - :literal, - :oneof, - :has, - :add_tag, - :rmv_tag, - - :Hierarchy, - :Toggle, - :NamespacedToggle, -} diff --git a/root/experiments/tags/text$moonscript -> fn -> mmm$component.moon b/root/experiments/tags/text$moonscript -> fn -> mmm$component.moon deleted file mode 100644 index 24972ac..0000000 --- a/root/experiments/tags/text$moonscript -> fn -> mmm$component.moon +++ /dev/null @@ -1,92 +0,0 @@ -=> - assert MODE == 'CLIENT', '[nossr]' - - import add_tag, rmv_tag, Node, Hierarchy, Toggle, NamespacedToggle from @get 'tags: table' - import ReactiveVar, tohtml, text, elements from require 'mmm.component' - import article, div, form, span, h3, a, input, textarea, button from elements - - clone = (set) -> - assert set and 'table' == (type set), 'not a set' - { k,v for k,v in pairs set } - - set_append = (val) -> (set) -> - with copy = clone set - copy[val] = val - - set_remove = (val) -> (set) -> - with copy = clone set - copy[val] = nil - - set_join = (tbl, sep=' ') -> - ret = '' - for tag in pairs tbl - ret ..= (tostring tag) .. sep - ret - - entries = div! - - class ReactiveNode extends Node - new: (...) => - super ... - @tags = ReactiveVar @tags - @_node = div { - span @name, style: { 'font-weight': 'bold' }, - @tags\map (tags) -> with div! - for tag,_ in pairs tags - \append a (text tag), href: '#', style: { - display: 'inline-block', - margin: '0 5px', - } - } - - @node = tohtml @_node - - has: (tag) => @tags\get![tag] - add: (tag) => @tags\transform set_append tag - rmv: (tag) => @tags\transform set_remove tag - - rules = { - Hierarchy 'home', 'sol' - Hierarchy 'sol', 'desktop' - Hierarchy 'desktop', 'vacation' - Hierarchy 'desktop', 'documents' - NamespacedToggle 'documents', 'work', 'personal' - -- Toggle 'work', 'personal' - -- Hierarchy 'documents', 'work' - -- Hierarchy 'documents', 'personal' - } - - pictures = for i=1,10 - with node = ReactiveNode "picture#{i}.jpg" - entries\append node - add_tag node, 'vacation' - - pers = ReactiveNode 'mypersonalfile.doc' - entries\append pers - - article entries, div do - yield = coroutine.yield - step = coroutine.wrap -> - yield "mark document" - add_tag pers, 'documents' - - yield "mark personal" - add_tag pers, 'personal' - - yield "mark work" - add_tag pers, 'work' - - yield "unmark work" - rmv_tag pers, 'work' - - yield "remove from documents" - rmv_tag pers, 'documents' - - yield false - - next_step = ReactiveVar step! - next_step\map (desc) -> - if desc - button (text desc), onclick: (e) => next_step\set step! - else - text '' diff --git a/root/experiments/text$moonscript -> fn -> mmm$dom.moon b/root/experiments/text$moonscript -> fn -> mmm$dom.moon deleted file mode 100644 index 70779be..0000000 --- a/root/experiments/text$moonscript -> fn -> mmm$dom.moon +++ /dev/null @@ -1,11 +0,0 @@ -import div, h3, ul, li from require 'mmm.dom' -import link_to from (require 'mmm.mmmfs.util') require 'mmm.dom' - -=> - div { - h3 link_to @ - ul for child in *@children - continue if child\get 'hidden: bool' - desc = child\gett 'description: mmm/dom' - li (link_to child), ': ', desc - } diff --git a/root/experiments/title: text$plain b/root/experiments/title: text$plain deleted file mode 100644 index 0487531..0000000 --- a/root/experiments/title: text$plain +++ /dev/null @@ -1 +0,0 @@ -various experiments diff --git a/root/experiments/torus4d/description: text$plain b/root/experiments/torus4d/description: text$plain deleted file mode 100644 index 07b0020..0000000 --- a/root/experiments/torus4d/description: text$plain +++ /dev/null @@ -1 +0,0 @@ -Attempt at rendering a spiral pattern on a 4d meta-torus. diff --git a/root/experiments/torus4d/link: URL -> git b/root/experiments/torus4d/link: URL -> git deleted file mode 100644 index a134ff1..0000000 --- a/root/experiments/torus4d/link: URL -> git +++ /dev/null @@ -1 +0,0 @@ -https://github.com/s-ol/torus4d |
