canvas

Stencil buffer in WebGL

a 夏天 提交于 2020-05-09 07:30:08
问题 How I can use to stencil buffer for my easiest program? I have read many different themes about it, but I not found a detailed guide about it. I want to cut out for hole each side in a created tetrahedron. Please explain to me step by step use stencil buffer? Link for my program 回答1: To use the stencil buffer you have to first request it when you create the webgl context const gl = someCanvasElement.getContext('webgl', {stencil: true}); Then you turn on the stencil test gl.enable(gl.STENCIL

How to post immediately after svg to canvas conversion is done?

冷暖自知 提交于 2020-05-01 14:30:12
问题 I am attempting post with html2canvas after converting all the svgs in a html element to canvas, but the post executes immediately before the svg to canvas conversion finishes, since it takes a few seconds. I have tried using deferred and promises, but I am still having the same issue. // https://github.com/niklasvh/html2canvas/issues/95#issuecomment-45114424 // First render all SVGs to canvases targetElem = $('#dashboard'); var elements = targetElem.find('svg').map(function() { var svg = $

What are security concerns around use of canvas.toDataURL?

本小妞迷上赌 提交于 2020-04-30 11:34:13
问题 What security threads would canvas.toDataURL generate in general? What measures we have to take to make use of it secure and thread free to our website? In the following links there are discussions around security error that .toDataURL raises if the image is not hosted locally, but why is that? canvas.toDataURL() causing a security error Capture HTML Canvas as gif/jpg/png/pdf? 回答1: You may be aware of the same-origin policy. In essence, it's a security mechanism employed by browsers to make

What are security concerns around use of canvas.toDataURL?

做~自己de王妃 提交于 2020-04-30 11:32:13
问题 What security threads would canvas.toDataURL generate in general? What measures we have to take to make use of it secure and thread free to our website? In the following links there are discussions around security error that .toDataURL raises if the image is not hosted locally, but why is that? canvas.toDataURL() causing a security error Capture HTML Canvas as gif/jpg/png/pdf? 回答1: You may be aware of the same-origin policy. In essence, it's a security mechanism employed by browsers to make

Loading PDF in Canvas and Drawing rectangles

落爺英雄遲暮 提交于 2020-04-30 10:07:36
问题 I am trying to build a web page to display a PDF file inside canvas and allow user to draw rectangles. Below is the code I'm trying. The problem is mouse event is going outside canvas also. How to restrict mouse dragging event only inside the canvas. var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf'; //Loaded via <script> tag, create shortcut to access PDF.js exports. var pdfjsLib = window['pdfjs-dist/build/pdf']; // The workerSrc property

Loading PDF in Canvas and Drawing rectangles

僤鯓⒐⒋嵵緔 提交于 2020-04-30 10:05:14
问题 I am trying to build a web page to display a PDF file inside canvas and allow user to draw rectangles. Below is the code I'm trying. The problem is mouse event is going outside canvas also. How to restrict mouse dragging event only inside the canvas. var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf'; //Loaded via <script> tag, create shortcut to access PDF.js exports. var pdfjsLib = window['pdfjs-dist/build/pdf']; // The workerSrc property

how to make a fog effect or blur effect in canvas with js?

邮差的信 提交于 2020-04-30 07:36:42
问题 I'm using javascript and THREE.js 3d engine, and I want to do a fog effect, here's an example http://mrdoob.github.com/three.js/examples/webgl_geometry_terrain_fog.html but it only support WebGL , so is there any way to simulate fog effect , or a blur effect with javascript and canvas? thanks alot. 回答1: Three.js is WebGL. The example you're looking at is created by the same person who made three.js. Three.js supports fog already with scene.fog . https://github.com/mrdoob/three.js/wiki/API

how to make a fog effect or blur effect in canvas with js?

冷暖自知 提交于 2020-04-30 07:35:08
问题 I'm using javascript and THREE.js 3d engine, and I want to do a fog effect, here's an example http://mrdoob.github.com/three.js/examples/webgl_geometry_terrain_fog.html but it only support WebGL , so is there any way to simulate fog effect , or a blur effect with javascript and canvas? thanks alot. 回答1: Three.js is WebGL. The example you're looking at is created by the same person who made three.js. Three.js supports fog already with scene.fog . https://github.com/mrdoob/three.js/wiki/API

How can I avoid exceeding the max call stack size during a flood fill algorithm?

不打扰是莪最后的温柔 提交于 2020-04-30 06:31:08
问题 I am using a recursive flood fill algorithm in javascript and I am not sure how to avoid exceeding the max call stack size. This is a little project that runs in the browser. I got the idea from here: https://guide.freecodecamp.org/algorithms/flood-fill/ I chose this algorithm because it's easy to understand and so far I like it because it's pretty quick. x and y are the 2-d coordinates from the top-left, targetColor and newColor are each a Uint8ClampedArray , and id = ctx.createImageData(1,1

Canvas inner stroke

点点圈 提交于 2020-04-29 09:39:07
问题 I studied strokeStyle a bit but I cant find how to control the position of the stroke from inner/center/outer. It seems all stroke is outside the rectangle I draw. Is there anyway make the stroke be inner? (or even centered on the rectangle bounds)? Thanks 回答1: The default stroke do use centered stroke but there is unfortunately no parameter to control the alignment of the stroke so you would either have to calculate an offset value for the rectangle's position and size, or combine two