<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<canvas id = "Mycanvas" width="300" height="300" style="border:2px solid red;"></canvas>
<script type="text/jscript">
var canvas = document.getElementById("Mycanvas");
var context = canvas.getContext("2d");
var x = 100;
var y = 100;
var a = 50;
var b = 30
//选择a、b中的较大者作为arc方法的半径参数
var r = (a > b) ? a : b;
var ratioX = a / r; //横轴缩放比率
var ratioY = b / r; //纵轴缩放比率
context.scale(ratioX, ratioY); //进行缩放(均匀压缩)
context.beginPath();
//从椭圆的左端点开始逆时针绘制
context.arc(x , y , r, 0, 2 * Math.PI);
context.fillStyle="#E2C1A7";
context.fill();
context.stroke();
</script>
</body>
</html>
效果图:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL4AAABsCAIAAABb4J/uAAAK00lEQVR4Ae2deVRTVx7HE5JAEAwQURAkBaEKdWSrtAWEIoJFcDk909ZxVNQ61kp1xhap1pUzMmrd921qRWFARe04RXHjiFqWMmMRqokKCARRCUsIRJJIlrmWcyKHgkeeeXn3PX75677l97u/3/f34eaR9969bIPBwIIPKNB3BSz6bgIWoMBzBQAd4ICgAoAOQeHADNABBggqAOgQFA7MAB1ggKACgA5B4cAM0AEGCCoA6BAUDswAHWCAoAKADkHhwAzQAQYIKgDoEBQOzAAdYICgAoAOQeHADNABBggqAOgQFA7MAB1ggKACgA5B4cAM0AEGCCoA6BAUDswAHWCAoAJcgnaMMNNoNPX19Q0NDSgblUqlVquNaVlbW/P5fLQ55LePlZWV8RA0OhXoF+hotdqqqiqJWCy+XVZx/55K9ZTDZul1Oisex9FeILS3tWCxLXlcvuULNdTPtM86tHqWoalF2SBXoKYFh6MzsKytbUZ4e3uP8vXx8fHw8OByX5j0N6TYTH2Fr7y8v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bEQiUS5V6/dqlUs3fy9grkPE6LJbxM3H/61ru1y7lV6cYMqhemoY2QIvb22YlnSgo+jo4MDjDuZ0bhUUHLo1OUNm7ZERkbSMSNMRx2jlOPHj8/Nuy6u18xZsb30bqVxP60b6ObU3JU7JDINSo2m3CD9cR91jIigq59V3yxTymWJ8VNpvbzI1qNnBYOcUzZ8S7tvKGMtOhu0QaczXLSo0eaNKXq1cmZsOO0WNUo/d507wC5p+UpY1KgbhebbrKur27V96+1bN6dGjKHFUmpnr930CxyzeEmiiwtz5tmk2ajTFc/29vajqakXc7LRAo5TwgN9MVtZ7ZbkQfaNX54v4Bg7efacObRbPaSr1D22aYyOMR+0MEdmetov//t5AI891m9E6NujyF5l2Nh1t8ZTlbqgRPzTrfsqrSEwKHj6jJmwbGw3iTDdbGpqunghBy0k+7RVPvINFzMvVn1f+tjWTvjBxEkTYmKEQiGmGpkuLCaMOj2qUV5eXliQX1yUr2xp4Vno3ZwHiZwc3F2cREOH8HjEn1Lq6NBKH8uq6+qlMnntk+YOPWugvfCd4NDgkFAvL68eI2HqTsai07VgaL7LqqoqiVgsvl1Wcf+eWtVuwTbodTorHsfRXiC0t2WzWKhtxUVI6X8ztNBotZoOnYHFampRNsgVHVq9BYejN7D51gNGeHt7j/JFr2N6eHhwn5v000+/QKe32mo0GjTND/qgE9Cif2q12ngmuqrl8/nonY3Bgwej973RM9TGQ9DoVKBfowMQvI4CuN+IeJ3cwJZUBQAdUuVlsnNAh8nVJTU3QIdUeZnsHNBhcnVJzQ3QIVVeJjsHdJhcXVJzA3RIlZfJzgEdJleX1NwAHVLlZbJzQIfJ1SU1N0CHVHmZ7BzQYXJ1Sc0N0CFVXiY7B3SYXF1ScwN0SJWXyc4BHSZXl9TcAB1S5WWyc0CHydUlNTdAh1R5mewc0GFydUnNDdAhVV4mO/8/7TuegRvzpVEAAAAASUVORK5CYII=" alt="" />
- 如何使用canvas绘制椭圆,扩展非chrome浏览器中的ellipse方法
这篇博文主要针对浏览器中绘制椭圆的方法扩展.在网上搜索了很多,发现他们绘制椭圆的方式都有缺陷.其中有压缩法,计算法,贝塞尔曲线法等多种方式.但是都不能很好的绘制出椭圆.所有我就对这个绘制椭圆的方式进行 ...
- HTML5 Canvas中绘制椭圆的几种方法
1.canvas自带的绘制椭圆的方法 ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise)是后来 ...
- 使用Canvas绘制图形的基本教程
原文地址:http://www.cnblogs.com/picaso/archive/2012/11/26/2789077.html HTML5火的正热,最近有个想法也是要用到HTML的相关功能,所以 ...
- HTML5之Canvas绘图——使用Canvas绘制图形的基本教程
原文转自:http://www.cnblogs.com/picaso/archive/2012/11/26/2789077.html HTML5火的正热,最近有个想法也是要用到HTML的相关功能,所以 ...
- HTML5学习总结——canvas绘制象棋(canvas绘图)
一.HTML5学习总结——canvas绘制象棋 1.第一次:canvas绘制象棋(笨方法)示例代码: <!DOCTYPE html> <html> <head> & ...
- 用canvas绘制折线图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 封装 用canvas绘制直线的函数--面向对象
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 学习笔记:HTML5 Canvas绘制简单图形
HTML5 Canvas绘制简单图形 1.添加Canvas标签,添加id供js操作. <canvas id="mycanvas" height="700" ...
- canvas绘制经典折线图(一)
最终效果图如下: 实现步骤如下:注-引用了jQuery HTML代码 <!doctype html> <html lang="en"> <head&g ...
随机推荐
- Android -- 从源码的角度一步步打造自己的TextView
1,自定义控件一直是我们的痛点,今天就和大家一点点去了解了解,首先一般的自定义控件都是继承于View类,所以我们先来看看view的一些重要的方法,这是官方文档,大家想了解更多也可以去看看,这里我展示对 ...
- Luogu P3367 【模板】并查集
题目描述 如题,现在有一个并查集,你需要完成合并和查询操作. 输入输出格式 输入格式: 第一行包含两个整数N.M,表示共有N个元素和M个操作. 接下来M行,每行包含三个整数Zi.Xi.Yi 当Zi=1 ...
- [算法题] Remove Duplicates from Sorted Array ii
题目内容 本题来源LeetCode Follow up for "Remove Duplicates": What if duplicates are allowed at mos ...
- Linux IP_FORWARD说明
--Linux IP_FORWARD说明 -----------------------------2014/03/01 ip地址分公有地址和私有地址,public address是由INIC(int ...
- MFC加载PNG图片并实现双缓冲
因为PNG包含Alpha通道,所以不同于BITMAP,在MFC中使用CImage类对其进行处理,通常使用load和draw成员函数. 所以标题的论述可以进一步解释为,使用CImage实现双缓冲. 通常 ...
- Hadoop分布式集群搭建
layout: "post" title: "Hadoop分布式集群搭建" date: "2017-08-17 10:23" catalog ...
- python中金额计算的小问题
由于二进制对浮点运算存在精度问题,所以一些浮点计算经常会出现以下情况: # -*- coding: utf-8 -*- a = 1 b = 0.9 print(a-b) 结果: 0.099999999 ...
- zTree理解和简单Demo(转)
zTree是利用 jQuery 的核心代码,实现一套能完成大部分常用功能的 Tree 插件.整个zTree的页面显示核心 代码是. <span style="font-family:V ...
- Vim入门基础
公司新员工学习有用到,Vim官网的手册又太大而全,而网上各方资料要么不全面,要么不够基础.在网上搜集各方资料,按照自己的框架整理一份Vim入门基础教程,分享出来.特点是偏向基础,但对入门者来说足够全面 ...
- php 开发调试的常用技巧和工具
nginx的access.log 作用: 记录一个页面请求中,服务器接收到的所用相关的url. 根据此log, 对服务器上调用了哪些服务,可以一目了然,快速理清业务关系,调试开发非常赞! 注意: ...