html5-canvas

Finding size of rotated image to match top-line based on angle

微笑、不失礼 提交于 2020-01-24 22:07:06
问题 (illustration for reference: https://i.stack.imgur.com/Wsge0.png) Code example https://jsfiddle.net/waaentz/htrqdwjp/9/ const width = 1000; const height = 100; const canvas = document.createElement("canvas"); const stage = new createjs.Stage(canvas); const img = new Image(); const bitmap = new createjs.Bitmap(img); const baseGrid = new createjs.Shape(); const angle = 45; // Is dynamic const magicScaleFormular = 1.39 // Find scale based on height and angle img.src = getBase64(); img

How to write to Uint8ClampedArray?

£可爱£侵袭症+ 提交于 2020-01-24 21:58:30
问题 I'm writing a node addon which accepts HTML canvas Image data, that's of type Uint8ClampedArray . I want to modify the the contents of this array without any extra copy. The best candidate I've found is the v8::Object::Set method (v8::Object being a class in Uint8ClampedArray's inheritance hierarchy) However that method requires a handle to v8::Context object as first argument. I don't know how to get that. I've searched through github repos and found code inside Webkit that directly casts

Javascript: Setting img src with absolute path

瘦欲@ 提交于 2020-01-24 21:26:42
问题 I am trying to manually set the img src to a path on the filesystem, and then I want to draw that image on a canvas. I am using: var curr_canv = document.getElementById('c_main').getContext('2d'); var img = new Image(); img.width = 525; img.height = 400; img.src = "..\AAAA\BBBB\CCCC\myimage.jpg"; curr_canv.drawImage(img,0,0); But nothing is drawn on the canvas after I do this. Any thoughts? 回答1: You need to set the path to an absolute path within your webserver . Javascript in the browser has

creating overlay and removing parts of it on canvas using kineticjs

牧云@^-^@ 提交于 2020-01-24 10:14:50
问题 In a canvas painting application I want to add feature to create overlay over the whole canvas and then when I make a particular rectangle on the canvas the overlay should get removed from that region ,exactly like one on https://onpaste.com/ (select focus tool) . What I have thought is that if a rectangle is made on the canvas , then I can crop the current image and then paste the image on the canvas again over the overlay at the place which was selected . I am not sure , how to crop the

Javascript: Upload image from Canvas to FB via Graph API

谁说胖子不能爱 提交于 2020-01-24 08:28:27
问题 I am composing an image in a canvas, I get the base64 image data by using canvas.toDataURL('png') and trimming the additional information. var dataUrl = canvas.toDataURL('png'); var escapedBase64Data = dataUrl.replace("data:image/png;base64,",""); After that I try to post to facebook using: FB.api('/me/photos', 'post', { source:data}); Photos (https://developers.facebook.com/docs/reference/api/user/) has a source property. This is where you will place the data content ( multipart/form-data )

How to save an HTML5 Canvas as an image on a server?

浪尽此生 提交于 2020-01-24 00:53:05
问题 I'm working on a generative art project where I would like to allow users to save the resulting images from an algorithm. The general idea is: Create an image on an HTML5 Canvas using a generative algorithm When the image is completed, allow users to save the canvas as an image file to the server Allow the user to either download the image or add it to a gallery of pieces of produced using the algorithm. However, I’m stuck on the second step. After some help from Google, I found this blog

Capturing data stream of a JS / Leaflet animation as MP4

醉酒当歌 提交于 2020-01-24 00:32:11
问题 How can I capture the datastream of a JS / Leaflet animation and download it to MP4? I am looking for output that looks something like the smooth path traced in these demos: https://github.com/IvanSanchez/Leaflet.Polyline.SnakeAnim Their author appears to have done them in ffcast or some screencasting softare. However, I am looking for an automated solution that can be run as script, ideally one that works on the data stream itself (not the screen), perhaps with a headless browser. I have

load image to fabric canvas background

邮差的信 提交于 2020-01-23 09:26:38
问题 hi im trying to upload an image and put it as canvas background. code snippet: function handleMenuImage(e){ var reader = new FileReader(); reader.onload = function(event){ var img = new Image(); img.src = event.target.result; canvas.setWidth(img.width); canvas.setHeight(img.height); canvas.setBackgroundImage(img.src, canvas.renderAll.bind(canvas)); //set the page background menuPages[currentPage].pageBackground.src = img.src; canvas.backgroundImageStretch = false; } reader.readAsDataURL(e

Screenshot from video at different time

回眸只為那壹抹淺笑 提交于 2020-01-22 02:33:07
问题 I have 3 canvas on a line, and in each I want to put an image (screenshot form a video, at different time). The problem is that all 3 screenshots are at the same time (the last time specified). Bellow is my JavaScript code. function getVideoScreenShot(videoFile, currentIncidentTime, idx) { var images = []; for(var canvas=1; canvas<=3; canvas++) { var canvasId = "#canvas"+ idx + canvas; var milisec = parseInt(currentIncidentTime)%1000; var secFromMilisec = milisec/1000; var sec = (parseInt

Line Width in Canvas

為{幸葍}努か 提交于 2020-01-21 17:24:45
问题 Well, if I draw a line with an odd value of lineWidth in HTML5 Canvas I get a blurred line and I know the reason for this problem. Now, I want to know the solutions to overcome this. I already know a solution for this and which i couldn't implement now. So, please comment on any other solution for this problem. My Solution : If you have to draw a line with an odd numbered width, then you will have to offset the center of your line by 0.5 up or down. That way rendering will happen at boundary