Skip to content

Commit

Permalink
change turtle color, fillcolor, pencolor implement
Browse files Browse the repository at this point in the history
in python, turtle color is set both fillcolor and pencolor, but in
skulpt color equal pencolor, so i change them like python do.
  • Loading branch information
slobber committed Mar 24, 2013
1 parent 397608d commit 4b219b1
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 4b219b1

Please sign in to comment.