- [NEW] draw.mode(), amb modes NORMAL, PATTERN, AND, OR, XOR i NOT

- [NEW] Ara per a pintar en pattern hi ha que dir-ho en draw.mode(), no es automatic al ficar un pattern.
- [NEW] Nous modes de pintat booleans. AND, OR i XOR fan l'operació pixel_actual = pixel_actual OP color_especificat. NOT no usa el color especificat, nomes fa un NOT del pixel actual.
This commit is contained in:
2026-02-24 11:03:21 +01:00
parent 9581ce67fd
commit fc962b4e18
5 changed files with 85 additions and 2 deletions

15
lua.cpp
View File

@@ -578,6 +578,12 @@ extern "C" {
return 0;
}
static int cpp_draw_mode(lua_State *L) {
int mode = luaL_checknumber(L, 1);
set_draw_mode(mode);
return 0;
}
// shaders
// ===============================================
@@ -1032,6 +1038,15 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_draw_surface); lua_setfield(L, -2, "surf");
lua_pushcfunction(L,cpp_draw_surfaceRotated); lua_setfield(L, -2, "surfrot");
lua_pushcfunction(L,cpp_draw_text); lua_setfield(L, -2, "text");
lua_pushcfunction(L,cpp_draw_mode); lua_setfield(L, -2, "mode");
lua_pushinteger(L, 0); lua_setfield(L, -2, "NORMAL");
lua_pushinteger(L, 1); lua_setfield(L, -2, "PATTERN");
lua_pushinteger(L, 2); lua_setfield(L, -2, "AND");
lua_pushinteger(L, 3); lua_setfield(L, -2, "OR");
lua_pushinteger(L, 4); lua_setfield(L, -2, "XOR");
lua_pushinteger(L, 5); lua_setfield(L, -2, "NOT");
lua_setglobal(L, "draw");
lua_newtable(L);