Skip to content

Instantly share code, notes, and snippets.

@Inc0n
Last active May 12, 2020 23:40
Show Gist options
  • Save Inc0n/d22ae5f190a7db8e67aa2c380d81e428 to your computer and use it in GitHub Desktop.
Save Inc0n/d22ae5f190a7db8e67aa2c380d81e428 to your computer and use it in GitHub Desktop.
alloy graph
(let* ((data (make-instance 'data))
(freq (alloy:represent (frequency data) 'alloy:ranged-slider
:range '(.1 . 10) :step 0.1))
(phas (alloy:represent (wavephase data) 'alloy:ranged-slider
:range (cons 0 PI) :step 0.1))
(amps (alloy:represent (amplitude data) 'alloy:ranged-slider
:range '(0 . 100)))
(plot (alloy:represent (lambda ((frequency (frequency data))
(amplitude (amplitude data))
(phase (wavephase data)))
(make-plot-data
(let ((range (* 2 PI frequency)))
(lambda (i)
(* (sin (* phase range i))
amplitude)))
'(0 . 1000)))
'alloy:plot :y-range '(-100 . 100)
:style `((:curve :line-width ,(alloy:un 10))))))
(let ((l1 (make-instance 'alloy:vertical-linear-layout
:layout-parent layout
:cell-margins (alloy:margins 5))))
(let ((l2 (make-instance 'alloy:grid-layout :layout-parent l1
:cell-margins (alloy:margins 5)
:col-sizes (list (alloy:un 100) T)
:row-sizes (list (alloy:un 30) (alloy:un 30)
(alloy:un 30)))))
(alloy:enter "Frequency" l2 :row 2 :col 0)
(alloy:enter freq l2 :row 2 :col 1)
(alloy:enter "Amplitude" l2 :row 1 :col 0)
(alloy:enter amps l2 :row 1 :col 1)
(alloy:enter "Phase" l2 :row 0 :col 0)
(alloy:enter phas l2 :row 0 :col 1))
(alloy:enter plot l1))
(alloy:enter freq focus)
(alloy:enter amps focus)
(alloy:enter phas focus))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment