Skip to content

Commit

Permalink
Merge pull request skulpt#56 from slobber/master
Browse files Browse the repository at this point in the history
change turtle color, fillcolor, pencolor implement
  • Loading branch information
bnmnetp committed Mar 24, 2013
2 parents 397608d + 4b219b1 commit e6a5c26
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/lib/turtle/__init__.js
Original file line number Diff line number Diff line change
Expand Up @@ -1529,16 +1529,19 @@ var $builtinmodule = function(name) {
// Color Control
//

$loc.fillcolor = new Sk.builtin.func(function(self, color) {
checkArgs(2,arguments.length,"fillcolor()");
$loc.fillcolor = new Sk.builtin.func(function(self, color, green, blue) {
if (color) {
color = color.v || self.theTurtle.context.fillStyle;
self.theTurtle.set_fill_color(color);
if (blue) {
self.theTurtle.set_fill_color(color, green, blue);
} else {
color = color.v || self.theTurtle.context.fillStyle;
self.theTurtle.set_fill_color(color);
}
} else
return self.theTurtle.fillStyle;
});

$loc.color = new Sk.builtin.func(function(self, color, green, blue) {
$loc.pencolor = new Sk.builtin.func(function(self, color, green, blue) {
if (color) {
if (blue) {
self.theTurtle.set_pen_color(color, green, blue);
Expand All @@ -1550,7 +1553,19 @@ var $builtinmodule = function(name) {
return self.theTurtle.penStyle;
});

$loc.pencolor = $loc.color;
$loc.color = new Sk.builtin.func(function(self, color, green, blue) {
if(color) {
if (blue) {
self.theTurtle.set_pen_color(color, green, blue);
self.theTurtle.set_fill_color(color, green, blue);
} else {
color = color.v || self.theTurtle.context.fillStyle;
self.theTurtle.set_pen_color(color);
self.theTurtle.set_fill_color(color);
}
} else
return [self.theTurtle.penStyle, self.theTurtle.fillStyle];
});

//
// Filling
Expand Down

0 comments on commit e6a5c26

Please sign in to comment.