Created
December 13, 2015 16:02
-
-
Save nielsvanvelzen/236a43c207a0d96f0ae7 to your computer and use it in GitHub Desktop.
interface_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local width = 1600 | |
local height = 900 | |
-- Create window & show loading message | |
window.create(width, height, "Interface test") | |
canvas.init() | |
canvas.beginFrame(width, height, 1.0) | |
canvas.createFont("Open Sans", "test/font/OpenSans-Regular.ttf") | |
canvas.fontFace("Open Sans") | |
canvas.fontSize(24) | |
canvas.fillColor(canvas.color(255, 255, 255, 255)) | |
canvas.text(0, 0, "Loading...") | |
canvas.endFrame(); | |
window.update() | |
-- Load resources | |
local background = canvas.color(135, 206, 250, 255) | |
local logo = {} | |
logo.image = canvas.createImage("editor/texture/test.png") | |
logo.width, logo.height = canvas.imageSize(logo.image) | |
logo.paint = canvas.imagePattern((width - logo.width / 2) / 2, 100, logo.width / 2, logo.height / 2, 0, logo.image, 1) | |
utils.sleep(5) | |
while not window.shouldClose() do | |
window.update() | |
canvas.beginFrame(width, height, 1.0) | |
-- Draw background | |
canvas.beginPath() | |
canvas.rect(0, 0, width, height) | |
canvas.fillColor(background) | |
canvas.fill() | |
-- Draw logo | |
canvas.beginPath() | |
canvas.fillPaint(logo.paint) | |
canvas.rect((width - logo.width / 2) / 2, 100, logo.width / 2, logo.height / 2) | |
canvas.fill() | |
canvas.endFrame(); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment