canvas

canvas 贝塞尔曲线

血红的双手。 提交于 2020-03-05 17:04:45
1、二次贝塞尔曲线   quadraticCurveTo(cpx,cpy,x,y)  //cpx,cpy表示控制点的坐标, x,y表示终点坐标; 数学公式表示如下: 二次方贝兹曲线的路径由给定点 P 0、 P 1、 P 2的函数 B ( t )追踪: 代码实例: <! DOCTYPE html > < html > < head > < meta charset ="utf-8" > < title > canvas直线 </ title > < meta name ="Keywords" content ="" > < meta name ="Description" content ="" > < style type ="text/css" > body, h1 { margin : 0 ; } canvas { margin : 20px ; } </ style > </ head > < body onload ="draw()" > < h1 > 二次贝塞尔曲线 </ h1 > < canvas id ="canvas" width =200 height =200 style ="border: 1px solid #ccc;" ></canvas> < script > function draw() { var canvas = document

HTML - 动画Demo

泄露秘密 提交于 2020-03-05 17:02:31
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 <style> 7 * { 8 margin: 0; 9 padding: 0; 10 } 11 12 html, body { 13 width: 100%; 14 height: 100%; 15 overflow: hidden; 16 } 17 </style> 18 </head> 19 <body> 20 <canvas id="canvas" style="width:100%;height:100%"></canvas> 21 <!--<script> 22 // 先拿到canvas 的 Dom对象 23 var canvas = document.getElementById('canvas'); 24 canvas.width = canvas.clientWidth; 25 canvas.height = canvas.clientHeight; 26 // 拿到绘图上下文对象 27 var context = canvas

Open/Save file in javascript

送分小仙女□ 提交于 2020-03-03 07:42:05
问题 I'll write an app that'd need to let user load PNG&JSON files and then save them. How could I let user open and save such files? I wouldn't like to write up an echo server for those images. 回答1: You can load files with File API (only supported in firefox 3.6 and chrome unstable (maybe beta) at the moment): http://dev.w3.org/2006/webapi/FileAPI/ Currently there is no way to save the file 回答2: I'll pull Facebook into the conversation. Facebook uses Java to do such a thing. I should note that

Legend not appearing when using document.createElement('canvas')

只愿长相守 提交于 2020-03-03 07:31:27
问题 I followed this Observable post to easily create a legend. Since the line DOM.canvas(1, n) in the ramp works only on Observable, I replaced it with document.createElement("canvas") and also modified the SVG so that it's appended to the main div tag. These changed do not cause any errors however the problem is that the legend is not displayed even though the legend SVG is present in the raw HTML. Here's the link to a JSFiddle. Any guidance would be greatly appreciated. 回答1: The canvas is being

Legend not appearing when using document.createElement('canvas')

▼魔方 西西 提交于 2020-03-03 07:31:08
问题 I followed this Observable post to easily create a legend. Since the line DOM.canvas(1, n) in the ramp works only on Observable, I replaced it with document.createElement("canvas") and also modified the SVG so that it's appended to the main div tag. These changed do not cause any errors however the problem is that the legend is not displayed even though the legend SVG is present in the raw HTML. Here's the link to a JSFiddle. Any guidance would be greatly appreciated. 回答1: The canvas is being

Android中canvas.save()和canvas.restore()的使用

半世苍凉 提交于 2020-03-03 02:19:17
自己定义控件时经常遇到重写View的Ondraw()方法,Ondraw()方法经常设计到save()和restore()这两个方法.这 两个相互匹配出现的,作用是用来保存画布的状态和取出保存的状态的。 详细作用例如以下: 1.save() :用来保存 Canvas 的状态, save()方法 之后的代码,能够调用 Canvas 的平移、放缩、旋转、裁剪等操作! 2.restore() :用来恢复 Canvas 之前保存的状态,防止 save()方法代码之 后对 Canvas 运行的操作。继续对兴许的绘制会产生影响。通过该方法能够避免连带的影响! 以下简单举个样例。说明一下,先来看第一段代码: private class DemoView extends View { private Paint mPaint; private Bitmap bitmap1; private Bitmap bitmap2; public DemoView(Context context) { super(context); mPaint = new Paint(); bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.a); bitmap2 = BitmapFactory.decodeResource

Pongo网页版JavaScript源代码及设计思路

谁都会走 提交于 2020-03-02 12:12:02
1.游戏背景介绍(写在前面的废话): 五月初的某天,看到某网推荐了这款游戏,Pongo,看着还不错的样子就用ipad下下来试玩了下,玩了两局感觉还错挺过瘾的,因为是手欠类游戏嘛大家懂的。 但是没一会发现游戏在ipad似乎有些bug,玩一会就会卡住然后只能强退了,真是揪心,记录还等着破呢。 怎么办?玩游戏不如玩自己的游戏的念头又邪恶的出现了,然后就把pad丢给了朋友虐心去,我默默回到电脑前开始动手自己写个不会卡的。 大概两小时吧,写出了基本框架,然后扔sinaapp里试了下效果基本能玩就洗洗睡了。 第二天醒来因为周末没事就花了些时间设计了下界面,同时不幸自己测出了一些比较严重的bug,最后又花了些时间给改掉了。 最后游戏取名 ”Pongo+“(手机党点我即玩) ,电脑端暂时不支持,并顺便在Github上上传了 源码 并去掉了提交成绩模块。 2.游戏试玩网址: Pongo+(仅限移动端): http://mypongo.sinaapp.com/ ‍ ‍ ‍ ‍ github开源(欢迎star/fork让游戏更好): https://github.com/ChenReason/pongo/blob/gh-pages/index.html ‍ ‍ ‍ ‍ 3.游戏规则玩法: 点击屏幕会改变挡板的运动方向,点击一次挡板方向相应改变一次,目的是为了能刚好挡住四处滚动的小球不让其跑出大圆外

Android 运动小球加载效果

只愿长相守 提交于 2020-03-02 11:18:45
一、效果图 二、代码实现 public class LoadingView extends View { private static final long ANIMATION_TIMEOUT = 1500; private TextPaint mPaint; private int mMaxRadius; private int mDotWidth; private int mColor = Color.TRANSPARENT; private AnimatorSet mCircleDotAnimatorSet; private float[] mDotAngles = null; public final static int LINE_STYLE_DOT =0; public final static int LINE_STYLE_ARC =1; private int mLineStyle = LINE_STYLE_DOT; public LoadingView(Context context) { this(context,null); } public LoadingView(Context context, @Nullable AttributeSet attrs) { this(context, attrs,0); } public LoadingView

一入前端深似海,从此红尘是路人系列第五弹之微信小程序canvas篇

本小妞迷上赌 提交于 2020-03-02 09:57:14
看着 小程序 这些日子这么火爆,对于新鲜事物炒鸡感兴趣的我肯定也小小的研究了一下。于是乎便搞出了一个小程序版本的倒计时Demo。Demo效果图如下: 一、Demo思路来源 之所以写了这样一个Demo,是因为很久之前在慕课网看到了一个很好玩很酷炫利用canvas绘制的时钟,于是想着这样炫酷好玩的东西在小程序当中是否也能够得以实现呢?答案肯定是可以的。接下来我将把这个Demo的思路一步一步分享给大家。 二、Demo实现 1.微信小程序开发环境搭建 http://www.helloxcx.com/jc/devtools/download.html 2.开发环境搭建后利用开发工具创建自己的Demo项目 1)创建项目 2)添加核心代码countdown.js ,digit.js到index目录下 3.核心代码实现(代码中有详细的开发注释) 1)digit.js(这里实现倒计时数字的排列,是一个3维数组) // 数字排列 var digit = [ [ [0,0,1,1,1,0,0], [0,1,1,0,1,1,0], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [0,1,1,0,1,1,0], [0,0,1,1,1,0,0] ],/

基于 HTML5 Canvas 的 3D 热力云图效果

半城伤御伤魂 提交于 2020-03-02 09:47:34
前言    数据蕴藏价值,但数据的价值需要用 IT 技术去发现、探索,可视化可以帮助人更好的去分析数据,信息的质量很大程度上依赖于其呈现方式。在数据分析上,热力图无疑是一种很好的方式。在很多行业中都有着广泛的应用。    最近刚好项目中需要用到 3D 热力图 的效果展示。网上搜了相关资料,发现大多 数是 2D 效果或者伪 3D 的,而 3D 粒子 效果对于性能上的体验不是很好,于是取巧写 了个 3D 热力图的 效果 。    Demo : http://www.hightopo.com/demo/heatMap3D/   部分效果图: 应用场景    大楼内的人员分布热力图。我们可以通过观察到一个区域的颜色深浅来判断该区域内实时的人员流动情况,知道哪个区域人多,哪个区域人少。该场景可适用于大楼内的警务监控,在发生突发事件时科学高效地制定分流疏导策略提供有力的帮助和支持,减少损失。亦可用于火险预警,监控区域实时温度。    室内设备温度热力图。传统的数据中心汇报方式枯燥单调、真实感不强,互动性差等,借助于 3D 热力图的可视化呈 现方式,机房运维管理人员可大大提高工作效率及降低工作失误的可能性。 整体思路    在场景反序列化之后,设置热力图的初始参数,初始化后得到的热力图模型添加进场景中,模拟 3D 热力图效果,最后再添加扫描、换肤、温度提示等功能。 1.数据准备