新增九宫格绘制函数 function DrawNineBox(X, Y, Width, Height, Img, StartIndex)

This commit is contained in:
Lenheart 2025-06-30 00:25:18 +08:00
parent bdb6e79723
commit 20269c25b3
1 changed files with 44 additions and 2 deletions

View File

@ -186,15 +186,57 @@ class Rindro_BaseToolClass {
return null; return null;
} }
function DrawNineBox(X, Y, Width, Height, Img, StartIndex) {
//如果没有载入img就载入
if (!Rindro_Image_GlobalMap.rawin(Img)) {
Rindro_Image_GlobalMap[Img] <- Rindro_Image(Img);
}
//绘制左上角
Rindro_Image_GlobalMap[Img].DrawPng(StartIndex, X, Y);
//获取左上角的图片宽高
local LeftTopW = Rindro_Image_GlobalMap[Img].GetPng(StartIndex).GetWidth();
local LeftTopH = Rindro_Image_GlobalMap[Img].GetPng(StartIndex).GetHeight();
//绘制上边
//获取上边的宽
local TopW = Rindro_Image_GlobalMap[Img].GetPng(StartIndex + 1).GetWidth();
Rindro_Image_GlobalMap[Img].DrawExPng(StartIndex + 1, X + LeftTopW, Y, 0, sq_RGBA(255, 255, 255, 250), (Width - LeftTopW * 2).tofloat() / TopW, 1.0);
//绘制右上角
Rindro_Image_GlobalMap[Img].DrawPng(StartIndex + 2, X + Width - LeftTopW, Y);
//绘制左边
//获取左边的高
local LeftH = Rindro_Image_GlobalMap[Img].GetPng(StartIndex + 3).GetHeight();
Rindro_Image_GlobalMap[Img].DrawExPng(StartIndex + 3, X, Y + LeftTopH, 0, sq_RGBA(255, 255, 255, 250), 1.0, (Height - LeftTopH * 2).tofloat() / LeftH);
//绘制中间
//获取中间的宽高
local MiddleW = Rindro_Image_GlobalMap[Img].GetPng(StartIndex + 4).GetWidth();
local MiddleH = Rindro_Image_GlobalMap[Img].GetPng(StartIndex + 4).GetHeight();
Rindro_Image_GlobalMap[Img].DrawExPng(StartIndex + 4, X + LeftTopW, Y + LeftTopH, 0, sq_RGBA(255, 255, 255, 250), (Width - LeftTopW * 2).tofloat() / MiddleW, (Height - LeftTopH * 2).tofloat() / MiddleH);
//绘制右边
Rindro_Image_GlobalMap[Img].DrawExPng(StartIndex + 5, X + Width - LeftTopW, Y + LeftTopH, 0, sq_RGBA(255, 255, 255, 250), 1.0, (Height - LeftTopH * 2).tofloat() / LeftH);
//绘制左下角
Rindro_Image_GlobalMap[Img].DrawPng(StartIndex + 6, X, Y + Height - LeftTopH);
//绘制下边
Rindro_Image_GlobalMap[Img].DrawExPng(StartIndex + 7, X + LeftTopW, Y + Height - LeftTopH, 0, sq_RGBA(255, 255, 255, 250), (Width - LeftTopW * 2).tofloat() / TopW, 1.0);
//绘制右下角
Rindro_Image_GlobalMap[Img].DrawPng(StartIndex + 8, X + Width - LeftTopW, Y + Height - LeftTopH);
}
} }
//获取文字绘制长度 //获取文字绘制长度
class LenheartTextClass { class LenheartTextClass {
function GetStringLength(str) { function GetStringLength(str) {
if(typeof str != "string")str = "无字符";
return L_sq_GetStringDrawLength(str); return L_sq_GetStringDrawLength(str);
} }
} }
class MemoryTool { class MemoryTool {
//给指定地址写入字节数组 //给指定地址写入字节数组
function WirteByteArr(Address, ByteArr) { function WirteByteArr(Address, ByteArr) {