From 839c1e82eb172834bd4f959f990d9d8e2a6d2c51 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 27 Nov 2025 17:18:07 +0100 Subject: [PATCH] =?UTF-8?q?VERSI=C3=93=201.3.12=20-=20[FIX]=20La=20paleta?= =?UTF-8?q?=20per=20defecte=20era=20tota=20transparent=20-=20[NEW]=20draw.?= =?UTF-8?q?rrect()=20i=20draw.rrectf()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/game.ini | 10 +++---- lua.cpp | 24 +++++++++++++++ mini.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++-- mini.h | 6 ++++ version.h | 2 +- vscode/library.lua | 42 ++++++++++++++++++-------- 6 files changed, 139 insertions(+), 20 deletions(-) diff --git a/data/game.ini b/data/game.ini index 74de424..b6690ed 100644 --- a/data/game.ini +++ b/data/game.ini @@ -1,5 +1,5 @@ -title=PAKU SIMBEL PROFANATION -config=paku -width=160 -height=144 -zoom=4 +title=TESTS +config=minitests +width=400 +height=300 +zoom=2 diff --git a/lua.cpp b/lua.cpp index 0433374..2a31630 100644 --- a/lua.cpp +++ b/lua.cpp @@ -429,6 +429,28 @@ extern "C" { return 0; } + static int cpp_draw_roundrect(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + int w = luaL_checknumber(L, 3); + int h = luaL_checknumber(L, 4); + int r = luaL_optnumber(L, 5, 4); + uint8_t color = luaL_checkinteger(L, 6); + roundrect(x, y, w, h, r, color); + return 0; + } + + static int cpp_draw_roundrectfill(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + int w = luaL_checknumber(L, 3); + int h = luaL_checknumber(L, 4); + int r = luaL_optnumber(L, 5, 4); + uint8_t color = luaL_checkinteger(L, 6); + roundrectfill(x, y, w, h, r, color); + return 0; + } + static int cpp_draw_oval(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); @@ -924,6 +946,8 @@ void push_lua_funcs() { lua_pushcfunction(L,cpp_draw_rectfill); lua_setfield(L, -2, "rectf"); lua_pushcfunction(L,cpp_draw_circ); lua_setfield(L, -2, "circ"); lua_pushcfunction(L,cpp_draw_circfill); lua_setfield(L, -2, "circf"); + lua_pushcfunction(L,cpp_draw_roundrect); lua_setfield(L, -2, "rrect"); + lua_pushcfunction(L,cpp_draw_roundrectfill); lua_setfield(L, -2, "rrectf"); lua_pushcfunction(L,cpp_draw_oval); lua_setfield(L, -2, "oval"); lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalf"); lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "pattern"); diff --git a/mini.cpp b/mini.cpp index f3742b7..a7afa78 100644 --- a/mini.cpp +++ b/mini.cpp @@ -84,8 +84,8 @@ Uint32 windowID; Uint32 *pixels; int pitch; -uint32_t palette[256] = { 0x001a1c2c, 0x005d275d, 0x00b13e53, 0x00ef7d57, 0x00ffcd75, 0x00a7f070, 0x0038b764, 0x00257179, - 0x0029366f, 0x003b5dc9, 0x0041a6f6, 0x0073eff7, 0x00f4f4f4, 0x0094b0c2, 0x00566c86, 0x00333c57 }; +uint32_t palette[256] = { 0xFF1a1c2c, 0xFF5d275d, 0xFFb13e53, 0xFFef7d57, 0xFFffcd75, 0xFFa7f070, 0xFF38b764, 0xFF257179, + 0xFF29366f, 0xFF3b5dc9, 0xFF41a6f6, 0xFF73eff7, 0xFFf4f4f4, 0xFF94b0c2, 0xFF566c86, 0xFF333c57 }; const char base64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -921,6 +921,77 @@ void circfill(int x, int y, uint8_t r, uint8_t color) { circfill(x, y, r); } + +void roundrect(int x, int y, int w, int h, uint8_t r) { + int xi=0, yi=r; + int d=3-2*r; + + int xf = w+x-1; + int yf = h+y-1; + int x1 = x+r, y1 = y+r; + int x2 = xf-r, y2 = yf-r; + hline(x1, y, x2); + hline(x1, yf, x2); + vline(x, y1, y2); + vline(xf, y1, y2); + + while (yi>=xi++) { + d += d>0 ? 4*(xi-yi--)+10 : 4*xi+6; + pset(x2+xi, y2+yi); + pset(x1-xi, y2+yi); + pset(x2+xi, y1-yi); + pset(x1-xi, y1-yi); + pset(x2+yi, y2+xi); + pset(x1-yi, y2+xi); + pset(x2+yi, y1-xi); + pset(x1-yi, y1-xi); + } +} + +void roundrect(int x, int y, int w, int h, uint8_t r, uint8_t color) { + ds::pen_color=color; + roundrect(x, y, w, h, r); +} + +void roundrectfill(int x, int y, int w, int h, uint8_t r) { + int xi=0, yi=r; + int d=3-2*r; + + int xf = w+x-1; + int yf = h+y-1; + int x1 = x+r, y1 = y+r; + int x2 = xf-r, y2 = yf-r; + for (int i=y1; i<=y2; ++i) hline(x, i, xf); + + while (yi>=xi++) { + d += d>0 ? 4*(xi-yi--)+10 : 4*xi+6; + hline(x1-xi, y2+yi, x2+xi); + hline(x1-xi, y1-yi, x2+xi); + hline(x1-yi, y2+xi, x2+yi); + hline(x1-yi, y1-xi, x2+yi); + } +} + +void roundrectfill(int x, int y, int w, int h, uint8_t r, uint8_t color) { + ds::pen_color=color; + roundrectfill(x, y, w, h, r); +} +/* +void roundrectfill(int x, int y, uint8_t r) { + int xi=0, yi=r; + int d=3-2*r; + (*fun_ptr)(x, y, xi, yi); + while (yi>=xi++) { + d += d>0 ? 4*(xi-yi--)+10 : 4*xi+6; + (*fun_ptr)(x, y, xi, yi); + } +} + +void roundrectfill(int x, int y, uint8_t r, uint8_t color) { + ds::pen_color=color; + roundrectfill(x, y, r); +} +*/ void _drawoval(int xc, int yc, int x, int y, float xf, float yf) { pset((xc+x)*xf, (yc+y)*yf); pset((xc-x)*xf, (yc+y)*yf); diff --git a/mini.h b/mini.h index 7ae8f1f..1aa2636 100644 --- a/mini.h +++ b/mini.h @@ -183,6 +183,12 @@ void circ(int x, int y, uint8_t r, uint8_t color); void circfill(int x, int y, uint8_t r = 4); void circfill(int x, int y, uint8_t r, uint8_t color); +void roundrect(int x, int y, int w, int h, uint8_t r); +void roundrect(int x, int y, int w, int h, uint8_t r, uint8_t color); + +void roundrectfill(int x, int y, int w, int h, uint8_t r); +void roundrectfill(int x, int y, int w, int h, uint8_t r, uint8_t color); + void oval(int x0, int y0, int x1, int y1); void oval(int x0, int y0, int x1, int y1, uint8_t color); diff --git a/version.h b/version.h index 6f5ea14..e6b07d6 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "1.3.11" +#define MINI_VERSION "1.3.12" diff --git a/vscode/library.lua b/vscode/library.lua index 6f0216c..df6ee7c 100644 --- a/vscode/library.lua +++ b/vscode/library.lua @@ -184,21 +184,21 @@ function draw.hline(x1, y, x2, color) end ---Draw a vertical line from (x,y1) to (x,y2) with the givencolor function draw.vline(x, y1, y2, color) end ----@param x1 number ----@param y1 number ----@param x2 number ----@param y2 number +---@param x number +---@param y number +---@param w number +---@param h number ---@param color number ----Draw the ouline of a rectangle from (x1,y1) to (x2,y2) with the given color -function draw.rect(x1, y1, x2, y2, color) end +---Draw the ouline of a rectangle at (x,y) of size (w,h) with the given color +function draw.rect(x, y, w, h, color) end ----@param x1 number ----@param y1 number ----@param x2 number ----@param y2 number +---@param x number +---@param y number +---@param w number +---@param h number ---@param color number ----Draw a filled rectangle from (x1,y1) to (x2,y2) with the given color -function draw.rectf(x1, y1, x2, y2, color) end +---Draw a filled rectangle at (x,y) of size (w,h) with the given color +function draw.rectf(x, y, w, h, color) end ---@param x number ---@param y number @@ -214,6 +214,24 @@ function draw.circ(x, y, r, color) end ---Draw a filled cicle at position(x,y) with radius r and the given color function draw.circf(x, y, r, color) end +---@param x number +---@param y number +---@param w number +---@param h number +---@param r number +---@param color number +---Draw the outline of a round rectangle at (x,y) of size (w,h) with border radius r and the given color +function draw.rrect(x, y, w, h, r, color) end + +---@param x number +---@param y number +---@param w number +---@param h number +---@param r number +---@param color number +---Draw a filled round rectangle at (x,y) of size (w,h) with border radius r and the given color +function draw.rrectf(x, y, w, h, r, color) end + ---@param x1 number ---@param y1 number ---@param x2 number