This commit is contained in:
恍兮惚兮 2024-06-22 18:23:59 +08:00
parent 5bc71c24f7
commit 8fcbebd11d
3 changed files with 42 additions and 27 deletions

View File

@ -35,10 +35,10 @@ class TextLine(base):
font_m = QFontMetrics(font)
path = QPainterPath()
for i in range(self.config["trace"]):
for i in range(1 + int(10 * self.config["trace"])):
path.addText(
fontOutLineWidth + i,
fontOutLineWidth + i + font_m.ascent(),
fontOutLineWidth + i / 10,
fontOutLineWidth + i / 10 + font_m.ascent(),
font,
text,
)

View File

@ -102,32 +102,39 @@
commoninit_font_align_height(ele, args)
let style = document.createElement('style')
style.innerHTML = `
#${_id} .stroken{
#${_id}{
display: grid;
}
#${_id} div{
margin: 0;
grid-column: 1;
grid-row: 1;
}
#${_id} .nostroken {
color: ${c2};
}`
for (let i = 0; i < 1 + styleargs.trace * 10; i++) {
style.innerHTML += `#${_id} .stroken${i}{
-webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
position: relative;
}
#${_id} .stroken::after {
content: attr(content1);
color: ${c2};
position: absolute;
left: 0;
right: 0;
top: 0;
-webkit-text-stroke-width: 0;
z-index: -1;
left: ${(i + i) / 10}px;
top: ${(i + i) / 10}px;
user-select: none;
}`
ele.appendChild(style)
let sps = text.split('\n')
for (let i = 0; i < sps.length; i++) {
let div = document.createElement('div')
div.innerText = sps[i]
div.setAttribute('content1', sps[i])
div.classList.add('stroken')
ele.appendChild(div)
}
ele.appendChild(style)
let p = document.createElement('div')
p.innerText = text;
p.classList.add('nostroken')
ele.appendChild(p)
for (let i = 0; i < styleargs.trace * 10; i++) {
let p = document.createElement('div')
p.innerText = text;
p.classList.add(`stroken${i}`)
ele.appendChild(p)
}
return ele
}

View File

@ -90,6 +90,7 @@
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3,
"trace": 0,
"reverse": true
},
"argstype": {
@ -114,6 +115,13 @@
"min": 0,
"max": 10,
"step": 0.01
},
"trace": {
"name": "投影距离",
"type": "spin",
"min": 0,
"max": 100,
"step": 0.1
}
}
}
@ -148,7 +156,7 @@
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3,
"trace": 5,
"trace": 0,
"reverse": true
},
"argstype": {
@ -176,10 +184,10 @@
},
"trace": {
"name": "投影距离",
"type": "intspin",
"type": "spin",
"min": 0,
"max": 100,
"step": 1
"step": 0.1
}
}
},