canvas

Mouse position within HTML 5 Canvas

天涯浪子 提交于 2020-01-23 01:23:07
问题 I am writing a simple drawing app to get an understanding of the HTML 5 canvas. The problem is that I simply can't seem to get the correct mouse position within the canvas element.I've looked at the other questions on stackoverflow like the one here getting mouse position with javascript within canvas that address this issue but their solutions don't seem to help me. Here is my code: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title

Vue 动态生成二维码 QRCode

一个人想着一个人 提交于 2020-01-22 21:33:57
想在页面中加入微信扫描二维码进行分享的功能,网上有demo: https://github.com/sinchang/vue-social-share 研究下QRCode 生成二维码吧, 引入: npm install qrcode --save main.js中import: import QRCode from 'qrcode' 并在需要的组件中导入: import QRCode from 'qrcode' 编写canvas : <div> <canvas id="canvas"></canvas> </div> ------------js------------- useqrcode(txt) { //生成的二维码内容,可以添加变量 var canvas = document.getElementById('canvas') QRCode.toCanvas(canvas, txt, error=>{ if (error) console.error(error) console.log('二维码 生成成功!'); }) } 全部代码: <template> <div> <h1>测试二维码 plan</h1> <Button @click="useqrcode('111')">生成111</Button> <Button @click="useqrcode('222')"

Pie, bar, line: SVG/VML better than Canvas

旧街凉风 提交于 2020-01-22 17:47:52
问题 I need to choose a library for "standard" charting: pies, lines and bars. From what I've read, it seems to me that the best format is SVG/VML, like Highcharts for example. SVG is becoming standard across all major browsers, now that IE 9 accepts it. It seems easier to rescale and export than Canvas. Still, I see that several charting libraries rely on Canvas. Am I missing something? Is there any reason for considering Canvas over SVG for such applications? 回答1: You can generally achieve the

Pie, bar, line: SVG/VML better than Canvas

独自空忆成欢 提交于 2020-01-22 17:47:06
问题 I need to choose a library for "standard" charting: pies, lines and bars. From what I've read, it seems to me that the best format is SVG/VML, like Highcharts for example. SVG is becoming standard across all major browsers, now that IE 9 accepts it. It seems easier to rescale and export than Canvas. Still, I see that several charting libraries rely on Canvas. Am I missing something? Is there any reason for considering Canvas over SVG for such applications? 回答1: You can generally achieve the

Cross Origin Resource Sharing Headers not working only for safari

强颜欢笑 提交于 2020-01-22 15:05:32
问题 I'm using rackspace to host my image files that are drawn on an html5 canvas object. Because of an HTML security feature when saving a canvas I have to use CORS (Cross Origin Resource Headers) to make save work. I have tested my code on Chrome, IE with Chrome Frame, and Firefox , and none of them give me a security error after I added to the image request headers: Access-Control-Allow-Origin: * and I have added the following attribute to all the images drawn on to the canvas crossOrigin =

Building an Image Editor with HTML 5 and Canvas

爷,独闯天下 提交于 2020-01-22 05:06:06
问题 I wanted to build a product customizer similar to http://www.getuncommon.com. But instead of Flash, I will utilize HTML5 canvas and Javascript. Is there a library which I can use to create and achieve similar editor/product customizer as Uncommon? I did look at jQuery UI but it is seem more focused on interface than creating my own editor. 回答1: I did something similar to this a while ago. I used JQuery and Raphael JS. Raphael uses VML in Internet Explorer and SVG and Canvas in other browsers

tiff格式的图片在html中显示

时光毁灭记忆、已成空白 提交于 2020-01-22 04:20:43
###什么是tiff tiff是一种图片的格式 今天突然看到有一个图片加载失败,控制台调出来一看,有图片地址,tiff格式的。 于是就百度查/问朋友,最后查到了一个tiff.js的文件 npm 安装 照着别人的教程来并不行,接下来,记录记录我显示tiff的过程 1.安装 命令如下 npm install --save tiff.js 引入tiff var Tiff = require('tiff.js') 使用 图片不能返回地址,需要后台返回base64的文件流, 我从后台获取的文件流,并处理的js,完整代码,最下方 // w 为图片的宽度 h为图片的高度,设置顶比例缩放需要使用的 // getImg 是后台返回的base64图片 getImg({ responseType: 'json', source: url }).then(res => { var buffer = decodeBase64(res) var tiff = new Tiff({ buffer: buffer }) var canvas = tiff.toCanvas() var width = tiff.width() var height = tiff.height() if (canvas) { // 设置宽高 width: 560px; height: 300px; 等比例缩放图片 var scale

Canvas Image Animation (Crossfade)

狂风中的少年 提交于 2020-01-22 02:51:14
问题 Using HTML5 canvas I'm trying to load images and create a 'crossfade' effect where the first image fades into view then, after a short delay, the second image fades in over top of first image, etc. With the help of answers to similar questions on this forum I've got 2 separate bits of code working ... one which loads an array of images and a second which animates a 'fade in' effect. My problem is that I don't know how to combine these 2 scripts to load an array of images AND ALSO have each

Isometric simple sorting with xdim and ydim

倾然丶 夕夏残阳落幕 提交于 2020-01-22 01:36:07
问题 I have a simple isometric sorting system with this function (code is in Typescript / Javascript ) : public Sort(a: PIXI.Sprite, b: PIXI.Sprite) { return ((a.IsoZ - b.IsoZ) == 0 ? (a.TileZ - b.TileZ == 0 ? (a.Tile2Z ? (a.Tile2Z < b.Tile2Z ? -1 : (a.Tile2Z > b.Tile2Z ? 1 : 0)) : 0) : a.TileZ - b.TileZ) : (a.IsoZ - b.IsoZ)); } It depends on three parameters: IsoZ : the first sorting variables, used to sort tiles TileZ : the tile sorting variable, used if a.IsoZ == b.IsoZ Tile2Z : used if a.TileZ

Learn HTML5 in 5 Minutes!

前提是你 提交于 2020-01-22 00:14:49
There’s no question, HTML5 is a hot topic for developers. If you need a crash course to quickly understand the fundamentals of HTML5’s functionality, you’re in the right place. Editorial Note This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers. I’ll cover the new semantic markup, canvas for drawing and animation, audio and video support, and how to use HTML5 with older browsers. Might be a bit more than five minutes, but I promise I