summaryrefslogtreecommitdiff
path: root/src/assets/viz/2/quil/middlewares/fun_mode.js
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2021-01-21 17:22:53 -0700
committerBrian Picciano <mediocregopher@gmail.com>2021-01-21 17:22:53 -0700
commitbcf9b230be6d74c71567fd0771b31d47d8dd39c7 (patch)
tree2d0fc16142d55bbd5876ac6b8174c2857883b40e /src/assets/viz/2/quil/middlewares/fun_mode.js
parentd57fd70640948cf20eeb41b56e8d4e23e616cec0 (diff)
build the blog with nix
Diffstat (limited to 'src/assets/viz/2/quil/middlewares/fun_mode.js')
-rw-r--r--src/assets/viz/2/quil/middlewares/fun_mode.js142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/assets/viz/2/quil/middlewares/fun_mode.js b/src/assets/viz/2/quil/middlewares/fun_mode.js
new file mode 100644
index 0000000..5eabdf8
--- /dev/null
+++ b/src/assets/viz/2/quil/middlewares/fun_mode.js
@@ -0,0 +1,142 @@
+// Compiled by ClojureScript 1.10.439 {}
+goog.provide('quil.middlewares.fun_mode');
+goog.require('cljs.core');
+goog.require('quil.core');
+quil.middlewares.fun_mode.wrap_setup = (function quil$middlewares$fun_mode$wrap_setup(options){
+var setup = new cljs.core.Keyword(null,"setup","setup",1987730512).cljs$core$IFn$_invoke$arity$2(options,(function (){
+return null;
+}));
+return cljs.core.assoc.call(null,options,new cljs.core.Keyword(null,"setup","setup",1987730512),((function (setup){
+return (function (){
+return cljs.core.reset_BANG_.call(null,quil.core.state_atom.call(null),setup.call(null));
+});})(setup))
+);
+});
+quil.middlewares.fun_mode.wrap_draw_update = (function quil$middlewares$fun_mode$wrap_draw_update(options){
+var draw = new cljs.core.Keyword(null,"draw","draw",1358331674).cljs$core$IFn$_invoke$arity$2(options,(function (_){
+return null;
+}));
+var update = new cljs.core.Keyword(null,"update","update",1045576396).cljs$core$IFn$_invoke$arity$2(options,cljs.core.identity);
+var quil_draw = ((function (draw,update){
+return (function (){
+return draw.call(null,cljs.core.swap_BANG_.call(null,quil.core.state_atom.call(null),((cljs.core._EQ_.call(null,quil.core.frame_count.call(null),(1)))?cljs.core.identity:update)));
+});})(draw,update))
+;
+return cljs.core.assoc.call(null,cljs.core.dissoc.call(null,options,new cljs.core.Keyword(null,"update","update",1045576396)),new cljs.core.Keyword(null,"draw","draw",1358331674),quil_draw);
+});
+quil.middlewares.fun_mode.mouse_event = (function quil$middlewares$fun_mode$mouse_event(){
+return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"x","x",2099068185),quil.core.mouse_x.call(null),new cljs.core.Keyword(null,"y","y",-1757859776),quil.core.mouse_y.call(null)], null);
+});
+quil.middlewares.fun_mode.mouse_event_full = (function quil$middlewares$fun_mode$mouse_event_full(){
+return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"x","x",2099068185),quil.core.mouse_x.call(null),new cljs.core.Keyword(null,"y","y",-1757859776),quil.core.mouse_y.call(null),new cljs.core.Keyword(null,"button","button",1456579943),quil.core.mouse_button.call(null)], null);
+});
+quil.middlewares.fun_mode.key_event = (function quil$middlewares$fun_mode$key_event(){
+return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"key","key",-1516042587),quil.core.key_as_keyword.call(null),new cljs.core.Keyword(null,"key-code","key-code",-1732114304),quil.core.key_code.call(null),new cljs.core.Keyword(null,"raw-key","raw-key",-162482279),quil.core.raw_key.call(null)], null);
+});
+quil.middlewares.fun_mode.wrap_handler = (function quil$middlewares$fun_mode$wrap_handler(var_args){
+var G__2134 = arguments.length;
+switch (G__2134) {
+case 2:
+return quil.middlewares.fun_mode.wrap_handler.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
+
+break;
+case 3:
+return quil.middlewares.fun_mode.wrap_handler.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
+
+break;
+default:
+throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
+
+}
+});
+
+quil.middlewares.fun_mode.wrap_handler.cljs$core$IFn$_invoke$arity$2 = (function (options,handler_key){
+return quil.middlewares.fun_mode.wrap_handler.call(null,options,handler_key,null);
+});
+
+quil.middlewares.fun_mode.wrap_handler.cljs$core$IFn$_invoke$arity$3 = (function (options,handler_key,event_fn){
+var temp__4655__auto__ = options.call(null,handler_key);
+if(cljs.core.truth_(temp__4655__auto__)){
+var handler = temp__4655__auto__;
+return cljs.core.assoc.call(null,options,handler_key,(cljs.core.truth_(event_fn)?((function (handler,temp__4655__auto__){
+return (function (){
+return cljs.core.swap_BANG_.call(null,quil.core.state_atom.call(null),handler,event_fn.call(null));
+});})(handler,temp__4655__auto__))
+:((function (handler,temp__4655__auto__){
+return (function (){
+return cljs.core.swap_BANG_.call(null,quil.core.state_atom.call(null),handler);
+});})(handler,temp__4655__auto__))
+));
+} else {
+return options;
+}
+});
+
+quil.middlewares.fun_mode.wrap_handler.cljs$lang$maxFixedArity = 3;
+
+quil.middlewares.fun_mode.wrap_handlers = (function quil$middlewares$fun_mode$wrap_handlers(var_args){
+var args__4647__auto__ = [];
+var len__4641__auto___2138 = arguments.length;
+var i__4642__auto___2139 = (0);
+while(true){
+if((i__4642__auto___2139 < len__4641__auto___2138)){
+args__4647__auto__.push((arguments[i__4642__auto___2139]));
+
+var G__2140 = (i__4642__auto___2139 + (1));
+i__4642__auto___2139 = G__2140;
+continue;
+} else {
+}
+break;
+}
+
+var argseq__4648__auto__ = ((((1) < args__4647__auto__.length))?(new cljs.core.IndexedSeq(args__4647__auto__.slice((1)),(0),null)):null);
+return quil.middlewares.fun_mode.wrap_handlers.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4648__auto__);
+});
+
+quil.middlewares.fun_mode.wrap_handlers.cljs$core$IFn$_invoke$arity$variadic = (function (options,handlers){
+return cljs.core.reduce.call(null,(function (options__$1,handler){
+if((handler instanceof cljs.core.Keyword)){
+return quil.middlewares.fun_mode.wrap_handler.call(null,options__$1,handler);
+} else {
+return cljs.core.apply.call(null,quil.middlewares.fun_mode.wrap_handler,options__$1,handler);
+}
+}),options,handlers);
+});
+
+quil.middlewares.fun_mode.wrap_handlers.cljs$lang$maxFixedArity = (1);
+
+/** @this {Function} */
+quil.middlewares.fun_mode.wrap_handlers.cljs$lang$applyTo = (function (seq2136){
+var G__2137 = cljs.core.first.call(null,seq2136);
+var seq2136__$1 = cljs.core.next.call(null,seq2136);
+var self__4628__auto__ = this;
+return self__4628__auto__.cljs$core$IFn$_invoke$arity$variadic(G__2137,seq2136__$1);
+});
+
+quil.middlewares.fun_mode.wrap_mouse_wheel = (function quil$middlewares$fun_mode$wrap_mouse_wheel(options){
+var temp__4655__auto__ = new cljs.core.Keyword(null,"mouse-wheel","mouse-wheel",1811662439).cljs$core$IFn$_invoke$arity$1(options);
+if(cljs.core.truth_(temp__4655__auto__)){
+var handler = temp__4655__auto__;
+return cljs.core.assoc.call(null,options,new cljs.core.Keyword(null,"mouse-wheel","mouse-wheel",1811662439),((function (handler,temp__4655__auto__){
+return (function (rotation){
+return cljs.core.swap_BANG_.call(null,quil.core.state_atom.call(null),handler,rotation);
+});})(handler,temp__4655__auto__))
+);
+} else {
+return options;
+}
+});
+/**
+ * Introduces function mode making all handlers (setup, draw, mouse-click, etc)
+ * state-aware. Adds support for 'update' function.
+ */
+quil.middlewares.fun_mode.fun_mode = (function quil$middlewares$fun_mode$fun_mode(options){
+return quil.middlewares.fun_mode.wrap_mouse_wheel.call(null,quil.middlewares.fun_mode.wrap_handlers.call(null,quil.middlewares.fun_mode.wrap_draw_update.call(null,quil.middlewares.fun_mode.wrap_setup.call(null,options)),new cljs.core.Keyword(null,"focus-gained","focus-gained",-857086384),new cljs.core.Keyword(null,"focus-lost","focus-lost",-554849613),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-entered","mouse-entered",811350322),quil.middlewares.fun_mode.mouse_event], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-exited","mouse-exited",-483205244),quil.middlewares.fun_mode.mouse_event], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-pressed","mouse-pressed",736955536),quil.middlewares.fun_mode.mouse_event_full], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-released","mouse-released",-664480061),quil.middlewares.fun_mode.mouse_event], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-clicked","mouse-clicked",-199339421),quil.middlewares.fun_mode.mouse_event_full], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-moved","mouse-moved",-1918152310),(function (){
+return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"x","x",2099068185),quil.core.mouse_x.call(null),new cljs.core.Keyword(null,"y","y",-1757859776),quil.core.mouse_y.call(null),new cljs.core.Keyword(null,"p-x","p-x",-1721211211),quil.core.pmouse_x.call(null),new cljs.core.Keyword(null,"p-y","p-y",-530704830),quil.core.pmouse_y.call(null)], null);
+})], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"mouse-dragged","mouse-dragged",-1220073441),(function (){
+return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"x","x",2099068185),quil.core.mouse_x.call(null),new cljs.core.Keyword(null,"y","y",-1757859776),quil.core.mouse_y.call(null),new cljs.core.Keyword(null,"p-x","p-x",-1721211211),quil.core.pmouse_x.call(null),new cljs.core.Keyword(null,"p-y","p-y",-530704830),quil.core.pmouse_y.call(null),new cljs.core.Keyword(null,"button","button",1456579943),quil.core.mouse_button.call(null)], null);
+})], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"key-pressed","key-pressed",-757100364),quil.middlewares.fun_mode.key_event], null),new cljs.core.Keyword(null,"key-released","key-released",215919828),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"key-typed","key-typed",-876037597),quil.middlewares.fun_mode.key_event], null),new cljs.core.Keyword(null,"on-close","on-close",-761178394)));
+});
+
+//# sourceMappingURL=fun_mode.js.map