ÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÀ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌÀ¬ÀÀÀ¬ÀÀÀ¬ÀÀÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÌ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌ̬ÀÀÀ¬ÀÀÀ¬ÀÀ¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî Á>??;??????????????????????????=?????????????????????????????4 X>ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ ÐÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-""""""""""""""""""""""""ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""""Ò""""""""""""""""""Òÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""""""ÂÌ"ÿÿÿÿÿÿÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""ÌÌÂ,"Â,"""Ì""""""""""Òÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""""""Ì",ÌÌÿÏÌÿÌÿÿÌüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""Â,ÂÌ,""ÌÌ"Ì",ÌÌ"ÂÌ"ÂÌÜÏÌüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""""""Ì",ÌÿüüÏüÌÿÏüÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""Â,Â,ÂÂ,Ì",ÌÌ"Ì",ÌÂ,Ì,ÒÌüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""""""ÌÌ,ÌÿüÌÌüÌÿÏÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""Â,Â,ÂÂ,Ì",Ì",Ì",Ì,""ÌÜÿÌüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""""""Ì",ÌÿüÿÏüÏÌÿÌüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""Â,Â,ÂÂ,Ì",Ì",Ì",ÂÌ"ÌÌÒÌÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-""""""""""""""""""""""""ÿÿÿÏÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""""Ò""""""""""""""""""Òÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-""""""""""""""""""""""""ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ð""""""""""""""""""Ò""""""""""""""""""ÒÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ ÐÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-ÂÌ,Ì""Ì""""""""""" -ÂÌ""""Ì"""""""Ò-Ì,"""ÌÌ"Ì,"""""""" -Ì",ÂÌ"Ì""Ì,ÂÌ,Ò-ÂÌ"ÌÂ"ÌÂ,Ì"""""""" -Ì""Ì",Ì"Â,ÂÂ,ÂÒ-"Ì,ÌÂ"ÌÂÌ""""""""" -Ì",Ì",Ì"Â,ÂÂ,"Ò-ÌÌ"Ì"ÌÌ"Ì,"""""""" ÝÍÌÝÍÌÝÍÌÝÌÜÍÜÝÝ-"""""""""""""""""" -""""""""""""""Ò-Ì"""""""""""Â,"Ì"" -""""""""""""""Ò-Ì""ÂÌ"ÌÌ"ÂÌ"ÌÌ,ÌÌ" -""""""""""""""Ò-Ì""ÌÂ,Ì",,Â,Â,"Ì", -""""""""""""""Ò-Ì""Ì,"Ì",ÌÌ,Â,"Ì", -""""""""""""""Ò-ÌÌ,ÂÌ"Ì","Â,"Ì,Ì", -""""""""""""""Ò-"""""""""ÂÌ""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" °» -""""""""""""""Ò-"""""""""""""""""" »»»-""""""""""""""Ò-"""""""""""""""""" »»» -""""""""""""""Ò-"""""""""""""""""" »»»»-""""""""""""""Ò-"""""""""""""""""" °»»» ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»-""""""""""""""Ò-"""""""""""""""""" °»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» -""""""""""""""Ò-"""""""""""""""""" »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" °»»»»-""""""""""""""Ò-"""""""""""""""""" »»»» -""""""""""""""Ò-"""""""""""""""""" °»»» -""""""""""""""Ò-"""""""""""""""""" »»»»-""""""""""""""Ò-"""""""""""""""""" »»» -""""""""""""""Ò-"""""""""""""""""" »»»-""""""""""""""Ò-"""""""""""""""""" °» ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" -""""""""""""""Ò-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿß-"""""""""""""""""" ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÍÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÍÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÍÌÀ ÀÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ À ÀÌÌÌÌÌÌÌÜÍÌ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÀÌÌÌÌÌÌÌÌÌÌÌÌÌ ÀÌÌÌÌÌÌÜÍ À ÀÌ ÀÌÀÌÀÌÌÌ Ì À ÌÌ ÀÌÀÌÌÌÀÌÌÀ ÀÜÍÌÌÀÌ ÀÌ Ì ÌÌÌ ÌÌ ÀÌÌÌ Ì ÀÌ ÌÌ ÌÌÜÍ ÀÌ À Ì À Ì ÀÌÌ ÌÌÌ Ì À ÌÌÌÌ À À Ì À ÀÌ À À ÜÍÌÌÌÌÀÀ ÀÌÀÀ À ÀÌÌ ÀÌÀÀ ÀÌÌÌÀÌÀÀÌÌÌ ÀÌÀÌÀÜÍ À À Ì À ÌÌÌÌ ÌÌ Ì ÀÌÌÌÌÌ À À Ì À ÀÌ À À ÜÍÌÌÀÌÀÀ ÀÌÀÀÀÌÌÌÀÌÌÀÀ ÀÌÌÌÀÌÀÌÀÌÌ ÀÌÀÌÀÜÍÌÀ À Ì À ÌÌÌÀÌÌ ÀÌ Ì ÀÌÌ ÌÌ ÀÌÀ À ÀÌÀÌÀ À ÜÍÌ ÌÌÀ ÀÌÀÌ À ÌÌÌ ÌÌÀ ÀÌÌÌ ÌÌÌ À ÌÌÀÜÍÌÌÌÌÌÌÌÌÌÌÌÌÌÀÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÀÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÍÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÍÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÍÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÜÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝݵ)-- title: EasyUI -- author: Sava -- desc: A library for simple GUI! (documentation included) -- license: MIT License -- version: 0.1 -- script: lua -------------- START OF LIBRARY -------------- function newSlider(x, y, w, h, colBack, colFill, colBorder, text, textCol, min, max, cur, snap, showSnap, snapCol, snapHook, hoverHook) return {x=x, y=y, w=w, h=h, colBack=colBack, colFill=colFill, colBorder=colBorder, text=text, textSize=print(text, -1000, -1000), textCol=textCol, holding=false, snap=snap, showSnap=showSnap, snapCol=snapCol, snapHook=snapHook, leftp=false, leftr=false, hovering=false, hoverHook=hoverHook, val=cur, max=max, min=min, update=function(self) local mx, my, left = mouse() self.leftp = false if left and not self.leftr then self.leftr = true self.leftp = true end if not left and self.leftr then self.leftr = false self.holding = false end if mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h and not self.hovering then self.hovering = true if self.hoverHook then self.hoverHook() end end if not (mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h) and self.hovering then self.hovering = false end if (self.leftp and self.hovering) or self.holding then self.holding = true local prevVal = self.val self.val = math.min(math.max((mx-self.x-1)/(self.w-2), 0), 1)*(self.max-self.min)+self.min if self.snap ~= 0 then self.val = math.floor(self.val/self.snap+0.5)*self.snap if self.val ~= prevVal and self.snapHook then self.snapHook() end end end end, draw=function(self) rect(self.x, self.y, self.w, self.h, self.colBack) rect(self.x+1, self.y, (self.w-1)*((self.val-self.min)/(self.max-self.min)), self.h, self.colFill) if self.snap ~= 0 and self.showSnap then for i=self.min, self.max, self.snap do line(self.x+(self.w-1)*((i-self.min)/(self.max-self.min)), self.y, self.x+(self.w-1)*((i-self.min)/(self.max-self.min)), self.y+self.h-1, self.snapCol) end end rectb(self.x, self.y, self.w, self.h, self.colBorder) print(self.text, self.x-self.textSize/2+self.w/2+1, self.y+2, self.textCol) end} end function newVertSlider(x, y, w, h, colBack, colFill, colBorder, text, textCol, min, max, cur, snap, showSnap, snapCol, snapHook, hoverHook) return {x=x, y=y, w=w, h=h, colBack=colBack, colFill=colFill, colBorder=colBorder, text=text, textSize=print(text, -1000, -1000), textCol=textCol, holding=false, snap=snap, showSnap=showSnap, snapCol=snapCol, snapHook=snapHook, leftp=false, leftr=false, hovering=false, hoverHook=hoverHook, val=cur, max=max, min=min, update=function(self) local mx, my, left = mouse() self.leftp = false if left and not self.leftr then self.leftr = true self.leftp = true end if not left and self.leftr then self.leftr = false self.holding = false end if mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h and not self.hovering then self.hovering = true if self.hoverHook then self.hoverHook() end end if not (mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h) and self.hovering then self.hovering = false end if (self.leftp and self.hovering) or self.holding then self.holding = true local prevVal = self.val self.val = math.min(math.max((my-self.y-1)/(self.h-2), 0), 1)*(self.max-self.min)+self.min if self.snap ~= 0 then self.val = math.floor(self.val/self.snap+0.5)*self.snap if self.val ~= prevVal and self.snapHook then self.snapHook() end end end end, draw=function(self) rect(self.x, self.y, self.w, self.h, self.colBack) rect(self.x, self.y+1, self.w, (self.h-1)*((self.val-self.min)/(self.max-self.min)), self.colFill) if self.snap ~= 0 and self.showSnap then for i=self.min, self.max, self.snap do line(self.x, self.y+(self.h-1)*((i-self.min)/(self.max-self.min)), self.x+self.w-1, self.y+(self.h-1)*((i-self.min)/(self.max-self.min)), self.snapCol) end end rectb(self.x, self.y, self.w, self.h, self.colBorder) print(self.text, self.x-self.textSize/2+self.w/2+1, self.y+2, self.textCol) end} end function newButton(x, y, w, h, colBack, colFill, colBorder, text, textCol, hook, holdable, toggle, hoverHook) return {x=x, y=y, w=w, h=h, colBack=colBack, colFill=colFill, colBorder=colBorder, text=text, textSize=print(text, -1000, -1000), textCol=textCol, holdable=holdable, toggle=toggle, holding=false, pressed=false, hovering=false, hoverHook=hoverHook, leftp=false, leftr=false, hook=hook, update=function(self) local mx, my, left = mouse() self.leftp = false self.pressed = false if left and not self.leftr then self.leftr = true self.leftp = true end if not left and self.leftr then self.leftr = false if not self.toggle then self.holding = false end end if mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h and not self.hovering then self.hovering = true if self.hoverHook then self.hoverHook() end end if not (mx >= self.x and mx < self.x+self.w and my > self.y and my < self.y+self.h) and self.hovering then self.hovering = false end if self.leftp and self.hovering then self.pressed = true if self.holdable and not self.toggle then self.holding = true end if self.toggle then self.holding = not self.holding end self.hook() end if self.holding then self.pressed = true end end, draw=function(self) rect(self.x, self.y, self.w, self.h, self.pressed and self.colFill or self.colBack) rectb(self.x, self.y, self.w, self.h, self.colBorder) print(self.text, self.x-self.textSize/2+self.w/2+1, self.y+2, self.textCol) end} end -------------- END OF LIBRARY -------------- -- DOCUMENTATION -- This library includes: -- 2 slider creation functions -- 1 button creation function -- Sliders: -- There're 2 slider functions: -- newSlider and newVertSlider -- for horizontal and vertical sliders -- They have the same arguments -- newSlider creates a horisontally controlled slider -- with example arguments being: newSlider( 110, -- x position 5, -- y position 100, -- width 10, -- height 15, -- color of the empty area (shows output) 2, -- color of the filled area (shows output) 13, -- color of the border "test", -- text 12, -- color of the text 0, -- minimum output 10, -- maximum output 5, -- starting position 1, -- snap regulator true, -- show snap locations 13, -- snap location color (if shown) function() sfx(1) end, -- snap function function() sfx(2) end -- hover function ) -- The output snaps to the closest multiple of the regulator -- For example: -- Raw output: 3.2 -- Regulator: 2 -- Actual output: 4 -- The regulator basically sets the max distance of a snap -- 0 being no snaps -- So, if the regulator is set to 1 then it'll snap to every integer -- Snap function activates on snaps -- Hover function activates on hover -- pretty simple -- Since both slider functions have -- the same output I won't explain both -- Button: -- The function newButton has these arguments: newButton( 50, -- x position 20, -- y position 80, -- width 16, -- height 12, -- unpressed color 2, -- pressed color 13, -- border color "test", -- text 0, -- text color function() sfx(0) end, -- hook function true, -- holdable/clickable false, -- toggle function() sfx(2) end -- hover function ) -- The hook executes once when you click the button -- Holdable/clickable toggle determines -- if the button can be held down for more than 1 frame -- false = 1 frame max -- true = no cap -- Hover function activates on hover -- Quick reference: -- newSlider(x, y, width, height, emptyColor, fillColor, borderColor, text, textColor, min, max, start, snap, showSnap, snapColor, snapHook) -- newButton(x, y, width, height, emptyColor, fillColor, borderColor, text, textColor, hook, holdable, toggle) -- P.S. The text gets centered on the UI elements automatically -- but only horizontally w=240 h=136 function thinkLine(startX, startY, endX, endY, thinkness, col) for i=0, (startX+startY)*3 do local t = i/((startX+startY)*3) local x, y = startX+(endX-startX)*t, startY+(endY-startY)*t circ(x+0.5, y+0.5, thinkness, col) end end function arrow(startX, startY, endX, endY, angle, sideLen, thinkness, col) thinkLine(startX, startY, endX, endY, thinkness, col) local rotX, rotY = rotate2D(startX-endX, startY-endY, math.rad(angle)) local dist = math.max(math.sqrt(rotX*rotX+rotY*rotY), 1) rotX, rotY = rotX/dist, rotY/dist thinkLine(endX, endY, endX+rotX*sideLen, endY+rotY*sideLen, thinkness, col) rotX, rotY = rotate2D(startX-endX, startY-endY, -math.rad(angle)) rotX, rotY = rotX/dist, rotY/dist thinkLine(endX, endY, endX+rotX*sideLen, endY+rotY*sideLen, thinkness, col) end function rotate2D(x, y, ang) return x*math.cos(ang)-y*math.sin(ang), x*math.sin(ang)+y*math.cos(ang) end arrowStartX, arrowStartY = w/2, h/2 arrowEndX, arrowEndY = w/2+20, h/2 changeStartPosButton = newButton(0, 123, 120, 10, 12, 2, 13, "Change start position", 0, function() sfx(0) end, true, false, function() sfx(2) end) changeEndPosButton = newButton(130, 123, 110, 10, 12, 2, 13, "Change end position", 0, function() sfx(0) end, true, false, function() sfx(2) end) thinknessSlider = newSlider(125, 0, 115, 10, 15, 2, 13, "Thinkness", 12, 0, 3, 1, 1, true, 13, function() sfx(1) end, function() sfx(2) end) angleSlider=newSlider(0, 0, 115, 10, 15, 2, 13, "Angle", 12, 0, 90, 45, 0, false, 0, nil, function() sfx(2) end) sideLenSlider=newVertSlider(0, 15, 39, 100, 15, 2, 13, "Side\nLength", 12, 0, 20, 5, 0, false, 0, nil, function() sfx(2) end) colorSlider=newVertSlider(208, 15, 32, 100, 15, 2, 13, "Color", 12, 0, 15, 5, 1, true, 13, function() sfx(1) end, function() sfx(2) end) function TIC() cls(0) angleSlider:update() sideLenSlider:update() thinknessSlider:update() changeStartPosButton:update() changeEndPosButton:update() colorSlider:update() angleSlider:draw() sideLenSlider:draw() thinknessSlider:draw() changeStartPosButton:draw() changeEndPosButton:draw() colorSlider:draw() local mx, my = mouse() if changeStartPosButton.pressed then arrowStartX = mx arrowStartY = my end if changeEndPosButton.pressed then arrowEndX = mx arrowEndY = my end arrow(arrowStartX, arrowStartY, arrowEndX, arrowEndY, angleSlider.val, sideLenSlider.val, thinknessSlider.val, colorSlider.val) end