VERSIÓ 1.3.12
- [FIX] La paleta per defecte era tota transparent - [NEW] draw.rrect() i draw.rrectf()
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
title=PAKU SIMBEL PROFANATION
|
title=TESTS
|
||||||
config=paku
|
config=minitests
|
||||||
width=160
|
width=400
|
||||||
height=144
|
height=300
|
||||||
zoom=4
|
zoom=2
|
||||||
|
|||||||
24
lua.cpp
24
lua.cpp
@@ -429,6 +429,28 @@ extern "C" {
|
|||||||
return 0;
|
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) {
|
static int cpp_draw_oval(lua_State *L) {
|
||||||
int x0 = luaL_checknumber(L, 1);
|
int x0 = luaL_checknumber(L, 1);
|
||||||
int y0 = luaL_checknumber(L, 2);
|
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_rectfill); lua_setfield(L, -2, "rectf");
|
||||||
lua_pushcfunction(L,cpp_draw_circ); lua_setfield(L, -2, "circ");
|
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_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_oval); lua_setfield(L, -2, "oval");
|
||||||
lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalf");
|
lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalf");
|
||||||
lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "pattern");
|
lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "pattern");
|
||||||
|
|||||||
75
mini.cpp
75
mini.cpp
@@ -84,8 +84,8 @@ Uint32 windowID;
|
|||||||
Uint32 *pixels;
|
Uint32 *pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
|
||||||
uint32_t palette[256] = { 0x001a1c2c, 0x005d275d, 0x00b13e53, 0x00ef7d57, 0x00ffcd75, 0x00a7f070, 0x0038b764, 0x00257179,
|
uint32_t palette[256] = { 0xFF1a1c2c, 0xFF5d275d, 0xFFb13e53, 0xFFef7d57, 0xFFffcd75, 0xFFa7f070, 0xFF38b764, 0xFF257179,
|
||||||
0x0029366f, 0x003b5dc9, 0x0041a6f6, 0x0073eff7, 0x00f4f4f4, 0x0094b0c2, 0x00566c86, 0x00333c57 };
|
0xFF29366f, 0xFF3b5dc9, 0xFF41a6f6, 0xFF73eff7, 0xFFf4f4f4, 0xFF94b0c2, 0xFF566c86, 0xFF333c57 };
|
||||||
|
|
||||||
const char base64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
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);
|
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) {
|
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);
|
||||||
pset((xc-x)*xf, (yc+y)*yf);
|
pset((xc-x)*xf, (yc+y)*yf);
|
||||||
|
|||||||
6
mini.h
6
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 = 4);
|
||||||
void circfill(int x, int y, uint8_t r, uint8_t color);
|
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);
|
||||||
void oval(int x0, int y0, int x1, int y1, uint8_t color);
|
void oval(int x0, int y0, int x1, int y1, uint8_t color);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MINI_VERSION "1.3.11"
|
#define MINI_VERSION "1.3.12"
|
||||||
|
|||||||
@@ -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
|
---Draw a vertical line from (x,y1) to (x,y2) with the givencolor
|
||||||
function draw.vline(x, y1, y2, color) end
|
function draw.vline(x, y1, y2, color) end
|
||||||
|
|
||||||
---@param x1 number
|
---@param x number
|
||||||
---@param y1 number
|
---@param y number
|
||||||
---@param x2 number
|
---@param w number
|
||||||
---@param y2 number
|
---@param h number
|
||||||
---@param color number
|
---@param color number
|
||||||
---Draw the ouline of a rectangle from (x1,y1) to (x2,y2) with the given color
|
---Draw the ouline of a rectangle at (x,y) of size (w,h) with the given color
|
||||||
function draw.rect(x1, y1, x2, y2, color) end
|
function draw.rect(x, y, w, h, color) end
|
||||||
|
|
||||||
---@param x1 number
|
---@param x number
|
||||||
---@param y1 number
|
---@param y number
|
||||||
---@param x2 number
|
---@param w number
|
||||||
---@param y2 number
|
---@param h number
|
||||||
---@param color number
|
---@param color number
|
||||||
---Draw a filled rectangle from (x1,y1) to (x2,y2) with the given color
|
---Draw a filled rectangle at (x,y) of size (w,h) with the given color
|
||||||
function draw.rectf(x1, y1, x2, y2, color) end
|
function draw.rectf(x, y, w, h, color) end
|
||||||
|
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y 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
|
---Draw a filled cicle at position(x,y) with radius r and the given color
|
||||||
function draw.circf(x, y, r, color) end
|
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 x1 number
|
||||||
---@param y1 number
|
---@param y1 number
|
||||||
---@param x2 number
|
---@param x2 number
|
||||||
|
|||||||
Reference in New Issue
Block a user