XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 10th, 2025, 6:24 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 16 posts ] 
Author Message
PostPosted: February 11th, 2015, 1:24 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
I'm recreating Windows sidebar weather in xwidget and I would like to know if it's possible to change text color with a function. Basically... would be possible to change text form black to white when the dark and grey images are used as weather image?

Another question: I want to add moonphases and I already got an idea about how to do it in terms of design. There's an offline script with 30 images, but how many images are instead supported in accuweather core moon phases and how do you need to name them?

Thank you in advance :)

a w.i.p. of the widget is attached :)


Attachments:
weather_gadget_w7(1).xwp [1.69 MiB]
Downloaded 466 times


Last edited by dark13 on February 12th, 2015, 8:37 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: February 12th, 2015, 1:05 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
About the moon phases with this script:
http://jimking.deviantart.com/art/Moon- ... -369398725
(it's great because doesn't need internet connection to work)

I downloaded your .xwp but you need to create someting...
There is no design to edit...

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 12th, 2015, 8:46 am 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
Oops, I uploaded the wrong file, now the widget in the first post is the correct one and is almost finished :p

I already tested that offline script, i may use it but the original windows gaget has lonly 8 state and the script support 30 images, so i was guessing if accuweather core has less state :p I could "convert" the 8 state into 30 state but i would like to see how accuweather core works with moon phases. Moreover, as far as i've seen (consider i'm not a coder and most of the script seems "alien language" to me) the moonphases script runs only on load widget and does not automatically update


Top
 Profile  
 
PostPosted: February 12th, 2015, 1:48 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Quote:
I already tested that offline script, i may use it but the original windows gaget has lonly 8 state and the script support 30 images, so i was guessing if accuweather core has less state :p I could "convert" the 8 state into 30 state but i would like to see how accuweather core works with moon phases. Moreover, as far as i've seen (consider i'm not a coder and most of the script seems "alien language" to me) the moonphases script runs only on load widget and does not automatically update

Normally the moonphases must be created with 30 images (one for each day of the month)
The script code was made from a guy who is prof so don't worry, it will show the right image! ;)

I don't understand very well your thought about the txt, but you can create a secondary layer with the same components but with other color for the text, and with a right click option the user will can select the color..

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 12th, 2015, 2:29 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
Image

See the image above. On the original gadget the text is white when black or gray images are used (bad weather/night) and black when blue images are used (day/good time). So the question is: is it possible to change text color using weather image as variable?

Currently adding "docked" version of original gadget using xwidget's back side :p


Top
 Profile  
 
PostPosted: February 12th, 2015, 3:19 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Look, I know two modes for day/night mode:
1) Add a datetimecore and put "bg_${dayOrNight}.png" for tag
Works for images: create two images one for the day "bg_d" and one for the night "bg_n"

2) You can create two layers, one with the light and one with the dark text and use is this kind of script:
Code:
function datetimecore1OnUpdate(Sender)
{
    var mydate = new Date();
    var h = mydate.getHours();
    if(h>19||h<6) //night
    {
       layerlight = visible.false
       layerdark = visible.true
    }
    else          //day  6:00~20:00
    {
       layerlight = visible.true
       layerdark = visible.false
    }

}

The "bad" using this script is that the day/night hours depend on the values of the script..

The solution for me is more simple: Add shadow on the text to have better and more clear visual on day and night without any particular trick or script, like I did when I made something similar porting all the Win Vista-7 gadgets: ;)
http://jimking.deviantart.com/art/Windo ... -409728691
(check the weather widget to see what I mean)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 12th, 2015, 4:07 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
Havent' seen that, probably if I would have found it before i wouldn have just modified your widget, consider that in italian weather description are REALLY long :D

Image

Just curious... why didn't you used the original graphic and used "flip" function for big/small variant?

Thanks for the script, i'll try also shadow. The fact is i don't like too much how xwidget render fonts, I wanted to convert my samurize widget but having a decent rendering on little font seems almost impossible (yeah, tryed gdi++ but rendering is still inferior to samurize on tiny font)...

Image


Top
 Profile  
 
PostPosted: February 13th, 2015, 2:16 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Quote:
consider that in italian weather description are REALLY long

Vivo in Italia da tanti anni quindi ti posso parlare anche in italiano! :D
Quote:
Just curious... why didn't you used the original graphic and used "flip" function for big/small variant?

Non lo pensato... :lol:
Quote:
The fact is i don't like too much how xwidget render fonts, I wanted to convert my samurize widget but having a decent rendering on little font seems almost impossible (yeah, tryed gdi++ but rendering is still inferior to samurize on tiny font)...

Si, lo so che XWidget ha un piccolo problema con il "rendering" ma nella versione 2.0 sara' anche questa parte ottimizata. :)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 13th, 2015, 3:02 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
La cosa piu' divertente dei forum internazionali e' che finisci sempre per trovare qualcuno che parla la tua lingua :p

The widget is almost complete. Settings images have the same behaviour of w7 gadget's, sadly when the mouse is on a button the main button with setting GUI disappear. Honestly I don't think there's a fix for this as I want to keep settings buttons showing only on mouseover.

Now I need only to understant how "convert" the 30 moon phases in the traditional 8 moon phases...


Attachments:
weather_gadget_w7.xwp [2.24 MiB]
Downloaded 445 times
Top
 Profile  
 
PostPosted: February 14th, 2015, 1:32 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Quote:
sadly when the mouse is on a button the main button with setting GUI disappear. Honestly I don't think there's a fix for this as I want to keep settings buttons showing only on mouseover.

@dark13 the buttons are made a little confusing..
You need to edit them properly. No need to assign all the four images.
Please re-upload the widget but this time use only the "Buttom Up Image" and the Buttom Hot Image".
Put them all in a layer. Then we have to test various modes to fix it or if we have to use a script.
Is it possible...

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 14th, 2015, 2:01 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
Ok, I fixed the setting buttons. I was using a button for background but in the very end all I needed was an image with fadeIn/fadeOut animation. Now it's MUCH better. :p

Now the problem is only one: how can i convert the 0-30 accuweather icon to w7 gadget's 8 icon? I tried to use RSS core but farmer but farmer's almanac return "Moon Phases: Waning Crescent". ":" can't be used in a filename and html code "&#58;" does not seems to work either. I did a bit of research but I really can't understand why AW uses 31 icon for the lunar phases...


Attachments:
weather_gadget_w7.xwp [2.24 MiB]
Downloaded 462 times
Top
 Profile  
 
PostPosted: February 14th, 2015, 5:24 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
The right representation of the moon phases should have 30 images, one for each day of the month.
No need to convert the icons. Just look to select 8 from the 30 images that will be similar with the 8 images of the defaut/original widget. I think that you should use 30 to your design and the script from the widget that I sent you..

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 14th, 2015, 8:12 pm 
Offline

Joined: February 11th, 2015, 1:14 pm
Posts: 7
Jim, I'll gonna use accuweather core for moonphases as the script seems to show a different moonphase (maybe wrong iconset?). The widget needs internet anyway, so I think using accuweather makes sense :p

The problem is "understanding" when a certain phase starts and ends looking at the icons :p. Anyway I'll do the "longest" (and more precise) way... checking moonphases and the icon showed by accuweather core.

Many people don't like "repros" as there's no design freedom but I really like to re-create (good) skins in a different software. I'ts like "hacking" a software using only design, searching the most polished way to "force" a software doing something it's not specifically designed to do :D Obviously you need as base a software coded for a great degree of design possibilities :p

Here's the "trick": the moonphases layer is behind the weather layer and some weather layers have an "hole", so the moonphases will be showed ONLY in some weather states, just like the original w7 widget :D

Need just to check when monnphases starts and ends, and make the same "trick" with "back" graphics :)


Attachments:
weather_gadget_w7.xwp [2.27 MiB]
Downloaded 494 times
Top
 Profile  
 
PostPosted: February 15th, 2015, 2:06 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
The script that I used on my widgets with moon phases no need Internet connection to work..
Now, if you want some more complicated things like the moon phases appeared only in a certain weather conditions you need an extra script....

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: February 27th, 2015, 8:23 am 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
dark13 wrote:
Jim, I'll gonna use accuweather core for moonphases as the script seems to show a different moonphase (maybe wrong iconset?).


I might have made some mathematical errors. Let me check

New moon - Disk completely in Sun's shadow (lit by earthshine only)
Waxing crescent - Right side, 1–49% lit disc Left side, 1–49% lit disc
First quarter - Right side, 50%-lit disc Left side, 50%-lit disc
Waxing gibbous - Right side, 51–99% lit disc Left side, 51–99% lit disc
Full moon - Completely illuminated disc
Waning gibbous - Left side, 51–99% lit disc Right side, 51–99% lit disc
Last quarter - Left side, 50%-lit disc Right side, 50%-lit disc
Waning crescent - Left side, 49-1% lit disc

It isn't that difficult to write moon phases.

I lost my code :( Just can't find it. And this search doesn't seem to work fine

Remember the post Jim where I gave the code?

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: February 27th, 2015, 9:08 am 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
Well I got it! (Dropbox!)

Code:
function moonage(d, m, y)
{
   var j;
   var ip, ag;
   j = juliandate(d, m, y);
   ip = (j + 4.867) / 29.53059;
   ip = ip - Math.floor(ip);
   if(ip < 0.5)
   {
      ag = ip * 29.53059 + 29.53059 / 2;
   }
   else
   {
      ag = ip * 29.53059 - 29.53059 / 2;
   }
   ag = Math.floor(ag) + 1;
   return ag;
}

function juliandate ( d, m, y )
{
   var d, m, y;
   var mm,  yy;
   var k1, k2, k3;
   var j;
   yy = y - Math.floor((12 - m) / 10);
   mm = m + 9;
   if (mm >= 12)
   {
      mm = mm - 12;
   }
   k1 = Math.floor(365.25 * (yy + 4712));
   k2 = Math.floor(30.6001 * mm + 0.5);
   k3 = Math.floor(Math.floor((yy / 100) + 49) * 0.75) - 38;
   j = k1 + k2 + d + 59;
   if (j > 2299160)
   {
      j = j - k3;
   }
   return j ;
}

function getPhase(d) {
           if(d == 0)
                return "new moon"; //zero moon? exists??
           else if(d <= 6)
                return "waxing cresent";
           else if(d == 7)
                return "first quarter";
           else if(d <= 14)
                return "waxing gibbous";
           else if(d == 15)
                return "full moon";
           else if(d <= 22)
                return "waning gibbous";
           else if(d == 23)
                return "last quarter";
           else if(d <= 29)
                return "waning cresent";
           else if(d == 30)
                return "new moon"; //It should not show
           else
                return "invalid";
}


Usage:
Code:
    var age = moonage(today.getDate(), today.getMonth(), today.getYear());
    print(age);
    print(getPhase(age));


About maths:
I think 5 digit precision should work fine. After all we're rounding up everything!
Anomaly? Please check what is used in getPhase(). That somewhat depends upon the definition, I wrote what I remember reading in my school. I tried google but may be not in the right direction

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group