调整线条显示效果

This commit is contained in:
Euni4U 2025-01-03 16:36:13 +08:00
parent 98d140e8fd
commit 5a756f38ae

View File

@ -168,8 +168,17 @@ function lineTo(x, y, x1, y1, type) {
ctx.value.beginPath() ctx.value.beginPath()
ctx.value.moveTo(x, y) ctx.value.moveTo(x, y)
ctx.value.lineTo(x1, y1) ctx.value.lineTo(x1, y1)
ctx.value.strokeStyle = 'black' ctx.value.strokeStyle = '#000000'
ctx.value.lineWidth = 1 ctx.value.lineWidth = 0.8 // 线使线
ctx.value.lineCap = 'round' // 使线
ctx.value.lineJoin = 'round' // 使线
ctx.value.imageSmoothingEnabled = true //
ctx.value.imageSmoothingQuality = 'high' //
// 齿
ctx.value.shadowBlur = 0.5 //
ctx.value.shadowColor = '#000000'
// 线
ctx.value.globalAlpha = 0.8
ctx.value.stroke() ctx.value.stroke()
// //
@ -459,7 +468,7 @@ const lead_name = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF']
const rlead_name = ['V1', 'V2', 'V3', 'V4', 'V5', 'V6'] const rlead_name = ['V1', 'V2', 'V3', 'V4', 'V5', 'V6']
//<EFBFBD><EFBFBD><EFBFBD> //
function handleFileChange() { function handleFileChange() {
const json = JSON.parse(text.value) const json = JSON.parse(text.value)
@ -584,6 +593,9 @@ function begin(c_canvas, beatArray) {
const ctx = c_canvas.getContext('2d') const ctx = c_canvas.getContext('2d')
ctx.globalAlpha = 1 ctx.globalAlpha = 1
ctx.strokeStyle = '#000000' ctx.strokeStyle = '#000000'
ctx.lineWidth = 1.0
ctx.lineCap = 'round'
ctx.lineJoin = 'round'
let offset = -50 let offset = -50
const spacing = heightoff.value const spacing = heightoff.value
beatArray.forEach((dataArray, index) => { beatArray.forEach((dataArray, index) => {
@ -622,6 +634,9 @@ function beginr(c_canvas, beatArray) {
const ctx = c_canvas.getContext('2d') const ctx = c_canvas.getContext('2d')
ctx.globalAlpha = 1 ctx.globalAlpha = 1
ctx.strokeStyle = '#000000' ctx.strokeStyle = '#000000'
ctx.lineWidth = 1.0
ctx.lineCap = 'round'
ctx.lineJoin = 'round'
let offset = -50 let offset = -50
const spacing = heightoff.value const spacing = heightoff.value
beatArray.forEach((dataArray, index) => { beatArray.forEach((dataArray, index) => {
@ -687,37 +702,48 @@ function drawMultipleLinesr(c_canvas, beatArrays) {
//线 //线
function drawLine1(c_canvas, beatArray, offset, index) { function drawLine1(c_canvas, beatArray, offset, index) {
const ctx = c_canvas.getContext('2d') const ctx = c_canvas.getContext('2d')
ctx.strokeStyle = '#030101'
ctx.lineWidth = 1 //
ctx.globalAlpha = 1
ctx.strokeStyle = '#000000'
ctx.lineWidth = 1.0
ctx.lineCap = 'round'
ctx.lineJoin = 'round'
//
ctx.beginPath() ctx.beginPath()
if (index <= 5) {
// 使
if (beatArray.length > 0) { if (beatArray.length > 0) {
const firstX = 0 const firstX = 0
const firstY = (heightoff.value-50) - beatArray[0] * infoParams.lineratio + offset const firstY = (heightoff.value-50) - beatArray[0] * infoParams.lineratio + offset
ctx.moveTo(firstX, firstY) ctx.moveTo(firstX, firstY)
for (let i = 0; i < beatArray.length - 1; i++) {
const x2 = (0 + (i + 1) / 10) * infoParams.suduratio // 使
const y2 = (heightoff.value-50) - beatArray[i + 1] * infoParams.lineratio + offset const step = Math.max(1, Math.floor(beatArray.length / 1000)) //
ctx.lineTo(x2, y2)
for (let i = 0; i < beatArray.length - step; i += step) {
const x = (0 + i / 10) * infoParams.suduratio
const y = (heightoff.value-50) - beatArray[i] * infoParams.lineratio + offset
// 使线线
const nextX = (0 + (i + step) / 10) * infoParams.suduratio
const nextY = (heightoff.value-50) - beatArray[i + step] * infoParams.lineratio + offset
const cpX = (x + nextX) / 2
const cpY = (y + nextY) / 2
ctx.quadraticCurveTo(x, y, cpX, cpY)
} }
//
const lastX = (0 + (beatArray.length - 1) / 10) * infoParams.suduratio
const lastY = (heightoff.value-50) - beatArray[beatArray.length - 1] * infoParams.lineratio + offset
ctx.lineTo(lastX, lastY)
}
//
ctx.stroke() ctx.stroke()
ctx.closePath()
}
}
if (index > 5) {
if (beatArray.length > 0) {
const firstX = 0
const firstY = (heightoff.value-50) - beatArray[0] * infoParams.lineratio + offset
ctx.moveTo(firstX, firstY)
for (let i = 0; i < beatArray.length - 1; i++) {
const x2 = (0 + (i + 1) / 10) * infoParams.suduratio
const y2 = (heightoff.value-50) - beatArray[i + 1] * infoParams.lineratio + offset
ctx.lineTo(x2, y2)
}
ctx.stroke()
ctx.closePath()
}
}
} }
</script> </script>