canvas

Transforming data to screen coordinates

那年仲夏 提交于 2019-12-25 02:57:51
问题 I would like to transform data to screen coordinates in javascript using a function. The function has to look like this: function createTransform(domain, range){ // domain is a two-element array of the domain’s bounds // range is a two-element array of the range’s bounds // implement the actual calculation here var alpha = ...; var beta = ...; return function(x){ return alpha * x + beta; }; } // to use this for instance: var tranform = createTransform([10, 20], [10, 20]); console.log

Camanjs clear canvas when init Caman()?

南楼画角 提交于 2019-12-25 02:47:49
问题 I apply Caman Filter to a canvas with existing image data. But when I create Caman object to use later, it emply my canvas. var ca = Caman('#myCanvas'); I'm try to do exactly with Caman Guide , like this: Caman('#myCanvas',function(){ this.render(); }); But the same problem, canvas is clear! Why I cannot load canvas to Caman then modify, although documentation says can be? 回答1: You don't need to grab a reference to the Caman object with: var ca = Caman("#myCanvas"); First, draw something on

How to create ad-hoc tweens sequence without recursion in KineticJS?

放肆的年华 提交于 2019-12-25 02:46:09
问题 is it possible to create tweens sequence in KineticJS according to data saved in array without recursion? This is my current solution including recursion: function tweenFunc( image ) { setGlobalCoordinates(); tween = new Kinetic.Tween({ node: image, duration: 1, x: x, y: y, rotation: rot, onFinish: function(){ if ( counter++ < arr.length ) { tweenFunc( image ); } } }); tween.play(); } I would like to have solution which creates tweens before first animation and following tweens start from

Paint canvas not working properly

南笙酒味 提交于 2019-12-25 02:41:13
问题 http://www.asifslab.com/reveal.js-master/Why%20does%20wind%20feel%20cold.html#/4 Why doesn't the drawing canvas work properly? The line drawn is away from the point clicked. However, if I use the canvas out of reveal.js it works perfectly. http://codepen.io/anon/pen/eEaKh Also when the erase function is run, it leaves a white border outside. How do I fix these problems? 回答1: just change e.pageX to e.clientX and e.pageY to e.clientY because in your codepen account canvas origin and page origin

HTML5 canvas alternative to putImageData

二次信任 提交于 2019-12-25 02:29:40
问题 is there another method to copy region of pixels from (let say) Canvas A to canvas B other than using respectively getImageData and putImageData . also, when copy to Canvas B it should be rounded like a paint brush not rectangle. 回答1: To copy content from one canvas to another you can use drawImage() . This method can take image, canvas or video as image source. To draw rounded there are two ways: Method A - Use composite mode This method assumes the target canvas is empty. First set up a

globalCompositeOperation and concentric, hollow, moving shapes

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 02:20:06
问题 I'm trying to achieve the following: A number of concentric circles (or rings) are drawn on a canvas. Each circle has a "hole" in it, so the smaller circles, drawn behind it are partially visible. Each frame (we're using window.requestAnimationFrame to render) the radius of each circle/shape/ring is slightly increased. A scenario with two rings is depicted in the image here. The code: function draw() { drawBgr(); for (var i = 0, len = rings.length; i < len; i++) { rings[i].draw(); } }

Angular 6- canvas.toDataURL('image/png') not capturing canvas background image

旧街凉风 提交于 2019-12-25 02:16:45
问题 Currently I am choosing one image from device gallery and using that picture as a background image for canvas. After I draw something I want to save the image. But whenever I am trying to save the image, canvas will get saved with transparent background. It's not taking background image source. Below is my code. I can see image on canvas but not capturing while saving canvas as an image. 1. HTML <canvas no-bounce id="canvas" (touchstart)='handleStart($event)' (touchmove)='handleMove($event)'

Canvas image is not the same size as the canvas or orginal image

ⅰ亾dé卋堺 提交于 2019-12-25 02:15:01
问题 I've put a canvas on top a background image. When I press the 'Try It' button the image appears in the canvas but it does not appear the same size as the parent or fit in the canvas. I only see the top left of the image. The parent image and the canvas are the same size. HTML <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <script src="script.js"></script> </head> <body> <div class="bg"> <img src="Assets/Images/background.png" alt="background"> </div>

Canvas not rendering In reactjs

好久不见. 提交于 2019-12-25 01:58:58
问题 I want to add canvas on the website that i am developing but i can seem to understand why the canvas in not showing up. what could be the issue? Below is what i have tried. When i hover the mouse on the header it shows that the canvas is updating but not showing anything on the screen Canvas.jsx export class Canvas extends Component { state = { container: document.getElementById('test'), canvas: document.createElement('canvas'), ctx: document.createElement('canvas').getContext("2d"),

Setting the opacity of drawing canvas in android

◇◆丶佛笑我妖孽 提交于 2019-12-25 01:55:58
问题 I am working on a function that drawing some transparent line on the canvas, the problem is , there is some "ball shape" on the line as the screenshot show. Here is my code: canvas = new Canvas(alteredBitmap); paint = new Paint(); paint.setAntiAlias(true); paint.setStrokeWidth(width); paint.setColor(color); paint.setStyle(Paint.Style.STROKE); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); paint.setAlpha(alpha); matrix_draw = new Matrix(); canvas.drawBitmap(bmp,