shithub: slug

Download patch

ref: 2c2a11db8b8e6c7243050854c4dbca226966f12b
parent: 476f6ebc9a88727fadb2cb5d18634008f814d401
author: phil9 <telephil9@gmail.com>
date: Fri Dec 2 04:34:51 EST 2022

reset transformations before each draw() iteration

	replicate Processing behaviour by resetting all transformations (translate()/rotate()) before
	each draw() loop iteration

--- a/a.h
+++ b/a.h
@@ -13,6 +13,7 @@
 
 void	drawcanvas(void);
 void	initstate(lua_State*);
+void	reset(void);
 void	registerapi(lua_State*);
 
 Image*	color(int, int, int, int);
--- a/api.c
+++ b/api.c
@@ -46,6 +46,13 @@
 }
 
 void
+reset(void)
+{
+	origin = ZP;
+	angle = 0.0;
+}
+
+void
 drawcanvas(void)
 {
 	draw(screen, screen->r, canvas, nil, ZP);
--- a/slug.c
+++ b/slug.c
@@ -131,6 +131,7 @@
 	drawing = 1;
 	for(;;){
 		if(looping){
+			reset();
 			t0 = nsec();
 			lcall(L, "draw");
 			t1 = nsec();