This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-09
Channels
- # announcements (3)
- # asami (1)
- # babashka (19)
- # beginners (84)
- # calva (3)
- # cider (5)
- # clj-commons (22)
- # clj-kondo (31)
- # cljdoc (4)
- # cljs-dev (5)
- # clojure (65)
- # clojure-australia (1)
- # clojure-europe (44)
- # clojure-nl (2)
- # clojure-uk (2)
- # clojurescript (18)
- # code-reviews (12)
- # conjure (2)
- # core-async (12)
- # data-science (1)
- # datomic (47)
- # deps-new (1)
- # emacs (2)
- # events (4)
- # fulcro (35)
- # integrant (1)
- # jobs (5)
- # jobs-discuss (10)
- # london-clojurians (1)
- # lsp (13)
- # music (1)
- # nextjournal (1)
- # off-topic (11)
- # parinfer (3)
- # pathom (6)
- # polylith (11)
- # portal (41)
- # re-frame (4)
- # reagent (13)
- # reitit (8)
- # remote-jobs (3)
- # sci (18)
- # shadow-cljs (34)
- # spacemacs (3)
- # tools-build (12)
- # tools-deps (6)
- # vim (2)
- # xtdb (7)
I'm trying to define a context and import some functions in this context, this is right, how can I make this work??
(def context
(sci/init {'quil.core (into {}
(map (fn [[k v]]
[k v])) (ns-publics 'quil.core))
'reagent.core {'create-class r/create-class}
'codemirror-sci {'->quil-canvas ->quil-canvas}}))
maybe is not working because sci can't use p5js?Please be more specific. What error do you get? is p5js a JS library? Do you have a public repo? What program are you trying to run in the SCI context?
@U9ABG0ERZ I think you might need to add :classes {'js goog/global :allow :all}
to your context options
and then you can access all JS library from the global environment. But more information is better
also you need to put the namespaces inside
(sci/init {:namespaces {'quil.core ...}})
(def context
(sci/init {:classes {'js goog/global :allow :all}
:namespaces {'quil.core (into {}
(map (fn [[k v]]
[k v])) (ns-publics 'quil.core))
'reagent.core {'create-class r/create-class}
'codemirror-sci {'->quil-canvas ->quil-canvas}}}))
,,,,
(defn editor
[source
{:keys [eval?]}]
(r/with-let [!view (r/atom nil)
last-result (when eval? (r/atom (eval-string source)))
mount! (fn [el]
(when el
(reset! !view (new EditorView
(j/obj :state
(test-utils/make-state
(cond-> #js [extensions]
eval? (.concat #js [(extension {:modifier "Alt"
:on-result (partial reset! last-result)})]))
source)
:parent el)))))]
[:div
[:div {:class "rounded-md mb-0 text-sm monospace overflow-auto relative border shadow-lg bg-white"
:ref mount!
:style {:max-height 410}}]
(when eval?
[:div.mt-3.mv-4.pl-6 {:style {:white-space "pre-wrap" :font-family "var(--code-font)"}}
@last-result])]
(finally
(j/call @!view :destroy))))
(->quil-canvas {:title "Oh so many grey circles" ;; Set the title of the sketch
:settings #(smooth 2) ;; Turn on anti-aliasing
:setup setup ;; Specify the setup fn
:draw draw ;; Specify the draw fn
:size [323 200]})
;; gives :
#error {:message "Could not resolve symbol: ->quil-canvas", :data {:type :sci/error, :line 1, :column 6, :file nil, :phase "analysis"}}
I'm trying to add code-mirror + sci to run quil
@U9ABG0ERZ You need to write (quil.core/->quil->canvas ..)
or evaluate (require '[quil.core :refer :all])
in the ctx beforehand
This ->quil-canvas
. Is a function that's declared in the ns that I'm declaring context
The same holds there: use (require '[code-mirror-sci :refer [->quil-canvas]])
if you want to use it without a namespace prefix
(require '[code-mirror-sci :refer [->quil-canvas]])
=> inside the the context for sci to begin with it, right?