Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-15 15:07:47 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-15 15:07:47 (GMT)
commit18ddba47083044f35d10d19cdfd155ea21df1047 (patch)
tree520289b1c5a8cf1c1cd59722b12fbc6797733da0
parent88cd4c47e95e48d15ab504db80356bf01e52186d (diff)
fixed Logo export bug
-rw-r--r--taexportlogo.py69
-rwxr-xr-xturtleart.py17
2 files changed, 60 insertions, 26 deletions
diff --git a/taexportlogo.py b/taexportlogo.py
index 2311872..7fde81c 100644
--- a/taexportlogo.py
+++ b/taexportlogo.py
@@ -19,7 +19,7 @@
#THE SOFTWARE.
IGNORE = ["hideblocks", "showblocks", "fullscreen", "polar", "cartesian",
- "sandwichbottom"]
+ "sandwichbottom", "id"]
import math
from tautils import walk_stack
@@ -40,9 +40,9 @@ make \"g (:g * :s) \r\
make \"b (:b * :s) \r\
] [ \
make \"s (:s * 0.9) \r\
-make \"r (:r + ((100-:r) * :s)) \r\
-make \"g (:g + ((100-:g) * :s)) \r\
-make \"b (:b + ((100-:b) * :s)) \r\
+make \"r (:r + ((99-:r) * :s)) \r\
+make \"g (:g + ((99-:g) * :s)) \r\
+make \"b (:b + ((99-:b) * :s)) \r\
] \
setpalette :i (list :r :g :b) \r\
end \r\
@@ -78,27 +78,27 @@ setpencolor :color + 8 \r\
end \r\
\
make \"colors [ \
-100 0 0 100 5 0 100 10 0 100 15 0 100 20 0 \
-100 25 0 100 30 0 100 35 0 100 40 0 100 45 0 \
-100 50 0 100 55 0 100 60 0 100 65 0 100 70 0 \
-100 75 0 100 80 0 100 85 0 100 90 0 100 95 0 \
-100 100 0 90 100 0 80 100 0 70 100 0 60 100 0 \
-50 100 0 40 100 0 30 100 0 20 100 0 10 100 0 \
-0 100 0 0 100 5 0 100 10 0 100 15 0 100 20 0 \
-100 25 0 100 30 0 100 35 0 100 40 0 100 45 \
-0 100 50 0 100 55 0 100 60 0 100 65 0 100 70 \
-0 100 75 0 100 80 0 100 85 0 100 90 0 100 95 \
-0 100 100 0 95 100 0 90 100 0 85 100 0 80 100 \
-0 75 100 0 70 100 0 65 100 0 60 100 0 55 100 \
-0 50 100 0 45 100 0 40 100 0 35 100 0 30 100 \
-0 25 100 0 20 100 0 15 100 0 10 100 0 5 100 \
-0 0 100 5 0 100 10 0 100 15 0 100 20 0 100 25 \
-0 100 30 0 100 35 0 100 40 0 100 45 0 100 \
-50 0 100 55 0 100 60 0 100 65 0 100 70 0 100 \
-75 0 100 80 0 100 85 0 100 90 0 100 95 0 100 \
-100 0 100 100 0 90 100 0 80 100 0 70 100 0 60 \
-100 0 50 100 0 40 100 0 30 100 0 20 100 0 10] \r\
-make \"shade 50 \r\
+99 0 0 99 5 0 99 10 0 99 15 0 99 20 0 \
+99 25 0 99 30 0 99 35 0 99 40 0 99 45 0 \
+99 50 0 99 55 0 99 60 0 99 65 0 99 70 0 \
+99 75 0 99 80 0 99 85 0 99 90 0 99 95 0 \
+99 99 0 90 99 0 80 99 0 70 99 0 60 99 0 \
+50 99 0 40 99 0 30 99 0 20 99 0 10 99 0 \
+ 0 99 0 0 99 5 0 99 10 0 99 15 0 99 20 \
+ 0 99 25 0 99 30 0 99 35 0 99 40 0 99 45 \
+ 0 99 50 0 99 55 0 99 60 0 99 65 0 99 70 \
+ 0 99 75 0 99 80 0 99 85 0 99 90 0 99 95 \
+ 0 99 99 0 95 99 0 90 99 0 85 99 0 80 99 \
+ 0 75 99 0 70 99 0 65 99 0 60 99 0 55 99 \
+ 0 50 99 0 45 99 0 40 99 0 35 99 0 30 99 \
+ 0 25 99 0 20 99 0 15 99 0 10 99 0 5 99 \
+ 0 0 99 5 0 99 10 0 99 15 0 99 20 0 99 \
+25 0 99 30 0 99 35 0 99 40 0 99 45 0 99 \
+50 0 99 55 0 99 60 0 99 65 0 99 70 0 99 \
+75 0 99 80 0 99 85 0 99 90 0 99 95 0 99 \
+99 0 99 99 0 90 99 0 80 99 0 70 99 0 60 \
+99 0 50 99 0 40 99 0 30 99 0 20 99 0 10] \r\
+make \"shade 50 \r\
tasetshade :shade \r"
bs = tw.just_blocks()
@@ -112,10 +112,12 @@ tasetshade :shade \r"
setcolor = False
setxy = False
pensize = False
+ setpensize = False
arc = False
heap = False
write = False
minus = False
+ division = False
image = False
"""
@@ -240,6 +242,9 @@ tasetshade :shade \r"
elif d == "pensize":
pensize = True
this_stack += "tapensize"
+ elif d == "setpensize":
+ setpensize = True
+ this_stack += "tasetpensize"
elif d == "arc":
arc = True
this_stack += "taarc"
@@ -284,8 +289,18 @@ tasetshade :shade \r"
this_stack += "label"
show = 1
elif d == "minus2":
- this_stack == "taminus"
+ this_stack += "taminus"
minus = True
+ elif d == "division":
+ this_stack += "quotient"
+ elif d == "lpos":
+ this_stack += str(-tw.canvas.width/(tw.coord_scale*2))
+ elif d == "rpos":
+ this_stack += str(tw.canvas.width/(tw.coord_scale*2))
+ elif d == "bpos":
+ this_stack += str(-tw.canvas.height/(tw.coord_scale*2))
+ elif d == "tpos":
+ this_stack += str(tw.canvas.height/(tw.coord_scale*2))
elif d in IGNORE:
this_stack += " "
elif show == 1 and d[0:2] == "#s":
@@ -315,6 +330,8 @@ tasetshade :shade \r"
"tasetshade :shade\rsetbackground :color\rend\r" + code
if setcolor: # Load the Turtle Art color palette.
code = color_processing + code
+ if setpensize: # Set int of pensize
+ code = "to tasetpensize :a\rsetpensize round :a\rend\r" + code
if pensize: # Return only the first argument.
code = "to tapensize\routput first round pensize\rend\r" + code
if setxy: # Swap and round arguments
diff --git a/turtleart.py b/turtleart.py
index 9cad683..caaa8ea 100755
--- a/turtleart.py
+++ b/turtleart.py
@@ -31,6 +31,7 @@ from tautils import data_to_string, data_from_string, get_save_name
from tawindow import TurtleArtWindow
from taexporthtml import save_html
+from taexportlogo import save_logo
def makepath(path):
""" Make a path if it doesn't previously exist """
@@ -91,6 +92,10 @@ class TurtleMain():
menu.append(menu_items)
menu_items.connect("activate", self._do_save_html_cb)
menu_items.show()
+ menu_items = gtk.MenuItem(_("Save as Logo"))
+ menu.append(menu_items)
+ menu_items.connect("activate", self._do_save_logo_cb)
+ menu_items.show()
activity_menu = gtk.MenuItem(_("File"))
activity_menu.show()
@@ -245,6 +250,18 @@ class TurtleMain():
f.close()
self.tw.saved_pictures = []
+ def _do_save_logo_cb(self, widget):
+ """ Callback for save project to Logo. """
+ logocode = save_logo(self.tw)
+ if len(logocode) == 0:
+ return
+ save_type = '.lg'
+ filename, self.tw.load_save_folder = get_save_name(save_type,
+ self.tw.load_save_folder, 'logosession')
+ f = file(filename, "w")
+ f.write(logocode)
+ f.close()
+
def _do_resize_cb(self, widget, factor):
""" Callback to resize blocks. """
if factor == -1: