canvas

HTML 5 Canvas and Javascript: Combining layered canvases

陌路散爱 提交于 2020-01-04 05:49:11
问题 I wanted to combine images from different canvases (layered on top of each other using z-index) to export as one single image. Is this possible? 回答1: Same : How can I save div as image at client side where div contains one or more than one HTML5 canvas elements? Save many canvas element as image 回答2: Try using the context.getImageData() and context.putImageData(). I haven't tried that in Javascript before, but it shouldn't be that difficult. HTML Canvas 2D Context 来源: https://stackoverflow

Convert Inline svg to canvas using canvg script

送分小仙女□ 提交于 2020-01-04 05:10:16
问题 I have this website: http://materialground.com/icon-maker I have this code above my body <symbol id="fa-flaticon-3" viewBox="0 0 512 512"> <path d="m512 247c0 118-87 216-200 233 1-5 2-11 1-16 0 0-1-6-2-14 41-6 77-25 105-51-1-2-3-3-5-6-7-11 3-22 3-32 0-9-20-9-20-15-3-22 13-22 22-30 8-9-9-28-20-27-11 1-41-5-39-28 4-29-36-27-42-40-8-19 6-43 24-49 25-7 51-28 49-52-3-26-14-50-34-64-21-8-43-13-66-14-20 0-38 5-37 14 2 23 67 29 56 51-6 11-49 27-41 44 6 11 19 1 14 22-2 10-11 28-24 29-13 1-24-34-60-35

RXJS draw line on html5 canvas

丶灬走出姿态 提交于 2020-01-04 05:05:45
问题 I'm trying to achieve the same effect I'm posting here using Reactive Extensions for Javascript (RX-JS). I'm a bit puzzled on how to do it. Here is the page: <!DOCTYPE html> <html> <head> <title>drag and drop</title> </head> <style type="text/css"> canvas { border:1px solid steelblue; background-color: whitesmoke; } </style> <body> <canvas id="canvas" width=300 height=300></canvas> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text

how to make firefox fullscreen mode like chrome (i.e. not streching content)

≯℡__Kan透↙ 提交于 2020-01-04 04:35:12
问题 I am using the fullscreen API of modern browsers for my game application, Chrome works great in this respect and gives a window resize event that allows the resetting of the canvas dimensions according to the new fullscreen size. Firefox also respects the event and allows re-sizing but anyway streches the canvas to the fullscreen, all graphics and mouse distances are distorted. Does anyone know how to get firefox behaving like chrome in this regard, i.e. how to remove the automatic css rules

spawn random images in canvas in javascript

余生颓废 提交于 2020-01-04 04:16:05
问题 Good day all, I'm trying to make a javascript game using canvas. I want to spawn random enemy objects. So far I found this as a spawning example: JSFiddle Demo How can I load image(s) instead of balls? Any help would be great. Tnx. // get a refrence to the canvas and its context var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); // newly spawned objects start at Y=25 var spawnLineY = 25; // spawn a new object every 1500ms var spawnRate = 1500; // set how fast

Image On HTML Canvas Can't Be Downloaded

百般思念 提交于 2020-01-04 03:53:08
问题 I have HTML canvas and it work fine to display image. And I have this jquery code to download the image : $(".img-download").click(function(){ var data = canvas.toDataURL(); download.href = data; -- I tried this to download image, but PNG file generated cannot be opened in photoshop or any other image manipulation apps alert (data); -- then, I tried to see what's actually the data content }); And here's my download button : <a href="" class="img-download btn btn-lg btn-default" download=

“canvas.toDataURL(”image/png“)” not working properly in firefox

孤街醉人 提交于 2020-01-04 03:49:08
问题 I have a web page with file input field.I wanted to , Upload a image file. create image element using uploaded image. draw it on canvas get "DataURL" of canvas. This process works on Google Chrome,but not working on Mozilla Firefox.When i console.log the canvas.toDataURL output it shows data:image/png;base64

SecurityError: Load an image in canvas, modify it and create dataURL

ぃ、小莉子 提交于 2020-01-04 03:25:23
问题 I'm attempting to use HTML5 to bring in an image file, draw it to the canvas, do some manipulation of it, then return the dataURL so that I can reference this newly generated image. Here's a quick example of what the image loading code looks like: <canvas id="myCanvas" style="border:1px solid #c3c3c3;"> Your browser does not support the canvas element. </canvas> <script type="text/javascript"> c = document.getElementById("myCanvas"); cxt = c.getContext("2d"); var img=new Image(); img.src =

canvas、cocos基础知识

情到浓时终转凉″ 提交于 2020-01-04 03:19:39
文章目录 canvas基础 使用cocos2d 基本功能 创建导演(Director)、场景(Scene)、层(layer)、精灵(sprite) 精灵的操作 场景的操作 ui组件 cc、node的常用方法 canvas基础 基本操作 context . save ( ) //保存状态 context . restore ( ) //回复状态 context . moveTo ( ) //开始点 context . lineTo ( ) //画直线 context . beginPath ( ) //开始一条新路径 context . closePath ( ) //闭合一条路径 context . lineWidth //线宽 context . strokeStyle //边颜色 context . fillStyle //填充颜色 context . lineCap //线端点样式 butt round square context . lineJoin //连接点样式 miter bevel round context . arc ( ) //画圆 var a = context . createLinearGradient ( x , y , x0 , y0 ) //线性渐变 a . addColorStop ( stop , color ) //渐变颜色 var a =

Connect two objects using fabric js

牧云@^-^@ 提交于 2020-01-04 02:04:07
问题 I currently have a canvas application where I can add objects(shapes). Here is my FIDDLE. You basically click on new simulation which will initialize the canvas, then you can add a circle or rectangle. I am trying to add a feature called "Add child" where you can click on some object (shape) then click add child and add another object(shape) and they are both linked with a line. Something similar to this DEMO. I figured the pesudo code for this feature would go something like as following: