canvas

66.环形加载动画(canvas/svg)

可紊 提交于 2020-01-15 08:10:56
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> body { margin: 0; padding: 0; text-align: center; } </style> </head> <body> <canvas id="canvas"></canvas> <script> let canvasWidth = 200; let canvasHeight = 200; let centerX = canvasWidth / 2; let centerY = canvasHeight / 2; let r = canvasWidth / 2 - 10; let canvas = document.getElementById('canvas'); canvas.width = canvasWidth; canvas.height = canvasHeight; let ctx = canvas

Canvas Game Timer

不打扰是莪最后的温柔 提交于 2020-01-15 07:29:06
问题 I'm making a HTML5 Canvas Game with a rectangle that moves around the canvas. The objective is to dodge multiple Balls moving across the canvas for as long as possible. But i'm struggling to put a Timer to show your Time/Score when a ball hits the rectangle. (The rectangle is moved by the UP,DOWN,LEFT and RIGHT keys). Anyone with knowledge of this that could help me out would be much appreciated, thanks. 回答1: Here’s how to integrate a timer into your game: Set the startingTime just before you

canvas字符雨 - JavaScript实现

笑着哭i 提交于 2020-01-15 07:28:32
canvas字符雨 字符雨效果 分析如何实现 字符雨从上往下逐渐消失: 这是 canvas 每次画字符的时候就画一遍黑色背景,但是这个背景是有透明度的,并且这个黑色背景的透明度还比较小,只有零点零八(经过测试,0.08比较合适,也可以更改查看效果);字符是从上往下落,上面的字符先出现,下面的字符后出现,程序重复地画黑色背景,就算有透明度,叠加起来,上面的字符就会先被覆盖,下面的后出现的字符还是还比较明显,就形成了逐渐消失的效果。 只有其中一些列出现了字符: 如果不加以控制的话,那么 canvas 中每一列都会出现字符,不会出现参差不齐的效果。所以用一个代表 出现机率 的数来控制,当字符落到 canvas 的底部,并且拿一个随机数和 出现机率 进行比较,如果随机数大于其,那么这一列就可以从顶部再次出现字符,否则这一列在本次循环就不会出现字符,只有等待下次循环再次拿随机数来比较。这样就实现了有一些列出现字符,而另一些不出现字符的效果。 创建实例 let charRain = new CharRain ( "canvas_id" ) ; HTML结构 < canvas id = " canvas " > </ canvas > CSS代码 body { margin : 0 ; padding : 0 ; overflow : hidden ; } #canvas {

authenticating facebook canvas application returns ?code=

坚强是说给别人听的谎言 提交于 2020-01-15 07:14:20
问题 i have a problem with my facebook canvas app that is currently on development i'm working on http://localhost:8080 my canvas url is http://localhost:8080/fbcanvas/ on facebook the url is set to http://apps.facebook.com/app_name/ the problem is i'm getting a code as an $_GET['code'] variable after a user approves my app. in facebook documentation it doesnt say anything about getting a $_GET['code'] it just says getting signed_request this is the code i'm using from facebook examples. require

Facebook Canvas setAutoGrow grows forever in IE

亡梦爱人 提交于 2020-01-15 06:06:08
问题 I am seeing a weird issue in Internet Explorer 9 on my Facebook pagetab when I have setAutoGrow to true. The height grows continuously without end. This is only happening in Internet Explorer for me. Tested with Chrome and Firefox as well. An example can be found at https://www.facebook.com/GunSweeps/app_480125662005248 Any ideas on what could be the cause? I read another thread on here that suggested it was html, body being set to 100%, and another which said a top-margin was the cause. I'm

Facebook Canvas setAutoGrow grows forever in IE

我的未来我决定 提交于 2020-01-15 06:04:07
问题 I am seeing a weird issue in Internet Explorer 9 on my Facebook pagetab when I have setAutoGrow to true. The height grows continuously without end. This is only happening in Internet Explorer for me. Tested with Chrome and Firefox as well. An example can be found at https://www.facebook.com/GunSweeps/app_480125662005248 Any ideas on what could be the cause? I read another thread on here that suggested it was html, body being set to 100%, and another which said a top-margin was the cause. I'm

Facebook Canvas setAutoGrow grows forever in IE

故事扮演 提交于 2020-01-15 06:04:06
问题 I am seeing a weird issue in Internet Explorer 9 on my Facebook pagetab when I have setAutoGrow to true. The height grows continuously without end. This is only happening in Internet Explorer for me. Tested with Chrome and Firefox as well. An example can be found at https://www.facebook.com/GunSweeps/app_480125662005248 Any ideas on what could be the cause? I read another thread on here that suggested it was html, body being set to 100%, and another which said a top-margin was the cause. I'm

Android 画图Paint和Canvas

ぐ巨炮叔叔 提交于 2020-01-15 05:20:38
在Android中需要通过graphics类来显示2D图形。   graphics中包括了Canvas(画布)、Paint(画笔)、Color(颜色)、Bitmap(图像)等常用的类。graphics具有绘制点、线、颜色、2D几何图形、图像处理等功能。 Canvas: void drawRect(RectF rect, Paint paint) //绘制区域,参数一为RectF一个区域 void drawPath(Path path, Paint paint) //绘制一个路径,参数一为Path路径对象 void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) //贴图,参数一就是我们常规的Bitmap对象,参数二是源区域(这里是bitmap),参数三是目标区域(应该在 canvas的位置和大小),参数四是Paint画刷对象,因为用到了缩放和拉伸的可能,当原始Rect不等于目标Rect时性能将会有大幅损失。 void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) //画线,参数一起始点的x轴位置,参数二起始点的y轴位置,参数三终点的x轴水平位置,参数四y轴垂直位置,最后一个参数为Paint画刷对象。 void

html5 Canvas画图5:画曲线之arc

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 04:40:41
在 canvas画线条 这篇文章中,我讲了画直线的方法,按理这篇画曲线的文章早该发了,但由于canvas画曲线比较特殊,我还没摸透,所以要一步步尝试。 canvas里画曲线的难点之一,就在于他连曲线的函数就有4个!分别是 arc , arcTo , quadraticCurveTo , bezierCurveTo .我从最简单的arc方法讲起吧。 arc的作用是画一个正规的圆弧,可以是一个完整的圆,也可以是一个圆的某一段弧线。 arc的语法如下: context.arc(x, y, radius, startAngle, endAngle, anticlockwise) 他的参数我解释一下,即 arc(圆心x,圆心y,半径,开始的角度,结束的角度,是否逆时针) 如果我们用arc画一个完整的圆,该怎么搞?大家注意到参数中有个开始角度与结束角度,如果我们开始角度是0,结束角度是360,不就是个正圆了? 正解!但要注意的是,这里的角度是用“弧度”来表示的(Flash也是如此), 一个完整的圆即360度,就是2PI弧度 。 所以我们这么写: ctx.arc(400,400,20,0,Math.PI*2); ctx.fill(); ctx.stroke(); (为什么博客园的代码高亮不亮了呢?) 和lineTo一样,arc也是画的路径,所以我们要在他后面调用填充或描边的方法才能显出图形

How to increase performance using WebGL?

南楼画角 提交于 2020-01-15 04:02:09
问题 I am rendering a texture using WebGL ,However ,the way I am rendering is I am rendering few lines of data and then moving those lines to right and again drawing another set of lines. For example : I have a image of 640*480 ,which contains 640*480*4 pixels of RGBA, however I am only filling the alpha values and it is a GrayScale medical Dicom image. Now ,the issue that I am facing is it is rendering the texture with jerks ,the image rendering is not happening smoothly. For example, This is