neiam
/lambent_ex
Lambent Aether 5
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
library re-sorting, library add button now does things
4bbf308 · gmorell · 2023-01-28 01:11
Files changed
modified
lib/lambent_ex/machine.ex
+1
−1
@@ -38,7 +38,7 @@ defmodule LambentEx.Machine do
| 38 | 38 | 255 => :FULL |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | − def start_link(_foo, opts) do | |
| 41 | + def start_link(_foo, opts) do # check to see if machine-opts[:step]-name is better in machine-name | |
| 42 | 42 | Parent.GenServer.start_link(__MODULE__, opts, name: via_tuple("machine-#{opts[:name]}")) |
| 43 | 43 | end |
| 44 | 44 |
modified
lib/lambent_ex/machine/library.ex
+201
−67
@@ -1,70 +1,204 @@
| 1 | 1 | defmodule LambentEx.Machines.Library do |
| 2 | − def machines do [ | |
| 3 | − solid: %{ | |
| 4 | − red: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 0}}, | |
| 5 | − blue: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 128}}, | |
| 6 | − green: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 84}}, | |
| 7 | − | |
| 8 | − wwhite: %{ machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 255, b: 190}}, | |
| 9 | − sapphire: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 0, g: 102, b: 202}}, | |
| 10 | − ruby: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 155, g: 17, b: 30}}, | |
| 11 | − emerald: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 4, g: 93, b: 28}}, | |
| 12 | − gold: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 215, b: 0}}, | |
| 13 | − cafe: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 117, g: 86, b: 56}}, | |
| 14 | − orange: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 204, b: 16}}, | |
| 15 | − plum: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 122, g: 14, b: 190}}, | |
| 16 | − guava: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 240, g: 122, b: 190}}, | |
| 17 | − lime: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 8, g: 255, b: 107}}, | |
| 18 | − lemon: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 243, g: 255, b: 7}}, | |
| 19 | − }, | |
| 20 | − chase: %{ | |
| 21 | − red: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 0}}, | |
| 22 | − blue: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 128}}, | |
| 23 | − green: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 84}}, | |
| 24 | − yellow: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 42}}, | |
| 25 | − pink: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 212}}, | |
| 26 | − purple: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 170}}, | |
| 27 | − }, | |
| 28 | − scapes: %{ | |
| 29 | − vista: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 240, h_h: 120}}, | |
| 30 | − love: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 230, h_h: 20}}, | |
| 31 | − ocean: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 90, h_h: 160}}, | |
| 32 | − forest: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 60, h_h: 90}}, | |
| 33 | − royal: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 34, h_h: 43}}, | |
| 34 | − sunny: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 245, h_h: 10}}, | |
| 35 | − night: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 250, h_h: 20}}, | |
| 36 | − fire: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 240, h_h: 120, v: 128}}, | |
| 37 | − vapor: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 150, h_h: 220}}, | |
| 38 | − }, | |
| 39 | − rocker: %{ | |
| 40 | − vapor: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [136, 245]}}, | |
| 41 | − halloween: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [13, 187]}}, | |
| 42 | − halloween_2: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [13, 187, 85]}}, | |
| 43 | − xmas: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,85]}}, | |
| 44 | − rgb: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,85,171]}}, | |
| 45 | − cmy: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [42,127,212]}}, | |
| 46 | − cmyrgb: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,42,85,127,171,212]}}, | |
| 47 | − }, | |
| 48 | − ] | |
| 2 | + def machines do | |
| 3 | + [ | |
| 4 | + solid: %{ | |
| 5 | + red: %{machine: LambentEx.Machine.Steps.Solid, args: %{h: 0}, mach_opts: [single: true]}, | |
| 6 | + blue: %{ | |
| 7 | + machine: LambentEx.Machine.Steps.Solid, | |
| 8 | + args: %{h: 128}, | |
| 9 | + mach_opts: [single: true] | |
| 10 | + }, | |
| 11 | + green: %{ | |
| 12 | + machine: LambentEx.Machine.Steps.Solid, | |
| 13 | + args: %{h: 84}, | |
| 14 | + mach_opts: [single: true] | |
| 15 | + } | |
| 16 | + }, | |
| 17 | + solidrgb: %{ | |
| 18 | + wwhite: %{ | |
| 19 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 20 | + args: %{r: 255, g: 255, b: 190}, | |
| 21 | + mach_opts: [single: true] | |
| 22 | + }, | |
| 23 | + sapphire: %{ | |
| 24 | + desc: "gem", | |
| 25 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 26 | + args: %{r: 0, g: 102, b: 202}, | |
| 27 | + mach_opts: [single: true] | |
| 28 | + }, | |
| 29 | + ruby: %{ | |
| 30 | + desc: "gem", | |
| 31 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 32 | + args: %{r: 155, g: 17, b: 30}, | |
| 33 | + mach_opts: [single: true] | |
| 34 | + }, | |
| 35 | + emerald: %{ | |
| 36 | + desc: "gem", | |
| 37 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 38 | + args: %{r: 4, g: 93, b: 28}, | |
| 39 | + mach_opts: [single: true] | |
| 40 | + }, | |
| 41 | + gold: %{ | |
| 42 | + desc: "gem", | |
| 43 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 44 | + args: %{r: 255, g: 215, b: 0}, | |
| 45 | + mach_opts: [single: true] | |
| 46 | + }, | |
| 47 | + cafe: %{ | |
| 48 | + desc: "gem", | |
| 49 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 50 | + args: %{r: 117, g: 86, b: 56}, | |
| 51 | + mach_opts: [single: true] | |
| 52 | + }, | |
| 53 | + orange: %{ | |
| 54 | + desc: "lemon", | |
| 55 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 56 | + args: %{r: 255, g: 204, b: 16}, | |
| 57 | + mach_opts: [single: true] | |
| 58 | + }, | |
| 59 | + plum: %{ | |
| 60 | + desc: "lemon", | |
| 61 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 62 | + args: %{r: 122, g: 14, b: 190}, | |
| 63 | + mach_opts: [single: true] | |
| 64 | + }, | |
| 65 | + guava: %{ | |
| 66 | + desc: "lemon", | |
| 67 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 68 | + args: %{r: 240, g: 122, b: 190}, | |
| 69 | + mach_opts: [single: true] | |
| 70 | + }, | |
| 71 | + lime: %{ | |
| 72 | + desc: "lemon", | |
| 73 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 74 | + args: %{r: 8, g: 255, b: 107}, | |
| 75 | + mach_opts: [single: true] | |
| 76 | + }, | |
| 77 | + lemon: %{ | |
| 78 | + desc: "lemon", | |
| 79 | + machine: LambentEx.Machine.Steps.SolidRGB, | |
| 80 | + args: %{r: 243, g: 255, b: 7}, | |
| 81 | + mach_opts: [single: true] | |
| 82 | + } | |
| 83 | + }, | |
| 84 | + chase: %{ | |
| 85 | + red: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 0}}, | |
| 86 | + blue: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 128}}, | |
| 87 | + green: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 84}}, | |
| 88 | + yellow: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 42}}, | |
| 89 | + pink: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 212}}, | |
| 90 | + purple: %{desc: "flag", machine: LambentEx.Machine.Steps.Chase, args: %{h: 170}} | |
| 91 | + }, | |
| 92 | + chasem: %{}, # todo the flags | |
| 93 | + scape: %{ | |
| 94 | + vista: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 240, h_h: 120}}, | |
| 95 | + love: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 230, h_h: 20}}, | |
| 96 | + ocean: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 90, h_h: 160}}, | |
| 97 | + forest: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 60, h_h: 90}}, | |
| 98 | + royal: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 34, h_h: 43}}, | |
| 99 | + sunny: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 245, h_h: 10}}, | |
| 100 | + night: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 250, h_h: 20}}, | |
| 101 | + fire: %{ | |
| 102 | + desc: "map", | |
| 103 | + machine: LambentEx.Machine.Steps.Scape, | |
| 104 | + args: %{h_l: 240, h_h: 120, v: 128} | |
| 105 | + }, | |
| 106 | + vapor: %{desc: "map", machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 150, h_h: 220}} | |
| 107 | + }, | |
| 108 | + rocker: %{ | |
| 109 | + vapor: %{desc: "star", machine: LambentEx.Machine.Steps.Rocker, args: %{h: [136, 245]}}, | |
| 110 | + halloween: %{desc: "star", machine: LambentEx.Machine.Steps.Rocker, args: %{h: [13, 187]}}, | |
| 111 | + halloween_2: %{ | |
| 112 | + desc: "star", | |
| 113 | + machine: LambentEx.Machine.Steps.Rocker, | |
| 114 | + args: %{h: [13, 187, 85]} | |
| 115 | + }, | |
| 116 | + xmas: %{desc: "star", machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0, 85]}}, | |
| 117 | + rgb: %{desc: "star", machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0, 85, 171]}}, | |
| 118 | + cmy: %{desc: "star", machine: LambentEx.Machine.Steps.Rocker, args: %{h: [42, 127, 212]}}, | |
| 119 | + cmyrgb: %{ | |
| 120 | + desc: "star", | |
| 121 | + machine: LambentEx.Machine.Steps.Rocker, | |
| 122 | + args: %{h: [0, 42, 85, 127, 171, 212]} | |
| 123 | + } | |
| 124 | + }, | |
| 125 | + twinkle: %{}, # todo port this from LA3 | |
| 126 | + rainbow: %{ | |
| 127 | + regular: %{desc: "futbol", machine: LambentEx.Machine.Steps.Rainbow, args: %{modulo: 255}}, | |
| 128 | + regular64: %{ | |
| 129 | + desc: "futbol", | |
| 130 | + machine: LambentEx.Machine.Steps.Rainbow, | |
| 131 | + args: %{modulo: 64} | |
| 132 | + }, | |
| 133 | + solid: %{ | |
| 134 | + desc: "futbol", | |
| 135 | + machine: LambentEx.Machine.Steps.Rainbow, | |
| 136 | + args: %{modulo: 255}, | |
| 137 | + mach_opts: [single: true] | |
| 138 | + }, | |
| 139 | + solid64: %{ | |
| 140 | + desc: "futbol", | |
| 141 | + machine: LambentEx.Machine.Steps.Rainbow, | |
| 142 | + args: %{modulo: 64}, | |
| 143 | + mach_opts: [single: true] | |
| 144 | + } | |
| 145 | + }, | |
| 146 | + firefly: %{ | |
| 147 | + default: %{desc: "lightbulb", machine: LambentEx.Machine.Steps.Firefly, args: %{h: [52]}}, | |
| 148 | + others: %{ | |
| 149 | + desc: "lightbulb", | |
| 150 | + machine: LambentEx.Machine.Steps.Firefly, | |
| 151 | + args: %{h: [52, 15, 140]} | |
| 152 | + } | |
| 153 | + }, | |
| 154 | + growth: %{ | |
| 155 | + leaves: %{ | |
| 156 | + desc: "leaf", | |
| 157 | + machine: LambentEx.Machine.Steps.Growth, | |
| 158 | + args: %{ | |
| 159 | + h_g: [90, 98, 94, 95, 90], | |
| 160 | + h_d: [ | |
| 161 | + 90, | |
| 162 | + 95, | |
| 163 | + 85, | |
| 164 | + 90, | |
| 165 | + 80, | |
| 166 | + 85, | |
| 167 | + 75, | |
| 168 | + 80, | |
| 169 | + 70, | |
| 170 | + 75, | |
| 171 | + 65, | |
| 172 | + 70, | |
| 173 | + 60, | |
| 174 | + 65, | |
| 175 | + 55, | |
| 176 | + 60, | |
| 177 | + 50, | |
| 178 | + 55, | |
| 179 | + 45, | |
| 180 | + 50, | |
| 181 | + 40, | |
| 182 | + 45, | |
| 183 | + 35, | |
| 184 | + 40, | |
| 185 | + 30, | |
| 186 | + 35, | |
| 187 | + 25, | |
| 188 | + 30, | |
| 189 | + 20, | |
| 190 | + 25, | |
| 191 | + 15, | |
| 192 | + 20, | |
| 193 | + 10, | |
| 194 | + 15, | |
| 195 | + 5, | |
| 196 | + 10, | |
| 197 | + 0 | |
| 198 | + ] | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } | |
| 202 | + ] | |
| 49 | 203 | end |
| 50 | 204 | end |
| 51 | − | |
| 52 | −defmodule LambentEx.Machines.Library.Worker do | |
| 53 | − @moduledoc false | |
| 54 | − use GenServer | |
| 55 | − | |
| 56 | − @impl true | |
| 57 | − def init(stack) do | |
| 58 | − {:ok, stack} | |
| 59 | − end | |
| 60 | − | |
| 61 | − @impl true | |
| 62 | − def handle_call(:pop, _from, [head | tail]) do | |
| 63 | − {:reply, head, tail} | |
| 64 | − end | |
| 65 | − | |
| 66 | − @impl true | |
| 67 | − def handle_cast({:push, element}, state) do | |
| 68 | − {:noreply, [element | state]} | |
| 69 | − end | |
| 70 | −end |
modified
lib/lambent_ex_web/live/machines/index.ex
+7
−0
@@ -112,6 +112,13 @@ defmodule LambentExWeb.MachinesLive.Index do
| 112 | 112 | {:noreply, socket} |
| 113 | 113 | end |
| 114 | 114 | |
| 115 | + def handle_event("library-add", %{"cls" => cls, "entry" => entry}, socket) do | |
| 116 | + spec = LambentEx.Machines.Library.machines |> get_in([String.to_atom(cls),String.to_atom(entry)]) | |
| 117 | + opts = spec[:mach_opts] || [] | |
| 118 | + LambentEx.MachineSupervisor.start_child(spec[:machine], spec[:args], entry, opts) |> IO.inspect | |
| 119 | + {:noreply, socket} | |
| 120 | + end | |
| 121 | + | |
| 115 | 122 | def handle_info(:update_library, socket) do |
| 116 | 123 | send_update(LambentEx.MachinesLive.LibraryFormComponent, id: :library) |
| 117 | 124 | {:noreply, socket} |
modified
lib/lambent_ex_web/live/machines/library_form_component.ex
+1
−1
@@ -3,7 +3,7 @@ defmodule LambentEx.MachinesLive.LibraryFormComponent do
| 3 | 3 | alias LambentEx.Names |
| 4 | 4 | import LambentEx.Utils.Color, only: [hex: 1] |
| 5 | 5 | |
| 6 | − @count 32 | |
| 6 | + @count 64 | |
| 7 | 7 | |
| 8 | 8 | defp combine(extant, new, max \\ @count) do |
| 9 | 9 | extant |
modified
lib/lambent_ex_web/live/machines/library_form_component.html.heex
+9
−24
@@ -1,6 +1,6 @@
| 1 | 1 | <div> |
| 2 | 2 | <h1 class="text-4xl font-bold py-3">Machine Library</h1> |
| 3 | − <p>Start some preconfigured machines to showcase the capabilities of Lambent Aether</p> | |
| 3 | + <p>Start some preconfigured machines to showcase the capabilities of Lambent Aether. The previews below represent a single pixel over time.</p> | |
| 4 | 4 | <%= for {cls, entries} <- @library do %> |
| 5 | 5 | <h2 class="text-3xl font-bold py-3"><%= cls %></h2> |
| 6 | 6 | <div class="grid grid-cols-3 gap-3"> |
@@ -26,11 +26,17 @@
| 26 | 26 | <% else %> |
| 27 | 27 | <div class="stats shadow bg-secondary text-secondary-content"> |
| 28 | 28 | <div class="stat"> |
| 29 | − <div class="stat-figure text-primary"> | |
| 29 | + <div class="stat-figure text-primary" phx-click="library-add" phx-value-cls={cls} phx-value-entry={name}> | |
| 30 | + <%= if data[:desc] do %> | |
| 31 | + <i class={"fa fa-regular fa-#{data[:desc]} fa-2x"} /> | |
| 32 | + <% else %> | |
| 30 | 33 | <i class="fa fa-plus fa-2x" /> |
| 34 | + <% end %> | |
| 31 | 35 | </div> |
| 32 | 36 | <div class="stat-title"><%= data[:machine] |> machy %></div> |
| 33 | − <div class="stat-value"><%= name %></div> | |
| 37 | + <div class="stat-value"> | |
| 38 | + <%= name %> | |
| 39 | + </div> | |
| 34 | 40 | <div class="stat-desc"> |
| 35 | 41 | <code><%= data[:args] |> Jason.encode! %></code> |
| 36 | 42 | <div class="flex"> |
@@ -45,25 +51,4 @@
| 45 | 51 | <% end %> |
| 46 | 52 | </div> |
| 47 | 53 | <% end %> |
| 48 | − <br/> | |
| 49 | − <div class="stats shadow bg-secondary text-secondary-content"> | |
| 50 | − <div class="stat"> | |
| 51 | − <div class="stat-title">Total Page Views</div> | |
| 52 | − <div class="stat-value">89,400</div> | |
| 53 | − <div class="stat-desc">21% more than last month</div> | |
| 54 | − </div> | |
| 55 | − </div> | |
| 56 | − <div class="stats shadow"> | |
| 57 | − <div class="stat"> | |
| 58 | − <div class="stat-title">Total Page Views</div> | |
| 59 | − <div class="stat-value">89,400</div> | |
| 60 | − <div class="stat-desc">21% more than last month</div> | |
| 61 | − </div> | |
| 62 | − </div> | |
| 63 | − | |
| 64 | − <br> | |
| 65 | − todo have the pane spawn a parented process with each of these instantiated and tick through 30 on load to preview | |
| 66 | − the values | |
| 67 | − | |
| 68 | − | |
| 69 | 54 | </div> |
Parents: a72ce53