| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,8 +60,8 @@ mpl.figure = function(figure_id, websocket, ondownload, parent_element) { | |||
| 60 | 60 | this.ws.onopen = function () { | |
| 61 | 61 | fig.send_message("supports_binary", {value: fig.supports_binary}); | |
| 62 | 62 | fig.send_message("send_image_mode", {}); | |
| 63 | - if (fig.ratio != 1) { | ||
| 64 | - fig.send_message("set_dpi_ratio", {'dpi_ratio': fig.ratio}); | ||
| 63 | + if (mpl.ratio != 1) { | ||
| 64 | + fig.send_message("set_dpi_ratio", {'dpi_ratio': mpl.ratio}); | ||
| 65 | 65 | } | |
| 66 | 66 | fig.send_message("refresh", {}); | |
| 67 | 67 | } | |
@@ -139,7 +139,7 @@ mpl.figure.prototype._init_canvas = function() { | |||
| 139 | 139 | this.context.oBackingStorePixelRatio || | |
| 140 | 140 | this.context.backingStorePixelRatio || 1; | |
| 141 | 141 | ||
| 142 | - this.ratio = (window.devicePixelRatio || 1) / backingStore; | ||
| 142 | + mpl.ratio = (window.devicePixelRatio || 1) / backingStore; | ||
| 143 | 143 | ||
| 144 | 144 | var rubberband = $('<canvas/>'); | |
| 145 | 145 | rubberband.attr('style', "position: absolute; left: 0; top: 0; z-index: 1;") | |
@@ -197,8 +197,8 @@ mpl.figure.prototype._init_canvas = function() { | |||
| 197 | 197 | canvas_div.css('width', width) | |
| 198 | 198 | canvas_div.css('height', height) | |
| 199 | 199 | ||
| 200 | - canvas.attr('width', width * this.ratio); | ||
| 201 | - canvas.attr('height', height * this.ratio); | ||
| 200 | + canvas.attr('width', width * mpl.ratio); | ||
| 201 | + canvas.attr('height', height * mpl.ratio); | ||
| 202 | 202 | canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;'); | |
| 203 | 203 | ||
| 204 | 204 | rubberband.attr('width', width); | |
@@ -332,10 +332,10 @@ mpl.figure.prototype.handle_resize = function(fig, msg) { | |||
| 332 | 332 | } | |
| 333 | 333 | ||
| 334 | 334 | mpl.figure.prototype.handle_rubberband = function(fig, msg) { | |
| 335 | - var x0 = msg['x0']; | ||
| 336 | - var y0 = fig.canvas.height - msg['y0']; | ||
| 337 | - var x1 = msg['x1']; | ||
| 338 | - var y1 = fig.canvas.height - msg['y1']; | ||
| 335 | + var x0 = msg['x0'] / mpl.ratio; | ||
| 336 | + var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio; | ||
| 337 | + var x1 = msg['x1'] / mpl.ratio; | ||
| 338 | + var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio; | ||
| 339 | 339 | x0 = Math.floor(x0) + 0.5; | |
| 340 | 340 | y0 = Math.floor(y0) + 0.5; | |
| 341 | 341 | x1 = Math.floor(x1) + 0.5; | |
@@ -491,8 +491,8 @@ mpl.figure.prototype.mouse_event = function(event, name) { | |||
| 491 | 491 | this.canvas_div.focus(); | |
| 492 | 492 | } | |
| 493 | 493 | ||
| 494 | - var x = canvas_pos.x; | ||
| 495 | - var y = canvas_pos.y; | ||
| 494 | + var x = canvas_pos.x * mpl.ratio; | ||
| 495 | + var y = canvas_pos.y * mpl.ratio; | ||
| 496 | 496 | ||
| 497 | 497 | this.send_message(name, {x: x, y: y, button: event.button, | |
| 498 | 498 | step: event.step, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments