Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Moonwidgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'Moonwidgets.py')
-rw-r--r--Moonwidgets.py69
1 files changed, 35 insertions, 34 deletions
diff --git a/Moonwidgets.py b/Moonwidgets.py
index 051e682..7a1c233 100644
--- a/Moonwidgets.py
+++ b/Moonwidgets.py
@@ -137,33 +137,9 @@ class CalendarButton(gtk.EventBox):
wgc = mask_pixmap.new_gc(foreground=MG.FOREGROUND)
mask_pixmap.draw_rectangle(kgc, True, 0, 0, self.imagen_size, self.imagen_size)
-
- if self.data_model.phase_of_moon <= .25:
- #print "New Moon to First Quarter"
- phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
- arc_scale = int(self.imagen_size * (1 - (phase_shadow_adjust * 4)))
- mask_pixmap.draw_rectangle(wgc, True, self.imagen_size/2 + 1, 0, self.imagen_size/2, self.imagen_size - 1)
- mask_pixmap.draw_arc(kgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 17280, 11520)
- elif self.data_model.phase_of_moon <= .5:
- #print "First Quarter to Full Moon"
- phase_shadow_adjust = self.data_model.phase_of_moon + abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
- arc_scale = int(self.imagen_size * ((phase_shadow_adjust - .25) * 4))
- mask_pixmap.draw_rectangle(wgc, True, self.imagen_size/2, 0, self.imagen_size/2, self.imagen_size)
- mask_pixmap.draw_arc(wgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 5760, 11520)
- elif self.data_model.phase_of_moon <= .75:
- #print "Full Moon to Last Quarter"
- phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
- arc_scale = int(self.imagen_size * (1 - ((phase_shadow_adjust - .5) * 4)))
- mask_pixmap.draw_rectangle(wgc, True, 0, 0, self.imagen_size/2 + 1, self.imagen_size)
- mask_pixmap.draw_arc(wgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 17280, 11520)
- else:
- #print "Last Quarter to New Moon"
- phase_shadow_adjust = self.data_model.phase_of_moon + abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
- arc_scale = int(self.imagen_size * ((phase_shadow_adjust - .75) * 4))
- mask_pixmap.draw_rectangle(wgc, True, 0, 0, self.imagen_size/2, self.imagen_size) # mitad de luna blanca
- mask_pixmap.draw_arc(kgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 5760, 11520)
-
+ mask_pixmap = self.draw_fase_moon(mask_pixmap, kgc, wgc)
maskgc = self.image_pixmap.new_gc(clip_mask=mask_pixmap)
+
moon_pixbuf = self.moon_stamp.scale_simple(self.imagen_size, self.imagen_size, gtk.gdk.INTERP_BILINEAR)
# Composite bright Moon image and semi-transparant Moon for shadow detail
@@ -172,29 +148,27 @@ class CalendarButton(gtk.EventBox):
uno = (self.data_model.next_lunar_eclipse_sec == -1 and self.data_model.last_lunar_eclipse_sec > 7200)
dos = (self.data_model.next_lunar_eclipse_sec > 7200 and self.data_model.last_lunar_eclipse_sec == -1)
- tres = min(self.data_model.next_lunar_eclipse_sec, self.data_model.last_lunar_eclipse_sec) > 7200
+ tres = min([self.data_model.next_lunar_eclipse_sec, self.data_model.last_lunar_eclipse_sec]) > 7200
- if uno or dos or tres:
- #print "Normal Moon phase render"
+ if uno or dos or tres: #print "Normal Moon phase render"
moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size, 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 127)
self.image_pixmap.draw_pixbuf(gc, dark_pixbuf, 0, 0, 0, 0) # parte oscura
self.image_pixmap.draw_pixbuf(maskgc, moon_pixbuf, 0, 0, 0, 0) # parte iluminada
- else:
- #print "Reddening eclipse effect, 2hrs (7200sec) before and after (by masking out green & blue)"
+
+ else: #print "Reddening eclipse effect, 2hrs (7200sec) before and after (by masking out green & blue)"
if self.data_model.next_lunar_eclipse_sec == -1:
eclipse_alpha = self.data_model.last_lunar_eclipse_sec / 7200.0 * 256
elif self.data_model.last_lunar_eclipse_sec == -1:
eclipse_alpha = self.data_model.next_lunar_eclipse_sec / 7200.0 * 256
else:
- eclipse_alpha = min(self.data_model.next_lunar_eclipse_sec,
- self.data_model.last_lunar_eclipse_sec) / 7200.0 * 256
+ eclipse_alpha = min([self.data_model.next_lunar_eclipse_sec,
+ self.data_model.last_lunar_eclipse_sec]) / 7200.0 * 256
moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size,
0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, int(196 - eclipse_alpha / 2))
self.image_pixmap.draw_pixbuf(gc, dark_pixbuf, 0, 0, 0, 0)
- del dark_pixbuf
dark_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.imagen_size, self.imagen_size)
moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size,
0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, int(eclipse_alpha))
@@ -279,6 +253,33 @@ class CalendarButton(gtk.EventBox):
pango_layout.set_text(compass_text[3])
self.image_pixmap.draw_layout(rgc, 15, 36 + 15, pango_layout)
+ def draw_fase_moon(self, mask_pixmap, kgc, wgc):
+ if self.data_model.phase_of_moon <= .25:
+ #print "New Moon to First Quarter"
+ phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
+ arc_scale = int(self.imagen_size * (1 - (phase_shadow_adjust * 4)))
+ mask_pixmap.draw_rectangle(wgc, True, self.imagen_size/2 + 1, 0, self.imagen_size/2, self.imagen_size - 1)
+ mask_pixmap.draw_arc(kgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 17280, 11520)
+ elif self.data_model.phase_of_moon <= .5:
+ #print "First Quarter to Full Moon"
+ phase_shadow_adjust = self.data_model.phase_of_moon + abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
+ arc_scale = int(self.imagen_size * ((phase_shadow_adjust - .25) * 4))
+ mask_pixmap.draw_rectangle(wgc, True, self.imagen_size/2, 0, self.imagen_size/2, self.imagen_size)
+ mask_pixmap.draw_arc(wgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 5760, 11520)
+ elif self.data_model.phase_of_moon <= .75:
+ #print "Full Moon to Last Quarter"
+ phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
+ arc_scale = int(self.imagen_size * (1 - ((phase_shadow_adjust - .5) * 4)))
+ mask_pixmap.draw_rectangle(wgc, True, 0, 0, self.imagen_size/2 + 1, self.imagen_size)
+ mask_pixmap.draw_arc(wgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 17280, 11520)
+ else:
+ #print "Last Quarter to New Moon"
+ phase_shadow_adjust = self.data_model.phase_of_moon + abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
+ arc_scale = int(self.imagen_size * ((phase_shadow_adjust - .75) * 4))
+ mask_pixmap.draw_rectangle(wgc, True, 0, 0, self.imagen_size/2, self.imagen_size) # mitad de luna blanca
+ mask_pixmap.draw_arc(kgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 5760, 11520)
+ return mask_pixmap
+
class DataModel():
def __init__(self, ahora):
self.ahora = ahora