shithub: lua9

Download patch

ref: 1dac4632944d701fce9f2ddfa6dbe62fd36b4a1e
parent: fd782c7b42481d116fb70fe3e8ecf20c959b5f07
author: telephil9 <[email protected]>
date: Mon Oct 26 05:53:59 EDT 2020

Add more demos

--- a/demo.lua
+++ b/demo.lua
@@ -28,11 +28,55 @@
 	p1 = g.addpt(p, pt(200, 200))
 	p2 = g.addpt(p, pt(0, 200))
 	draw.poly(screen, { p, p1, p2, p }, draw.END_SQUARE, draw.END_SQUARE, 0, display.black, ZP)
+	p = g.addpt(p, pt(0, 250))
+	draw.string(screen, p, display.black, nil, font, "draw.fillpoly(screen, { p0, p1, p2, p3, p4, p0 }, 3, display.black, ZP)")
+	p = g.addpt(p, pt(50, 50))
+	p1 = g.addpt(p, pt(200, 100))
+	p2 = g.addpt(p, pt(100, 150))
+	p3 = g.addpt(p, pt(50, 200))
+	p4 = g.addpt(p, pt(-50, 50))
+	draw.fillpoly(screen, { p, p1, p2, p3, p4, p }, 3, display.black, ZP)
 end
 
+function strings()
+	local p = g.addpt(screen.r.min, pt(10, 10))
+	draw.draw(screen, screen.r, display.white, nil, ZP)
+	draw.string(screen, p, display.black, nil, font, "draw.string(screen, p, display.black, ZP, font, 'Hello LUA')")
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.string(screen, p, display.black, ZP, font, 'Hello LUA')
+	p = g.addpt(p, pt(0, 2 * font.height + 2))
+	draw.string(screen, p, display.black, nil, font, "draw.stringn(screen, p, display.black, ZP, font, 'Hello LUA', 5)")
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.stringn(screen, p, display.black, ZP, font, 'Hello LUA', 5)
+	p = g.addpt(p, pt(0, 2 * font.height + 2))
+	draw.string(screen, p, display.black, nil, font, "draw.stringbg(screen, p, display.white, ZP, font, 'Hello LUA', display.black, ZP)")
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.stringbg(screen, p, display.white, ZP, font, 'Hello LUA', display.black, ZP)
+	p = g.addpt(p, pt(0, 2 * font.height + 2))
+	draw.string(screen, p, display.black, nil, font, "draw.stringnbg(screen, p, display.white, ZP, font, 'Hello LUA', 5, display.black, ZP)")
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.stringnbg(screen, p, display.white, ZP, font, 'Hello LUA', 5, display.black, ZP)
+end
+
+function colors()
+	local p = g.addpt(screen.r.min, pt(10, 10))
+	draw.draw(screen, screen.r, display.white, nil, ZP)
+	draw.string(screen, p, display.black, nil, font, "red = draw.allocimage(display, rect(0,0,1,1), screen.chan, 1, color.RED)")
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.string(screen, p, display.black, nil, font, "draw.draw(screen, r, red, nil, ZP)")
+	local red = draw.allocimage(display, rect(0,0,1,1), screen.chan, 1, color.RED)
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.draw(screen, g.rectaddpt(rect(0,0,50,50), p), red, nil, ZP)
+	p = g.addpt(p, pt(0, font.height + 2 + 50))
+	draw.string(screen, p, display.black, nil, font, "draw.allocimagemix(display, color.BLUE, color.YELLOW)")
+	local c = draw.allocimagemix(display, color.BLUE, color.YELLOW)
+	p = g.addpt(p, pt(0, font.height + 2))
+	draw.draw(screen, g.rectaddpt(rect(0,0,50,50), p), c, nil, ZP)
+end
+
 local index = nil
-local menu = { "line", "poly", "exit" }
-local demos = { lines, polys, os.exit }
+local menu = { "line", "poly", "string", "colors", "exit" }
+local demos = { lines, polys, strings, colors, os.exit }
 
 function eresized()
 	if index then