当前位置:网站首页>客户评分控件
客户评分控件
2022-08-02 03:22:00 【cjx177187】
五角星评分控件
<body>
<style>
#box {
border: 1px solid black;
margin: 100px 0 0 100px;
width: 510px;
height: 100px;
position: absolute;
}
</style>
<h1>点亮小星星:</h1>
<div id="box"></div>
<script>
//画五角星
//1.利用圆形画五角星,在圆上找均匀分布的五个点
//2.利用三角函数算出每个点的坐标,作为连线的坐标
//3.将五个点两两间隔连接起来,形成五角星。
Object.prototype.start = function (x, y, r, color = "gray", ancolor = "yellow") {
this.beginPath()
var arr = []
var deg = Math.PI / 180
for (let i = 0; i < 5; i++) {
//1.利用圆形画五角星,在圆上找均匀分布的五个点
//2.利用三角函数算出每个点的坐标,作为连线的坐标
var x1 = x + Math.cos((72 * i - 90) * deg) * r
var y1 = y + Math.sin((72 * i - 90) * deg) * r
arr.push(x1, y1)
}
//3.将五个点两两间隔连接起来,形成五角星。
this.moveTo(arr[0], arr[1])
this.lineTo(arr[4], arr[5])
this.lineTo(arr[8], arr[9])
this.lineTo(arr[2], arr[3])
this.lineTo(arr[6], arr[7])
this.lineTo(arr[0], arr[1])
this.fillStyle = color
this.fill()
// this.stroke()
}
//封装一个canvas函数,在盒子里面添加一个人canvas根据盒子的宽高来决定五角星的大小
Object.prototype.canvas = function (n, color) {
var canvas = document.createElement("canvas")
var pen = canvas.getContext("2d")
var r = this.offsetHeight / 2
canvas.heigth = r * 2
canvas.width = (this.offsetHeight + 4) * 5
this.appendChild(canvas)
//判断点亮五角星的个数,将要改变的五角星填充为黄色
for (let i = 0; i < 5; i++) {
if (i < n) {
pen.start(r + r * 2 * i, r, r, "yellow")
} else {
pen.start(r + r * 2 * i, r, r, color)
}
}
}
</script>
<script>
var box = document.querySelector("#box")
box.canvas()
//给box绑定移动事件,通过事件的属性和弹性盒子的属性来计算出鼠标移动到那个五角星,将前面所有的五角星的填充颜色变为黄色
box.onmousemove = function (el) {
var n = Math.ceil((el.clientX - this.offsetLeft) / (this.offsetHeight + 4))
this.innerHTML = " "
this.canvas(n)
}
</script>
边栏推荐
- Debian 10 NTP 服务配置
- 远程调试、无cuDnn、自定义模块无法导入问题记录
- 知识工程作业2:知识工程相关领域介绍
- Redis simple study notes
- Source Insight 使用教程(2)——常用功能
- C语言入门小游戏—三子棋
- @Autowired与@Resource区别
- Chemical reagent Phospholipid-polyethylene glycol-hydroxyl, DSPE-PEG-OH, DSPE-PEG-Hydroxyl, MW: 5000
- 化学试剂磷脂-聚乙二醇-羟基,DSPE-PEG-OH,DSPE-PEG-Hydroxyl,MW:5000
- AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
猜你喜欢
@Configuration详解
【 application 】 life many years of operations, what turned scored 12 k + annual bonus salary?
PCL—point cloud data segmentation
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the index ing argu
DSPE-PEG-PDP,DSPE-PEG-OPSS,磷脂-聚乙二醇-巯基吡啶供应,MW:5000
parser = argparse.ArgumentParser()解析
C语言 0长度数组/柔性数组
通过PS 2021 将网页图标抠下来
磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
随机推荐
Detailed explanation of the usage of exists in mysql
Mysql8创建用户以及赋权操作
String comparison size in MySQL (date string comparison problem)
亚马逊卖家怎么提升转化率
解决glob()返回文件排序不一致问题&onnx本地按照安装方法
Week 7 Review
HCIP-第十一天-MPLS+BGP
Error: with open(txt_path,'r') as f: FileNotFoundError: [Errno 2] No such file or directory:
np.isnan()
How to check whether a table is locked in mysql
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
@Configuration详解
subprocess.CalledProcessError: Command ‘pip install ‘thop‘‘ returned non-zero exit status 1.
Redis simple study notes
Deveco studio 鸿蒙app访问网络详细过程(js)
__dirname
【深度学习】从LeNet-5识别手写数字入门深度学习
kettle 安装与配置
oracle inner join and outer join
@Autowired注解的使用