当前位置:网站首页>Customer Rating Control
Customer Rating Control
2022-08-02 03:39:00 【cjx177187】
Pentagram rating control

<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.Draw a five-pointed star using a circle,Find five evenly spaced points on the circle
//2.Use trigonometric functions to calculate the coordinates of each point,as the coordinates of the line
//3.Connect the five dots in two intervals,form a five-pointed star.
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.Draw a five-pointed star using a circle,Find five evenly spaced points on the circle
//2.Use trigonometric functions to calculate the coordinates of each point,as the coordinates of the line
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.Connect the five dots in two intervals,form a five-pointed star.
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函数,Add a person to the boxcanvasDetermine the size of the five-pointed star according to the width and height of the box
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)
//Determine the number of lit five-pointed stars,Fill the pentagram to be changed with yellow
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绑定移动事件,Calculate which pentagram the mouse moves to through the properties of the event and the properties of the elastic box,Change the fill color of all the previous pentagrams to yellow
box.onmousemove = function (el) {
var n = Math.ceil((el.clientX - this.offsetLeft) / (this.offsetHeight + 4))
this.innerHTML = " "
this.canvas(n)
}
</script>
边栏推荐
猜你喜欢

ThunderBirde无法登录问题、pycharm调试一直收集数据、RuntimeError: CUDA error: device-side assert triggered等疑难杂症解决

How to check whether a table is locked in mysql

Chemical reagent Phospholipid-polyethylene glycol-hydroxyl, DSPE-PEG-OH, DSPE-PEG-Hydroxyl, MW: 5000

客户评分控件

kettle 安装与配置

化学试剂磷脂-聚乙二醇-羟基,DSPE-PEG-OH,DSPE-PEG-Hydroxyl,MW:5000

oracle内连接和外连接

C语言 0长度数组/柔性数组

Advanced gradient of skeleton effect, suitable for waiting for pictures

【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
随机推荐
Cloud server installation and deployment of Nacos 2.0.4 version
磷脂-聚乙二醇-酰肼,DSPE-PEG-Hydrazide,DSPE-PEG-HZ,MW:5000
云服务器安装部署Nacos2.0.4版本
亚马逊卖家怎么提升转化率
猴子选大王(约瑟环问题)
Phospholipid-polyethylene glycol-thiol, DSPE-PEG-Thiol, DSPE-PEG-SH, MW: 5000
JJWT工具类
知识工程作业2:知识工程相关领域介绍
枚举法方法:(leetcode1300)转变数组后最接近目标值的数组和
COCO数据集训练TPH-YoloV5
知识问答与知识会话的区别
磷脂-聚乙二醇-醛基 DSPE-PEG-Aldehyde DSPE-PEG-CHO MW:5000
相对路径和绝对路径
kettle 安装与配置
PCL—point cloud data segmentation
querystring模块
js 数组去重的常用方法
How to check whether a table is locked in mysql
oracle inner join and outer join
解决MySQL创建子视图并查看的时候,字符集报错问题