2018-11-13 05:24:09 +00:00
// Compiled by ClojureScript 1.10.439 {}
2018-11-12 21:18:45 +00:00
goog . provide ( 'quil.util' ) ;
goog . require ( 'cljs.core' ) ;
goog . require ( 'clojure.string' ) ;
/ * *
* Function that does nothing .
* /
quil . util . no _fn = ( function quil$util$no _fn ( ) {
return null ;
} ) ;
/ * *
* Returns the val associated with key in mappings or key directly if it
* is one of the vals in mappings . Otherwise throws an exception .
* /
quil . util . resolve _constant _key = ( function quil$util$resolve _constant _key ( key , mappings ) {
if ( cljs . core . truth _ ( cljs . core . get . call ( null , mappings , key ) ) ) {
return cljs . core . get . call ( null , mappings , key ) ;
} else {
2018-11-13 05:24:09 +00:00
if ( cljs . core . truth _ ( cljs . core . some . call ( null , cljs . core . PersistentHashSet . createAsIfByAssoc ( [ key ] ) , cljs . core . vals . call ( null , mappings ) ) ) ) {
2018-11-12 21:18:45 +00:00
return key ;
} else {
2018-11-13 05:24:09 +00:00
throw ( new Error ( [ "Expecting a keyword, got: " , cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( key ) , ". Expected one of: " , cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( cljs . core . vec . call ( null , cljs . core . sort . call ( null , cljs . core . keys . call ( null , mappings ) ) ) ) ] . join ( '' ) ) ) ;
2018-11-12 21:18:45 +00:00
}
}
} ) ;
/ * *
* Returns the length of the longest key of map m . Assumes m ' s keys are strings
* and returns 0 if map is empty :
* ( length - of - longest - key { "foo" 1 "barr" 2 "bazzz" 3 } ) ; => 5
* ( length - of - longest - key { } ) ; => 0
* /
quil . util . length _of _longest _key = ( function quil$util$length _of _longest _key ( m ) {
2018-11-13 05:24:09 +00:00
var or _ _4047 _ _auto _ _ = cljs . core . last . call ( null , cljs . core . sort . call ( null , cljs . core . map . call ( null , ( function ( p1 _ _1156 _SHARP _ ) {
return p1 _ _1156 _SHARP _ . length ( ) ;
2018-11-12 21:18:45 +00:00
} ) , cljs . core . keys . call ( null , m ) ) ) ) ;
2018-11-13 05:24:09 +00:00
if ( cljs . core . truth _ ( or _ _4047 _ _auto _ _ ) ) {
return or _ _4047 _ _auto _ _ ;
2018-11-12 21:18:45 +00:00
} else {
return ( 0 ) ;
}
} ) ;
/ * *
* Generates a padding string starting concatting s with len times pad :
* ( gen - padding "" 5 "b" ) ; => "bbbbb"
* May be called without starting string s in which case it defaults to the
* empty string and also without pad in which case it defaults to a single space
* /
quil . util . gen _padding = ( function quil$util$gen _padding ( var _args ) {
2018-11-13 05:24:09 +00:00
var G _ _1158 = arguments . length ;
switch ( G _ _1158 ) {
2018-11-12 21:18:45 +00:00
case 1 :
return quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$1 ( ( arguments [ ( 0 ) ] ) ) ;
break ;
case 2 :
return quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$2 ( ( arguments [ ( 0 ) ] ) , ( arguments [ ( 1 ) ] ) ) ;
break ;
case 3 :
return quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$3 ( ( arguments [ ( 0 ) ] ) , ( arguments [ ( 1 ) ] ) , ( arguments [ ( 2 ) ] ) ) ;
break ;
default :
2018-11-13 05:24:09 +00:00
throw ( new Error ( [ "Invalid arity: " , cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( arguments . length ) ] . join ( '' ) ) ) ;
2018-11-12 21:18:45 +00:00
}
} ) ;
quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$1 = ( function ( len ) {
return quil . util . gen _padding . call ( null , "" , len , " " ) ;
} ) ;
quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$2 = ( function ( len , pad ) {
return quil . util . gen _padding . call ( null , "" , len , pad ) ;
} ) ;
quil . util . gen _padding . cljs$core$IFn$ _invoke$arity$3 = ( function ( s , len , pad ) {
if ( ( len > ( 0 ) ) ) {
return quil . util . gen _padding . call ( null , [ cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( s ) , cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( pad ) ] . join ( '' ) , ( len - ( 1 ) ) , pad ) ;
} else {
return s ;
}
} ) ;
quil . util . gen _padding . cljs$lang$maxFixedArity = 3 ;
quil . util . print _definition _list = ( function quil$util$print _definition _list ( definitions ) {
var longest _key = quil . util . length _of _longest _key . call ( null , definitions ) ;
return cljs . core . dorun . call ( null , cljs . core . map . call ( null , ( ( function ( longest _key ) {
2018-11-13 05:24:09 +00:00
return ( function ( p _ _1160 ) {
var vec _ _1161 = p _ _1160 ;
var k = cljs . core . nth . call ( null , vec _ _1161 , ( 0 ) , null ) ;
var v = cljs . core . nth . call ( null , vec _ _1161 , ( 1 ) , null ) ;
2018-11-12 21:18:45 +00:00
var len = k . length ( ) ;
var diff = ( longest _key - len ) ;
var pad = quil . util . gen _padding . call ( null , diff ) ;
return cljs . core . println . call ( null , k , pad , "- " , v ) ;
} ) ; } ) ( longest _key ) )
, definitions ) ) ;
} ) ;
quil . util . clj _compilation _QMARK _ = ( function quil$util$clj _compilation _QMARK _ ( ) {
return false ;
} ) ;
quil . util . prepare _quil _name = ( function quil$util$prepare _quil _name ( const _keyword ) {
return clojure . string . replace . call ( null , clojure . string . upper _case . call ( null , cljs . core . name . call ( null , const _keyword ) ) , /-/ , "_" ) ;
} ) ;
quil . util . prepare _quil _clj _constants = ( function quil$util$prepare _quil _clj _constants ( constants ) {
2018-11-13 05:24:09 +00:00
return cljs . core . into . call ( null , cljs . core . PersistentArrayMap . EMPTY , cljs . core . map . call ( null , ( function ( p1 _ _1164 _SHARP _ ) {
return ( new cljs . core . PersistentVector ( null , 2 , ( 5 ) , cljs . core . PersistentVector . EMPTY _NODE , [ p1 _ _1164 _SHARP _ , cljs . core . symbol . call ( null , [ "PConstants/" , cljs . core . str . cljs$core$IFn$ _invoke$arity$1 ( quil . util . prepare _quil _name . call ( null , p1 _ _1164 _SHARP _ ) ) ] . join ( '' ) ) ] , null ) ) ;
2018-11-12 21:18:45 +00:00
} ) , constants ) ) ;
} ) ;
quil . util . prepare _quil _cljs _constants = ( function quil$util$prepare _quil _cljs _constants ( constants ) {
2018-11-13 05:24:09 +00:00
return cljs . core . into . call ( null , cljs . core . PersistentArrayMap . EMPTY , cljs . core . map . call ( null , ( function ( p1 _ _1165 _SHARP _ ) {
return ( new cljs . core . PersistentVector ( null , 2 , ( 5 ) , cljs . core . PersistentVector . EMPTY _NODE , [ p1 _ _1165 _SHARP _ , cljs . core . sequence . call ( null , cljs . core . seq . call ( null , cljs . core . concat . call ( null , ( new cljs . core . List ( null , new cljs . core . Symbol ( "cljs.core" , "aget" , "cljs.core/aget" , 6345791 , null ) , null , ( 1 ) , null ) ) , ( new cljs . core . List ( null , new cljs . core . Symbol ( "js" , "Processing.prototype.PConstants" , "js/Processing.prototype.PConstants" , 2034048972 , null ) , null , ( 1 ) , null ) ) , ( new cljs . core . List ( null , quil . util . prepare _quil _name . call ( null , p1 _ _1165 _SHARP _ ) , null , ( 1 ) , null ) ) ) ) ) ] , null ) ) ;
2018-11-12 21:18:45 +00:00
} ) , constants ) ) ;
} ) ;
quil . util . make _quil _constant _map = ( function quil$util$make _quil _constant _map ( target , const _map _name , const _map ) {
2018-11-13 05:24:09 +00:00
return cljs . core . sequence . call ( null , cljs . core . seq . call ( null , cljs . core . concat . call ( null , ( new cljs . core . List ( null , new cljs . core . Symbol ( null , "def" , "def" , 597100991 , null ) , null , ( 1 ) , null ) ) , ( new cljs . core . List ( null , const _map _name , null , ( 1 ) , null ) ) , ( new cljs . core . List ( null , ( ( cljs . core . _EQ _ . call ( null , target , new cljs . core . Keyword ( null , "clj" , "clj" , - 660495428 ) ) ) ? quil . util . prepare _quil _clj _constants . call ( null , const _map ) : quil . util . prepare _quil _cljs _constants . call ( null , const _map ) ) , null , ( 1 ) , null ) ) ) ) ) ;
2018-11-12 21:18:45 +00:00
} ) ;
2018-11-13 05:24:09 +00:00
var ret _ _4684 _ _auto _ _ _1171 = ( function ( ) {
2018-11-12 21:18:45 +00:00
quil . util . generate _quil _constants = ( function quil$util$generate _quil _constants ( var _args ) {
2018-11-13 05:24:09 +00:00
var args _ _4647 _ _auto _ _ = [ ] ;
var len _ _4641 _ _auto _ _ _1172 = arguments . length ;
var i _ _4642 _ _auto _ _ _1173 = ( 0 ) ;
2018-11-12 21:18:45 +00:00
while ( true ) {
2018-11-13 05:24:09 +00:00
if ( ( i _ _4642 _ _auto _ _ _1173 < len _ _4641 _ _auto _ _ _1172 ) ) {
args _ _4647 _ _auto _ _ . push ( ( arguments [ i _ _4642 _ _auto _ _ _1173 ] ) ) ;
2018-11-12 21:18:45 +00:00
2018-11-13 05:24:09 +00:00
var G _ _1174 = ( i _ _4642 _ _auto _ _ _1173 + ( 1 ) ) ;
i _ _4642 _ _auto _ _ _1173 = G _ _1174 ;
2018-11-12 21:18:45 +00:00
continue ;
} else {
}
break ;
}
2018-11-13 05:24:09 +00:00
var argseq _ _4648 _ _auto _ _ = ( ( ( ( 3 ) < args _ _4647 _ _auto _ _ . length ) ) ? ( new cljs . core . IndexedSeq ( args _ _4647 _ _auto _ _ . slice ( ( 3 ) ) , ( 0 ) , null ) ) : null ) ;
return quil . util . generate _quil _constants . cljs$core$IFn$ _invoke$arity$variadic ( ( arguments [ ( 0 ) ] ) , ( arguments [ ( 1 ) ] ) , ( arguments [ ( 2 ) ] ) , argseq _ _4648 _ _auto _ _ ) ;
2018-11-12 21:18:45 +00:00
} ) ;
quil . util . generate _quil _constants . cljs$core$IFn$ _invoke$arity$variadic = ( function ( _AMPERSAND _form , _AMPERSAND _env , target , opts ) {
2018-11-13 05:24:09 +00:00
return cljs . core . sequence . call ( null , cljs . core . seq . call ( null , cljs . core . concat . call ( null , ( new cljs . core . List ( null , new cljs . core . Symbol ( null , "do" , "do" , 1686842252 , null ) , null , ( 1 ) , null ) ) , cljs . core . map . call ( null , ( function ( p1 _ _1166 _SHARP _ ) {
return quil . util . make _quil _constant _map . call ( null , target , cljs . core . first . call ( null , p1 _ _1166 _SHARP _ ) , cljs . core . second . call ( null , p1 _ _1166 _SHARP _ ) ) ;
2018-11-12 21:18:45 +00:00
} ) , cljs . core . partition . call ( null , ( 2 ) , opts ) ) ) ) ) ;
} ) ;
quil . util . generate _quil _constants . cljs$lang$maxFixedArity = ( 3 ) ;
2018-11-13 05:24:09 +00:00
/** @this {Function} */
quil . util . generate _quil _constants . cljs$lang$applyTo = ( function ( seq1167 ) {
var G _ _1168 = cljs . core . first . call ( null , seq1167 ) ;
var seq1167 _ _$1 = cljs . core . next . call ( null , seq1167 ) ;
var G _ _1169 = cljs . core . first . call ( null , seq1167 _ _$1 ) ;
var seq1167 _ _$2 = cljs . core . next . call ( null , seq1167 _ _$1 ) ;
var G _ _1170 = cljs . core . first . call ( null , seq1167 _ _$2 ) ;
var seq1167 _ _$3 = cljs . core . next . call ( null , seq1167 _ _$2 ) ;
var self _ _4628 _ _auto _ _ = this ;
return self _ _4628 _ _auto _ _ . cljs$core$IFn$ _invoke$arity$variadic ( G _ _1168 , G _ _1169 , G _ _1170 , seq1167 _ _$3 ) ;
2018-11-12 21:18:45 +00:00
} ) ;
2018-11-13 05:24:09 +00:00
return null ;
} ) ( )
;
2018-11-12 21:18:45 +00:00
quil . util . generate _quil _constants . cljs$lang$macro = true ;
2018-11-13 05:24:09 +00:00
//# sourceMappingURL=util.js.map