创建画布失败后会降低尺寸上限然后重试而不是报错

This commit is contained in:
MrZ626
2021-06-26 01:35:20 +08:00
parent 076d854f11
commit b554409b32

View File

@@ -40,7 +40,12 @@ local cmds={
local sizeLimit=gc.getSystemLimits().texturesize
return function(L)
gc.push()
local canvas=gc.newCanvas(math.min(L[1],sizeLimit),math.min(L[2],sizeLimit))
::REPEAT_tryAgain::
local success,canvas=pcall(gc.newCanvas,math.min(L[1],sizeLimit),math.min(L[2],sizeLimit))
if not success then
texturesize=math.floor(texturesize*.8)
goto REPEAT_tryAgain
end
gc.setCanvas(canvas)
gc.origin()
gc.setColor(1,1,1)