Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tacanvas.py28
-rw-r--r--taconstants.py16
-rw-r--r--talogo.py5
3 files changed, 36 insertions, 13 deletions
diff --git a/tacanvas.py b/tacanvas.py
index bf256a8..d7a9e9a 100644
--- a/tacanvas.py
+++ b/tacanvas.py
@@ -26,7 +26,7 @@ from tasprite_factory import SVG
from tautils import image_to_base64, data_to_string, round_int
import pango
import cairo
-from taconstants import CANVAS_LAYER, DEFAULT_TURTLE
+from taconstants import CANVAS_LAYER, DEFAULT_TURTLE, BLACK, WHITE
import logging
_logger = logging.getLogger('turtleart-activity')
@@ -391,12 +391,26 @@ class TurtleGraphics:
self.poly_points = []
def set_fgcolor(self):
- sh = (wrap100(self.shade) - 50)/50.0
- rgb = color_table[wrap100(self.color)]
- r, g, b = (rgb>>8)&0xff00, rgb&0xff00, (rgb<<8)&0xff00
- r, g, b = calc_gray(r, self.gray), calc_gray(g, self.gray),\
- calc_gray(b, self.gray)
- r, g, b = calc_shade(r, sh), calc_shade(g, sh), calc_shade(b, sh)
+ if self.color == WHITE or self.shade == WHITE:
+ r = 0xFF00
+ g = 0xFF00
+ b = 0xFF00
+ elif self.color == BLACK or self.shade == BLACK:
+ r = 0x0000
+ g = 0x0000
+ b = 0x0000
+ else:
+ sh = (wrap100(self.shade) - 50)/50.0
+ rgb = color_table[wrap100(self.color)]
+ r = (rgb>>8)&0xff00
+ r = calc_gray(r, self.gray)
+ r = calc_shade(r, sh)
+ g = rgb&0xff00
+ g = calc_gray(g, self.gray)
+ g = calc_shade(g, sh)
+ b = (rgb<<8)&0xff00
+ b = calc_gray(b, self.gray)
+ b = calc_shade(b, sh)
self.fgrgb = [r>>8, g>>8, b>>8]
self.fgcolor = self.cm.alloc_color(r, g, b)
self.svg.set_stroke_color("#%02x%02x%02x" % (self.fgrgb[0],
diff --git a/taconstants.py b/taconstants.py
index 7bd52ec..fb4f191 100644
--- a/taconstants.py
+++ b/taconstants.py
@@ -122,7 +122,8 @@ PALETTES = [['clean', 'forward', 'back', 'show', 'left', 'right',
['penup','pendown', 'setpensize', 'fillscreen', 'pensize',
'setcolor', 'setshade', 'setgray', 'color', 'shade',
'gray', 'startfill', 'stopfill' ],
- [ 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple'],
+ [ 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple',
+ 'white', 'black'],
['plus2', 'minus2', 'product2',
'division2', 'identity2', 'remainder2', 'sqrt', 'random',
'number', 'greater2', 'less2', 'equal2', 'not', 'and2', 'or2'],
@@ -152,7 +153,8 @@ COLORS = [["#00FF00","#00A000"], ["#00FFFF","#00A0A0"], ["#00FFFF","#00A0A0"],
BOX_COLORS = {'red':["#FF0000","#A00000"],'orange':["#FFD000","#AA8000"],
'yellow':["#FFFF00","#A0A000"],'green':["#00FF00","#008000"],
'cyan':["#00FFFF","#00A0A0"],'blue':["#0000FF","#000080"],
- 'purple':["#FF00FF","#A000A0"]}
+ 'purple':["#FF00FF","#A000A0"], 'white':["#FFFFFF", "#A0A0A0"],
+ 'black':["#000000", "#000000"]}
#
# Misc. parameters
@@ -169,6 +171,8 @@ PALETTE_SCALE = 1.5
DEFAULT_TURTLE = 1
HORIZONTAL_PALETTE = 0
VERTICAL_PALETTE = 1
+BLACK = 0xFFFFFFFF
+WHITE = 0xFFFFFFFE
#
# Block-style definitions
@@ -193,8 +197,8 @@ BASIC_STYLE_2ARG = ['arc', 'setxy', 'fillscreen', 'storein', 'write']
BOX_STYLE = ['number', 'xcor', 'ycor', 'heading', 'pensize', 'color', 'shade',
'textcolor', 'textsize', 'box1', 'box2', 'string', 'leftpos', 'scale',
'toppos', 'rightpos', 'bottompos', 'width', 'height', 'pop', 'keyboard',
- 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple',
- 'titlex', 'titley', 'leftx', 'topy', 'rightx', 'bottomy',
+ 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'white',
+ 'black', 'titlex', 'titley', 'leftx', 'topy', 'rightx', 'bottomy',
'volume', 'pitch', 'voltage', 'resistance', 'gray']
BOX_STYLE_MEDIA = ['description', 'audio', 'journal']
NUMBER_STYLE = ['plus2', 'product2', 'myfunc']
@@ -261,6 +265,7 @@ BLOCK_NAMES = {
'arc':[_('arc'), _('angle'), _('radius')],
'audio':[' '],
'back':[_('back')],
+ 'black':[_('black')],
'blue':[_('blue')+' = 70'],
'bottompos':[_('bottom')],
'bottomy':[_('picture bottom')],
@@ -395,6 +400,7 @@ BLOCK_NAMES = {
'wait':[_('wait')],
'while':[_('while')],
'while2':[_('while')],
+ 'white':[_('white')],
'width':[_('width')],
'write':[_('write')],
'xcor':[_('xcor')],
@@ -410,6 +416,7 @@ PRIMITIVES = {
'and2':'and',
'arc':'arc',
'back':'back',
+ 'black':'black',
'blue':'blue',
'bottompos':'bpos',
'bottomy':'boty',
@@ -528,6 +535,7 @@ PRIMITIVES = {
'vspace':'nop',
'wait':'wait',
'while2':'while',
+ 'white':'white',
'width':'hres',
'write':'write',
'xcor':'xcor',
diff --git a/talogo.py b/talogo.py
index 87e89ba..09f1e0a 100644
--- a/talogo.py
+++ b/talogo.py
@@ -32,7 +32,7 @@ try:
except:
pass
-from taconstants import PALETTES, PALETTE_NAMES, TAB_LAYER
+from taconstants import PALETTES, PALETTE_NAMES, TAB_LAYER, BLACK, WHITE
from tagplay import play_audio, play_movie_from_file, stop_media
from tajail import myfunc, myfunc_import
from tautils import get_pixbuf_from_journal, movie_media_type, convert, \
@@ -251,6 +251,7 @@ class LogoCode:
'and':[2, lambda self, x, y: taand(x, y)],
'arc':[2, lambda self, x, y: self.tw.canvas.arc(x, y)],
'back':[1, lambda self, x: self.tw.canvas.forward(-x)],
+ 'black':[0, lambda self: BLACK],
'blue':[0, lambda self: 70],
'bpos':[0, lambda self: -self.tw.canvas.height/(self.tw.coord_scale*2)],
'boty':[0, lambda self: self.tw.bottomy],
@@ -367,6 +368,7 @@ class LogoCode:
'vres':[0, lambda self: self.tw.canvas.height/self.tw.coord_scale],
'wait':[1, self.prim_wait, True],
# 'while':[2, self.prim_while, True],
+ 'white':[0, lambda self: WHITE],
'write':[2, lambda self, x, y: self.write(self, x, y)],
'xcor':[0, lambda self: self.tw.canvas.xcor/self.tw.coord_scale],
'ycor':[0, lambda self: self.tw.canvas.ycor/self.tw.coord_scale],
@@ -1167,7 +1169,6 @@ class LogoCode:
if text is not None:
self.tw.canvas.draw_text(text, int(x), int(y),
self.body_height, int(w))
-
# Depreciated block methods