canvas

Resize rectangle in Paper.js

爱⌒轻易说出口 提交于 2020-01-04 01:39:10
问题 I have a very ordinary rectangle created in Paper.js and I'd like to resize it, but I can't find any obvious ways to do it. var rect = new Rectangle([0, 0],[width,height]); rect.center = mousePoint; var path = new Path.Rectangle(rect, 4); path.fillColor = fillColor; path.meta = fillColor; There's a scale transformation method, but it's not really for mouse interaction and my goal is to create a handle that can resize a component. 回答1: You can calculate the scaling by dividing the intended

delphi textrect wordwrap

萝らか妹 提交于 2020-01-03 20:48:09
问题 I am using Canvas.TextRect in Delphi 7 to output something on the screen. I need my text to be word wrapped in the rectangle. 回答1: You need to use DrawText (or DrawTextEx) with the DT_WORDBREAK flag. See the sample in this thread. 回答2: Use DrawText( hdc, pchar(s), length(s), rcRect, DT_NOPREFIX or DT_WORDBREAK); where s : string to print rcRect : TRect the rect wherein the string should be printed. 来源: https://stackoverflow.com/questions/1648277/delphi-textrect-wordwrap

HTML5 Canvas DrawImage Stutter / Choppiness

∥☆過路亽.° 提交于 2020-01-03 20:11:40
问题 PROBLEM I am trying to get an image on a canvas to move from left to right smoothly. It's not too bad on Chrome/Safari (still stutters a little), but there is noticeable stutter in Firefox on multiple machines (tried on Windows and Mac). I'm a bit stumped as to how to solve this. WHAT I TRIED I am using requestAnimationFrame instead of setTimeout. I am using clearRect instead of setting the canvas width, though I am clearing the entire canvas instead of the minimum bounding box as I wanted to

How do I calculate logrithmic labels for a VU meter scale?

[亡魂溺海] 提交于 2020-01-03 15:35:09
问题 I writing a meter widget using canvas and need to calculate the label values for the scale. No problem except when I'm trying to re-create the scale for a VU meter. I understand it's logrithmic, but the values aren't powers of 10 on that type of meter. see: https://en.wikipedia.org/wiki/VU_meter The function I have is given the min and max values for the scale. For normal scales, it also is given the step between values. For example, given -20 and 30 with a step of 10, it would produce labels

Glow Effect on HTML Canvas, Potentially Using Convolute Kernel / Matrix

孤者浪人 提交于 2020-01-03 14:48:08
问题 I am drawing a PNG image to an HTML canvas and I have implemented a filter system to allow convolute filters to be executed against the image data before it is blitted to the canvas. Does anyone have an idea how to create a glow effect using either a convolute kernel / matrix (I'm not sure what the terminology is but I'm talking about these: http://www.html5rocks.com/en/tutorials/canvas/imagefilters/) or by other means such as using the globalCompositeOperation (https://developer.mozilla.org

Poor Canvas2D performance with Firefox on Linux

…衆ロ難τιáo~ 提交于 2020-01-03 11:20:47
问题 I just hit something particularly hard to debug when doing some pretty intensive rendering with Canvas2D. I use all kinds of things, from globalCompositeOperation to multiple off-screen canvases, with some drawImage magic in-between. It works perfectly fine and smooth on : Chrome (26) [OSX 10.7.5] Safari (6.0.2) [OSX 10.7.5] Firefox (Both 18 and 20 Aurora) [OSX 10.7.5] Chrome (24) [Windows 7] Firefox (12) [Windows 7] Chromium (24) [Archlinux, Gnome 3] EDIT: Added tests for Windows 7.

HTML5的十大新特性

独自空忆成欢 提交于 2020-01-03 07:12:31
为了更好地处理今天的互联网应用,HTML5添加了很多新元素及功能,比如: 图形的绘制,多媒体内容,更好的页面结构,更好的形式 处理,和几个api拖放元素,定位,包括网页 应用程序缓存,存储,网络工作者,等 (1)语义标签 语义化标签使得页面的内容结构化,见名知义 标签 描述 <hrader></header> 定义了文档的头部区域 <footer></footer> 定义了文档的尾部区域 <nav></nav> 定义文档的导航 <section></section> 定义文档中的节(section、区段) <article></article> 定义页面独立的内容区域 <aside></aside> 定义页面的侧边栏内容 <detailes></detailes> 用于描述文档或文档某个部分的细节 <summary></summary> 标签包含 details 元素的标题 <dialog></dialog> 定义对话框,比如提示框 (2)增强型表单 HTML5 拥有多个新的表单 Input 输入类型。这些新特性提供了更好的输入控制和验证。 输入类型 描述 color 主要用于选取颜色 date 从一个日期选择器选择一个日期 datetime 选择一个日期(UTC 时间) datetime-local 选择一个日期和时间 (无时区) email 包含 e-mail 地址的输入域

HTML5的十大新特性

a 夏天 提交于 2020-01-03 07:11:59
  为了更好地处理今天的互联网应用,HTML5添加了很多新元素及功能,比如: 图形的绘制,多媒体内容,更好的页面结构,更好的形式 处理,和几个api拖放元素,定位,包括网页 应用程序缓存,存储,网络工作者,等 (1)语义标签    语义化标签使得页面的内容结构化,见名知义 标签 描述 <hrader></header> 定义了文档的头部区域 <footer></footer> 定义了文档的尾部区域 <nav></nav> 定义文档的导航 <section></section> 定义文档中的节(section、区段) <article></article> 定义页面独立的内容区域 <aside></aside> 定义页面的侧边栏内容 <detailes></detailes> 用于描述文档或文档某个部分的细节 <summary></summary> 标签包含 details 元素的标题 <dialog></dialog> 定义对话框,比如提示框 (2)增强型表单    HTML5 拥有多个新的表单 Input 输入类型。这些新特性提供了更好的输入控制和验证。 输入类型 描述 color 主要用于选取颜色 date 从一个日期选择器选择一个日期 datetime 选择一个日期(UTC 时间) datetime-local 选择一个日期和时间 (无时区) email 包含 e-mail

Take screenshot of the whole webpage

天涯浪子 提交于 2020-01-03 06:41:31
问题 Need a working code with only javascript and no extra library files (-> jquery,...) That take a screenshot from the whole webpage. (top to bottom page) Current i have this which does not work why? <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function () { var window = document.getElementById('item'); var canvas = document.getElementById('my-canvas'); var ctx = canvas.getContext("2D"); ctx.drawImage(window, 0,0, 100, 200, "rgb(255,255,255)"); canvas.toDataURL(

How to remove the previous draw image from canvas

天大地大妈咪最大 提交于 2020-01-03 06:21:09
问题 I have been trying to print arc in the html page. How can i remove the already drawn arch from the page?. i have written the below code. <!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="1200" height="1000" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); /*ctx.beginPath(); ctx.arc(600,500,20, 0.5*Math.PI,2*Math.PI); ctx.stroke(); ctx.beginPath(); ctx.arc