Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canvas backgroundColor does not accommodate for zoom and panning of the canvas #2631

Closed
jtweku opened this issue Nov 17, 2015 · 5 comments
Closed
Assignees
Labels

Comments

@jtweku
Copy link

jtweku commented Nov 17, 2015

if the canvas has fill color and you start zooming and panning the canvas the background is only showing up the original width and height. this javacript code in the static_canvas.class.js below supposed to fix that.

_renderBackgroundOrOverlay: function(ctx, property) {

      var object = this[property + 'Color'];
      if (object) {
        ctx.fillStyle = object.toLive
          ? object.toLive(ctx)
          : object;
        ctx.fillRect(
           (-this.viewportTransform[4] * 1/this.viewportTransform[0]),
           (-this.viewportTransform[5] * 1/this.viewportTransform[0]),
          this.width * 1/this.viewportTransform[0],
          this.height * 1/this.viewportTransform[0]);
      }
      object = this[property + 'Image'];
      if (object) {
        object.render(ctx);
      }

    },
@asturur
Copy link
Member

asturur commented Nov 17, 2015

ctx.fillRect(
           -this.viewportTransform[4] / this.viewportTransform[0],
           -this.viewportTransform[5] / this.viewportTransform[3],
          this.width / this.viewportTransform[0],
          this.height / this.viewportTransform[3]);

Just in case let's use proper x and y scaling for x and y.
Anyway this need further investigation. I do not know if backgroundImage is supposed to scale or not.
Also gradients should be checked.

@jtweku
Copy link
Author

jtweku commented Nov 17, 2015

thanks,
I made a sample code. if you start zooming out and pan the background color is becoming white.

https://jsfiddle.net/rvj293xw/1/

@asturur asturur mentioned this issue Nov 17, 2015
@asturur asturur self-assigned this Nov 17, 2015
@asturur
Copy link
Member

asturur commented Nov 17, 2015

https://jsfiddle.net/asturur/rvj293xw/2/

See updated fiddle with fixed behaviour.
Yes there was a bug in the library.

@jtweku
Copy link
Author

jtweku commented Nov 17, 2015

thank you @asturur !

@asturur
Copy link
Member

asturur commented Nov 18, 2015

closed via #2632

@asturur asturur closed this as completed Nov 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants