XWidgetSoft Forum
https://www.bbs.xwidget.com/

Attributes and Functions Relevant to Color
https://www.bbs.xwidget.com/viewtopic.php?f=10&t=3684
Page 1 of 1

Author:  qiancang [ October 23rd, 2013, 7:03 am ]
Post subject:  Attributes and Functions Relevant to Color

Attributes

.font.fill.color
text,edit and memo component font color.
Code:
text1.font.fill.color = rgba(0,0,0,255)  //black
edit1.font.fill.color = rgba(0,0,0,255)  //black
memo1.font.fill.color = rgba(0,0,0,255)  //black


.text.font.fill.color
button and badge component text font color.
Code:
button1.text.font.fill.color = rgba(0,0,0,255)  //black
badge1.text.font.fill.color = rgba(255,128,128,255)  //pink


.background.solidColor.color
all components background solid color.
Code:
image1.background.solidColor.color = rgba(0,255,0,255)  //green
layer1.background.solidColor.color = rgba(150,150,150,255)  //grey
text1.background.solidColor.color = rgba(0,0,255,200)  //blue




Functions
rgba(red,green,blue,alpha)
set color as rgb format.
red,green,blue: integer,0~255. example: black=0,0,0 white=255,255,255 red=255,0,0
alpha:transparency, integer, 0~255.



SelectColor(defaultColor)
select color via colorboard.
Attachment:
color board.png
color board.png [ 126.14 KiB | Viewed 9107 times ]

defaultColor:colorboard will return defaultColor if you click cancel button.
Code:
text1.font.fill.color = selectColor(text1.font.fill.color);
image1.backgroud.solidcolor.color = selectColor( rgba(255,2,2,255) );





getScreenRGB(x,y)
get the color of screen point(x,y).
x,y:screen point.
this function will return string in 255,4,29 form. it doesn't contain the alpha information.
Code:
var rgb_str = getscreenRGB(100,34);
var color_str = rgb_str+ "," + 240; // add alpha to the string
var color = eval(  "rgba(" + color_str + ")"   );
text1.fill.font.color  = color;


to be continued

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/