数据网格中较浅的颜色交替行颜色

时间:2015-07-29 13:21:24

标签: datagrid livecode

我有一个数据网格,我使用颜色主题来设置row hilite color

  set the dgprop["hilite color"] of group "dg_xxx" to color1 -- #dc8400

现在我希望alternate row color基于color1,但更轻松(i.E。30%减轻了#FFD14D)。

有没有办法在执行color1更改时使用RGB或HEX计算执行以下操作以使其动态更改?

set the dgprop["alternate row color"] of group "dg_xxx" to (color1 - 30%)

1 个答案:

答案 0 :(得分:0)

以下函数返回一个阴影,通过将剩余距离的份额s添加到白色来计算。警告1:基本上你通过使用这个功能增加亮度,你可能会得到一个丑陋的灰色,最终是白色。警告2:s和-s没有给出完全相反的结果。

function rgbShade
  if the paramCount is 4 then
    put param(1) into r
    put param(2) into g
    put param(3) into b
    put param(4) into s
  else
    put item 1 of param(1) into r
    put item 2 of param(1) into g
    put item 3 of param(1) into b
    put param(2) into s
  end if
  put r+(255-r)*s into r
  put g+(255-g)*s into g
  put b+(255-b)*s into b
  return r,g,b
end rgbShade

用法:

get rgbShade("123,45,67",0.2) // increase of 20% of remaining distance
put rgbShade(123,45,67,0.2) into myShade // same as above

示例:

set the dgprop["hilite color"] of group "dg_xxx" to color1 -- #dc8400
set the dgprop["alternate row color"] of group "dg_xxx" to rgbShade(color1,.3)