sách gpt4 ai đã đi

jqplot - HIDPI/Retina 绘图?

In lại 作者:行者123 更新时间:2023-12-05 00:27:41 hai mươi bốn 4
mua khóa gpt4 Nike

我见过3 tickets去年在 bitbucket 上询问过这个问题,但从未看到明确的答案。

One这些票中的一些给出了一些代码,但我不知道该代码属于哪里。

var devicePixelRatio = window.devicePixelRatio || 1,
backingStoreRatio = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;

ratio = devicePixelRatio / backingStoreRatio;
if (devicePixelRatio !== backingStoreRatio) {
var oldWidth = canvas.width;
var oldHeight = canvas.height;
this.canvasOrigWidth = oldWidth;
this.canvasOrigHeight = oldHeight;
canvas.width = oldWidth * ratio;
canvas.height = oldHeight * ratio;

canvas.style.width = oldWidth + 'px';
canvas.style.height = oldHeight + 'px';

// now scale the context to counter
// the fact that we've manually scaled
// our canvas element
ctx.scale(ratio, ratio);
}

你如何让 JQPlot 输出高分辨率图形?

编辑 1
上面的代码好像来自这个 website .

1 Câu trả lời

我根据问题中链接的示例弄清楚了。

thay thế

this.initCanvas = function(canvas) {
if ($.jqplot.use_excanvas) {
return window.G_vmlCanvasManager.initElement(canvas);
}
return canvas;
}


this.initCanvas = function(canvas) {
if ($.jqplot.use_excanvas) {
return window.G_vmlCanvasManager.initElement(canvas);
}

var cctx = canvas.getContext('2d');

var canvasBackingScale = 1;
if (window.devicePixelRatio > 1 && (cctx.webkitBackingStorePixelRatio === undefined ||
cctx.webkitBackingStorePixelRatio < 2)) {
canvasBackingScale = window.devicePixelRatio;
}
var oldWidth = canvas.width;
var oldHeight = canvas.height;

canvas.width = canvasBackingScale * canvas.width;
canvas.height = canvasBackingScale * canvas.height;
canvas.style.width = oldWidth + 'px';
canvas.style.height = oldHeight + 'px';
cctx.save();

cctx.scale(canvasBackingScale, canvasBackingScale);

return canvas;
};

该方法可以在 jquery.jqplot.js 的第 290 行附近找到。

然后,如果您没有 HIDPI 或 Retina 显示器但有 Mac,您可以使用 Quartz Debug 和 System Pref/Displays 来模拟 HIDPI 分辨率以进行测试。这是显示正常图形和带有替换代码的相同图形的复合屏幕截图。
JQPlot Retina Comparison

关于jqplot - HIDPI/Retina 绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20221461/

hai mươi bốn 4 0
Bài viết được đề xuất: r - 用逻辑测试索引
Bài viết được đề xuất: javascript - 如何使用 Jest 检查元素是否可见?
Bài viết được đề xuất: javascript - Mongoose 错误 : Operation 'featureds.find()` buffering timed out after 10000ms
Bài viết được đề xuất: r - ggplot 中的嵌套面板
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com