local gui = require 'src.gui' local wins = { {x = 64, y = 64, w = 64, h = 64}, } local bw, th = 8, 16 function gui.draw() draw:color(0, 100, 150) :rect(FILL, 0, 0, gui.w, gui.h) :color(255, 255, 255) :text('This is a demo of GUI in ErDOS', gui.w / 4, gui.h / 2) for i = #wins, 1, -1 do local v = wins[i] draw :color(100, 100, 100) :rrect(FILL, v.x - bw, v.y - bw - th, v.w + bw * 2, v.h + bw * 2 + th, {bw} ) :color(255, 255, 255) :rect(FILL, v.x, v.y, v.w, v.h) end end function AABB(x1, y1, w1, h1, x2, y2, w2, h2) return x1 + w1 > x2 and x2 + w2 > x1 and y1 + h1 > y2 and y2 + h2 > y1 end function gui.update(dt) updM() for i = 1, #wins do local v = wins[i] if AABB(m.x, m.y, 0, 0, v.x - bw, v.y - bw - th, v.w + bw * 2, v.h + bw * 2 + th ) then gui.stop() end end end return function(w, h) gui.init() gui.w, gui.h = w or gui.w or 0, h or gui.h or 0 end