简体   繁体   English

Javascript画布显示错误

[英]Javascript Canvas Display Error

I am working on an offshoot of Snap! 我正在研究Snap的分支! which is a visual, javascript IDE (I know, I know). 这是一个视觉,JavaScript的IDE(我知道,我知道)。 The newest release looks fine to me, as it does for the two others working on this. 最新版本对我来说很好,就像其他两个人一样。 However, one person who uses this code gets a big white box over the black background on some of the projects. 但是,使用此代码的一个人会在某些项目的黑色背景上获得一个大白框。

I cannot reproduce the error on any other computer. 我无法在任何其他计算机上重现该错误。 I have tried Chrome versions 38-45 (they were using 45), tried running with and without their extensions, cleared cache, checked their settings especially hardware optimization, restarted and checked the OS (windows 7 up to date), and closed all other programs that were running. 我尝试过Chrome版本38-45(他们使用的是45),尝试使用和不使用扩展程序运行,清除缓存,检查其设置,尤其是硬件优化,重新启动并检查操作系统(Windows 7最新),并关闭所有其他正在运行的程序。 I have gone over the code half a dozen times, and while there must be something that I missed, I cannot find the source. 我已经对代码进行了六次检查,虽然必须有一些我错过的东西,但我找不到来源。

Question 1. When you open (chrome only) https://dev1.csdt.rpi.edu/projects/293/run , does anyone else see something in the top right corner besides a bunch of "beads" on a black, numbered background? 问题1.当你打开(仅镀铬) https://dev1.csdt.rpi.edu/projects/293/run时 ,除了黑色的一堆“珠子”之外,还有其他人看到右上角的东西,编号背景? Specifically a white box. 特别是白盒子。

Question 2. Does anyone have any guesses as to what I might have missed? 问题2.有没有人猜测我可能错过了什么?

Thank you in advance. 先感谢您。

Thanks to Octopus and Damon Smith I set up a virtual box running Ubuntu and was able to reproduce the error, and then solve it. 感谢Octopus和Damon Smith,我设置了一个运行Ubuntu的虚拟盒子,能够重现错误,然后解决它。

Specifically the error was that in some versions of chrome, especially Linux chrome, the default canvas is not transparent as it is on Windows. 特别是错误是在某些版本的chrome中,尤其是Linux chrome,默认画布不像Windows上那样透明。 So when one canvas was created on top of another one, it would create a white box. 因此,当一个画布在另一个画布的顶部创建时,它将创建一个白色框。 Because we are using two canvases, one for 2D and one for 3D, there is a white box over the 2D background image. 因为我们使用两个画布,一个用于2D,一个用于3D,所以在2D背景图像上有一个白色框。

Thus, my solution is to force all 3D canvases to have a transparent background. 因此,我的解决方案是强制所有3D画布都具有透明背景。 This was done by modifying the code as bellow: 这是通过修改代码来完成的:

StageMorph.prototype.get3dCanvas = function () {
    if (!this.canvas3D) {
         this.canvas3D = newCanvas(this.dimensions);
         context = this.canvas3D.getContext("2d");
         context.fillRect(0, 0, this.dimensions.x, this.dimensions.y);
         context.fillStyle="rgba(0, 0, 200, 0)";
         context.fill();
    }
    return this.canvas3D;
};

I don't know how this problem cropped up on windows, but I am glad it did, so that we could troubleshoot this for all users. 我不知道这个问题是如何在Windows上出现的,但我很高兴它能做到,所以我们可以为所有用户解决这个问题。 Once again, thanks for all the help. 再次感谢所有的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM