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

[ASK] Code for change image in %
https://www.bbs.xwidget.com/viewtopic.php?f=8&t=3876
Page 1 of 1

Author:  dexterkamiya [ December 9th, 2013, 3:10 pm ]
Post subject:  [ASK] Code for change image in %

can somebody give me a code for change image with percent
the example like if ram make higher the progress bar on xwidget will change the colour from green to red

anybody can help me ?

i want port this rainmeter widget for xwidget
(sorry for my bad english)
Image

Author:  Jimking [ December 9th, 2013, 5:03 pm ]
Post subject:  Re: [ASK] Code for change image in %

You can use the default "Gradient option" of the Designer or create a .png image and then apply it like the "Foreground Fill" for the progress bar choosing "fill with graphic"- "Allow clipped". You can find all these in the designer. Just play with the options to see the results..

Author:  dexterkamiya [ December 9th, 2013, 6:02 pm ]
Post subject:  Re: [ASK] Code for change image in %

oke, i will try, thanks for helping
EDIT:
but i need to change it with 3 colour
green - yellow - red

and what u say just for 1 colour, i need how it be change in percent

Author:  Jimking [ December 9th, 2013, 6:25 pm ]
Post subject:  Re: [ASK] Code for change image in %

dexterkamiya wrote:
oke, i will try, thanks for helping
EDIT:
but i need to change it with 3 colour
green - yellow - red

and what u say just for 1 colour, i need how it be change in percent

When you use the gradient option is not for one colour! Set the start colour "green" and the end colour "red" and you will see..
Also as I said you can use a ready png image and use it for the "Foreground Fill" of the progress bar, like this one for example:

Attachments:
34-35-gorgeous-progress-bars.jpeg
34-35-gorgeous-progress-bars.jpeg [ 35.55 KiB | Viewed 6287 times ]

Author:  dexterkamiya [ December 9th, 2013, 6:32 pm ]
Post subject:  Re: [ASK] Code for change image in %

jimking wrote:
dexterkamiya wrote:
oke, i will try, thanks for helping
EDIT:
but i need to change it with 3 colour
green - yellow - red

and what u say just for 1 colour, i need how it be change in percent

When you use the gradient option is not for one colour! Set the start colour "green" and the end colour "red" and you will see..
Also as I said you can use a ready png image and use it for the "Foreground Fill" of the progress bar, like this one for example:


but not like that, what i mean is full green, when 60% the image will be yellow, if 30% that will be red

Author:  Jimking [ December 9th, 2013, 6:41 pm ]
Post subject:  Re: [ASK] Code for change image in %

dexterkamiya wrote:
but not like that, what i mean is full green, when 60% the image will be yellow, if 30% that will be red

Then you should make the image by yourself dexterkamiya and use the %tenth code! All who made a widgets like this use custom images..
Like this one:
http://android.xwidget.com/page/widgets ... ontal.html
or
use the "when the % is .... show this" script like this one:
viewtopic.php?f=11&t=3036&hilit=lights

Author:  dexterkamiya [ December 9th, 2013, 10:31 pm ]
Post subject:  Re: [ASK] Code for change image in %

jimking wrote:
dexterkamiya wrote:
but not like that, what i mean is full green, when 60% the image will be yellow, if 30% that will be red

Then you should make the image by yourself dexterkamiya and use the %tenth code! All who made a widgets like this use custom images..
Like this one:
http://android.xwidget.com/page/widgets ... ontal.html
or
use the "when the % is .... show this" script like this one:
viewtopic.php?f=11&t=3036&hilit=lights


thanks, its work now :D
thanks for helping

ScreenShoot

Author:  hamid [ December 10th, 2013, 9:52 am ]
Post subject:  Re: [ASK] Code for change image in %

as an another way:
you could also use this in your code:
Code:
progressbar1.Fore.Draw.SolidColor.Color=rgba(241,117,0,255)

and use your color inside rgba()
for example:
rgba(241,117,0,255) //for orange color
rgba(19,228,0,255) //for green color
rgba(226,0,0,255) //for red color

you can get color numbers from one of the select color dialogs in designer


====================
by using this method
the code will be like this:
Code:
function cpucore1OnUpdate(Sender)
{
  if(cpucore1.get("%Percent")<50)
  {
     progressbar1.Fore.Draw.SolidColor.Color=rgba(19,228,0,255)
  }
  else if(cpucore1.get("%Percent")>=50&cpucore1.get("%Percent")<80)
  {
     progressbar1.Fore.Draw.SolidColor.Color=rgba(241,117,0,255)
  }
  else if(cpucore1.get("%Percent")>=80)
  {
     progressbar1.Fore.Draw.SolidColor.Color=rgba(226,0,0,255)
  }
}

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