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) font_m = QFontMetrics(font)
path = QPainterPath() path = QPainterPath()
for i in range(self.config["trace"]): for i in range(1 + int(10 * self.config["trace"])):
path.addText( path.addText(
fontOutLineWidth + i, fontOutLineWidth + i / 10,
fontOutLineWidth + i + font_m.ascent(), fontOutLineWidth + i / 10 + font_m.ascent(),
font, font,
text, text,
) )

View File

@ -102,32 +102,39 @@
commoninit_font_align_height(ele, args) commoninit_font_align_height(ele, args)
let style = document.createElement('style') let style = document.createElement('style')
style.innerHTML = ` 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}; -webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
position: relative; position: relative;
} z-index: -1;
#${_id} .stroken::after { left: ${(i + i) / 10}px;
content: attr(content1); top: ${(i + i) / 10}px;
color: ${c2}; user-select: none;
position: absolute;
left: 0;
right: 0;
top: 0;
-webkit-text-stroke-width: 0;
}` }`
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 return ele
} }

View File

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