Rank: Newbie
Groups: Registered
Joined: 5/18/2020(UTC) Posts: 2
|
I would like to realize the next application - Each time the button is pressed, the canvas\background is painted with various colors generated randomly. Please, help me. I not found nothing in Designer for it
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/22/2019(UTC) Posts: 20 Location: Vienna Was thanked: 4 time(s) in 4 post(s)
|
Hi, just one way how you can create a random color via xpath on a button press. is to create a random number from 0 to 0xffffff, then add leading 0 until you reach 6 digits, prefix the whole thing with # Code:
'#'|| pad-string-left(
integer-to-hex-string( xs:integer ( fn:random-number-generator(fn:current-dateTime())?number * hex-string-to-integer('ffffff') ) ),
6, '0' )
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/18/2020(UTC) Posts: 2
|
Hi, Thanks for the hint how to get a random color through its recording in RGB, but I don’t understand how to set the background color by clicking. This is where help is needed :)
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/22/2019(UTC) Posts: 20 Location: Vienna Was thanked: 4 time(s) in 4 post(s)
|
just create an attribute, element, variable,... for your bk color. Initialize with whatever color you want "#000000" for black for example. Assign this element to the tables background color. On button click: update node -> your bk color element,... with result of -> the random color code
|
|
|
|
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.