XWidgetSoft Forum https://xwidget.com/bbs/ |
|
Help with Round Corners. https://xwidget.com/bbs/viewtopic.php?f=7&t=2103 |
Page 1 of 1 |
Author: | Nutu [ September 10th, 2012, 2:32 am ] |
Post subject: | Help with Round Corners. |
Is there a way to check/uncheck the round corners via script? An example would be: Code: function widgetOnLoad() { backboard_small.Corner.Corners.BottomLeft.Checked = true; backboard_small.Corner.Corners.BottomRight.Checked = true; } Thanks in advance. |
Author: | vlad [ September 10th, 2012, 3:53 am ] |
Post subject: | Re: Help with Round Corners. |
Well i have to admit that was a challenge, i had to go back 4 the old school stuff and learn over again bit-wise operations ![]() Shortly use this function to convert 4 Boolean to an integer. Code: /** Written by vlad. Contact me for question or help at http://4ybak47.deviantart.com/ convertCornersToInt( [topleft] , [topright] , [buttonleft] , [buttonright] ). Example : object.Corner.Corners = convertCornersToInt(true,true,false,false);*/ function convertCornersToInt(tl,tr,bl,br) { return tl | tr << 1 | bl << 2 | br << 3; } If you wish some explanations here is my code while i was testing the function above. ![]() Code: //print(true << 2); //convertCornersToInt(true,true,true,true); //print(convertCornersToInt(true,false,false,false)); //Works!!! ////widgetContainer.Corner.Corners = convertCornersToInt(false,true,false,true); /** Written by vlad. Contact me for question or help at http://4ybak47.deviantart.com/ **function usage Example : //Curve only the top two corners. object.Corner.Corners = convertCornersToInt(true,true,false,false); **Variables: //tl - topleft : Boolean [true / false] //tr - topright : Boolean [true / false] //bl - buttonleft : Boolean [true / false] //br - buttonright : Boolean [true / false] */ function convertCornersToInt(tl,tr,bl,br) { //obj.Corner.Corners = "topleft,topright,buttonleft,buttonright"; //printBinary(4); //printBinary(15); // var b = true; //printBinary(b ? 1 : 0); //printBinary(cb2i(true)); //printBinary(tl); // tl = 1, tl << 1 = 10, tl << 2 = 100, tl << 3 = 1000 //printBinary(cb2i(tl) << 2); return tl | tr << 1 | bl << 2 | br << 3; } //Usage : check the binary value of the number n. function printBinary(n) { print("~~~~~~~~~~~~~~~~~~~"); print(" Binary ( " + parseInt(n).toString(2) + " )"); print(" Number ( " + parseInt(n).toString() + " )"); print(" Value ( " + n.toString() + " )"); print("~~~~~~printBinary~~~~~~"); } //Convert boolean to int / binary [1,0] function cb2i(bool) { return bool ? 1 : 0; } |
Author: | Nutu [ September 10th, 2012, 3:58 am ] |
Post subject: | Re: Help with Round Corners. |
Wow. Thanks dude. It helped me a lot O_O I could've never figure this out on my own -_- |
Author: | qiancang [ September 11th, 2012, 3:14 am ] |
Post subject: | Re: Help with Round Corners. |
Code: backboard_small.Corner.Corners =0(disable corner)
=1(TopLeft) =2(TopRight) =3(TopLeft + TopRight) =4(BottomLeft) ...... =7(TopLeft + TopRight +BottomLeft) =8(BottomRight) ...... =15(TopLeft + TopRight +BottomLeft + BottomRight) |
Author: | Nutu [ September 11th, 2012, 3:30 am ] |
Post subject: | Re: Help with Round Corners. |
Thanks qiancang but the script vlad gave me seems easier to use and less likely to bug. |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |