From 3e898b8b42b8e930e7e33fcfd89d9a4fafcbd18a Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 08 Mar 2011 03:55:04 +0000 Subject: force scaling to predefined constants to fix pixel alignment problems (#2442) --- (limited to 'TurtleArtActivity.py') diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 21a9480..3826e13 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -44,7 +44,7 @@ import os.path import tarfile from TurtleArt.tapalette import palette_names, help_strings -from TurtleArt.taconstants import OVERLAY_LAYER, ICON_SIZE +from TurtleArt.taconstants import OVERLAY_LAYER, ICON_SIZE, BLOCK_SCALE from TurtleArt.taexporthtml import save_html from TurtleArt.taexportlogo import save_logo from TurtleArt.tautils import data_to_file, data_to_string, data_from_string, \ @@ -343,15 +343,24 @@ class TurtleArtActivity(activity.Activity): def do_grow_blocks_cb(self, button): """ Grow the blocks. """ - self.do_resize_blocks(1.5) + self.do_resize_blocks(1) def do_shrink_blocks_cb(self, button): """ Shrink the blocks. """ - self.do_resize_blocks(0.67) + self.do_resize_blocks(-1) - def do_resize_blocks(self, scale_factor): + def do_resize_blocks(self, inc): """ Scale the blocks. """ - self.tw.block_scale *= scale_factor + if self.tw.block_scale in BLOCK_SCALE: + i = BLOCK_SCALE.index(self.tw.block_scale) + inc + else: + i = 2.0 + if i < 0: + self.tw.block_scale = BLOCK_SCALE[0] + elif i == len(BLOCK_SCALE): + self.tw.block_scale = BLOCK_SCALE[-1] + else: + self.tw.block_scale = BLOCK_SCALE[i] self.tw.resize_blocks() def do_cartesian_cb(self, button): -- cgit v0.9.1