p5.touchgui.js 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812
  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. }
  1012. _drawState(fillBg) {
  1013. push();
  1014. // Draw background shape
  1015. rectMode(CORNER);
  1016. stroke(this._style.strokeBg);
  1017. strokeWeight(this._style.strokeWeight);
  1018. fill(fillBg);
  1019. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1020. pop();
  1021. }
  1022. _drawCheck(fillCheck) {
  1023. // Note: I don't really like how this is done lol; it's sloppy and can be better
  1024. let x8 = this.x+this.w/6;
  1025. let y8 = this.y+this.h/6;
  1026. let w16 = this.w-this.w/3;
  1027. let h16 = this.h-this.h/3;
  1028. let xw = x8+w16;
  1029. let yh = y8+h16;
  1030. let strokeMult = map(((this.w > this.h) ? this.w : this.h), 32, 1000, 2, 20);
  1031. push();
  1032. stroke(fillCheck);
  1033. strokeWeight(this._style.strokeWeight*strokeMult);
  1034. line(x8, y8, xw, yh);
  1035. line(xw, y8, x8, yh);
  1036. pop();
  1037. }
  1038. }
  1039. /**
  1040. * GuiSlider
  1041. * - Horizontal slider.
  1042. *
  1043. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1044. * TODO: fix so that touch corresponds with handle
  1045. */
  1046. class GuiSlider extends GuiObject {
  1047. constructor(label, x, y, w=256, h=32, min=0, max=1) {
  1048. super(label, x, y, w, h);
  1049. this.min = min;
  1050. this.max = max;
  1051. this.val = min + (max - min)/2;
  1052. this._family = "slider";
  1053. this._type = "slider";
  1054. this._style = {..._gui._style.slider};
  1055. }
  1056. _setActive(active) {
  1057. super._setActive(active);
  1058. if (this._active && this._selU != null) {
  1059. this.val = map(this._selU, 0, 1, this.min, this.max);
  1060. this.val = this.isInteger ? int(this.val) : this.val;
  1061. }
  1062. }
  1063. draw() {
  1064. if (this._active) {
  1065. this._drawState(this._style.fillBgActive,
  1066. this._style.fillTrackActive,
  1067. this._style.fillHandleActive,
  1068. this._style.strokeBgActive,
  1069. this._style.strokeTrackActive,
  1070. this._style.strokeHandleActive);
  1071. }
  1072. else if (this._hover) {
  1073. this._drawState(this._style.fillBgHover,
  1074. this._style.fillTrackHover,
  1075. this._style.fillHandleHover,
  1076. this._style.strokeBgHover,
  1077. this._style.strokeTrackHover,
  1078. this._style.strokeHandleHover);
  1079. }
  1080. else {
  1081. this._drawState(this._style.fillBg,
  1082. this._style.fillTrack,
  1083. this._style.fillHandle,
  1084. this._style.strokeBg,
  1085. this._style.strokeTrack,
  1086. this._style.strokeHandle);
  1087. }
  1088. }
  1089. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1090. let xpos = map(this.val, this.min, this.max, 8, this.w-24);
  1091. push();
  1092. strokeWeight(this._style.strokeWeight);
  1093. rectMode(CORNER);
  1094. // Render bg
  1095. stroke(strokeBg);
  1096. fill(fillBg);
  1097. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1098. // Render track
  1099. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1100. let h = this.h-20;
  1101. push();
  1102. stroke(strokeTrack);
  1103. fill(fillTrack);
  1104. if (this._style.trackWidth > 0) {
  1105. rect(this.x+10,
  1106. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1107. xpos,
  1108. h*this._style.trackWidth,
  1109. this._style.rounding, 0, 0, this._style.rounding);
  1110. }
  1111. else {
  1112. line(this.x+10,
  1113. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1114. this.x+10+xpos,
  1115. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1116. }
  1117. pop();
  1118. // Render handle
  1119. push();
  1120. stroke(strokeHandle);
  1121. fill(fillHandle);
  1122. rect(this.x+xpos, this.y+8, 16, this.h-16, this._style.rounding);
  1123. pop();
  1124. pop();
  1125. }
  1126. }
  1127. /**
  1128. * GuiSliderV
  1129. * - Vertical slider.
  1130. * Note: this may be modifiable to extend GuiSlider, but for simplicity it is
  1131. * presently extending GuiObject.
  1132. *
  1133. * TODO: fix hard coding of buffers (e.g. this.h-24)
  1134. * TODO: fix so that touch corresponds with handle
  1135. */
  1136. class GuiSliderV extends GuiObject {
  1137. constructor(label, x, y, w=32, h=256, min=0, max=1) {
  1138. super(label, x, y, w, h);
  1139. this.min = min;
  1140. this.max = max;
  1141. this.val = min + (max - min)/2;
  1142. this._family = "slider";
  1143. this._type = "slider";
  1144. this._style = {..._gui._style.slider};
  1145. }
  1146. _setActive(active) {
  1147. super._setActive(active);
  1148. if (this._active && this._selV != null) {
  1149. this.val = map(this._selV, 1, 0, this.min, this.max);
  1150. this.val = this.isInteger ? int(this.val) : this.val;
  1151. }
  1152. }
  1153. draw() {
  1154. if (this._active) {
  1155. this._drawState(this._style.fillBgActive,
  1156. this._style.fillTrackActive,
  1157. this._style.fillHandleActive,
  1158. this._style.strokeBgActive,
  1159. this._style.strokeTrackActive,
  1160. this._style.strokeHandleActive);
  1161. }
  1162. else if (this._hover) {
  1163. this._drawState(this._style.fillBgHover,
  1164. this._style.fillTrackHover,
  1165. this._style.fillHandleHover,
  1166. this._style.strokeBgHover,
  1167. this._style.strokeTrackHover,
  1168. this._style.strokeHandleHover);
  1169. }
  1170. else {
  1171. this._drawState(this._style.fillBg,
  1172. this._style.fillTrack,
  1173. this._style.fillHandle,
  1174. this._style.strokeBg,
  1175. this._style.strokeTrack,
  1176. this._style.strokeHandle);
  1177. }
  1178. }
  1179. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1180. let ypos = map(this.val, this.min, this.max, this.h-24, 8);
  1181. push();
  1182. strokeWeight(this._style.strokeWeight);
  1183. rectMode(CORNER);
  1184. // Render bg
  1185. stroke(strokeBg);
  1186. fill(fillBg);
  1187. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1188. // Render track
  1189. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1190. let w = this.w-20;
  1191. push();
  1192. stroke(strokeTrack);
  1193. fill(fillTrack);
  1194. if (this._style.trackWidth > 0) {
  1195. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1196. this.y+ypos+10,
  1197. w*this._style.trackWidth,
  1198. this.h-ypos-20,
  1199. 0, 0, this._style.rounding, this._style.rounding);
  1200. }
  1201. else {
  1202. line(this.x+10 + w*0.5, this.y+ypos+10,
  1203. this.x+10 + w*0.5, this.y+this.h-10);
  1204. }
  1205. pop();
  1206. // Render handle
  1207. push();
  1208. stroke(strokeHandle);
  1209. fill(fillHandle);
  1210. rect(this.x+8, this.y+ypos, this.w-16, 16, this._style.rounding);
  1211. pop();
  1212. pop();
  1213. }
  1214. }
  1215. /**
  1216. * GuiCrossfader
  1217. * - Horizontal cross fader. Indicator drawn from center.
  1218. *
  1219. * TODO: fix so that touch corresponds with handle
  1220. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1221. */
  1222. class GuiCrossfader extends GuiSlider {
  1223. constructor(label, x, y, w=256, h=32, min=(-1), max=1) {
  1224. super(label, x, y, w, h, min, max);
  1225. this.snap = false; // If true, snaps value back to 0 when not active
  1226. this._family = "slider";
  1227. this._type = "crossfader";
  1228. this._style = Object.create(_gui._style.slider);
  1229. this._style.strokeCenter = Object.create(_gui._style.crossfader.strokeCenter);
  1230. this._style.strokeCenterHover = Object.create(_gui._style.crossfader.strokeCenterHover);
  1231. this._style.strokeCenterActive = Object.create(_gui._style.crossfader.strokeCenterActive);
  1232. }
  1233. _setActive(active) {
  1234. super._setActive(active);
  1235. if (!this._active && this.snap) {
  1236. this.val = (this.min + this.max)/2;
  1237. }
  1238. }
  1239. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1240. let xpos = map(this.val, this.min, this.max, 8, this.w-24);
  1241. let halfXpos = (this.w-16)/2;
  1242. push();
  1243. strokeWeight(this._style.strokeWeight);
  1244. rectMode(CORNER);
  1245. // Render bg
  1246. stroke(strokeBg);
  1247. fill(fillBg);
  1248. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1249. // Render track from center
  1250. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1251. let h = this.h-20;
  1252. push();
  1253. stroke(strokeTrack);
  1254. fill(fillTrack);
  1255. if (xpos >= halfXpos) {
  1256. if (this._style.trackWidth > 0) {
  1257. rect(this.x+halfXpos+8,
  1258. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1259. xpos-halfXpos,
  1260. h*this._style.trackWidth);
  1261. }
  1262. else {
  1263. line(this.x+halfXpos+8,
  1264. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1265. this.x+8+xpos,
  1266. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1267. }
  1268. }
  1269. else {
  1270. if (this._style.trackWidth > 0) {
  1271. rect(this.x+xpos,
  1272. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1273. halfXpos-xpos+8,
  1274. h*this._style.trackWidth);
  1275. }
  1276. else {
  1277. line(this.x+xpos,
  1278. this.y+10 + h*(1-this._style.trackWidth)*0.5,
  1279. this.x+halfXpos+8,
  1280. this.y+10 + h*(1-this._style.trackWidth)*0.5);
  1281. }
  1282. }
  1283. // Draw center line
  1284. stroke(this._style.strokeCenter);
  1285. strokeWeight(this._style.strokeWeight);
  1286. line(this.x+this.w/2, this.y, this.x+this.w/2, this.y+this.h);
  1287. pop();
  1288. // Render handle
  1289. push();
  1290. stroke(strokeHandle);
  1291. fill(fillHandle);
  1292. rect(this.x+xpos, this.y+8, 16, this.h-16, this._style.rounding);
  1293. pop();
  1294. pop();
  1295. }
  1296. }
  1297. /**
  1298. * GuiCrossfaderV
  1299. * - Vertical cross fader. Indicator drawn from center.
  1300. *
  1301. * TODO: fix so that touch corresponds with handle
  1302. * TODO: fix hard coding of buffers (e.g. this.h-24)
  1303. */
  1304. class GuiCrossfaderV extends GuiSliderV {
  1305. constructor(label, x, y, w=256, h=32, min=(-1), max=1) {
  1306. super(label, x, y, w, h, min, max);
  1307. this.snap = false; // If true, snaps value back to 0 when not active
  1308. this._family = "slider";
  1309. this._type = "crossfader";
  1310. this._style = Object.create(_gui._style.slider);
  1311. this._style.strokeCenter = Object.create(_gui._style.crossfader.strokeCenter);
  1312. this._style.strokeCenterHover = Object.create(_gui._style.crossfader.strokeCenterHover);
  1313. this._style.strokeCenterActive = Object.create(_gui._style.crossfader.strokeCenterActive);
  1314. }
  1315. _setActive(active) {
  1316. super._setActive(active);
  1317. if (!this._active && this.snap) {
  1318. this.val = (this.min + this.max)/2;
  1319. }
  1320. }
  1321. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1322. let ypos = map(this.val, this.min, this.max, this.h-24, 8);
  1323. let halfYpos = (this.h-16)/2;
  1324. push();
  1325. strokeWeight(this._style.strokeWeight);
  1326. rectMode(CORNER);
  1327. // Render bg
  1328. stroke(strokeBg);
  1329. fill(fillBg);
  1330. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1331. // Render track from center
  1332. this._style.trackWidth = constrain(this._style.trackWidth, 0, 1);
  1333. let w = this.w-20;
  1334. push();
  1335. stroke(strokeTrack);
  1336. fill(fillTrack);
  1337. if (ypos >= halfYpos) {
  1338. if (this._style.trackWidth > 0) {
  1339. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1340. this.y+halfYpos+8,
  1341. w*this._style.trackWidth,
  1342. ypos-halfYpos);
  1343. }
  1344. else {
  1345. line(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1346. this.y+halfYpos+8,
  1347. this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1348. this.y+8+ypos);
  1349. }
  1350. }
  1351. else {
  1352. if (this._style.trackWidth > 0) {
  1353. rect(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1354. this.y+ypos,
  1355. w*this._style.trackWidth,
  1356. halfYpos-ypos+8);
  1357. }
  1358. else {
  1359. line(this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1360. this.y+ypos,
  1361. this.x+10 + w*(1-this._style.trackWidth)*0.5,
  1362. this.y+halfYpos+8);
  1363. }
  1364. }
  1365. // Draw center line
  1366. stroke(this._style.strokeCenter);
  1367. strokeWeight(this._style.strokeWeight);
  1368. line(this.x, this.y+this.h/2, this.x+this.w, this.y+this.h/2);
  1369. pop();
  1370. // Render handle
  1371. push();
  1372. stroke(strokeHandle);
  1373. fill(fillHandle);
  1374. rect(this.x+8, this.y+ypos, this.w-16, 16, this._style.rounding);
  1375. pop();
  1376. pop();
  1377. }
  1378. }
  1379. /**
  1380. * Gui2dSlider
  1381. * - Two dimensional slider that returns an X/Y pair of values
  1382. *
  1383. * TODO: fix hard coding of buffers (e.g. this.w-24)
  1384. * TODO: fix so that touch corresponds with handle
  1385. */
  1386. class GuiSlider2d extends GuiObject {
  1387. constructor(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  1388. super(label, x, y, w, h);
  1389. this.minX = minX;
  1390. this.maxX = maxX;
  1391. this.minY = minY;
  1392. this.maxY = maxY;
  1393. this.val = {x:0, y:0};
  1394. this.valX = minX + (maxX - minX)/2;
  1395. this.valY = minY + (maxY - minY)/2;
  1396. this._family = "slider";
  1397. this._type = "slider2d";
  1398. this._style = Object.create(_gui._style.slider);
  1399. this._style.handleRadius = _gui._style.slider2d.handleRadius;
  1400. }
  1401. _setActive(active) {
  1402. super._setActive(active);
  1403. if (this._active && this._selU != null && this._selV != null) {
  1404. this.valX = map(this._selU, 0, 1, this.minX, this.maxX);
  1405. this.valY = map(this._selV, 1, 0, this.minY, this.maxY);
  1406. if (this.isInteger && this._type == "slider2d") {
  1407. this.valX = int(this.valX);
  1408. this.valY = int(this.valY);
  1409. }
  1410. this.val = {x: this.valX, y:this.valY};
  1411. }
  1412. }
  1413. draw() {
  1414. if (this._active) {
  1415. this._drawState(this._style.fillBgActive,
  1416. this._style.fillTrackActive,
  1417. this._style.fillHandleActive,
  1418. this._style.strokeBgActive,
  1419. this._style.strokeTrackActive,
  1420. this._style.strokeHandleActive);
  1421. }
  1422. else if (this._hover) {
  1423. this._drawState(this._style.fillBgHover,
  1424. this._style.fillTrackHover,
  1425. this._style.fillHandleHover,
  1426. this._style.strokeBgHover,
  1427. this._style.strokeTrackHover,
  1428. this._style.strokeHandleHover);
  1429. }
  1430. else {
  1431. this._drawState(this._style.fillBg,
  1432. this._style.fillTrack,
  1433. this._style.fillHandle,
  1434. this._style.strokeBg,
  1435. this._style.strokeTrack,
  1436. this._style.strokeHandle);
  1437. }
  1438. }
  1439. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1440. let xpos = map(this.valX, this.minX, this.maxX, 8, this.w-24);
  1441. let ypos = map(this.valY, this.minY, this.maxY, this.h-24, 8);
  1442. push();
  1443. strokeWeight(this._style.strokeWeight);
  1444. rectMode(CORNER);
  1445. // Render bg
  1446. stroke(strokeBg);
  1447. fill(fillBg);
  1448. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1449. // Render crosshair (track)
  1450. push();
  1451. stroke(fillTrack);
  1452. line(this.x, this.y+ypos+8, this.x+this.w, this.y+ypos+8);
  1453. line(this.x+xpos+8, this.y, this.x+xpos+8, this.y+this.h);
  1454. pop();
  1455. // Render handle
  1456. push();
  1457. stroke(strokeHandle);
  1458. fill(fillHandle);
  1459. ellipse(this.x+xpos+8,
  1460. this.y+ypos+8,
  1461. this._style.handleRadius,
  1462. this._style.handleRadius);
  1463. pop();
  1464. pop();
  1465. }
  1466. }
  1467. /**
  1468. * GuiJoystick
  1469. * - Two dimensional slider that returns an X/Y pair of values
  1470. * relative to a resetting zero point at its center.
  1471. */
  1472. class GuiJoystick extends GuiSlider2d {
  1473. constructor(label, x, y, w=256, h=256, minX=(-1), maxX=1, minY=(-1), maxY=1) {
  1474. super(label, x, y, w, h, minX, maxX, minY, maxY);
  1475. this.snap = true; // If true, snaps value back to 0 when not active
  1476. this._family = "slider";
  1477. this._type = "joystick";
  1478. this._style = Object.create(_gui._style.slider);
  1479. this._style.handleRadius = _gui._style.joystick.handleRadius;
  1480. }
  1481. _setActive(active) {
  1482. super._setActive(active);
  1483. if (!this._active && this.snap) {
  1484. this.valX = (this.minX + this.maxX)/2;
  1485. this.valY = (this.minY + this.maxY)/2;
  1486. this.val = {x: this.valX, y:this.valY};
  1487. }
  1488. }
  1489. _drawState(fillBg, fillTrack, fillHandle, strokeBg, strokeTrack, strokeHandle) {
  1490. let xpos = map(this.valX, this.minX, this.maxX, 8, this.w-24);
  1491. let ypos = map(this.valY, this.minY, this.maxY, this.h-24, 8);
  1492. push();
  1493. strokeWeight(this._style.strokeWeight);
  1494. rectMode(CORNER);
  1495. // Render bg
  1496. stroke(strokeBg);
  1497. fill(fillBg);
  1498. rect(this.x, this.y, this.w, this.h, this._style.rounding);
  1499. // Render circle (track)
  1500. push();
  1501. stroke(fillTrack);
  1502. let r = this.w*this._style.trackRatio;
  1503. if (this.w > this.h) {
  1504. r = this.h*this._style.trackRatio;
  1505. }
  1506. ellipse(this.x+this.w/2, this.y+this.h/2, r)
  1507. pop();
  1508. // Render handle
  1509. push();
  1510. stroke(strokeHandle);
  1511. fill(fillHandle);
  1512. ellipse(this.x+xpos+8,
  1513. this.y+ypos+8,
  1514. this._style.handleRadius,
  1515. this._style.handleRadius);
  1516. pop();
  1517. pop();
  1518. }
  1519. }
  1520. /**
  1521. * GuiRadio
  1522. * - A user-defined number of toggles, of which only one can be turned on at a time.
  1523. */
  1524. class GuiRadio extends GuiObject {
  1525. // TODO: write this. Maybe this can be done by adding a 'group' property
  1526. }
  1527. /*******************
  1528. * GuiStyle
  1529. * - A style class that contains various presets for colors, rounding, etc.
  1530. *
  1531. * TODO: Create more color palettes.
  1532. * TODO: Study material-ui implementation of colors and try
  1533. * to implement something similar (i.e. primary and accent color)
  1534. */
  1535. class GuiStyle {
  1536. constructor() {
  1537. this.name = "DefaultGray";
  1538. // Global pars
  1539. this.strokeWeight = 2;
  1540. this.rounding = 10;
  1541. this.font = 'Arial';
  1542. this.textSize = 20;
  1543. this.button = {
  1544. strokeWeight: 2,
  1545. rounding: 10,
  1546. font: 'Arial',
  1547. textSize: 20,
  1548. fillBg: color(130),
  1549. fillBgHover: color(196),
  1550. fillBgActive: color(220),
  1551. fillLabel: color(0),
  1552. fillLabelHover: color(0),
  1553. fillLabelActive: color(0),
  1554. strokeBg: color(0),
  1555. strokeBgHover: color(0),
  1556. strokeBgActive: color(0)
  1557. };
  1558. this.toggle = {
  1559. strokeWeight: 2,
  1560. rounding: 10,
  1561. font: 'Arial',
  1562. textSize: 20,
  1563. fillBgOff: color(130),
  1564. fillBgOffHover: color(196),
  1565. fillBgOffActive: color(220),
  1566. fillBgOn: color(230),
  1567. fillBgOnHover: color(245),
  1568. fillBgOnActive: color(255),
  1569. fillLabelOff: color(0),
  1570. fillLabelOffHover: color(0),
  1571. fillLabelOffActive: color(0),
  1572. fillLabelOn: color(0),
  1573. fillLabelOnHover: color(0),
  1574. fillLabelOnActive: color(0),
  1575. strokeBgOff: color(0),
  1576. strokeBgOffHover: color(0),
  1577. strokeBgOffActive: color(0),
  1578. strokeBgOn: color(0),
  1579. strokeBgOnHover: color(0),
  1580. strokeBgOnActive: color(0)
  1581. }
  1582. this.checkbox = {
  1583. strokeWeight: 2,
  1584. rounding: 10,
  1585. fillBg: color(100),
  1586. fillBgHover: color(144),
  1587. fillBgActive: color(160),
  1588. fillCheck: color(200),
  1589. fillCheckHover: color(220),
  1590. fillCheckActive: color(240),
  1591. strokeBg: color(0)
  1592. }
  1593. this.slider = {
  1594. strokeWeight: 2,
  1595. rounding: 10,
  1596. trackWidth: 1,
  1597. fillBg: color(130),
  1598. fillBgHover: color(175),
  1599. fillBgActive: color(175),
  1600. fillTrack: color(100),
  1601. fillTrackHover: color(144),
  1602. fillTrackActive: color(144),
  1603. fillHandle: color(64),
  1604. fillHandleHover: color(96),
  1605. fillHandleActive: color(240),
  1606. strokeBg: color(0),
  1607. strokeBgHover: color(0),
  1608. strokeBgActive: color(0),
  1609. strokeTrack: color(100),
  1610. strokeTrackHover: color(144),
  1611. strokeTrackActive: color(144),
  1612. strokeHandle: color(64),
  1613. strokeHandleHover: color(0),
  1614. strokeHandleActive: color(0)
  1615. }
  1616. this.crossfader = {
  1617. strokeCenter: color(100),
  1618. strokeCenterHover: color(100),
  1619. strokeCenterActive: color(100)
  1620. }
  1621. this.slider2d = {
  1622. handleRadius: 16
  1623. }
  1624. this.joystick = {
  1625. handleRadius: 16
  1626. }
  1627. }
  1628. // Default
  1629. Gray() {
  1630. this.name = "DefaultGray";
  1631. // Global pars
  1632. this.strokeWeight = 2;
  1633. this.rounding = 10;
  1634. this.font = 'Arial';
  1635. this.textSize = 20;
  1636. this.button = {
  1637. strokeWeight: 2,
  1638. rounding: 10,
  1639. font: 'Arial',
  1640. textSize: 20,
  1641. fillBg: color(130),
  1642. fillBgHover: color(196),
  1643. fillBgActive: color(220),
  1644. fillLabel: color(0),
  1645. fillLabelHover: color(0),
  1646. fillLabelActive: color(0),
  1647. strokeBg: color(0),
  1648. strokeBgHover: color(0),
  1649. strokeBgActive: color(0)
  1650. };
  1651. this.toggle = {
  1652. strokeWeight: 2,
  1653. rounding: 10,
  1654. font: 'Arial',
  1655. textSize: 20,
  1656. fillBgOff: color(130),
  1657. fillBgOffHover: color(196),
  1658. fillBgOffActive: color(220),
  1659. fillBgOn: color(230),
  1660. fillBgOnHover: color(245),
  1661. fillBgOnActive: color(255),
  1662. fillLabelOff: color(0),
  1663. fillLabelOffHover: color(0),
  1664. fillLabelOffActive: color(0),
  1665. fillLabelOn: color(0),
  1666. fillLabelOnHover: color(0),
  1667. fillLabelOnActive: color(0),
  1668. strokeBgOff: color(0),
  1669. strokeBgOffHover: color(0),
  1670. strokeBgOffActive: color(0),
  1671. strokeBgOn: color(0),
  1672. strokeBgOnHover: color(0),
  1673. strokeBgOnActive: color(0)
  1674. }
  1675. this.checkbox = {
  1676. strokeWeight: 2,
  1677. rounding: 10,
  1678. fillBg: color(100),
  1679. fillBgHover: color(144),
  1680. fillBgActive: color(160),
  1681. fillCheck: color(200),
  1682. fillCheckHover: color(220),
  1683. fillCheckActive: color(240),
  1684. strokeBg: color(0)
  1685. }
  1686. this.slider = {
  1687. strokeWeight: 2,
  1688. rounding: 10,
  1689. trackWidth: 1,
  1690. fillBg: color(130),
  1691. fillBgHover: color(175),
  1692. fillBgActive: color(175),
  1693. fillTrack: color(100),
  1694. fillTrackHover: color(144),
  1695. fillTrackActive: color(144),
  1696. fillHandle: color(64),
  1697. fillHandleHover: color(96),
  1698. fillHandleActive: color(240),
  1699. strokeBg: color(0),
  1700. strokeBgHover: color(0),
  1701. strokeBgActive: color(0),
  1702. strokeTrack: color(100),
  1703. strokeTrackHover: color(144),
  1704. strokeTrackActive: color(144),
  1705. strokeHandle: color(64),
  1706. strokeHandleHover: color(0),
  1707. strokeHandleActive: color(0)
  1708. }
  1709. this.crossfader = {
  1710. strokeCenter: color(100),
  1711. strokeCenterHover: color(100),
  1712. strokeCenterActive: color(100)
  1713. }
  1714. this.slider2d = {
  1715. handleRadius: 16
  1716. }
  1717. this.joystick = {
  1718. handleRadius: 16
  1719. }
  1720. }
  1721. //
  1722. Rose() {
  1723. this.name = "Rose";
  1724. // Global pars
  1725. this.strokeWeight = 2;
  1726. this.rounding = 10;
  1727. this.font = 'Arial';
  1728. this.textSize = 20;
  1729. this.button = {
  1730. strokeWeight: 2,
  1731. rounding: 10,
  1732. font: 'Arial',
  1733. textSize: 20,
  1734. fillBg: color('#E57FBE'),
  1735. fillBgHover: color('#EFABD5'),
  1736. fillBgActive: color('#FFE6F4'),
  1737. fillLabel: color('#3F102F'),
  1738. fillLabelHover: color('#3F102F'),
  1739. fillLabelActive: color('#3F102F'),
  1740. strokeBg: color('#3F102F'),
  1741. strokeBgHover: color('#3F102F'),
  1742. strokeBgActive: color('#3F102F')
  1743. };
  1744. this.toggle = {
  1745. strokeWeight: 2,
  1746. rounding: 10,
  1747. font: 'Arial',
  1748. textSize: 20,
  1749. fillBgOff: color('#CC69AB'),
  1750. fillBgOffHover: color('#E288C4'),
  1751. fillBgOffActive: color('#FFF3FA'),
  1752. fillBgOn: color('#FFE6F4'),
  1753. fillBgOnHover: color('#FFF3FA'),
  1754. fillBgOnActive: color('#FAFAFA'),
  1755. fillLabelOff: color('#3F102F'),
  1756. fillLabelOffHover: color('#3F102F'),
  1757. fillLabelOffActive: color('#3F102F'),
  1758. fillLabelOn: color('#3F102F'),
  1759. fillLabelOnHover: color('#3F102F'),
  1760. fillLabelOnActive: color('#3F102F'),
  1761. strokeBgOff: color('#3F102F'),
  1762. strokeBgOffHover: color('#3F102F'),
  1763. strokeBgOffActive: color('#3F102F'),
  1764. strokeBgOn: color('#3F102F'),
  1765. strokeBgOnHover: color('#3F102F'),
  1766. strokeBgOnActive: color('#3F102F')
  1767. }
  1768. this.checkbox = {
  1769. strokeWeight: 2,
  1770. rounding: 10,
  1771. fillBg: color('#7F3663'),
  1772. fillBgHover: color('#C45093'),
  1773. fillBgActive: color('#E57FBE'),
  1774. fillCheck: color('#FFE6F4'),
  1775. fillCheckHover: color('#FFF3FA'),
  1776. fillCheckActive: color('#FAFAFA'),
  1777. strokeBg: color('#3F102F')
  1778. }
  1779. this.slider = {
  1780. strokeWeight: 2,
  1781. rounding: 10,
  1782. trackWidth: 1,
  1783. fillBg: color('#FFE6F4'),
  1784. fillBgHover: color('#FFE6F4'),
  1785. fillBgActive: color('#FFF3FA'),
  1786. fillTrack: color('#C45093'),
  1787. fillTrackHover: color('#CC66A6'),
  1788. fillTrackActive: color('#D877B4'),
  1789. fillHandle: color('#7F3663'),
  1790. fillHandleHover: color('#E57FBE'),
  1791. fillHandleActive: color('#FAFAFA'),
  1792. strokeBg: color('#3F102F'),
  1793. strokeBgHover: color('#3F102F'),
  1794. strokeBgActive: color('#3F102F'),
  1795. strokeTrack: color('#C45093'),
  1796. strokeTrackHover: color('#CC66A6'),
  1797. strokeTrackActive: color('#D877B4'),
  1798. strokeHandle: color('#3F102F'),
  1799. strokeHandleHover: color('#3F102F'),
  1800. strokeHandleActive: color('#3F102F')
  1801. }
  1802. this.crossfader = {
  1803. strokeCenter: color('#C45093'),
  1804. strokeCenterHover: color('#CC66A6'),
  1805. strokeCenterActive: color('#D877B4')
  1806. }
  1807. this.slider2d = {
  1808. handleRadius: 16
  1809. }
  1810. this.joystick = {
  1811. handleRadius: 16
  1812. }
  1813. }
  1814. //
  1815. Seafoam() {
  1816. this.name = "Seafoam";
  1817. // Global pars
  1818. this.strokeWeight = 2;
  1819. this.rounding = 10;
  1820. this.font = 'Arial';
  1821. this.textSize = 20;
  1822. this.button = {
  1823. strokeWeight: 2,
  1824. rounding: 10,
  1825. font: 'Arial',
  1826. textSize: 20,
  1827. fillBg: color('#7FE5BE'),
  1828. fillBgHover: color('#ABEFD5'),
  1829. fillBgActive: color('#E6FFF4'),
  1830. fillLabel: color('#103F2F'),
  1831. fillLabelHover: color('#103F2F'),
  1832. fillLabelActive: color('#103F2F'),
  1833. strokeBg: color('#103F2F'),
  1834. strokeBgHover: color('#103F2F'),
  1835. strokeBgActive: color('#103F2F')
  1836. };
  1837. this.toggle = {
  1838. strokeWeight: 2,
  1839. rounding: 10,
  1840. font: 'Arial',
  1841. textSize: 20,
  1842. fillBgOff: color('#69CCAB'),
  1843. fillBgOffHover: color('#88E2C4'),
  1844. fillBgOffActive: color('#F3FFFA'),
  1845. fillBgOn: color('#E6FFF4'),
  1846. fillBgOnHover: color('#F3FFFA'),
  1847. fillBgOnActive: color('#FAFAFA'),
  1848. fillLabelOff: color('#103F2F'),
  1849. fillLabelOffHover: color('#103F2F'),
  1850. fillLabelOffActive: color('#103F2F'),
  1851. fillLabelOn: color('#103F2F'),
  1852. fillLabelOnHover: color('#103F2F'),
  1853. fillLabelOnActive: color('#103F2F'),
  1854. strokeBgOff: color('#103F2F'),
  1855. strokeBgOffHover: color('#103F2F'),
  1856. strokeBgOffActive: color('#103F2F'),
  1857. strokeBgOn: color('#103F2F'),
  1858. strokeBgOnHover: color('#103F2F'),
  1859. strokeBgOnActive: color('#103F2F')
  1860. }
  1861. this.checkbox = {
  1862. strokeWeight: 2,
  1863. rounding: 10,
  1864. fillBg: color('#367F63'),
  1865. fillBgHover: color('#50C493'),
  1866. fillBgActive: color('#7FE5BE'),
  1867. fillCheck: color('#E6FFF4'),
  1868. fillCheckHover: color('#F3FFFA'),
  1869. fillCheckActive: color('#FAFAFA'),
  1870. strokeBg: color('#103F2F')
  1871. }
  1872. this.slider = {
  1873. strokeWeight: 2,
  1874. rounding: 10,
  1875. trackWidth: 1,
  1876. fillBg: color('#E6FFF4'),
  1877. fillBgHover: color('#E6FFF4'),
  1878. fillBgActive: color('#F3FFFA'),
  1879. fillTrack: color('#50C493'),
  1880. fillTrackHover: color('#66CCA6'),
  1881. fillTrackActive: color('#77D8B4'),
  1882. fillHandle: color('#367F63'),
  1883. fillHandleHover: color('#7FE5BE'),
  1884. fillHandleActive: color('#FAFAFA'),
  1885. strokeBg: color('#103F2F'),
  1886. strokeBgHover: color('#103F2F'),
  1887. strokeBgActive: color('#103F2F'),
  1888. strokeTrack: color('#50C493'),
  1889. strokeTrackHover: color('#66CCA6'),
  1890. strokeTrackActive: color('#77D8B4'),
  1891. strokeHandle: color('#103F2F'),
  1892. strokeHandleHover: color('#103F2F'),
  1893. strokeHandleActive: color('#103F2F')
  1894. }
  1895. this.crossfader = {
  1896. strokeCenter: color('#50C493'),
  1897. strokeCenterHover: color('#66CCA6'),
  1898. strokeCenterActive: color('#77D8B4')
  1899. }
  1900. this.slider2d = {
  1901. handleRadius: 16
  1902. }
  1903. this.joystick = {
  1904. handleRadius: 16
  1905. }
  1906. }
  1907. //
  1908. Blue() {
  1909. this.name = "Blue";
  1910. // Global pars
  1911. this.strokeWeight = 2;
  1912. this.rounding = 10;
  1913. this.font = 'Arial';
  1914. this.textSize = 20;
  1915. this.button = {
  1916. strokeWeight: 2,
  1917. rounding: 10,
  1918. font: 'Arial',
  1919. textSize: 20,
  1920. fillBg: color('#7FBEE5'),
  1921. fillBgHover: color('#ABD5EF'),
  1922. fillBgActive: color('#E6F4FF'),
  1923. fillLabel: color('#102F3F'),
  1924. fillLabelHover: color('#102F3F'),
  1925. fillLabelActive: color('#102F3F'),
  1926. strokeBg: color('#102F3F'),
  1927. strokeBgHover: color('#102F3F'),
  1928. strokeBgActive: color('#102F3F')
  1929. };
  1930. this.toggle = {
  1931. strokeWeight: 2,
  1932. rounding: 10,
  1933. font: 'Arial',
  1934. textSize: 20,
  1935. fillBgOff: color('#69ABCC'),
  1936. fillBgOffHover: color('#88C4E2'),
  1937. fillBgOffActive: color('#F3FAFF'),
  1938. fillBgOn: color('#E6F4FF'),
  1939. fillBgOnHover: color('#F3FAFF'),
  1940. fillBgOnActive: color('#FAFAFA'),
  1941. fillLabelOff: color('#102F3F'),
  1942. fillLabelOffHover: color('#102F3F'),
  1943. fillLabelOffActive: color('#102F3F'),
  1944. fillLabelOn: color('#102F3F'),
  1945. fillLabelOnHover: color('#102F3F'),
  1946. fillLabelOnActive: color('#102F3F'),
  1947. strokeBgOff: color('#102F3F'),
  1948. strokeBgOffHover: color('#102F3F'),
  1949. strokeBgOffActive: color('#102F3F'),
  1950. strokeBgOn: color('#102F3F'),
  1951. strokeBgOnHover: color('#102F3F'),
  1952. strokeBgOnActive: color('#102F3F')
  1953. }
  1954. this.checkbox = {
  1955. strokeWeight: 2,
  1956. rounding: 10,
  1957. fillBg: color('#36637F'),
  1958. fillBgHover: color('#5093C4'),
  1959. fillBgActive: color('#7FBEE5'),
  1960. fillCheck: color('#E6F4FF'),
  1961. fillCheckHover: color('#F3FAFF'),
  1962. fillCheckActive: color('#FAFAFA'),
  1963. strokeBg: color('#102F3F')
  1964. }
  1965. this.slider = {
  1966. strokeWeight: 2,
  1967. rounding: 10,
  1968. trackWidth: 1,
  1969. fillBg: color('#E6F4FF'),
  1970. fillBgHover: color('#E6F4FF'),
  1971. fillBgActive: color('#F3FAFF'),
  1972. fillTrack: color('#5093C4'),
  1973. fillTrackHover: color('#66A6CC'),
  1974. fillTrackActive: color('#77B4D8'),
  1975. fillHandle: color('#36637F'),
  1976. fillHandleHover: color('#7FBEE5'),
  1977. fillHandleActive: color('#FAFAFA'),
  1978. strokeBg: color('#102F3F'),
  1979. strokeBgHover: color('#102F3F'),
  1980. strokeBgActive: color('#102F3F'),
  1981. strokeTrack: color('#5093C4'),
  1982. strokeTrackHover: color('#66A6CC'),
  1983. strokeTrackActive: color('#77B4D8'),
  1984. strokeHandle: color('#102F3F'),
  1985. strokeHandleHover: color('#102F3F'),
  1986. strokeHandleActive: color('#102F3F')
  1987. }
  1988. this.crossfader = {
  1989. strokeCenter: color('#5093C4'),
  1990. strokeCenterHover: color('#66A6CC'),
  1991. strokeCenterActive: color('#77B4D8')
  1992. }
  1993. this.slider2d = {
  1994. handleRadius: 16
  1995. }
  1996. this.joystick = {
  1997. handleRadius: 16
  1998. }
  1999. }
  2000. //
  2001. TerminalGreen() {
  2002. this.name = "TerminalGreen";
  2003. // Global pars
  2004. this.strokeWeight = 2;
  2005. this.rounding = 10;
  2006. this.font = 'Arial';
  2007. this.textSize = 20;
  2008. this.button = {
  2009. strokeWeight: 2,
  2010. rounding: 10,
  2011. font: 'Arial',
  2012. textSize: 20,
  2013. fillBg: color('#000000'),
  2014. fillBgHover: color('#003000'),
  2015. fillBgActive: color('#00F200'),
  2016. fillLabel: color('#00FF00'),
  2017. fillLabelHover: color('#00FF00'),
  2018. fillLabelActive: color('#000000'),
  2019. strokeBg: color('#00FF00'),
  2020. strokeBgHover: color('#00FF00'),
  2021. strokeBgActive: color('#007F00')
  2022. };
  2023. this.toggle = {
  2024. strokeWeight: 2,
  2025. rounding: 10,
  2026. font: 'Arial',
  2027. textSize: 20,
  2028. fillBgOff: color('#000000'),
  2029. fillBgOffHover: color('#003000'),
  2030. fillBgOffActive: color('#00F200'),
  2031. fillBgOn: color('#00D800'),
  2032. fillBgOnHover: color('#00F200'),
  2033. fillBgOnActive: color('#00FF00'),
  2034. fillLabelOff: color('#00FF00'),
  2035. fillLabelOffHover: color('#00FF00'),
  2036. fillLabelOffActive: color('#000000'),
  2037. fillLabelOn: color('#000000'),
  2038. fillLabelOnHover: color('#000000'),
  2039. fillLabelOnActive: color('#000000'),
  2040. strokeBgOff: color('#00FF00'),
  2041. strokeBgOffHover: color('#00FF00'),
  2042. strokeBgOffActive: color('#007F00'),
  2043. strokeBgOn: color('#007F00'),
  2044. strokeBgOnHover: color('#007F00'),
  2045. strokeBgOnActive: color('#007F00')
  2046. }
  2047. this.checkbox = {
  2048. strokeWeight: 2,
  2049. rounding: 10,
  2050. fillBg: color('#000000'),
  2051. fillBgHover: color('#003000'),
  2052. fillBgActive: color('#007F00'),
  2053. fillCheck: color('#00D800'),
  2054. fillCheckHover: color('#00F200'),
  2055. fillCheckActive: color('#00FF00'),
  2056. strokeBg: color('#00FF00')
  2057. }
  2058. this.slider = {
  2059. strokeWeight: 2,
  2060. rounding: 10,
  2061. trackWidth: 1,
  2062. fillBg: color('#000000'),
  2063. fillBgHover: color('#003000'),
  2064. fillBgActive: color('#005000'),
  2065. fillTrack: color('#007F00'),
  2066. fillTrackHover: color('#008F00'),
  2067. fillTrackActive: color('#00AC00'),
  2068. fillHandle: color('#000000'),
  2069. fillHandleHover: color('#006000'),
  2070. fillHandleActive: color('#00FF00'),
  2071. strokeBg: color('#00FF00'),
  2072. strokeBgHover: color('#00FF00'),
  2073. strokeBgActive: color('#00FF00'),
  2074. strokeTrack: color('#007F00'),
  2075. strokeTrackHover: color('#008F00'),
  2076. strokeTrackActive: color('#00AC00'),
  2077. strokeHandle: color('#00FF00'),
  2078. strokeHandleHover: color('#00FF00'),
  2079. strokeHandleActive: color('#00FF00')
  2080. }
  2081. this.crossfader = {
  2082. strokeCenter: color('#007F00'),
  2083. strokeCenterHover: color('#007F00'),
  2084. strokeCenterActive: color('#007F00')
  2085. }
  2086. this.slider2d = {
  2087. handleRadius: 16
  2088. }
  2089. this.joystick = {
  2090. handleRadius: 16
  2091. }
  2092. }
  2093. //
  2094. TerminalRed() {
  2095. this.name = "TerminalRed";
  2096. // Global pars
  2097. this.strokeWeight = 2;
  2098. this.rounding = 10;
  2099. this.font = 'Arial';
  2100. this.textSize = 20;
  2101. this.button = {
  2102. strokeWeight: 2,
  2103. rounding: 10,
  2104. font: 'Arial',
  2105. textSize: 20,
  2106. fillBg: color('#000000'),
  2107. fillBgHover: color('#300000'),
  2108. fillBgActive: color('#F20000'),
  2109. fillLabel: color('#FF0000'),
  2110. fillLabelHover: color('#FF0000'),
  2111. fillLabelActive: color('#000000'),
  2112. strokeBg: color('#FF0000'),
  2113. strokeBgHover: color('#FF0000'),
  2114. strokeBgActive: color('#7F0000')
  2115. };
  2116. this.toggle = {
  2117. strokeWeight: 2,
  2118. rounding: 10,
  2119. font: 'Arial',
  2120. textSize: 20,
  2121. fillBgOff: color('#000000'),
  2122. fillBgOffHover: color('#300000'),
  2123. fillBgOffActive: color('#F20000'),
  2124. fillBgOn: color('#D80000'),
  2125. fillBgOnHover: color('#F20000'),
  2126. fillBgOnActive: color('#FF0000'),
  2127. fillLabelOff: color('#FF0000'),
  2128. fillLabelOffHover: color('#FF0000'),
  2129. fillLabelOffActive: color('#000000'),
  2130. fillLabelOn: color('#000000'),
  2131. fillLabelOnHover: color('#000000'),
  2132. fillLabelOnActive: color('#000000'),
  2133. strokeBgOff: color('#FF0000'),
  2134. strokeBgOffHover: color('#FF0000'),
  2135. strokeBgOffActive: color('#7F0000'),
  2136. strokeBgOn: color('#7F0000'),
  2137. strokeBgOnHover: color('#7F0000'),
  2138. strokeBgOnActive: color('#7F0000')
  2139. }
  2140. this.checkbox = {
  2141. strokeWeight: 2,
  2142. rounding: 10,
  2143. fillBg: color('#000000'),
  2144. fillBgHover: color('#300000'),
  2145. fillBgActive: color('#7F0000'),
  2146. fillCheck: color('#D80000'),
  2147. fillCheckHover: color('#F20000'),
  2148. fillCheckActive: color('#FF0000'),
  2149. strokeBg: color('#FF0000')
  2150. }
  2151. this.slider = {
  2152. strokeWeight: 2,
  2153. rounding: 10,
  2154. trackWidth: 1,
  2155. fillBg: color('#000000'),
  2156. fillBgHover: color('#300000'),
  2157. fillBgActive: color('#500000'),
  2158. fillTrack: color('#7F0000'),
  2159. fillTrackHover: color('#8F0000'),
  2160. fillTrackActive: color('#AC0000'),
  2161. fillHandle: color('#000000'),
  2162. fillHandleHover: color('#600000'),
  2163. fillHandleActive: color('#FF0000'),
  2164. strokeBg: color('#FF0000'),
  2165. strokeBgHover: color('#FF0000'),
  2166. strokeBgActive: color('#FF0000'),
  2167. strokeTrack: color('#7F0000'),
  2168. strokeTrackHover: color('#8F0000'),
  2169. strokeTrackActive: color('#AC0000'),
  2170. strokeHandle: color('#FF0000'),
  2171. strokeHandleHover: color('#FF0000'),
  2172. strokeHandleActive: color('#FF0000')
  2173. }
  2174. this.crossfader = {
  2175. strokeCenter: color('#7F0000'),
  2176. strokeCenterHover: color('#7F0000'),
  2177. strokeCenterActive: color('#7F0000')
  2178. }
  2179. this.slider2d = {
  2180. handleRadius: 16
  2181. }
  2182. this.joystick = {
  2183. handleRadius: 16
  2184. }
  2185. }
  2186. //
  2187. TerminalBlue() {
  2188. this.name = "TerminalBlue";
  2189. // Global pars
  2190. this.strokeWeight = 2;
  2191. this.rounding = 10;
  2192. this.font = 'Arial';
  2193. this.textSize = 20;
  2194. this.button = {
  2195. strokeWeight: 2,
  2196. rounding: 10,
  2197. font: 'Arial',
  2198. textSize: 20,
  2199. fillBg: color('#000000'),
  2200. fillBgHover: color('#000030'),
  2201. fillBgActive: color('#4040F2'),
  2202. fillLabel: color('#4040FF'),
  2203. fillLabelHover: color('#4040FF'),
  2204. fillLabelActive: color('#000000'),
  2205. strokeBg: color('#4040FF'),
  2206. strokeBgHover: color('#4040FF'),
  2207. strokeBgActive: color('#40407F')
  2208. };
  2209. this.toggle = {
  2210. strokeWeight: 2,
  2211. rounding: 10,
  2212. font: 'Arial',
  2213. textSize: 20,
  2214. fillBgOff: color('#000000'),
  2215. fillBgOffHover: color('#000030'),
  2216. fillBgOffActive: color('#4040F2'),
  2217. fillBgOn: color('#4040D8'),
  2218. fillBgOnHover: color('#4040F2'),
  2219. fillBgOnActive: color('#4040FF'),
  2220. fillLabelOff: color('#4040FF'),
  2221. fillLabelOffHover: color('#4040FF'),
  2222. fillLabelOffActive: color('#000000'),
  2223. fillLabelOn: color('#000000'),
  2224. fillLabelOnHover: color('#000000'),
  2225. fillLabelOnActive: color('#000000'),
  2226. strokeBgOff: color('#4040FF'),
  2227. strokeBgOffHover: color('#4040FF'),
  2228. strokeBgOffActive: color('#40407F'),
  2229. strokeBgOn: color('#40407F'),
  2230. strokeBgOnHover: color('#40407F'),
  2231. strokeBgOnActive: color('#40407F')
  2232. }
  2233. this.checkbox = {
  2234. strokeWeight: 2,
  2235. rounding: 10,
  2236. fillBg: color('#000000'),
  2237. fillBgHover: color('#000030'),
  2238. fillBgActive: color('#40407F'),
  2239. fillCheck: color('#4040D8'),
  2240. fillCheckHover: color('#4040F2'),
  2241. fillCheckActive: color('#4040FF'),
  2242. strokeBg: color('#4040FF')
  2243. }
  2244. this.slider = {
  2245. strokeWeight: 2,
  2246. rounding: 10,
  2247. trackWidth: 1,
  2248. fillBg: color('#000000'),
  2249. fillBgHover: color('#000030'),
  2250. fillBgActive: color('#000050'),
  2251. fillTrack: color('#20207F'),
  2252. fillTrackHover: color('#20208F'),
  2253. fillTrackActive: color('#2020AC'),
  2254. fillHandle: color('#000000'),
  2255. fillHandleHover: color('#000060'),
  2256. fillHandleActive: color('#4040FF'),
  2257. strokeBg: color('#4040FF'),
  2258. strokeBgHover: color('#4040FF'),
  2259. strokeBgActive: color('#4040FF'),
  2260. strokeTrack: color('#20207F'),
  2261. strokeTrackHover: color('#20208F'),
  2262. strokeTrackActive: color('#2020AC'),
  2263. strokeHandle: color('#4040FF'),
  2264. strokeHandleHover: color('#4040FF'),
  2265. strokeHandleActive: color('#4040FF')
  2266. }
  2267. this.crossfader = {
  2268. strokeCenter: color('#40407F'),
  2269. strokeCenterHover: color('#40407F'),
  2270. strokeCenterActive: color('#40407F')
  2271. }
  2272. this.slider2d = {
  2273. handleRadius: 16
  2274. }
  2275. this.joystick = {
  2276. handleRadius: 16
  2277. }
  2278. }
  2279. //
  2280. TerminalYellow() {
  2281. this.name = "TerminalYellow";
  2282. // Global pars
  2283. this.strokeWeight = 2;
  2284. this.rounding = 10;
  2285. this.font = 'Arial';
  2286. this.textSize = 20;
  2287. this.button = {
  2288. strokeWeight: 2,
  2289. rounding: 10,
  2290. font: 'Arial',
  2291. textSize: 20,
  2292. fillBg: color('#000000'),
  2293. fillBgHover: color('#303000'),
  2294. fillBgActive: color('#F2F200'),
  2295. fillLabel: color('#FFFF00'),
  2296. fillLabelHover: color('#FFFF00'),
  2297. fillLabelActive: color('#000000'),
  2298. strokeBg: color('#FFFF00'),
  2299. strokeBgHover: color('#FFFF00'),
  2300. strokeBgActive: color('#7F7F00')
  2301. };
  2302. this.toggle = {
  2303. strokeWeight: 2,
  2304. rounding: 10,
  2305. font: 'Arial',
  2306. textSize: 20,
  2307. fillBgOff: color('#000000'),
  2308. fillBgOffHover: color('#303000'),
  2309. fillBgOffActive: color('#F2F200'),
  2310. fillBgOn: color('#D8D800'),
  2311. fillBgOnHover: color('#F2F200'),
  2312. fillBgOnActive: color('#FFFF00'),
  2313. fillLabelOff: color('#FFFF00'),
  2314. fillLabelOffHover: color('#FFFF00'),
  2315. fillLabelOffActive: color('#000000'),
  2316. fillLabelOn: color('#000000'),
  2317. fillLabelOnHover: color('#000000'),
  2318. fillLabelOnActive: color('#000000'),
  2319. strokeBgOff: color('#FFFF00'),
  2320. strokeBgOffHover: color('#FFFF00'),
  2321. strokeBgOffActive: color('#7F7F00'),
  2322. strokeBgOn: color('#7F7F00'),
  2323. strokeBgOnHover: color('#7F7F00'),
  2324. strokeBgOnActive: color('#7F7F00')
  2325. }
  2326. this.checkbox = {
  2327. strokeWeight: 2,
  2328. rounding: 10,
  2329. fillBg: color('#000000'),
  2330. fillBgHover: color('#303000'),
  2331. fillBgActive: color('#7F7F00'),
  2332. fillCheck: color('#D8D800'),
  2333. fillCheckHover: color('#F2F200'),
  2334. fillCheckActive: color('#FFFF00'),
  2335. strokeBg: color('#FFFF00')
  2336. }
  2337. this.slider = {
  2338. strokeWeight: 2,
  2339. rounding: 10,
  2340. trackWidth: 1,
  2341. fillBg: color('#000000'),
  2342. fillBgHover: color('#303000'),
  2343. fillBgActive: color('#505000'),
  2344. fillTrack: color('#7F7F00'),
  2345. fillTrackHover: color('#8F8F00'),
  2346. fillTrackActive: color('#ACAC00'),
  2347. fillHandle: color('#000000'),
  2348. fillHandleHover: color('#606000'),
  2349. fillHandleActive: color('#FFFF00'),
  2350. strokeBg: color('#FFFF00'),
  2351. strokeBgHover: color('#FFFF00'),
  2352. strokeBgActive: color('#FFFF00'),
  2353. strokeTrack: color('#7F7F00'),
  2354. strokeTrackHover: color('#8F8F00'),
  2355. strokeTrackActive: color('#ACAC00'),
  2356. strokeHandle: color('#FFFF00'),
  2357. strokeHandleHover: color('#FFFF00'),
  2358. strokeHandleActive: color('#FFFF00')
  2359. }
  2360. this.crossfader = {
  2361. strokeCenter: color('#7F7F00'),
  2362. strokeCenterHover: color('#7F7F00'),
  2363. strokeCenterActive: color('#7F7F00')
  2364. }
  2365. this.slider2d = {
  2366. handleRadius: 16
  2367. }
  2368. this.joystick = {
  2369. handleRadius: 16
  2370. }
  2371. }
  2372. //
  2373. TerminalMagenta() {
  2374. this.name = "TerminalMagenta";
  2375. // Global pars
  2376. this.strokeWeight = 2;
  2377. this.rounding = 10;
  2378. this.font = 'Arial';
  2379. this.textSize = 20;
  2380. this.button = {
  2381. strokeWeight: 2,
  2382. rounding: 10,
  2383. font: 'Arial',
  2384. textSize: 20,
  2385. fillBg: color('#000000'),
  2386. fillBgHover: color('#300030'),
  2387. fillBgActive: color('#F200F2'),
  2388. fillLabel: color('#FF00FF'),
  2389. fillLabelHover: color('#FF00FF'),
  2390. fillLabelActive: color('#000000'),
  2391. strokeBg: color('#FF00FF'),
  2392. strokeBgHover: color('#FF00FF'),
  2393. strokeBgActive: color('#7F007F')
  2394. };
  2395. this.toggle = {
  2396. strokeWeight: 2,
  2397. rounding: 10,
  2398. font: 'Arial',
  2399. textSize: 20,
  2400. fillBgOff: color('#000000'),
  2401. fillBgOffHover: color('#300030'),
  2402. fillBgOffActive: color('#F200F2'),
  2403. fillBgOn: color('#D800D8'),
  2404. fillBgOnHover: color('#F200F2'),
  2405. fillBgOnActive: color('#FF00FF'),
  2406. fillLabelOff: color('#FF00FF'),
  2407. fillLabelOffHover: color('#FF00FF'),
  2408. fillLabelOffActive: color('#000000'),
  2409. fillLabelOn: color('#000000'),
  2410. fillLabelOnHover: color('#000000'),
  2411. fillLabelOnActive: color('#000000'),
  2412. strokeBgOff: color('#FF00FF'),
  2413. strokeBgOffHover: color('#FF00FF'),
  2414. strokeBgOffActive: color('#7F007F'),
  2415. strokeBgOn: color('#7F007F'),
  2416. strokeBgOnHover: color('#7F007F'),
  2417. strokeBgOnActive: color('#7F007F')
  2418. }
  2419. this.checkbox = {
  2420. strokeWeight: 2,
  2421. rounding: 10,
  2422. fillBg: color('#000000'),
  2423. fillBgHover: color('#300030'),
  2424. fillBgActive: color('#7F007F'),
  2425. fillCheck: color('#D800D8'),
  2426. fillCheckHover: color('#F200F2'),
  2427. fillCheckActive: color('#FF00FF'),
  2428. strokeBg: color('#FF00FF')
  2429. }
  2430. this.slider = {
  2431. strokeWeight: 2,
  2432. rounding: 10,
  2433. trackWidth: 1,
  2434. fillBg: color('#000000'),
  2435. fillBgHover: color('#300030'),
  2436. fillBgActive: color('#500050'),
  2437. fillTrack: color('#7F007F'),
  2438. fillTrackHover: color('#8F008F'),
  2439. fillTrackActive: color('#AC00AC'),
  2440. fillHandle: color('#000000'),
  2441. fillHandleHover: color('#600060'),
  2442. fillHandleActive: color('#FF00FF'),
  2443. strokeBg: color('#FF00FF'),
  2444. strokeBgHover: color('#FF00FF'),
  2445. strokeBgActive: color('#FF00FF'),
  2446. strokeTrack: color('#7F007F'),
  2447. strokeTrackHover: color('#8F008F'),
  2448. strokeTrackActive: color('#AC00AC'),
  2449. strokeHandle: color('#FF00FF'),
  2450. strokeHandleHover: color('#FF00FF'),
  2451. strokeHandleActive: color('#FF00FF')
  2452. }
  2453. this.crossfader = {
  2454. strokeCenter: color('#7F007F'),
  2455. strokeCenterHover: color('#7F007F'),
  2456. strokeCenterActive: color('#7F007F')
  2457. }
  2458. this.slider2d = {
  2459. handleRadius: 16
  2460. }
  2461. this.joystick = {
  2462. handleRadius: 16
  2463. }
  2464. }
  2465. }