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

add random color as back ground
https://bbs.xwidget.com/viewtopic.php?f=8&t=3062
Page 1 of 1

Author:  ShopanMaruf [ May 15th, 2013, 5:03 am ]
Post subject:  add random color as back ground

How to add it.

That,
ever time it loads and chooses a random color by itself.

is it possible?

to
Armando,
qiancang
&
Tony

Author:  Armando [ May 15th, 2013, 6:52 am ]
Post subject:  Re: add random color as back ground

Well... i'm not a pogrammer...we wait for Tony answer :)

Author:  digigamer [ May 19th, 2013, 5:00 pm ]
Post subject:  Re: add random color as back ground

Let your background object be bg
add this code to onWidgetLoaded...
Code:
var colornum = 0xFFFFFFFF
var randomcolor = Math.floor((Math.random()*colornum)+1) | 0xFF000000; //random color... use as bg

var opposite = (randomcolor ^ colornum) | 0xFF000000; //opposite (contrasting color)... use as text or foreground

bg.Background.SolidColor.Color=randomcolor;

Author:  ShopanMaruf [ May 20th, 2013, 2:28 am ]
Post subject:  Re: add random color as back ground

Nicely done!!!


many many thanks :D

Attachments:
Capture.PNG
Capture.PNG [ 17.88 KiB | Viewed 3649 times ]
Rendom Bg color test.XWidgetPkg [9.1 KiB]
Downloaded 266 times

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