小程序canvas画虚线圆

news/2024/7/20 2:36:12 标签: 小程序, canas, 圆形虚线

效果:

封装:

/**

* 画虚线园

* cxt_arc 画布

* thex 画的x坐标

* they 画的y坐标

* raduis 圆半径

* space 虚线的间隔 默认值 2 * Math.PI / 100 即一百空白点

*/

drawDashCircle: function (cxt_arc, thex, they, raduis, space) {

space = space || 2 * Math.PI / 100;

cxt_arc.setLineWidth(1);

cxt_arc.setStrokeStyle("rgba(134,181,162,0.5)");

cxt_arc.setLineCap('square')

var start = 0;//从原点开始画

while (start <= 2 * Math.PI) {

var end = start + space;

cxt_arc.beginPath();//开始一个新的路径

cxt_arc.arc(thex, they, raduis, start, end, false);

start = space + end;

cxt_arc.stroke();//对当前路径进行描边

}

},

 

使用:

this.drawDashCircle(ctx, 200, 200, 60);


http://www.niftyadmin.cn/n/797841.html

相关文章

小程序富文本WxParse插件

参考https://blog.csdn.net/loveyoulouyou/article/details/83413628 下载WxParse插件&#xff0c;插件地址https://github.com/icindy/wxParse css部分&#xff1a; import "../../utils/wxParse/wxParse.wxss"; html部分&#xff1a; <import src"../…

layui根据条件修改表格固定行的颜色

当按钮样式存在 “noedit”时&#xff0c;该行变灰色 var data{ table :{ id:userlist-table, options:{ done:function(res,curr,count){ res.data.forEach(function (item, index) { …

关于js中location.href的用法

window.location.href"、"location.href"是本页面跳转 parent.location.href"是上一层页面跳转 "top.location.href"是最外层的页面跳转举例说明&#xff1a;如果A,B,C,D都是jsp&#xff0c;D是C的iframe&#xff0c;C是B的iframe&#xff0c;B是…

小程序实现标尺滑动

效果图&#xff1a; html部分&#xff1a; <!--pages/test-rules/test-rules.wxml--> <view> <view class"ageCon"> <view class"title">年龄</view> <view class"ageOut"> <view class"hr&q…

vue引入bootstrap报错找不到模块modules

参考文档&#xff1a;https://segmentfault.com/a/1190000015765805 要使用bootstrap要先分两步&#xff0c; 第一步&#xff1a;引入jQuery 第二步&#xff1a;再引入bootstrap 1、建立一个vue工程。 2、使用命令npm install jquery --save-dev 引入jquery。 3、在webpa…

vue 实现数字滚动增加效果

参考&#xff1a;http://panjiachen.github.io/countTo/demo/ 效果&#xff1a; 使用vue-countTo插件 安装&#xff1a;npm install vue-count-to 使用&#xff1a; <template> <countTo refexample :startValstartVal :endValendVal :duration2000></coun…

CSS选择器汇总

一、overflow元素overflow : hidden,scroll,auto隐藏或显示滚动条overflow-yoverflow-x二、设置表格间间隔border-collapse: separate;border-spacing: 100px 50px;三、合并单元格border-collapse:collapse;四、border属性border : 1px solid black;border-styleborder-width;b…

vue监听滚动事件 实现元素吸顶

添加滚动监听事件&#xff1a; mounted () { window.addEventListener(scroll, this.handleScroll) }, 页面销毁需要取消监听&#xff1a; destroyed(){ window.removeEventListener(scroll, this.handleScroll) } 使用&#xff1a; <template> <div class&quo…