当前位置:网站首页>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>
边栏推荐
猜你喜欢
骨架效果 之高级渐变,适用图片等待时
oracle inner join and outer join
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
The @autowired distinguished from @ the Resource
PCL—point cloud data segmentation
亚马逊卖家怎么提升转化率
磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000
canvas--饼状图
Phospholipid-polyethylene glycol-hydrazide, DSPE-PEG-Hydrazide, DSPE-PEG-HZ, MW: 5000
磷脂-聚乙二醇-醛基 DSPE-PEG-Aldehyde DSPE-PEG-CHO MW:5000
随机推荐
Scientific research reagent DMPE-PEG-Mal dimyristoylphosphatidylethanolamine-polyethylene glycol-maleimide
相对路径和绝对路径
C语言的变长数组
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰活性基团
js作用域与闭包
磷脂-聚乙二醇-靶向新生血管靶向肽APRPG,DSPE-PEG-APRPG
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
Deveco studio 鸿蒙app访问网络详细过程(js)
磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
parser = argparse.ArgumentParser()解析
STM32 CAN过滤器
FreeRTOS内核详解(1) —— 临界段保护原理
通过PS 2021 将网页图标抠下来
ModuleNotFoundError No module named 'xxx' possible solutions
npm--package.json---require
canvas--pie chart
meime模块
C语言 结构体定义方法
ssm各类配置模板
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine supply, MW: 5000