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

W7 weather REPRO in xwidget, need help
https://bbs.xwidget.com/viewtopic.php?f=8&t=5476
Page 1 of 1

Author:  dark13 [ February 11th, 2015, 1:24 pm ]
Post subject:  W7 weather REPRO in xwidget, need help

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 500 times

Author:  Jimking [ February 12th, 2015, 1:05 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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...

Author:  dark13 [ February 12th, 2015, 8:46 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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

Author:  Jimking [ February 12th, 2015, 1:48 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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..

Author:  dark13 [ February 12th, 2015, 2:29 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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

Author:  Jimking [ February 12th, 2015, 3:19 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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)

Author:  dark13 [ February 12th, 2015, 4:07 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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

Author:  Jimking [ February 13th, 2015, 2:16 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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. :)

Author:  dark13 [ February 13th, 2015, 3:02 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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 475 times

Author:  Jimking [ February 14th, 2015, 1:32 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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...

Author:  dark13 [ February 14th, 2015, 2:01 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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 495 times

Author:  Jimking [ February 14th, 2015, 5:24 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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..

Author:  dark13 [ February 14th, 2015, 8:12 pm ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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 528 times

Author:  Jimking [ February 15th, 2015, 2:06 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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....

Author:  digigamer [ February 27th, 2015, 8:23 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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?

Author:  digigamer [ February 27th, 2015, 9:08 am ]
Post subject:  Re: W7 weather REPRO in xwidget, need help

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

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