inexorabletash / jslogo

Logo in JavaScript
https://calormen.com/jslogo
Other
368 stars 146 forks source link

Fill function does not work #98

Closed megaboich closed 7 years ago

megaboich commented 7 years ago

Well, i am not sure why this is happening, but looks like fill operation is not working. Sample program:

arc 360 100 fill

I would expect to have filled circle as a result. Instead I have only one pixel at the center of circle.

I played a bit with floodfill.js - looks like something wrong is happening inside getColorAt function, but I do not really understand the code, it is quite cryptic because of optimizations. And it is not quite clear why it is not working anymore, that code has not been changed for ages.

megaboich commented 7 years ago

After some investigation I discovered that floodFill does not like traslated context. I was able to fix behavior altering fill method in turtle.js

   fill: {value: function() {
      this.canvas_ctx.save();
      this.canvas_ctx.setTransform(1, 0, 0, 1, 0, 0);
      this.canvas_ctx.floodFill(this.x + this.width/2, - this.y + this.height/2);
      this.canvas_ctx.restore();
    }},
inexorabletash commented 7 years ago

Thanks for the report, and sorry about the regression!