Skip to content

Commit fe5df08

Browse files
committed
添加一个*比较科学的*实心按钮明暗分类算法决定文本使用亮色还是暗色
1 parent fb98ad6 commit fe5df08

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

widget.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ function Widgets.button_fill:draw()
363363
alignDraw(self,self._image)
364364
end
365365
if self._text then
366-
gc_setColor(r*.5,g*.5,b*.5)
366+
if r*.299+g*.587+b*.114<.626 then
367+
gc_setColor(1-(1-r)*.26,1-(1-g)*.26,1-(1-b)*.26)
368+
else
369+
gc_setColor(r*.26,g*.26,b*.26)
370+
end
367371
alignDraw(self,self._text)
368372
end
369373
gc_pop()

0 commit comments

Comments
 (0)