pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/9f122cff310d68c8f0273ab29110cc108523c433

.css" /> Make WebAgg rubberband consistent with Qt backend · matplotlib/matplotlib@9f122cf · GitHub
Skip to content

Commit 9f122cf

Browse files
lucasgruwezQuLogic
andcommitted
Make WebAgg rubberband consistent with Qt backend
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent 51cb731 commit 9f122cf

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

  • lib/matplotlib/backends/web_backend/js

lib/matplotlib/backends/web_backend/js/mpl.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ mpl.figure.prototype._init_canvas = function () {
325325
canvas_div.appendChild(rubberband_canvas);
326326

327327
this.rubberband_context = rubberband_canvas.getContext('2d');
328-
this.rubberband_context.strokeStyle = '#000000';
329328

330329
this._resize_canvas = function (width, height, forward) {
331330
if (forward) {
@@ -469,19 +468,38 @@ mpl.figure.prototype.handle_rubberband = function (fig, msg) {
469468
y0 = Math.floor(y0) + 0.5;
470469
x1 = Math.floor(x1) + 0.5;
471470
y1 = Math.floor(y1) + 0.5;
472-
var min_x = Math.min(x0, x1);
473-
var min_y = Math.min(y0, y1);
474-
var width = Math.abs(x1 - x0);
475-
var height = Math.abs(y1 - y0);
476471

477-
fig.rubberband_context.clearRect(
472+
var ctx = fig.rubberband_context;
473+
ctx.clearRect(
478474
0,
479475
0,
480476
fig.canvas.width / fig.ratio,
481477
fig.canvas.height / fig.ratio
482478
);
483479

484-
fig.rubberband_context.strokeRect(min_x, min_y, width, height);
480+
var drawRubberband = function () {
481+
// Draw the lines from x0, y0 towards x1, y1 so that the
482+
// dashes don't "jump" when moving the zoom box.
483+
ctx.beginPath();
484+
ctx.moveTo(x0, y0);
485+
ctx.lineTo(x0, y1);
486+
ctx.moveTo(x0, y0);
487+
ctx.lineTo(x1, y0);
488+
ctx.moveTo(x0, y1);
489+
ctx.lineTo(x1, y1);
490+
ctx.moveTo(x1, y0);
491+
ctx.lineTo(x1, y1);
492+
ctx.stroke();
493+
};
494+
495+
fig.rubberband_context.lineWidth = 1;
496+
fig.rubberband_context.setLineDash([3]);
497+
fig.rubberband_context.lineDashOffset = 0;
498+
fig.rubberband_context.strokeStyle = '#000000';
499+
drawRubberband();
500+
fig.rubberband_context.strokeStyle = '#ffffff';
501+
fig.rubberband_context.lineDashOffset = 3;
502+
drawRubberband();
485503
};
486504

487505
mpl.figure.prototype.handle_figure_label = function (fig, msg) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy