p5.touchgui.js 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814
  1. // Create GUI context
  2. let _gui;
  3. /**
  4. * Prototype functions to make library
  5. * method calls more like p5.js.
  6. */
  7. p5.prototype.createGui = function() {
  8. _gui = new Gui();
  9. return _gui;
  10. };
  11. p5.prototype.drawGui = function() {
  12. _gui.draw();
  13. };
  14. // Prototype functions for GUI elements
  15. p5.prototype.createButton = function(label, x, y, w=128, h=32) {
  16. let obj = new GuiButton(label, x, y, w, h);
  17. _gui._add(obj);
  18. return obj;
  19. };
  20. p5.prototype.createToggle = function(label, x, y, w=128, h=32, defaultVal = false) {
  21. let obj = new GuiToggle(label, x, y, w, h, defaultVal);
  22. _gui._add(obj);
  23. return obj;
  24. };
  25. p5.prototype.createCheckbox = function(label, x, y, w=32, h=32, defaultVal = false) {
  26. let obj = new GuiCheckbox(label, x, y, w, h, defaultVal);
  27. _gui._add(obj);
  28. return obj;
  29. };
  30. p5.prototype.createSlider = function(label, x, y, w=256, h=32, min=0, max=1) {
  31. let obj = new GuiSlider(label, x, y, w, h, min, max);
  32. _gui._add(obj);
  33. return obj;
  34. };
  35. p5.prototype.createSliderV = function(label, x, y, w=32, h=256, min=0, max=1) {
  36. let obj = new GuiSliderV(label, x, y, w, h, min, max);
  37. _gui._add(obj);
  38. return obj;
  39. };
  40. p5.prototype.createCrossfader = function(label, x, y, w=256, h=32, min=(-1), max=1) {
  41. let obj = new GuiCrossfader(label, x, y, w, h, min, max);
  42. _gui._add(obj);
  43. return obj;
  44. };
  45. p5.prototype.createCrossfaderV = function(label, x, y, w=256, h=32, min=(-1), max=1) {
  46. let obj = new GuiCrossfaderV(label, x, y, w, h, min, max);
  47. _gui._add(obj);
  48. return obj;
  49. };
  50. p5.prototype.createSlider2d = function(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  51. let obj = new GuiSlider2d(label, x, y, w, h, minX, maxX, minY, maxY);
  52. _gui._add(obj);
  53. return obj;
  54. };
  55. p5.prototype.createJoystick = function(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  56. let obj = new GuiJoystick(label, x, y, w, h, minX, maxX, minY, maxY);
  57. _gui._add(obj);
  58. return obj;
  59. };
  60. p5.prototype._guiPostDraw = function() {
  61. if (_gui != null) {
  62. _gui._postDraw();
  63. }
  64. };
  65. p5.prototype.registerMethod('post', p5.prototype._guiPostDraw);
  66. /**
  67. * Generates hash code from a string.
  68. * @see http://stackoverflow.com/q/7616461/940217
  69. * @return {number}
  70. * Note: this is not being used in this version of the library. Will remove once I'm
  71. * sure it's going to stay that way.
  72. */
  73. String.prototype.hashCode = function(){
  74. if (Array.prototype.reduce){
  75. return this.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
  76. }
  77. var hash = 0;
  78. if (this.length === 0) return hash;
  79. for (var i = 0; i < this.length; i++) {
  80. var character = this.charCodeAt(i);
  81. hash = ((hash<<5)-hash)+character;
  82. hash = hash & hash; // Convert to 32bit integer
  83. }
  84. return hash;
  85. }
  86. function _findByKey(obj, value) {
  87. return Object.keys(obj)[Object.values(obj).indexOf(value)];
  88. }
  89. /*******************
  90. * Gui
  91. * - Creates a GUI context to track all GUI objects.
  92. *
  93. * TODO: add 'page' property so that objects can be grouped and toggled by page
  94. */
  95. class Gui {
  96. constructor() {
  97. this.objects = [];
  98. this.touchInput = false; // true if the last input was a touch event
  99. this._activeIds = {};
  100. this._ptouches = {};
  101. this._hoverObj = null;
  102. this._style = new GuiStyle();
  103. this.updateStyle();
  104. // Define touchGui eventHandlers for mouse and touch so as not to interfere
  105. // with p5.js eventHandlers
  106. this._onMouseDown = this._onMouseDown.bind(this);
  107. this._onMouseMove = this._onMouseMove.bind(this);
  108. this._onMouseLeave = this._onMouseLeave.bind(this);
  109. this._onMouseUp = this._onMouseUp.bind(this);
  110. this._onTouchStart = this._onTouchStart.bind(this);
  111. this._onTouchMove = this._onTouchMove.bind(this);
  112. this._onTouchEnd = this._onTouchEnd.bind(this);
  113. this._onTouchCancel = this._onTouchCancel.bind(this);
  114. document.addEventListener("mousedown", this._onMouseDown, false);
  115. document.addEventListener("mousemove", this._onMouseMove, false);
  116. document.addEventListener("mouseleave", this._onMouseLeave, false);
  117. document.addEventListener("mouseup", this._onMouseUp, false);
  118. document.addEventListener("touchstart", this._onTouchStart, false);
  119. document.addEventListener("touchmove", this._onTouchMove, false);
  120. document.addEventListener("touchend", this._onTouchEnd, false);
  121. document.addEventListener("touchcancel", this._onTouchCancel, false);
  122. }
  123. // Add a new object to the GUI context
  124. _add(newObj) {
  125. newObj._index = this.objects.length;
  126. this.objects.push(newObj);
  127. return true;
  128. }
  129. // Gets array of objects from the GUI context that match the label
  130. get(label) {
  131. let fetched = [];
  132. this.objects.forEach((obj) => {
  133. if (obj.label == label) {
  134. fetched.push(obj);
  135. }
  136. });
  137. if (fetched.length == 0) {
  138. console.error("p5.touchgui: No GUI object with label \'" + label + "\' has been found.");
  139. }
  140. return fetched;
  141. }
  142. // Get position relative to canvas
  143. _getCanvasPos(x, y) {
  144. let rect = canvas.getBoundingClientRect();
  145. let sx = canvas.scrollWidth / this.width || 1;
  146. let sy = canvas.scrollHeight / this.height || 1;
  147. let p = {x: 0, y: 0};
  148. p.x = (x - rect.left) / sx;
  149. p.y = (y - rect.top) / sy;
  150. return p;
  151. }
  152. // Update and draw the GUI (should be run each frame after background())
  153. draw() {
  154. this.objects.forEach((obj) => {
  155. if (obj.visible) {
  156. obj.draw();
  157. }
  158. });
  159. }
  160. // Automatically gets run after the draw loop, storing each object's previous state
  161. // for reference in the next frame
  162. _postDraw() {
  163. this.objects.forEach((obj) => {
  164. obj._postDraw();
  165. });
  166. }
  167. //// STYLE
  168. // Loads a built-in preset style by string name
  169. loadStyle(presetName) {
  170. switch (presetName) {
  171. case "Default":
  172. this._style.Gray();
  173. break;
  174. case "Gray":
  175. this._style.Gray();
  176. break;
  177. case "Rose":
  178. this._style.Rose();
  179. break;
  180. case "Seafoam":
  181. this._style.Seafoam();
  182. break;
  183. case "Blue":
  184. this._style.Blue();
  185. break;
  186. case "TerminalGreen":
  187. this._style.TerminalGreen();
  188. break;
  189. case "TerminalRed":
  190. this._style.TerminalRed();
  191. break;
  192. case "TerminalBlue":
  193. this._style.TerminalBlue();
  194. break;
  195. case "TerminalYellow":
  196. this._style.TerminalYellow();
  197. break;
  198. case "TerminalMagenta":
  199. this._style.TerminalMagenta();
  200. break;
  201. default:
  202. console.warn("\'" + presetName + "\' preset does not exist. Defaulting to \'Gray\'.")
  203. this._style.Gray();
  204. }
  205. this.updateStyle();
  206. console.log("\'" + presetName + "\' preset loaded.")
  207. }
  208. // Update all objects' style parameters with global style
  209. updateStyle() {
  210. this.objects.forEach((obj) => {
  211. switch (obj._type) {
  212. case "button":
  213. obj._style = Object.create(this._style.button);
  214. break;
  215. case "toggle":
  216. obj._style = Object.create(this._style.toggle);
  217. break;
  218. case "checkbox":
  219. obj._style = Object.create(this._style.checkbox);
  220. break;
  221. case "slider":
  222. obj._style = Object.create(this._style.slider);
  223. break;
  224. case "crossfader":
  225. obj._style = Object.create(this._style.slider);
  226. obj._style.strokeCenter = Object.create(this._style.crossfader.strokeCenter);
  227. obj._style.strokeCenterHover = Object.create(this._style.crossfader.strokeCenterHover);
  228. obj._style.strokeCenterActive = Object.create(this._style.crossfader.strokeCenterActive);
  229. break;
  230. case "slider2d":
  231. obj._style = Object.create(this._style.slider);
  232. obj._style.handleRadius = this._style.slider2d.handleRadius;
  233. break;
  234. case "joystick":
  235. obj._style = Object.create(this._style.slider);
  236. obj._style.handleRadius = this._style.slider2d.handleRadius;
  237. break;
  238. default:
  239. console.error(obj.label + " has an invalid type. Please submit a bug report.");
  240. }
  241. });
  242. }
  243. // TODO: These load and save style as JSON functions need a lot more
  244. // consideration before implementation. There are questions such as:
  245. // - Does this save and load layout as well as style?
  246. // - What is the best way to deep copy elements?
  247. // Load style from a JSON file.
  248. /*loadStyleJSON(filename) {
  249. console.warn("loadStyleJSON(): This function is not yet implemented.");
  250. if (typeof filename === "string") {
  251. loadJSON(filename, (style)=> {
  252. let target = {};
  253. // Cycle through all top level style properties
  254. Object.keys(style).forEach((i) => {
  255. if (typeof style[i] !== "object") {
  256. // If the property is not an object, copy it to target
  257. target[i] = style[i];
  258. }
  259. else {
  260. // If the property is an object, create an empty object on the target...
  261. target[i] = {};
  262. // Loop through all child items...
  263. Object.keys(style[i]).forEach((j) => {
  264. if (typeof style[i][j] === "string" && style[i] != "font") {
  265. // Copy any non-font string objects as p5.Color objects
  266. target[i][j] = color(style[i][j]);
  267. }
  268. else {
  269. // Copy any other properties directly
  270. target[i][j] = style[i][j];
  271. }
  272. });
  273. }
  274. });
  275. this._style = Object.create(target);
  276. this.updateStyle();
  277. });
  278. }
  279. else {
  280. console.error("loadStyleJSON(): Please input a string as a filename.");
  281. }
  282. }
  283. // Saves current style as a JSON file.
  284. saveStyleJSON(filename) {
  285. console.warn("saveStyleJSON(): This function is not yet implemented.");
  286. if (typeof filename === "string") {
  287. // If the filename is a string, create target object to which we'll transfer the style properties
  288. let target = {};
  289. // Cycle through all top level style properties
  290. Object.keys(this._style).forEach((i) => {
  291. if (typeof this._style[i] !== "object") {
  292. // If the property is not an object, copy it to target
  293. target[i] = this._style[i];
  294. }
  295. else {
  296. // If the property is an object, create an empty object on the target...
  297. target[i] = {};
  298. // Loop through all child items...
  299. Object.keys(this._style[i]).forEach((j) => {
  300. if (typeof this._style[i][j] === "object") {
  301. // Copy any objects as strings (bc they are p5.Color objects)
  302. target[i][j] = this._style[i][j].toString();
  303. }
  304. else {
  305. // Copy any other properties directly
  306. target[i][j] = this._style[i][j];
  307. }
  308. });
  309. }
  310. });
  311. // Save the resultant target object as a JSON file
  312. saveJSON(target, filename, false);
  313. }
  314. else {
  315. console.error("saveStyleJSON(): Please input a string as a filename.");
  316. }
  317. }*/
  318. //// GLOBAL STYLE SETTINGS
  319. // These functions set specific style properties for all objects
  320. setStrokeWeight(strokeWeight) {
  321. if (typeof strokeWeight === "number") {
  322. this._style.strokeWeight = strokeWeight;
  323. this._style.button.strokeWeight = strokeWeight;
  324. this._style.toggle.strokeWeight = strokeWeight;
  325. this._style.checkbox.strokeWeight = strokeWeight;
  326. this._style.slider.strokeWeight = strokeWeight;
  327. this.objects.forEach((obj) => {
  328. obj.setStyle("strokeWeight", strokeWeight);
  329. });
  330. }
  331. else {
  332. console.error("setStrokeWeight(): please enter a number.");
  333. }
  334. }
  335. setRounding(rounding) {
  336. if (typeof rounding === "number") {
  337. this._style.rounding = rounding;
  338. this._style.button.rounding = rounding;
  339. this._style.toggle.rounding = rounding;
  340. this._style.checkbox.rounding = rounding;
  341. this._style.slider.rounding = rounding;
  342. this.objects.forEach((obj) => {
  343. obj.setStyle("rounding", rounding);
  344. });
  345. }
  346. else {
  347. console.error("setRounding(): please enter a number.");
  348. }
  349. }
  350. setFont(font) {
  351. if (typeof font === "string") {
  352. this._style.font = font;
  353. this._style.button.font = font;
  354. this._style.toggle.font = font;
  355. this.objects.forEach((obj) => {
  356. obj.setStyle("font", font);
  357. });
  358. }
  359. else if (typeof font === "object") {
  360. this.objects.forEach((obj) => {
  361. obj.setStyle("font", font);
  362. });
  363. }
  364. else {
  365. console.error("setFont(): please enter a string or p5.Font object.");
  366. }
  367. }
  368. setTextSize(textSize) {
  369. if (typeof textSize === "number") {
  370. this._style.textSize = textSize;
  371. this._style.button.textSize = textSize;
  372. this._style.toggle.textSize = textSize;
  373. this.objects.forEach((obj) => {
  374. obj.setStyle("textSize", textSize);
  375. });
  376. }
  377. else {
  378. console.error("setTextSize(): please enter a number.");
  379. }
  380. }
  381. setTrackWidth(trackWidth) {
  382. if (typeof trackWidth === "number") {
  383. this._style.slider.trackWidth = trackWidth;
  384. this.objects.forEach((obj) => {
  385. if (obj._family === "slider") {
  386. obj.setStyle("trackWidth", constrain(trackWidth, 0, 1));
  387. }
  388. });
  389. }
  390. }
  391. //// EVENT HANDLING
  392. // MOUSE
  393. _onMouseDown(e) {
  394. // Get a hit result for the click and the current mouse position
  395. let result = this._checkHit(mouseX, mouseY);
  396. let m = this._getCanvasPos(e.clientX, e.clientY);
  397. // If there's a successful hit and the object is visible and enabled,
  398. // process the mouse press
  399. if (result.hit) {
  400. if (result.obj.visible && result.obj.enabled) {
  401. let obj = result.obj;
  402. this._onPress(obj, m);
  403. this._activeIds[-1] = obj._index;
  404. }
  405. }
  406. }
  407. _onMouseMove(e) {
  408. let m = this._getCanvasPos(e.clientX, e.clientY);
  409. // If any mouse buttons are pressed
  410. if (e.buttons >= 1) {
  411. // And if the mouse isn't currently locked on an object,
  412. // process the mouse input
  413. if (this._activeIds[-1] != null) {
  414. let obj = this.objects[this._activeIds[-1]];
  415. this._onMove(obj, m);
  416. }
  417. }
  418. else {
  419. // If not, check for mouse hovering over an object
  420. let result = this._checkHit(mouseX, mouseY);
  421. if (this._hoverObj != null) {
  422. this._hoverObj._hover = false;
  423. this._hoverObj = null;
  424. }
  425. if (result.hit) {
  426. if (result.obj.visible && result.obj.enabled) {
  427. result.obj._hover = true;
  428. this._hoverObj = result.obj;
  429. }
  430. }
  431. }
  432. }
  433. // In case the mouse leaves the screen, make sure to
  434. // deactivate any hovers
  435. _onMouseLeave(e) {
  436. if (this._hoverObj != null) {
  437. this._hoverObj._hover = false;
  438. this._hoverObj = null;
  439. }
  440. }
  441. _onMouseUp(e) {
  442. // If the mouse was locked to an object, process the release
  443. if (this._activeIds[-1] != null) {
  444. let obj = this.objects[this._activeIds[-1]];
  445. this._onRelease(obj);
  446. }
  447. // Set the mouse active ID to null (no objects locked)
  448. this._activeIds[-1] = null;
  449. }
  450. // MULTI-TOUCH
  451. _onTouchStart(e) {
  452. // If any touch events are registered, shut off any hovered objects
  453. if (this._hoverObj != null) {
  454. this._hoverObj._hover = false;
  455. this._hoverObj = null;
  456. }
  457. // Loop through all active touchpoints
  458. for (let i = 0; i < e.touches.length; i++) {
  459. let t = this._getCanvasPos(e.touches[i].clientX, e.touches[i].clientY);
  460. let id = e.touches[i].identifier;
  461. let result = this._checkHit(t.x, t.y);
  462. // If there's a hit
  463. if (result.hit) {
  464. // And the object is visible and enabled and the touch is not
  465. // already locked on an object, process the input
  466. if (result.obj.visible && result.obj.enabled && this._activeIds[id] == null) {
  467. let obj = result.obj;
  468. this._onPress(obj, t);
  469. this._activeIds[id] = obj._index;
  470. }
  471. }
  472. }
  473. // Store current touches for future reference
  474. this._ptouches = e.touches;
  475. }
  476. _onTouchMove(e) {
  477. // If any touch events are registered, shut off any hovered objects
  478. if (this._hoverObj != null) {
  479. this._hoverObj._hover = false;
  480. this._hoverObj = null;
  481. }
  482. // Loop through all active touch
  483. for (let i = 0; i < e.touches.length; i++) {
  484. let t = this._getCanvasPos(e.touches[i].clientX, e.touches[i].clientY);
  485. let id = e.touches[i].identifier;
  486. // If the touch is already locked on an object, process the input
  487. if (this._activeIds[id] != null) {
  488. let obj = this.objects[this._activeIds[id]];
  489. this._onMove(obj, t);
  490. }
  491. }
  492. // Store current touches for future reference
  493. this._ptouches = e.touches;
  494. }
  495. _onTouchEnd(e) {
  496. // Prevent browser handling of touch event as mouse event
  497. if (e.cancelable) { e.preventDefault(); }
  498. // Get removed touch id
  499. let id = null;
  500. for (let i = 0; i < this._ptouches.length; i++) {
  501. let found = false;
  502. for (let j = 0; j < e.touches.length; j++) {
  503. if (e.touches[j].identifier == this._ptouches[i].identifier) {
  504. found = true;
  505. }
  506. }
  507. if (!found) { id = this._ptouches[i].identifier; }
  508. }
  509. // If the touch was locked on an object, release the object
  510. if (this._activeIds[id] != null) {
  511. let obj = this.objects[this._activeIds[id]];
  512. this._onRelease(obj);
  513. }
  514. // Set the touch active ID to null (no objects locked)
  515. this._activeIds[id] = null;
  516. // Store current touches for future reference
  517. this._ptouches = e.touches;
  518. }
  519. // In case there are 'touchcancel' events, issue a warning
  520. _onTouchCancel(e) {
  521. // Prevent browser handling of touch event as mouse event
  522. if (e.cancelable) { e.preventDefault(); }
  523. // Process as touch end for now
  524. this._onTouchEnd(e);
  525. }
  526. ////
  527. // Process input press 'p' on a specified object
  528. _onPress(obj, p) {
  529. obj._setStates(true, false, false);
  530. obj._setSelect(p.x, p.y);
  531. obj._setTrigger();
  532. obj._setActive(true);
  533. if (obj.onPress != null) {
  534. if (typeof obj.onPress === "function") {
  535. obj.onPress();
  536. }
  537. else {
  538. console.error("guiObject.onPress(): Please assign a valid function for " + obj.label + " \'onPress\' callback.");
  539. }
  540. }
  541. }
  542. // Process input move 'p' on a specified object
  543. _onMove(obj, p) {
  544. obj._setStates(false, true, false);
  545. obj._setSelect(p.x, p.y);
  546. obj._setTrigger();
  547. obj._setActive(true);
  548. }
  549. // Process input release on a specified object
  550. _onRelease(obj) {
  551. obj._setStates(false, false, true);
  552. obj._setTrigger();
  553. obj._setActive(false);
  554. if (obj.onRelease != null) {
  555. if (typeof obj.onRelease === "function") {
  556. obj.onRelease();
  557. }
  558. else {
  559. console.error("guiObject.onRelease(): Please assign a valid function for " + obj.label + " \'onRelease\' callback.");
  560. }
  561. }
  562. }
  563. _checkHit(x, y) {
  564. let result = {
  565. hit: false,
  566. index: null,
  567. obj: null
  568. };
  569. this.objects.forEach((obj) => {
  570. if (obj._checkHit(x, y)) {
  571. result.hit = true;
  572. result.index = obj._index;
  573. result.obj = obj;
  574. }
  575. });
  576. return result;
  577. }
  578. }
  579. /*******************
  580. * GuiObject
  581. * - This is the base class for all GuiObjects. It contains common variables
  582. * and its update() method handles mouse and touch inputs on a per object
  583. * basis depending on its defined interaction mode.
  584. *
  585. * TODO: add an individual input lock toggle. May require further checking at the
  586. * gui context scope.
  587. * TODO: add 'page' property so that objects can be grouped and toggled by page
  588. */
  589. class GuiObject {
  590. constructor(label, x, y, w, h) {
  591. // Internal variables not meant to be exposed to users
  592. this._active = false;
  593. this._pactive = false;
  594. this._hover = false;
  595. this._selU = null; // selection U and V within object
  596. this._selV = null;
  597. this._triggered = false; // An internal variable, but affected by behavior mode
  598. this._index = null; // Index representing object location when added to context stack
  599. this._pisPressed = false;
  600. this._pisHeld = false;
  601. this._pisReleased = false;
  602. this._pisChanged = false;
  603. this._pselU = null;
  604. this._pselV = null;
  605. this._family = "button"; // Default settings, defined in child class constructor
  606. this._type = "button";
  607. // Public variables meant for user access
  608. this.label = label;
  609. this.x = x;
  610. this.y = y;
  611. this.w = w;
  612. this.h = h;
  613. this.isInteger = false; // Used to have sliders lock to ints
  614. this.mode = "onPress"; // User can define behavior mode:
  615. // "onPress", "onHold", "onRelease"
  616. this.isPressed = false;
  617. this.isHeld = false;
  618. this.isReleased = false;
  619. this.isChanged = false;
  620. this.onPress = null;
  621. this.onHold = null;
  622. this.onRelease = null;
  623. this.onChange = null;
  624. this.val = 0;
  625. // this.lock = true;
  626. this.enabled = true; // enabled for input, false if for display only
  627. this.visible = true; // visibility flag for object;
  628. // when not visible, input is overridden to false
  629. this._style = null; // Stores object style settings
  630. // TODO: Implement object-level locking. Right now everything is locked
  631. // by default.
  632. // this.lock = true;
  633. // Check if the _gui has been created.
  634. if (_gui == null) {
  635. console.error("p5.touchgui: No Gui has been created. Please call CreateGui() before creating any GuiObjects.");
  636. }
  637. }
  638. // Basic function for checking hits on a rectangle
  639. _checkHit(x, y) {
  640. if (x < this.x ||
  641. y < this.y ||
  642. x >= this.x + this.w ||
  643. y >= this.y + this.h) {
  644. return false;
  645. }
  646. return true;
  647. }
  648. // Sets the object's 'isPressed', 'isHeld', 'isReleased', and 'isChanged' states
  649. _setStates(newPressed, newHeld, newReleased) {
  650. this.isPressed = newPressed;
  651. this.isHeld = newHeld;
  652. this.isReleased = newReleased;
  653. if (!(this._pisPressed && !this._pisHeld) &&
  654. (this._pisPressed != this.isPressed ||
  655. this._pisHeld != this.isHeld ||
  656. this._pisReleased != this.isReleased)) {
  657. this.isChanged = true;
  658. }
  659. }
  660. // Sets the input selection U and V, normalized and relative to UI object location and size
  661. // Note: this might break if objects are drawn with CENTER mode in the future
  662. // (instead of CORNERS mode)
  663. _setSelect(x, y) {
  664. this._selU = constrain(x - this.x, 0, this.w)/this.w;
  665. this._selV = constrain(y - this.y, 0, this.h)/this.h;
  666. // If the object is a 'slider' type, set 'isChanged' state if any input location change
  667. if (this._family == "slider" && (this._selU != this._pselU || this._selV != this._pselV)) {
  668. this.isChanged = true;
  669. }
  670. }
  671. // Set the object trigger, used internally for interaction behavior mode
  672. _setTrigger() {
  673. // Handle improper trigger mode input from user
  674. if (this.mode !== "onPress" &&
  675. this.mode !== "onHold" &&
  676. this.mode !== "onRelease") {
  677. console.warn("Interaction mode for " + this.label + " must be set to \"onPress\", \"onHold\", or \"onRelease\". Defaulting to \"onPress\".");
  678. this.mode = "onPress";
  679. }
  680. // Set triggered based on mode
  681. if (this.mode === "onPress" && this.isPressed) {
  682. this._triggered = true;
  683. }
  684. else if (this.mode === "onHold" && this.isHeld) {
  685. this._triggered = true;
  686. }
  687. else if (this.mode === "onRelease" && this.isReleased) {
  688. this._triggered = true;
  689. }
  690. else {
  691. this._triggered = false;
  692. }
  693. }
  694. // Set the object's 'active' state as well as 'isChanged' state if different than
  695. // previous frame. This gets further defined in children classes by calling
  696. // super._setActive().
  697. _setActive(active) {
  698. this._active = active;
  699. if (this._active != this._pactive) {
  700. this.isChanged = true;
  701. }
  702. }
  703. // Stores the object's state for reference in a future frame and
  704. // calls onHold or onChange if defined.
  705. _postDraw() {
  706. // Determine whether or not a press on the object is being isHeld
  707. if (this.isPressed) {
  708. this.isHeld = true;
  709. }
  710. else if (this.isReleased) {
  711. this.isHeld = false;
  712. }
  713. // These callbacks need to be implemented here because they need
  714. // to be triggered each frame, if triggered at all
  715. if (this.isHeld) {
  716. if (this.onHold != null) {
  717. if (typeof this.onHold === "function") {
  718. this.onHold();
  719. }
  720. else {
  721. console.error("guiObject.onHold(): Please assign a valid function for " + this.label + " \'onHold\' callback.");
  722. }
  723. }
  724. }
  725. if (this.isChanged) {
  726. if (this.onChange != null) {
  727. if (typeof this.onChange === "function") {
  728. this.onChange();
  729. }
  730. else {
  731. console.error("guiObject.onChange(): Please assign a valid function for " + this.label + " \'onChange\' callback.");
  732. }
  733. }
  734. }
  735. // Store all necessary values from this frame for future reference
  736. this._pisPressed = this.isPressed;
  737. this._pisHeld = this.isHeld;
  738. this._pisReleased = this.isReleased;
  739. this._pisChanged = this.isChanged;
  740. this._pactive = this._active;
  741. this._pselU = this._selU;
  742. this._pselV = this._selV;
  743. // Reset these variables
  744. this.isPressed = false;
  745. this.isReleased = false;
  746. this.isChanged = false;
  747. }
  748. //// STYLE
  749. /*
  750. * Method for setting style of individual GUI object. Use cases look like :
  751. * b1.setStyle("fillBg", color(128));
  752. * b1.setStyle({
  753. * fillBg: color(128),
  754. * strokeBg: color(0)
  755. * });
  756. *
  757. * TODO: review for any additional error handling that may be needed
  758. */
  759. setStyle(...args) {
  760. if (args.length === 2 && typeof args[0] === "string") {
  761. // If there are two input arguments and the first is a string (aka property name)
  762. if (this._style[args[0]] !== null) {
  763. // Set the style property if it exists
  764. this._style[args[0]] = args[1];
  765. }
  766. else {
  767. console.error("GuiObject.setStyle(): Object property \'" + args[0] + "\' does not exist.");
  768. }
  769. }
  770. else if (args.length === 1 && typeof args[0] === "object") {
  771. // If there is one input argument and it is an object
  772. let settings = args[0];
  773. let settingNames = Object.keys(settings);
  774. for (let i = 0; i < settingNames.length; i++) {
  775. // Loop through the inputted style properties
  776. let key = settingNames[i];
  777. if (this._style[key] != null) {
  778. // If it matches one of this object's properties in name and type, set it
  779. if (typeof this._style[key] === typeof settings[key]) {
  780. this._style[key] = settings[key];
  781. }
  782. else {
  783. console.error("GuiObject.setStyle(): wrong data type for \'" + settingNames[i] + "\' in object type \'" + this._type + "\'.");
  784. }
  785. }
  786. else {
  787. console.error("GuiObject.setStyle(): Object property \'" + settingNames[i] + "\' does not exist in type \'" + this._type + "\'.");
  788. }
  789. }
  790. }
  791. else {
  792. console.error("GuiObject.setStyle(): please provide a valid input.");
  793. }
  794. }
  795. }
  796. /**
  797. * GuiButton
  798. * - Momentary button with a label.
  799. */
  800. class GuiButton extends GuiObject {
  801. constructor(label, x, y, w=128, h=32) {
  802. super(label, x, y, w, h);
  803. this.labelOn = label;
  804. this.labelOff = label;
  805. this._family = "button";
  806. this._type = "button";
  807. this._plabel = label; // Internal handling for updating labelOn/labelOff
  808. this._style = {..._gui._style.button};
  809. }
  810. _setActive(active) {
  811. super._setActive(active);
  812. // Set val to active
  813. // Note: doesn't account for ability to override when input=false
  814. this.val = this._active;
  815. }
  816. draw() {
  817. // Render button
  818. push();
  819. strokeWeight(this._style.strokeWeight);
  820. rectMode(CORNER);
  821. if (this._active) {
  822. stroke(this._style.strokeBgActive);
  823. fill(this._style.fillBgActive);
  824. }
  825. else if (this._hover) {
  826. stroke(this._style.strokeBgHover);
  827. fill(this._style.fillBgHover);
  828. }
  829. else {
  830. stroke(this._style.strokeBg);
  831. fill(this._style.fillBg);
  832. }
  833. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  834. // Label rendering.
  835. push();
  836. if (this._active) { fill(this._style.fillLabelActive); }
  837. else if (this._hover) { fill(this._style.fillLabelHover); }
  838. else { fill(this._style.fillLabel); }
  839. noStroke();
  840. textAlign(CENTER, CENTER);
  841. textFont(this._style.font);
  842. let size = this.w*0.9;
  843. if (size > this._style.textSize) {
  844. size = this._style.textSize;
  845. }
  846. textSize(size);
  847. if (this.val) {
  848. text(this.labelOn, this.x + this.w/2, this.y + this.h/2);
  849. }
  850. else {
  851. text(this.labelOff, this.x + this.w/2, this.y + this.h/2);
  852. }
  853. pop();
  854. pop();
  855. }
  856. _postDraw() {
  857. super._postDraw();
  858. // Internal handling for updating labelOn/labelOff
  859. if (this._plabel != this.label) {
  860. this.labelOn = this.label;
  861. this.labelOff = this.label;
  862. this._plabel = this.label;
  863. }
  864. }
  865. }
  866. /**
  867. * GuiToggle
  868. * - Toggle button with a label.
  869. */
  870. class GuiToggle extends GuiObject {
  871. constructor(label, x, y, w=128, h=32, defaultVal = false) {
  872. super(label, x, y, w, h);
  873. this.val = defaultVal;
  874. this.labelOn = label;
  875. this.labelOff = label;
  876. this._family = "toggle";
  877. this._type = "toggle";
  878. this._plabel = label; // Internal handling for updating labelOn/labelOff
  879. this._style = {..._gui._style.toggle};
  880. }
  881. _setActive(active) {
  882. super._setActive(active);
  883. if (this._triggered) {
  884. this.val = !this.val;
  885. }
  886. }
  887. draw() {
  888. // Render button based on state
  889. if (this._active && this._hover && this.val) {
  890. // Active Off
  891. this._drawState(this._style.strokeBgOffActive,
  892. this._style.fillBgOffActive,
  893. this._style.fillLabelOffActive);
  894. }
  895. else if (this._active && this._hover && !this.val) {
  896. // Active On
  897. this._drawState(this._style.strokeBgOnActive,
  898. this._style.fillBgOnActive,
  899. this._style.fillLabelOnActive);
  900. }
  901. else if (this._hover && this.val) {
  902. // Hover On
  903. this._drawState(this._style.strokeBgOnHover,
  904. this._style.fillBgOnHover,
  905. this._style.fillLabelOnHover);
  906. }
  907. else if (this._hover && !this.val) {
  908. // Hover Off
  909. this._drawState(this._style.strokeBgOffHover,
  910. this._style.fillBgOffHover,
  911. this._style.fillLabelOffHover);
  912. }
  913. else if (this.val) {
  914. // Inactive On
  915. this._drawState(this._style.strokeBgOn,
  916. this._style.fillBgOn,
  917. this._style.fillLabelOn);
  918. }
  919. else {
  920. // Inactive Off
  921. this._drawState(this._style.strokeBgOff,
  922. this._style.fillBgOff,
  923. this._style.fillLabelOff);
  924. }
  925. }
  926. _drawState(strokeBg, fillBg, fillLabel) {
  927. push();
  928. strokeWeight(this._style.strokeWeight);
  929. rectMode(CORNER);
  930. stroke(strokeBg);
  931. fill(fillBg);
  932. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  933. // Label fill
  934. fill(fillLabel);
  935. // Label rendering.
  936. push();
  937. noStroke();
  938. textAlign(CENTER, CENTER);
  939. textFont(this._style.font);
  940. let size = this.w*0.9;
  941. if (size > this._style.textSize) {
  942. size = this._style.textSize;
  943. }
  944. textSize(size);
  945. if (this.val) {
  946. text(this.labelOn, this.x + this.w/2, this.y + this.h/2);
  947. }
  948. else {
  949. text(this.labelOff, this.x + this.w/2, this.y + this.h/2);
  950. }
  951. pop();
  952. pop();
  953. }
  954. _postDraw() {
  955. super._postDraw();
  956. // Internal handling for updating labelOn/labelOff
  957. if (this._plabel != this.label) {
  958. this.labelOn = this.label;
  959. this.labelOff = this.label;
  960. this._plabel = this.label;
  961. }
  962. }
  963. }
  964. /**
  965. * GuiCheckbox
  966. * - Checkbox. Similar to a toggle but with a big X instead of a label.
  967. */
  968. class GuiCheckbox extends GuiObject {
  969. constructor(label, x, y, w=32, h=32, defaultVal = false) {
  970. super(label, x, y, w, h);
  971. this.val = defaultVal;
  972. this._family = "checkbox";
  973. this._type = "checkbox";
  974. this._style = {..._gui._style.checkbox};
  975. }
  976. _setActive(active) {
  977. super._setActive(active);
  978. if (this._triggered) {
  979. this.val = !this.val;
  980. }
  981. }
  982. draw() {
  983. // Render checkbox
  984. if (this._active && this._hover && this.val) {
  985. // Active On
  986. this._drawState(this._style.fillBgActive);
  987. this._drawCheck(this._style.fillCheckActive);
  988. }
  989. else if (this._active && this._hover && !this.val) {
  990. // Active Off
  991. this._drawState(this._style.fillBgActive);
  992. }
  993. else if (this._hover && this.val) {
  994. // Hover On
  995. this._drawState(this._style.fillBgHover);
  996. this._drawCheck(this._style.fillCheckHover);
  997. }
  998. else if (this._hover && !this.val) {
  999. // Hover Off
  1000. this._drawState(this._style.fillBgHover);
  1001. }
  1002. else if (this.val) {
  1003. // Inactive On
  1004. this._drawState(this._style.fillBg);
  1005. this._drawCheck(this._style.fillCheck);
  1006. }
  1007. else {
  1008. // Inactive Off
  1009. this._drawState(this._style.fillBg);
  1010. }
  1011. textSize(this.h);
  1012. text(this.label,this.x+this.w+5,this.y+this.h/2);
  1013. }
  1014. _drawState(fillBg) {
  1015. push();
  1016. // Draw background shape
  1017. rectMode(CORNER);
  1018. stroke(this._style.strokeBg);
  1019. strokeWeight(this._style.strokeWeight);
  1020. fill(fillBg);
  1021. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1022. pop();
  1023. }
  1024. _drawCheck(fillCheck) {
  1025. // Note: I don't really like how this is done lol; it's sloppy and can be better
  1026. let x8 = this.x+this.w/6;
  1027. let y8 = this.y+this.h/6;
  1028. let w16 = this.w-this.w/3;
  1029. let h16 = this.h-this.h/3;
  1030. let xw = x8+w16;
  1031. let yh = y8+h16;
  1032. let strokeMult = map(((this.w > this.h) ? this.w : this.h), 32, 1000, 2, 20);
  1033. push();
  1034. stroke(fillCheck);
  1035. strokeWeight(this._style.strokeWeight*strokeMult);
  1036. line(x8, y8, xw, yh);
  1037. line(xw, y8, x8, yh);
  1038. pop();
  1039. }
  1040. }
  1041. /**
  1042. * GuiSlider
  1043. * - Horizontal slider.
  1044. *
  1045. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1046. * TODO: fix so that touch corresponds with handle
  1047. */
  1048. class GuiSlider extends GuiObject {
  1049. constructor(label, x, y, w=256, h=32, min=0, max=1) {
  1050. super(label, x, y, w, h);
  1051. this.min = min;
  1052. this.max = max;
  1053. this.val = min + (max - min)/2;
  1054. this._family = "slider";
  1055. this._type = "slider";
  1056. this._style = {..._gui._style.slider};
  1057. }
  1058. _setActive(active) {
  1059. super._setActive(active);
  1060. if (this._active && this._selU != null) {
  1061. this.val = map(this._selU, 0, 1, this.min, this.max);
  1062. this.val = this.isInteger ? int(this.val) : this.val;
  1063. }
  1064. }
  1065. draw() {
  1066. if (this._active) {
  1067. this._drawState(this._style.fillBgActive,
  1068. this._style.fillTrackActive,
  1069. this._style.fillHandleActive,
  1070. this._style.strokeBgActive,
  1071. this._style.strokeTrackActive,
  1072. this._style.strokeHandleActive);
  1073. }
  1074. else if (this._hover) {
  1075. this._drawState(this._style.fillBgHover,
  1076. this._style.fillTrackHover,
  1077. this._style.fillHandleHover,
  1078. this._style.strokeBgHover,
  1079. this._style.strokeTrackHover,
  1080. this._style.strokeHandleHover);
  1081. }
  1082. else {
  1083. this._drawState(this._style.fillBg,
  1084. this._style.fillTrack,
  1085. this._style.fillHandle,
  1086. this._style.strokeBg,
  1087. this._style.strokeTrack,
  1088. this._style.strokeHandle);
  1089. }
  1090. }
  1091. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1092. let xpos = map(this.val, this.min, this.max, 8, this.w-24);
  1093. push();
  1094. strokeWeight(this._style.strokeWeight);
  1095. rectMode(CORNER);
  1096. // Render bg
  1097. stroke(strokeBg);
  1098. fill(fillBg);
  1099. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1100. // Render track
  1101. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1102. let h = this.h-20;
  1103. push();
  1104. stroke(strokeTrack);
  1105. fill(fillTrack);
  1106. if (this._style.trackWidth > 0) {
  1107. rect(this.x+10,
  1108. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1109. xpos,
  1110. h*this._style.trackWidth,
  1111. this._style.rounding, 0, 0, this._style.rounding);
  1112. }
  1113. else {
  1114. line(this.x+10,
  1115. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1116. this.x+10+xpos,
  1117. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1118. }
  1119. pop();
  1120. // Render handle
  1121. push();
  1122. stroke(strokeHandle);
  1123. fill(fillHandle);
  1124. rect(this.x+xpos, this.y+8, 16, this.h-16, this._style.rounding);
  1125. pop();
  1126. pop();
  1127. }
  1128. }
  1129. /**
  1130. * GuiSliderV
  1131. * - Vertical slider.
  1132. * Note: this may be modifiable to extend GuiSlider, but for simplicity it is
  1133. * presently extending GuiObject.
  1134. *
  1135. * TODO: fix hard coding of buffers (e.g. this.h-24)
  1136. * TODO: fix so that touch corresponds with handle
  1137. */
  1138. class GuiSliderV extends GuiObject {
  1139. constructor(label, x, y, w=32, h=256, min=0, max=1) {
  1140. super(label, x, y, w, h);
  1141. this.min = min;
  1142. this.max = max;
  1143. this.val = min + (max - min)/2;
  1144. this._family = "slider";
  1145. this._type = "slider";
  1146. this._style = {..._gui._style.slider};
  1147. }
  1148. _setActive(active) {
  1149. super._setActive(active);
  1150. if (this._active && this._selV != null) {
  1151. this.val = map(this._selV, 1, 0, this.min, this.max);
  1152. this.val = this.isInteger ? int(this.val) : this.val;
  1153. }
  1154. }
  1155. draw() {
  1156. if (this._active) {
  1157. this._drawState(this._style.fillBgActive,
  1158. this._style.fillTrackActive,
  1159. this._style.fillHandleActive,
  1160. this._style.strokeBgActive,
  1161. this._style.strokeTrackActive,
  1162. this._style.strokeHandleActive);
  1163. }
  1164. else if (this._hover) {
  1165. this._drawState(this._style.fillBgHover,
  1166. this._style.fillTrackHover,
  1167. this._style.fillHandleHover,
  1168. this._style.strokeBgHover,
  1169. this._style.strokeTrackHover,
  1170. this._style.strokeHandleHover);
  1171. }
  1172. else {
  1173. this._drawState(this._style.fillBg,
  1174. this._style.fillTrack,
  1175. this._style.fillHandle,
  1176. this._style.strokeBg,
  1177. this._style.strokeTrack,
  1178. this._style.strokeHandle);
  1179. }
  1180. }
  1181. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1182. let ypos = map(this.val, this.min, this.max, this.h-24, 8);
  1183. push();
  1184. strokeWeight(this._style.strokeWeight);
  1185. rectMode(CORNER);
  1186. // Render bg
  1187. stroke(strokeBg);
  1188. fill(fillBg);
  1189. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1190. // Render track
  1191. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1192. let w = this.w-20;
  1193. push();
  1194. stroke(strokeTrack);
  1195. fill(fillTrack);
  1196. if (this._style.trackWidth > 0) {
  1197. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1198. this.y+ypos+10,
  1199. w*this._style.trackWidth,
  1200. this.h-ypos-20,
  1201. 0, 0, this._style.rounding, this._style.rounding);
  1202. }
  1203. else {
  1204. line(this.x+10 + w*0.5, this.y+ypos+10,
  1205. this.x+10 + w*0.5, this.y+this.h-10);
  1206. }
  1207. pop();
  1208. // Render handle
  1209. push();
  1210. stroke(strokeHandle);
  1211. fill(fillHandle);
  1212. rect(this.x+8, this.y+ypos, this.w-16, 16, this._style.rounding);
  1213. pop();
  1214. pop();
  1215. }
  1216. }
  1217. /**
  1218. * GuiCrossfader
  1219. * - Horizontal cross fader. Indicator drawn from center.
  1220. *
  1221. * TODO: fix so that touch corresponds with handle
  1222. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1223. */
  1224. class GuiCrossfader extends GuiSlider {
  1225. constructor(label, x, y, w=256, h=32, min=(-1), max=1) {
  1226. super(label, x, y, w, h, min, max);
  1227. this.snap = false; // If true, snaps value back to 0 when not active
  1228. this._family = "slider";
  1229. this._type = "crossfader";
  1230. this._style = Object.create(_gui._style.slider);
  1231. this._style.strokeCenter = Object.create(_gui._style.crossfader.strokeCenter);
  1232. this._style.strokeCenterHover = Object.create(_gui._style.crossfader.strokeCenterHover);
  1233. this._style.strokeCenterActive = Object.create(_gui._style.crossfader.strokeCenterActive);
  1234. }
  1235. _setActive(active) {
  1236. super._setActive(active);
  1237. if (!this._active && this.snap) {
  1238. this.val = (this.min + this.max)/2;
  1239. }
  1240. }
  1241. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1242. let xpos = map(this.val, this.min, this.max, 8, this.w-24);
  1243. let halfXpos = (this.w-16)/2;
  1244. push();
  1245. strokeWeight(this._style.strokeWeight);
  1246. rectMode(CORNER);
  1247. // Render bg
  1248. stroke(strokeBg);
  1249. fill(fillBg);
  1250. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1251. // Render track from center
  1252. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1253. let h = this.h-20;
  1254. push();
  1255. stroke(strokeTrack);
  1256. fill(fillTrack);
  1257. if (xpos >= halfXpos) {
  1258. if (this._style.trackWidth > 0) {
  1259. rect(this.x+halfXpos+8,
  1260. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1261. xpos-halfXpos,
  1262. h*this._style.trackWidth);
  1263. }
  1264. else {
  1265. line(this.x+halfXpos+8,
  1266. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1267. this.x+8+xpos,
  1268. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1269. }
  1270. }
  1271. else {
  1272. if (this._style.trackWidth > 0) {
  1273. rect(this.x+xpos,
  1274. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1275. halfXpos-xpos+8,
  1276. h*this._style.trackWidth);
  1277. }
  1278. else {
  1279. line(this.x+xpos,
  1280. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1281. this.x+halfXpos+8,
  1282. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1283. }
  1284. }
  1285. // Draw center line
  1286. stroke(this._style.strokeCenter);
  1287. strokeWeight(this._style.strokeWeight);
  1288. line(this.x+this.w/2, this.y, this.x+this.w/2, this.y+this.h);
  1289. pop();
  1290. // Render handle
  1291. push();
  1292. stroke(strokeHandle);
  1293. fill(fillHandle);
  1294. rect(this.x+xpos, this.y+8, 16, this.h-16, this._style.rounding);
  1295. pop();
  1296. pop();
  1297. }
  1298. }
  1299. /**
  1300. * GuiCrossfaderV
  1301. * - Vertical cross fader. Indicator drawn from center.
  1302. *
  1303. * TODO: fix so that touch corresponds with handle
  1304. * TODO: fix hard coding of buffers (e.g. this.h-24)
  1305. */
  1306. class GuiCrossfaderV extends GuiSliderV {
  1307. constructor(label, x, y, w=256, h=32, min=(-1), max=1) {
  1308. super(label, x, y, w, h, min, max);
  1309. this.snap = false; // If true, snaps value back to 0 when not active
  1310. this._family = "slider";
  1311. this._type = "crossfader";
  1312. this._style = Object.create(_gui._style.slider);
  1313. this._style.strokeCenter = Object.create(_gui._style.crossfader.strokeCenter);
  1314. this._style.strokeCenterHover = Object.create(_gui._style.crossfader.strokeCenterHover);
  1315. this._style.strokeCenterActive = Object.create(_gui._style.crossfader.strokeCenterActive);
  1316. }
  1317. _setActive(active) {
  1318. super._setActive(active);
  1319. if (!this._active && this.snap) {
  1320. this.val = (this.min + this.max)/2;
  1321. }
  1322. }
  1323. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1324. let ypos = map(this.val, this.min, this.max, this.h-24, 8);
  1325. let halfYpos = (this.h-16)/2;
  1326. push();
  1327. strokeWeight(this._style.strokeWeight);
  1328. rectMode(CORNER);
  1329. // Render bg
  1330. stroke(strokeBg);
  1331. fill(fillBg);
  1332. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1333. // Render track from center
  1334. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1335. let w = this.w-20;
  1336. push();
  1337. stroke(strokeTrack);
  1338. fill(fillTrack);
  1339. if (ypos >= halfYpos) {
  1340. if (this._style.trackWidth > 0) {
  1341. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1342. this.y+halfYpos+8,
  1343. w*this._style.trackWidth,
  1344. ypos-halfYpos);
  1345. }
  1346. else {
  1347. line(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1348. this.y+halfYpos+8,
  1349. this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1350. this.y+8+ypos);
  1351. }
  1352. }
  1353. else {
  1354. if (this._style.trackWidth > 0) {
  1355. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1356. this.y+ypos,
  1357. w*this._style.trackWidth,
  1358. halfYpos-ypos+8);
  1359. }
  1360. else {
  1361. line(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1362. this.y+ypos,
  1363. this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1364. this.y+halfYpos+8);
  1365. }
  1366. }
  1367. // Draw center line
  1368. stroke(this._style.strokeCenter);
  1369. strokeWeight(this._style.strokeWeight);
  1370. line(this.x, this.y+this.h/2, this.x+this.w, this.y+this.h/2);
  1371. pop();
  1372. // Render handle
  1373. push();
  1374. stroke(strokeHandle);
  1375. fill(fillHandle);
  1376. rect(this.x+8, this.y+ypos, this.w-16, 16, this._style.rounding);
  1377. pop();
  1378. pop();
  1379. }
  1380. }
  1381. /**
  1382. * Gui2dSlider
  1383. * - Two dimensional slider that returns an X/Y pair of values
  1384. *
  1385. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1386. * TODO: fix so that touch corresponds with handle
  1387. */
  1388. class GuiSlider2d extends GuiObject {
  1389. constructor(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  1390. super(label, x, y, w, h);
  1391. this.minX = minX;
  1392. this.maxX = maxX;
  1393. this.minY = minY;
  1394. this.maxY = maxY;
  1395. this.val = {x:0, y:0};
  1396. this.valX = minX + (maxX - minX)/2;
  1397. this.valY = minY + (maxY - minY)/2;
  1398. this._family = "slider";
  1399. this._type = "slider2d";
  1400. this._style = Object.create(_gui._style.slider);
  1401. this._style.handleRadius = _gui._style.slider2d.handleRadius;
  1402. }
  1403. _setActive(active) {
  1404. super._setActive(active);
  1405. if (this._active && this._selU != null && this._selV != null) {
  1406. this.valX = map(this._selU, 0, 1, this.minX, this.maxX);
  1407. this.valY = map(this._selV, 1, 0, this.minY, this.maxY);
  1408. if (this.isInteger && this._type == "slider2d") {
  1409. this.valX = int(this.valX);
  1410. this.valY = int(this.valY);
  1411. }
  1412. this.val = {x: this.valX, y:this.valY};
  1413. }
  1414. }
  1415. draw() {
  1416. if (this._active) {
  1417. this._drawState(this._style.fillBgActive,
  1418. this._style.fillTrackActive,
  1419. this._style.fillHandleActive,
  1420. this._style.strokeBgActive,
  1421. this._style.strokeTrackActive,
  1422. this._style.strokeHandleActive);
  1423. }
  1424. else if (this._hover) {
  1425. this._drawState(this._style.fillBgHover,
  1426. this._style.fillTrackHover,
  1427. this._style.fillHandleHover,
  1428. this._style.strokeBgHover,
  1429. this._style.strokeTrackHover,
  1430. this._style.strokeHandleHover);
  1431. }
  1432. else {
  1433. this._drawState(this._style.fillBg,
  1434. this._style.fillTrack,
  1435. this._style.fillHandle,
  1436. this._style.strokeBg,
  1437. this._style.strokeTrack,
  1438. this._style.strokeHandle);
  1439. }
  1440. }
  1441. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1442. let xpos = map(this.valX, this.minX, this.maxX, 8, this.w-24);
  1443. let ypos = map(this.valY, this.minY, this.maxY, this.h-24, 8);
  1444. push();
  1445. strokeWeight(this._style.strokeWeight);
  1446. rectMode(CORNER);
  1447. // Render bg
  1448. stroke(strokeBg);
  1449. fill(fillBg);
  1450. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1451. // Render crosshair (track)
  1452. push();
  1453. stroke(fillTrack);
  1454. line(this.x, this.y+ypos+8, this.x+this.w, this.y+ypos+8);
  1455. line(this.x+xpos+8, this.y, this.x+xpos+8, this.y+this.h);
  1456. pop();
  1457. // Render handle
  1458. push();
  1459. stroke(strokeHandle);
  1460. fill(fillHandle);
  1461. ellipse(this.x+xpos+8,
  1462. this.y+ypos+8,
  1463. this._style.handleRadius,
  1464. this._style.handleRadius);
  1465. pop();
  1466. pop();
  1467. }
  1468. }
  1469. /**
  1470. * GuiJoystick
  1471. * - Two dimensional slider that returns an X/Y pair of values
  1472. * relative to a resetting zero point at its center.
  1473. */
  1474. class GuiJoystick extends GuiSlider2d {
  1475. constructor(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  1476. super(label, x, y, w, h, minX, maxX, minY, maxY);
  1477. this.snap = true; // If true, snaps value back to 0 when not active
  1478. this._family = "slider";
  1479. this._type = "joystick";
  1480. this._style = Object.create(_gui._style.slider);
  1481. this._style.handleRadius = _gui._style.joystick.handleRadius;
  1482. }
  1483. _setActive(active) {
  1484. super._setActive(active);
  1485. if (!this._active && this.snap) {
  1486. this.valX = (this.minX + this.maxX)/2;
  1487. this.valY = (this.minY + this.maxY)/2;
  1488. this.val = {x: this.valX, y:this.valY};
  1489. }
  1490. }
  1491. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1492. let xpos = map(this.valX, this.minX, this.maxX, 8, this.w-24);
  1493. let ypos = map(this.valY, this.minY, this.maxY, this.h-24, 8);
  1494. push();
  1495. strokeWeight(this._style.strokeWeight);
  1496. rectMode(CORNER);
  1497. // Render bg
  1498. stroke(strokeBg);
  1499. fill(fillBg);
  1500. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1501. // Render circle (track)
  1502. push();
  1503. stroke(fillTrack);
  1504. let r = this.w*this._style.trackRatio;
  1505. if (this.w > this.h) {
  1506. r = this.h*this._style.trackRatio;
  1507. }
  1508. ellipse(this.x+this.w/2, this.y+this.h/2, r)
  1509. pop();
  1510. // Render handle
  1511. push();
  1512. stroke(strokeHandle);
  1513. fill(fillHandle);
  1514. ellipse(this.x+xpos+8,
  1515. this.y+ypos+8,
  1516. this._style.handleRadius,
  1517. this._style.handleRadius);
  1518. pop();
  1519. pop();
  1520. }
  1521. }
  1522. /**
  1523. * GuiRadio
  1524. * - A user-defined number of toggles, of which only one can be turned on at a time.
  1525. */
  1526. class GuiRadio extends GuiObject {
  1527. // TODO: write this. Maybe this can be done by adding a 'group' property
  1528. }
  1529. /*******************
  1530. * GuiStyle
  1531. * - A style class that contains various presets for colors, rounding, etc.
  1532. *
  1533. * TODO: Create more color palettes.
  1534. * TODO: Study material-ui implementation of colors and try
  1535. * to implement something similar (i.e. primary and accent color)
  1536. */
  1537. class GuiStyle {
  1538. constructor() {
  1539. this.name = "DefaultGray";
  1540. // Global pars
  1541. this.strokeWeight = 2;
  1542. this.rounding = 10;
  1543. this.font = 'Arial';
  1544. this.textSize = 20;
  1545. this.button = {
  1546. strokeWeight: 2,
  1547. rounding: 10,
  1548. font: 'Arial',
  1549. textSize: 20,
  1550. fillBg: color(130),
  1551. fillBgHover: color(196),
  1552. fillBgActive: color(220),
  1553. fillLabel: color(0),
  1554. fillLabelHover: color(0),
  1555. fillLabelActive: color(0),
  1556. strokeBg: color(0),
  1557. strokeBgHover: color(0),
  1558. strokeBgActive: color(0)
  1559. };
  1560. this.toggle = {
  1561. strokeWeight: 2,
  1562. rounding: 10,
  1563. font: 'Arial',
  1564. textSize: 20,
  1565. fillBgOff: color(130),
  1566. fillBgOffHover: color(196),
  1567. fillBgOffActive: color(220),
  1568. fillBgOn: color(230),
  1569. fillBgOnHover: color(245),
  1570. fillBgOnActive: color(255),
  1571. fillLabelOff: color(0),
  1572. fillLabelOffHover: color(0),
  1573. fillLabelOffActive: color(0),
  1574. fillLabelOn: color(0),
  1575. fillLabelOnHover: color(0),
  1576. fillLabelOnActive: color(0),
  1577. strokeBgOff: color(0),
  1578. strokeBgOffHover: color(0),
  1579. strokeBgOffActive: color(0),
  1580. strokeBgOn: color(0),
  1581. strokeBgOnHover: color(0),
  1582. strokeBgOnActive: color(0)
  1583. }
  1584. this.checkbox = {
  1585. strokeWeight: 2,
  1586. rounding: 10,
  1587. fillBg: color(100),
  1588. fillBgHover: color(144),
  1589. fillBgActive: color(160),
  1590. fillCheck: color(200),
  1591. fillCheckHover: color(220),
  1592. fillCheckActive: color(240),
  1593. strokeBg: color(0)
  1594. }
  1595. this.slider = {
  1596. strokeWeight: 2,
  1597. rounding: 10,
  1598. trackWidth: 1,
  1599. fillBg: color(130),
  1600. fillBgHover: color(175),
  1601. fillBgActive: color(175),
  1602. fillTrack: color(100),
  1603. fillTrackHover: color(144),
  1604. fillTrackActive: color(144),
  1605. fillHandle: color(64),
  1606. fillHandleHover: color(96),
  1607. fillHandleActive: color(240),
  1608. strokeBg: color(0),
  1609. strokeBgHover: color(0),
  1610. strokeBgActive: color(0),
  1611. strokeTrack: color(100),
  1612. strokeTrackHover: color(144),
  1613. strokeTrackActive: color(144),
  1614. strokeHandle: color(64),
  1615. strokeHandleHover: color(0),
  1616. strokeHandleActive: color(0)
  1617. }
  1618. this.crossfader = {
  1619. strokeCenter: color(100),
  1620. strokeCenterHover: color(100),
  1621. strokeCenterActive: color(100)
  1622. }
  1623. this.slider2d = {
  1624. handleRadius: 16
  1625. }
  1626. this.joystick = {
  1627. handleRadius: 16
  1628. }
  1629. }
  1630. // Default
  1631. Gray() {
  1632. this.name = "DefaultGray";
  1633. // Global pars
  1634. this.strokeWeight = 2;
  1635. this.rounding = 10;
  1636. this.font = 'Arial';
  1637. this.textSize = 20;
  1638. this.button = {
  1639. strokeWeight: 2,
  1640. rounding: 10,
  1641. font: 'Arial',
  1642. textSize: 20,
  1643. fillBg: color(130),
  1644. fillBgHover: color(196),
  1645. fillBgActive: color(220),
  1646. fillLabel: color(0),
  1647. fillLabelHover: color(0),
  1648. fillLabelActive: color(0),
  1649. strokeBg: color(0),
  1650. strokeBgHover: color(0),
  1651. strokeBgActive: color(0)
  1652. };
  1653. this.toggle = {
  1654. strokeWeight: 2,
  1655. rounding: 10,
  1656. font: 'Arial',
  1657. textSize: 20,
  1658. fillBgOff: color(130),
  1659. fillBgOffHover: color(196),
  1660. fillBgOffActive: color(220),
  1661. fillBgOn: color(230),
  1662. fillBgOnHover: color(245),
  1663. fillBgOnActive: color(255),
  1664. fillLabelOff: color(0),
  1665. fillLabelOffHover: color(0),
  1666. fillLabelOffActive: color(0),
  1667. fillLabelOn: color(0),
  1668. fillLabelOnHover: color(0),
  1669. fillLabelOnActive: color(0),
  1670. strokeBgOff: color(0),
  1671. strokeBgOffHover: color(0),
  1672. strokeBgOffActive: color(0),
  1673. strokeBgOn: color(0),
  1674. strokeBgOnHover: color(0),
  1675. strokeBgOnActive: color(0)
  1676. }
  1677. this.checkbox = {
  1678. strokeWeight: 2,
  1679. rounding: 10,
  1680. fillBg: color(100),
  1681. fillBgHover: color(144),
  1682. fillBgActive: color(160),
  1683. fillCheck: color(200),
  1684. fillCheckHover: color(220),
  1685. fillCheckActive: color(240),
  1686. strokeBg: color(0)
  1687. }
  1688. this.slider = {
  1689. strokeWeight: 2,
  1690. rounding: 10,
  1691. trackWidth: 1,
  1692. fillBg: color(130),
  1693. fillBgHover: color(175),
  1694. fillBgActive: color(175),
  1695. fillTrack: color(100),
  1696. fillTrackHover: color(144),
  1697. fillTrackActive: color(144),
  1698. fillHandle: color(64),
  1699. fillHandleHover: color(96),
  1700. fillHandleActive: color(240),
  1701. strokeBg: color(0),
  1702. strokeBgHover: color(0),
  1703. strokeBgActive: color(0),
  1704. strokeTrack: color(100),
  1705. strokeTrackHover: color(144),
  1706. strokeTrackActive: color(144),
  1707. strokeHandle: color(64),
  1708. strokeHandleHover: color(0),
  1709. strokeHandleActive: color(0)
  1710. }
  1711. this.crossfader = {
  1712. strokeCenter: color(100),
  1713. strokeCenterHover: color(100),
  1714. strokeCenterActive: color(100)
  1715. }
  1716. this.slider2d = {
  1717. handleRadius: 16
  1718. }
  1719. this.joystick = {
  1720. handleRadius: 16
  1721. }
  1722. }
  1723. //
  1724. Rose() {
  1725. this.name = "Rose";
  1726. // Global pars
  1727. this.strokeWeight = 2;
  1728. this.rounding = 10;
  1729. this.font = 'Arial';
  1730. this.textSize = 20;
  1731. this.button = {
  1732. strokeWeight: 2,
  1733. rounding: 10,
  1734. font: 'Arial',
  1735. textSize: 20,
  1736. fillBg: color('#E57FBE'),
  1737. fillBgHover: color('#EFABD5'),
  1738. fillBgActive: color('#FFE6F4'),
  1739. fillLabel: color('#3F102F'),
  1740. fillLabelHover: color('#3F102F'),
  1741. fillLabelActive: color('#3F102F'),
  1742. strokeBg: color('#3F102F'),
  1743. strokeBgHover: color('#3F102F'),
  1744. strokeBgActive: color('#3F102F')
  1745. };
  1746. this.toggle = {
  1747. strokeWeight: 2,
  1748. rounding: 10,
  1749. font: 'Arial',
  1750. textSize: 20,
  1751. fillBgOff: color('#CC69AB'),
  1752. fillBgOffHover: color('#E288C4'),
  1753. fillBgOffActive: color('#FFF3FA'),
  1754. fillBgOn: color('#FFE6F4'),
  1755. fillBgOnHover: color('#FFF3FA'),
  1756. fillBgOnActive: color('#FAFAFA'),
  1757. fillLabelOff: color('#3F102F'),
  1758. fillLabelOffHover: color('#3F102F'),
  1759. fillLabelOffActive: color('#3F102F'),
  1760. fillLabelOn: color('#3F102F'),
  1761. fillLabelOnHover: color('#3F102F'),
  1762. fillLabelOnActive: color('#3F102F'),
  1763. strokeBgOff: color('#3F102F'),
  1764. strokeBgOffHover: color('#3F102F'),
  1765. strokeBgOffActive: color('#3F102F'),
  1766. strokeBgOn: color('#3F102F'),
  1767. strokeBgOnHover: color('#3F102F'),
  1768. strokeBgOnActive: color('#3F102F')
  1769. }
  1770. this.checkbox = {
  1771. strokeWeight: 2,
  1772. rounding: 10,
  1773. fillBg: color('#7F3663'),
  1774. fillBgHover: color('#C45093'),
  1775. fillBgActive: color('#E57FBE'),
  1776. fillCheck: color('#FFE6F4'),
  1777. fillCheckHover: color('#FFF3FA'),
  1778. fillCheckActive: color('#FAFAFA'),
  1779. strokeBg: color('#3F102F')
  1780. }
  1781. this.slider = {
  1782. strokeWeight: 2,
  1783. rounding: 10,
  1784. trackWidth: 1,
  1785. fillBg: color('#FFE6F4'),
  1786. fillBgHover: color('#FFE6F4'),
  1787. fillBgActive: color('#FFF3FA'),
  1788. fillTrack: color('#C45093'),
  1789. fillTrackHover: color('#CC66A6'),
  1790. fillTrackActive: color('#D877B4'),
  1791. fillHandle: color('#7F3663'),
  1792. fillHandleHover: color('#E57FBE'),
  1793. fillHandleActive: color('#FAFAFA'),
  1794. strokeBg: color('#3F102F'),
  1795. strokeBgHover: color('#3F102F'),
  1796. strokeBgActive: color('#3F102F'),
  1797. strokeTrack: color('#C45093'),
  1798. strokeTrackHover: color('#CC66A6'),
  1799. strokeTrackActive: color('#D877B4'),
  1800. strokeHandle: color('#3F102F'),
  1801. strokeHandleHover: color('#3F102F'),
  1802. strokeHandleActive: color('#3F102F')
  1803. }
  1804. this.crossfader = {
  1805. strokeCenter: color('#C45093'),
  1806. strokeCenterHover: color('#CC66A6'),
  1807. strokeCenterActive: color('#D877B4')
  1808. }
  1809. this.slider2d = {
  1810. handleRadius: 16
  1811. }
  1812. this.joystick = {
  1813. handleRadius: 16
  1814. }
  1815. }
  1816. //
  1817. Seafoam() {
  1818. this.name = "Seafoam";
  1819. // Global pars
  1820. this.strokeWeight = 2;
  1821. this.rounding = 10;
  1822. this.font = 'Arial';
  1823. this.textSize = 20;
  1824. this.button = {
  1825. strokeWeight: 2,
  1826. rounding: 10,
  1827. font: 'Arial',
  1828. textSize: 20,
  1829. fillBg: color('#7FE5BE'),
  1830. fillBgHover: color('#ABEFD5'),
  1831. fillBgActive: color('#E6FFF4'),
  1832. fillLabel: color('#103F2F'),
  1833. fillLabelHover: color('#103F2F'),
  1834. fillLabelActive: color('#103F2F'),
  1835. strokeBg: color('#103F2F'),
  1836. strokeBgHover: color('#103F2F'),
  1837. strokeBgActive: color('#103F2F')
  1838. };
  1839. this.toggle = {
  1840. strokeWeight: 2,
  1841. rounding: 10,
  1842. font: 'Arial',
  1843. textSize: 20,
  1844. fillBgOff: color('#69CCAB'),
  1845. fillBgOffHover: color('#88E2C4'),
  1846. fillBgOffActive: color('#F3FFFA'),
  1847. fillBgOn: color('#E6FFF4'),
  1848. fillBgOnHover: color('#F3FFFA'),
  1849. fillBgOnActive: color('#FAFAFA'),
  1850. fillLabelOff: color('#103F2F'),
  1851. fillLabelOffHover: color('#103F2F'),
  1852. fillLabelOffActive: color('#103F2F'),
  1853. fillLabelOn: color('#103F2F'),
  1854. fillLabelOnHover: color('#103F2F'),
  1855. fillLabelOnActive: color('#103F2F'),
  1856. strokeBgOff: color('#103F2F'),
  1857. strokeBgOffHover: color('#103F2F'),
  1858. strokeBgOffActive: color('#103F2F'),
  1859. strokeBgOn: color('#103F2F'),
  1860. strokeBgOnHover: color('#103F2F'),
  1861. strokeBgOnActive: color('#103F2F')
  1862. }
  1863. this.checkbox = {
  1864. strokeWeight: 2,
  1865. rounding: 10,
  1866. fillBg: color('#367F63'),
  1867. fillBgHover: color('#50C493'),
  1868. fillBgActive: color('#7FE5BE'),
  1869. fillCheck: color('#E6FFF4'),
  1870. fillCheckHover: color('#F3FFFA'),
  1871. fillCheckActive: color('#FAFAFA'),
  1872. strokeBg: color('#103F2F')
  1873. }
  1874. this.slider = {
  1875. strokeWeight: 2,
  1876. rounding: 10,
  1877. trackWidth: 1,
  1878. fillBg: color('#E6FFF4'),
  1879. fillBgHover: color('#E6FFF4'),
  1880. fillBgActive: color('#F3FFFA'),
  1881. fillTrack: color('#50C493'),
  1882. fillTrackHover: color('#66CCA6'),
  1883. fillTrackActive: color('#77D8B4'),
  1884. fillHandle: color('#367F63'),
  1885. fillHandleHover: color('#7FE5BE'),
  1886. fillHandleActive: color('#FAFAFA'),
  1887. strokeBg: color('#103F2F'),
  1888. strokeBgHover: color('#103F2F'),
  1889. strokeBgActive: color('#103F2F'),
  1890. strokeTrack: color('#50C493'),
  1891. strokeTrackHover: color('#66CCA6'),
  1892. strokeTrackActive: color('#77D8B4'),
  1893. strokeHandle: color('#103F2F'),
  1894. strokeHandleHover: color('#103F2F'),
  1895. strokeHandleActive: color('#103F2F')
  1896. }
  1897. this.crossfader = {
  1898. strokeCenter: color('#50C493'),
  1899. strokeCenterHover: color('#66CCA6'),
  1900. strokeCenterActive: color('#77D8B4')
  1901. }
  1902. this.slider2d = {
  1903. handleRadius: 16
  1904. }
  1905. this.joystick = {
  1906. handleRadius: 16
  1907. }
  1908. }
  1909. //
  1910. Blue() {
  1911. this.name = "Blue";
  1912. // Global pars
  1913. this.strokeWeight = 2;
  1914. this.rounding = 10;
  1915. this.font = 'Arial';
  1916. this.textSize = 20;
  1917. this.button = {
  1918. strokeWeight: 2,
  1919. rounding: 10,
  1920. font: 'Arial',
  1921. textSize: 20,
  1922. fillBg: color('#7FBEE5'),
  1923. fillBgHover: color('#ABD5EF'),
  1924. fillBgActive: color('#E6F4FF'),
  1925. fillLabel: color('#102F3F'),
  1926. fillLabelHover: color('#102F3F'),
  1927. fillLabelActive: color('#102F3F'),
  1928. strokeBg: color('#102F3F'),
  1929. strokeBgHover: color('#102F3F'),
  1930. strokeBgActive: color('#102F3F')
  1931. };
  1932. this.toggle = {
  1933. strokeWeight: 2,
  1934. rounding: 10,
  1935. font: 'Arial',
  1936. textSize: 20,
  1937. fillBgOff: color('#69ABCC'),
  1938. fillBgOffHover: color('#88C4E2'),
  1939. fillBgOffActive: color('#F3FAFF'),
  1940. fillBgOn: color('#E6F4FF'),
  1941. fillBgOnHover: color('#F3FAFF'),
  1942. fillBgOnActive: color('#FAFAFA'),
  1943. fillLabelOff: color('#102F3F'),
  1944. fillLabelOffHover: color('#102F3F'),
  1945. fillLabelOffActive: color('#102F3F'),
  1946. fillLabelOn: color('#102F3F'),
  1947. fillLabelOnHover: color('#102F3F'),
  1948. fillLabelOnActive: color('#102F3F'),
  1949. strokeBgOff: color('#102F3F'),
  1950. strokeBgOffHover: color('#102F3F'),
  1951. strokeBgOffActive: color('#102F3F'),
  1952. strokeBgOn: color('#102F3F'),
  1953. strokeBgOnHover: color('#102F3F'),
  1954. strokeBgOnActive: color('#102F3F')
  1955. }
  1956. this.checkbox = {
  1957. strokeWeight: 2,
  1958. rounding: 10,
  1959. fillBg: color('#36637F'),
  1960. fillBgHover: color('#5093C4'),
  1961. fillBgActive: color('#7FBEE5'),
  1962. fillCheck: color('#E6F4FF'),
  1963. fillCheckHover: color('#F3FAFF'),
  1964. fillCheckActive: color('#FAFAFA'),
  1965. strokeBg: color('#102F3F')
  1966. }
  1967. this.slider = {
  1968. strokeWeight: 2,
  1969. rounding: 10,
  1970. trackWidth: 1,
  1971. fillBg: color('#E6F4FF'),
  1972. fillBgHover: color('#E6F4FF'),
  1973. fillBgActive: color('#F3FAFF'),
  1974. fillTrack: color('#5093C4'),
  1975. fillTrackHover: color('#66A6CC'),
  1976. fillTrackActive: color('#77B4D8'),
  1977. fillHandle: color('#36637F'),
  1978. fillHandleHover: color('#7FBEE5'),
  1979. fillHandleActive: color('#FAFAFA'),
  1980. strokeBg: color('#102F3F'),
  1981. strokeBgHover: color('#102F3F'),
  1982. strokeBgActive: color('#102F3F'),
  1983. strokeTrack: color('#5093C4'),
  1984. strokeTrackHover: color('#66A6CC'),
  1985. strokeTrackActive: color('#77B4D8'),
  1986. strokeHandle: color('#102F3F'),
  1987. strokeHandleHover: color('#102F3F'),
  1988. strokeHandleActive: color('#102F3F')
  1989. }
  1990. this.crossfader = {
  1991. strokeCenter: color('#5093C4'),
  1992. strokeCenterHover: color('#66A6CC'),
  1993. strokeCenterActive: color('#77B4D8')
  1994. }
  1995. this.slider2d = {
  1996. handleRadius: 16
  1997. }
  1998. this.joystick = {
  1999. handleRadius: 16
  2000. }
  2001. }
  2002. //
  2003. TerminalGreen() {
  2004. this.name = "TerminalGreen";
  2005. // Global pars
  2006. this.strokeWeight = 2;
  2007. this.rounding = 10;
  2008. this.font = 'Arial';
  2009. this.textSize = 20;
  2010. this.button = {
  2011. strokeWeight: 2,
  2012. rounding: 10,
  2013. font: 'Arial',
  2014. textSize: 20,
  2015. fillBg: color('#000000'),
  2016. fillBgHover: color('#003000'),
  2017. fillBgActive: color('#00F200'),
  2018. fillLabel: color('#00FF00'),
  2019. fillLabelHover: color('#00FF00'),
  2020. fillLabelActive: color('#000000'),
  2021. strokeBg: color('#00FF00'),
  2022. strokeBgHover: color('#00FF00'),
  2023. strokeBgActive: color('#007F00')
  2024. };
  2025. this.toggle = {
  2026. strokeWeight: 2,
  2027. rounding: 10,
  2028. font: 'Arial',
  2029. textSize: 20,
  2030. fillBgOff: color('#000000'),
  2031. fillBgOffHover: color('#003000'),
  2032. fillBgOffActive: color('#00F200'),
  2033. fillBgOn: color('#00D800'),
  2034. fillBgOnHover: color('#00F200'),
  2035. fillBgOnActive: color('#00FF00'),
  2036. fillLabelOff: color('#00FF00'),
  2037. fillLabelOffHover: color('#00FF00'),
  2038. fillLabelOffActive: color('#000000'),
  2039. fillLabelOn: color('#000000'),
  2040. fillLabelOnHover: color('#000000'),
  2041. fillLabelOnActive: color('#000000'),
  2042. strokeBgOff: color('#00FF00'),
  2043. strokeBgOffHover: color('#00FF00'),
  2044. strokeBgOffActive: color('#007F00'),
  2045. strokeBgOn: color('#007F00'),
  2046. strokeBgOnHover: color('#007F00'),
  2047. strokeBgOnActive: color('#007F00')
  2048. }
  2049. this.checkbox = {
  2050. strokeWeight: 2,
  2051. rounding: 10,
  2052. fillBg: color('#000000'),
  2053. fillBgHover: color('#003000'),
  2054. fillBgActive: color('#007F00'),
  2055. fillCheck: color('#00D800'),
  2056. fillCheckHover: color('#00F200'),
  2057. fillCheckActive: color('#00FF00'),
  2058. strokeBg: color('#00FF00')
  2059. }
  2060. this.slider = {
  2061. strokeWeight: 2,
  2062. rounding: 10,
  2063. trackWidth: 1,
  2064. fillBg: color('#000000'),
  2065. fillBgHover: color('#003000'),
  2066. fillBgActive: color('#005000'),
  2067. fillTrack: color('#007F00'),
  2068. fillTrackHover: color('#008F00'),
  2069. fillTrackActive: color('#00AC00'),
  2070. fillHandle: color('#000000'),
  2071. fillHandleHover: color('#006000'),
  2072. fillHandleActive: color('#00FF00'),
  2073. strokeBg: color('#00FF00'),
  2074. strokeBgHover: color('#00FF00'),
  2075. strokeBgActive: color('#00FF00'),
  2076. strokeTrack: color('#007F00'),
  2077. strokeTrackHover: color('#008F00'),
  2078. strokeTrackActive: color('#00AC00'),
  2079. strokeHandle: color('#00FF00'),
  2080. strokeHandleHover: color('#00FF00'),
  2081. strokeHandleActive: color('#00FF00')
  2082. }
  2083. this.crossfader = {
  2084. strokeCenter: color('#007F00'),
  2085. strokeCenterHover: color('#007F00'),
  2086. strokeCenterActive: color('#007F00')
  2087. }
  2088. this.slider2d = {
  2089. handleRadius: 16
  2090. }
  2091. this.joystick = {
  2092. handleRadius: 16
  2093. }
  2094. }
  2095. //
  2096. TerminalRed() {
  2097. this.name = "TerminalRed";
  2098. // Global pars
  2099. this.strokeWeight = 2;
  2100. this.rounding = 10;
  2101. this.font = 'Arial';
  2102. this.textSize = 20;
  2103. this.button = {
  2104. strokeWeight: 2,
  2105. rounding: 10,
  2106. font: 'Arial',
  2107. textSize: 20,
  2108. fillBg: color('#000000'),
  2109. fillBgHover: color('#300000'),
  2110. fillBgActive: color('#F20000'),
  2111. fillLabel: color('#FF0000'),
  2112. fillLabelHover: color('#FF0000'),
  2113. fillLabelActive: color('#000000'),
  2114. strokeBg: color('#FF0000'),
  2115. strokeBgHover: color('#FF0000'),
  2116. strokeBgActive: color('#7F0000')
  2117. };
  2118. this.toggle = {
  2119. strokeWeight: 2,
  2120. rounding: 10,
  2121. font: 'Arial',
  2122. textSize: 20,
  2123. fillBgOff: color('#000000'),
  2124. fillBgOffHover: color('#300000'),
  2125. fillBgOffActive: color('#F20000'),
  2126. fillBgOn: color('#D80000'),
  2127. fillBgOnHover: color('#F20000'),
  2128. fillBgOnActive: color('#FF0000'),
  2129. fillLabelOff: color('#FF0000'),
  2130. fillLabelOffHover: color('#FF0000'),
  2131. fillLabelOffActive: color('#000000'),
  2132. fillLabelOn: color('#000000'),
  2133. fillLabelOnHover: color('#000000'),
  2134. fillLabelOnActive: color('#000000'),
  2135. strokeBgOff: color('#FF0000'),
  2136. strokeBgOffHover: color('#FF0000'),
  2137. strokeBgOffActive: color('#7F0000'),
  2138. strokeBgOn: color('#7F0000'),
  2139. strokeBgOnHover: color('#7F0000'),
  2140. strokeBgOnActive: color('#7F0000')
  2141. }
  2142. this.checkbox = {
  2143. strokeWeight: 2,
  2144. rounding: 10,
  2145. fillBg: color('#000000'),
  2146. fillBgHover: color('#300000'),
  2147. fillBgActive: color('#7F0000'),
  2148. fillCheck: color('#D80000'),
  2149. fillCheckHover: color('#F20000'),
  2150. fillCheckActive: color('#FF0000'),
  2151. strokeBg: color('#FF0000')
  2152. }
  2153. this.slider = {
  2154. strokeWeight: 2,
  2155. rounding: 10,
  2156. trackWidth: 1,
  2157. fillBg: color('#000000'),
  2158. fillBgHover: color('#300000'),
  2159. fillBgActive: color('#500000'),
  2160. fillTrack: color('#7F0000'),
  2161. fillTrackHover: color('#8F0000'),
  2162. fillTrackActive: color('#AC0000'),
  2163. fillHandle: color('#000000'),
  2164. fillHandleHover: color('#600000'),
  2165. fillHandleActive: color('#FF0000'),
  2166. strokeBg: color('#FF0000'),
  2167. strokeBgHover: color('#FF0000'),
  2168. strokeBgActive: color('#FF0000'),
  2169. strokeTrack: color('#7F0000'),
  2170. strokeTrackHover: color('#8F0000'),
  2171. strokeTrackActive: color('#AC0000'),
  2172. strokeHandle: color('#FF0000'),
  2173. strokeHandleHover: color('#FF0000'),
  2174. strokeHandleActive: color('#FF0000')
  2175. }
  2176. this.crossfader = {
  2177. strokeCenter: color('#7F0000'),
  2178. strokeCenterHover: color('#7F0000'),
  2179. strokeCenterActive: color('#7F0000')
  2180. }
  2181. this.slider2d = {
  2182. handleRadius: 16
  2183. }
  2184. this.joystick = {
  2185. handleRadius: 16
  2186. }
  2187. }
  2188. //
  2189. TerminalBlue() {
  2190. this.name = "TerminalBlue";
  2191. // Global pars
  2192. this.strokeWeight = 2;
  2193. this.rounding = 10;
  2194. this.font = 'Arial';
  2195. this.textSize = 20;
  2196. this.button = {
  2197. strokeWeight: 2,
  2198. rounding: 10,
  2199. font: 'Arial',
  2200. textSize: 20,
  2201. fillBg: color('#000000'),
  2202. fillBgHover: color('#000030'),
  2203. fillBgActive: color('#4040F2'),
  2204. fillLabel: color('#4040FF'),
  2205. fillLabelHover: color('#4040FF'),
  2206. fillLabelActive: color('#000000'),
  2207. strokeBg: color('#4040FF'),
  2208. strokeBgHover: color('#4040FF'),
  2209. strokeBgActive: color('#40407F')
  2210. };
  2211. this.toggle = {
  2212. strokeWeight: 2,
  2213. rounding: 10,
  2214. font: 'Arial',
  2215. textSize: 20,
  2216. fillBgOff: color('#000000'),
  2217. fillBgOffHover: color('#000030'),
  2218. fillBgOffActive: color('#4040F2'),
  2219. fillBgOn: color('#4040D8'),
  2220. fillBgOnHover: color('#4040F2'),
  2221. fillBgOnActive: color('#4040FF'),
  2222. fillLabelOff: color('#4040FF'),
  2223. fillLabelOffHover: color('#4040FF'),
  2224. fillLabelOffActive: color('#000000'),
  2225. fillLabelOn: color('#000000'),
  2226. fillLabelOnHover: color('#000000'),
  2227. fillLabelOnActive: color('#000000'),
  2228. strokeBgOff: color('#4040FF'),
  2229. strokeBgOffHover: color('#4040FF'),
  2230. strokeBgOffActive: color('#40407F'),
  2231. strokeBgOn: color('#40407F'),
  2232. strokeBgOnHover: color('#40407F'),
  2233. strokeBgOnActive: color('#40407F')
  2234. }
  2235. this.checkbox = {
  2236. strokeWeight: 2,
  2237. rounding: 10,
  2238. fillBg: color('#000000'),
  2239. fillBgHover: color('#000030'),
  2240. fillBgActive: color('#40407F'),
  2241. fillCheck: color('#4040D8'),
  2242. fillCheckHover: color('#4040F2'),
  2243. fillCheckActive: color('#4040FF'),
  2244. strokeBg: color('#4040FF')
  2245. }
  2246. this.slider = {
  2247. strokeWeight: 2,
  2248. rounding: 10,
  2249. trackWidth: 1,
  2250. fillBg: color('#000000'),
  2251. fillBgHover: color('#000030'),
  2252. fillBgActive: color('#000050'),
  2253. fillTrack: color('#20207F'),
  2254. fillTrackHover: color('#20208F'),
  2255. fillTrackActive: color('#2020AC'),
  2256. fillHandle: color('#000000'),
  2257. fillHandleHover: color('#000060'),
  2258. fillHandleActive: color('#4040FF'),
  2259. strokeBg: color('#4040FF'),
  2260. strokeBgHover: color('#4040FF'),
  2261. strokeBgActive: color('#4040FF'),
  2262. strokeTrack: color('#20207F'),
  2263. strokeTrackHover: color('#20208F'),
  2264. strokeTrackActive: color('#2020AC'),
  2265. strokeHandle: color('#4040FF'),
  2266. strokeHandleHover: color('#4040FF'),
  2267. strokeHandleActive: color('#4040FF')
  2268. }
  2269. this.crossfader = {
  2270. strokeCenter: color('#40407F'),
  2271. strokeCenterHover: color('#40407F'),
  2272. strokeCenterActive: color('#40407F')
  2273. }
  2274. this.slider2d = {
  2275. handleRadius: 16
  2276. }
  2277. this.joystick = {
  2278. handleRadius: 16
  2279. }
  2280. }
  2281. //
  2282. TerminalYellow() {
  2283. this.name = "TerminalYellow";
  2284. // Global pars
  2285. this.strokeWeight = 2;
  2286. this.rounding = 10;
  2287. this.font = 'Arial';
  2288. this.textSize = 20;
  2289. this.button = {
  2290. strokeWeight: 2,
  2291. rounding: 10,
  2292. font: 'Arial',
  2293. textSize: 20,
  2294. fillBg: color('#000000'),
  2295. fillBgHover: color('#303000'),
  2296. fillBgActive: color('#F2F200'),
  2297. fillLabel: color('#FFFF00'),
  2298. fillLabelHover: color('#FFFF00'),
  2299. fillLabelActive: color('#000000'),
  2300. strokeBg: color('#FFFF00'),
  2301. strokeBgHover: color('#FFFF00'),
  2302. strokeBgActive: color('#7F7F00')
  2303. };
  2304. this.toggle = {
  2305. strokeWeight: 2,
  2306. rounding: 10,
  2307. font: 'Arial',
  2308. textSize: 20,
  2309. fillBgOff: color('#000000'),
  2310. fillBgOffHover: color('#303000'),
  2311. fillBgOffActive: color('#F2F200'),
  2312. fillBgOn: color('#D8D800'),
  2313. fillBgOnHover: color('#F2F200'),
  2314. fillBgOnActive: color('#FFFF00'),
  2315. fillLabelOff: color('#FFFF00'),
  2316. fillLabelOffHover: color('#FFFF00'),
  2317. fillLabelOffActive: color('#000000'),
  2318. fillLabelOn: color('#000000'),
  2319. fillLabelOnHover: color('#000000'),
  2320. fillLabelOnActive: color('#000000'),
  2321. strokeBgOff: color('#FFFF00'),
  2322. strokeBgOffHover: color('#FFFF00'),
  2323. strokeBgOffActive: color('#7F7F00'),
  2324. strokeBgOn: color('#7F7F00'),
  2325. strokeBgOnHover: color('#7F7F00'),
  2326. strokeBgOnActive: color('#7F7F00')
  2327. }
  2328. this.checkbox = {
  2329. strokeWeight: 2,
  2330. rounding: 10,
  2331. fillBg: color('#000000'),
  2332. fillBgHover: color('#303000'),
  2333. fillBgActive: color('#7F7F00'),
  2334. fillCheck: color('#D8D800'),
  2335. fillCheckHover: color('#F2F200'),
  2336. fillCheckActive: color('#FFFF00'),
  2337. strokeBg: color('#FFFF00')
  2338. }
  2339. this.slider = {
  2340. strokeWeight: 2,
  2341. rounding: 10,
  2342. trackWidth: 1,
  2343. fillBg: color('#000000'),
  2344. fillBgHover: color('#303000'),
  2345. fillBgActive: color('#505000'),
  2346. fillTrack: color('#7F7F00'),
  2347. fillTrackHover: color('#8F8F00'),
  2348. fillTrackActive: color('#ACAC00'),
  2349. fillHandle: color('#000000'),
  2350. fillHandleHover: color('#606000'),
  2351. fillHandleActive: color('#FFFF00'),
  2352. strokeBg: color('#FFFF00'),
  2353. strokeBgHover: color('#FFFF00'),
  2354. strokeBgActive: color('#FFFF00'),
  2355. strokeTrack: color('#7F7F00'),
  2356. strokeTrackHover: color('#8F8F00'),
  2357. strokeTrackActive: color('#ACAC00'),
  2358. strokeHandle: color('#FFFF00'),
  2359. strokeHandleHover: color('#FFFF00'),
  2360. strokeHandleActive: color('#FFFF00')
  2361. }
  2362. this.crossfader = {
  2363. strokeCenter: color('#7F7F00'),
  2364. strokeCenterHover: color('#7F7F00'),
  2365. strokeCenterActive: color('#7F7F00')
  2366. }
  2367. this.slider2d = {
  2368. handleRadius: 16
  2369. }
  2370. this.joystick = {
  2371. handleRadius: 16
  2372. }
  2373. }
  2374. //
  2375. TerminalMagenta() {
  2376. this.name = "TerminalMagenta";
  2377. // Global pars
  2378. this.strokeWeight = 2;
  2379. this.rounding = 10;
  2380. this.font = 'Arial';
  2381. this.textSize = 20;
  2382. this.button = {
  2383. strokeWeight: 2,
  2384. rounding: 10,
  2385. font: 'Arial',
  2386. textSize: 20,
  2387. fillBg: color('#000000'),
  2388. fillBgHover: color('#300030'),
  2389. fillBgActive: color('#F200F2'),
  2390. fillLabel: color('#FF00FF'),
  2391. fillLabelHover: color('#FF00FF'),
  2392. fillLabelActive: color('#000000'),
  2393. strokeBg: color('#FF00FF'),
  2394. strokeBgHover: color('#FF00FF'),
  2395. strokeBgActive: color('#7F007F')
  2396. };
  2397. this.toggle = {
  2398. strokeWeight: 2,
  2399. rounding: 10,
  2400. font: 'Arial',
  2401. textSize: 20,
  2402. fillBgOff: color('#000000'),
  2403. fillBgOffHover: color('#300030'),
  2404. fillBgOffActive: color('#F200F2'),
  2405. fillBgOn: color('#D800D8'),
  2406. fillBgOnHover: color('#F200F2'),
  2407. fillBgOnActive: color('#FF00FF'),
  2408. fillLabelOff: color('#FF00FF'),
  2409. fillLabelOffHover: color('#FF00FF'),
  2410. fillLabelOffActive: color('#000000'),
  2411. fillLabelOn: color('#000000'),
  2412. fillLabelOnHover: color('#000000'),
  2413. fillLabelOnActive: color('#000000'),
  2414. strokeBgOff: color('#FF00FF'),
  2415. strokeBgOffHover: color('#FF00FF'),
  2416. strokeBgOffActive: color('#7F007F'),
  2417. strokeBgOn: color('#7F007F'),
  2418. strokeBgOnHover: color('#7F007F'),
  2419. strokeBgOnActive: color('#7F007F')
  2420. }
  2421. this.checkbox = {
  2422. strokeWeight: 2,
  2423. rounding: 10,
  2424. fillBg: color('#000000'),
  2425. fillBgHover: color('#300030'),
  2426. fillBgActive: color('#7F007F'),
  2427. fillCheck: color('#D800D8'),
  2428. fillCheckHover: color('#F200F2'),
  2429. fillCheckActive: color('#FF00FF'),
  2430. strokeBg: color('#FF00FF')
  2431. }
  2432. this.slider = {
  2433. strokeWeight: 2,
  2434. rounding: 10,
  2435. trackWidth: 1,
  2436. fillBg: color('#000000'),
  2437. fillBgHover: color('#300030'),
  2438. fillBgActive: color('#500050'),
  2439. fillTrack: color('#7F007F'),
  2440. fillTrackHover: color('#8F008F'),
  2441. fillTrackActive: color('#AC00AC'),
  2442. fillHandle: color('#000000'),
  2443. fillHandleHover: color('#600060'),
  2444. fillHandleActive: color('#FF00FF'),
  2445. strokeBg: color('#FF00FF'),
  2446. strokeBgHover: color('#FF00FF'),
  2447. strokeBgActive: color('#FF00FF'),
  2448. strokeTrack: color('#7F007F'),
  2449. strokeTrackHover: color('#8F008F'),
  2450. strokeTrackActive: color('#AC00AC'),
  2451. strokeHandle: color('#FF00FF'),
  2452. strokeHandleHover: color('#FF00FF'),
  2453. strokeHandleActive: color('#FF00FF')
  2454. }
  2455. this.crossfader = {
  2456. strokeCenter: color('#7F007F'),
  2457. strokeCenterHover: color('#7F007F'),
  2458. strokeCenterActive: color('#7F007F')
  2459. }
  2460. this.slider2d = {
  2461. handleRadius: 16
  2462. }
  2463. this.joystick = {
  2464. handleRadius: 16
  2465. }
  2466. }
  2467. }