diff options
author | Samus_ <mail2samus@gmail.com> | 2010-03-21 07:27:18 (GMT) |
---|---|---|
committer | Samus_ <mail2samus@gmail.com> | 2010-03-21 07:27:18 (GMT) |
commit | 248d74da46a12f55876c6874d0cc6a81f6185de2 (patch) | |
tree | ddfa0c2ed4aab1012786e6993efbb5e633202f6c | |
parent | 5e7877265f3f3ba85557f6eaaa7c2a6ee20a3d8d (diff) |
renaming variable "N"
-rwxr-xr-x | fracciones.activity/gtkcake.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fracciones.activity/gtkcake.py b/fracciones.activity/gtkcake.py index 0c2ffe8..3fe307a 100755 --- a/fracciones.activity/gtkcake.py +++ b/fracciones.activity/gtkcake.py @@ -22,14 +22,14 @@ WRADIUS = 0.44 class Cake(gtk.DrawingArea): """Widget que dibuja una torta y permite seleccionar trozos de ella""" - def __init__(self, N): + def __init__(self, subdivisions): gtk.DrawingArea.__init__(self) self.connect("expose_event", self.expose) self.connect("button_press_event", self.button_press) # Los eventos del raton no estan activados para el DrawingArea self.add_events(gtk.gdk.BUTTON_PRESS_MASK) - self.N = N - self.selected = N * [0] + self.subdivisions = subdivisions + self.selected = subdivisions * [0] def expose(self, widget, event): @@ -51,13 +51,13 @@ class Cake(gtk.DrawingArea): def draw(self, context): """Dibuja el contenido del widget""" - def draw_grid(context, N): + def draw_grid(context, subdivisions): """Dibuja la rejilla de la torta y sus subdivisiones""" context.set_source_rgb(0, 0, 0) context.arc(WIDTH/2, HEIGHT/2, RADIUS, 0, 2 * math.pi) context.stroke() - for i in xrange(N): - angle = 2 * math.pi * i / N + for i in xrange(subdivisions): + angle = 2 * math.pi * i / subdivisions context.move_to(WIDTH/2, HEIGHT/2) context.line_to( WIDTH/2 + RADIUS*math.cos(angle), @@ -70,13 +70,13 @@ class Cake(gtk.DrawingArea): """Enmascara la imagen de la torta y dibuja solo los trozos que no fueron seleccionados """ - N = len(selected) + subdivisions = len(selected) image_ctx = cairo.Context(image) image_ctx.set_operator(cairo.OPERATOR_CLEAR) - for sector in xrange(N): + for sector in xrange(subdivisions): if selected[sector]: - angle_start = 2 * math.pi * sector / N - angle_end = 2 * math.pi * (sector + 1) / N + angle_start = 2 * math.pi * sector / subdivisions + angle_end = 2 * math.pi * (sector + 1) / subdivisions image_ctx.move_to(WIDTH/2, HEIGHT/2) image_ctx.line_to( WIDTH/2 + RADIUS*math.cos(angle_start), @@ -110,7 +110,7 @@ class Cake(gtk.DrawingArea): mask_image(context, self.selected, image_fg) # Dibuja la rejilla - draw_grid(context, self.N) + draw_grid(context, self.subdivisions) context.restore() @@ -129,7 +129,7 @@ class Cake(gtk.DrawingArea): angle = math.atan2(wy, wx) if angle < 0: angle += 2 * math.pi - sector = angle * self.N / (2 * math.pi) + sector = angle * self.subdivisions / (2 * math.pi) index = int(math.floor(sector)) self.selected[index] = 1 - self.selected[index] return True |