From b7d5a3f9c6032adebcb954a425c2d111f03fe867 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 26 Aug 2021 00:45:48 +0800 Subject: [PATCH] =?UTF-8?q?string=E6=89=A9=E5=B1=95=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=96=B0=E5=A2=9E16=E8=BF=9B=E5=88=B6=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/stringExtend.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Zframework/stringExtend.lua b/Zframework/stringExtend.lua index 5bbaf814..38def2b1 100644 --- a/Zframework/stringExtend.lua +++ b/Zframework/stringExtend.lua @@ -65,6 +65,17 @@ function STRING.time(s) end end +function STRING.hexColor(str)--[LOW PERFORMENCE] + assert(type(str)=='string') + if str:sub(1,1)=="#"then str=str:sub(2)end + assert(#str<=8) + local r=(tonumber(str:sub(1,2),16)or 0)/255 + local g=(tonumber(str:sub(3,4),16)or 0)/255 + local b=(tonumber(str:sub(5,6),16)or 0)/255 + local a=(tonumber(str:sub(7,8),16)or 255)/255 + return r,g,b,a +end + do--function STRING.urlEncode(s) local rshift=bit.rshift local b16={[0]='0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}