Skip to content

Commit

Permalink
一定程度上提升了桌布生成器的默认显示效果
Browse files Browse the repository at this point in the history
  • Loading branch information
iamapig120 committed Jan 13, 2019
1 parent aa9524b commit d4a8717
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tool/desktopCreator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<input id="saveAndInstall" type="button" value="保存并安装" /><br />

<canvas width="1024" height="1024" id="canvas"></canvas>
<canvas width="2048" height="2048" id="canvas"></canvas>
<script src="script.js"></script>
</body>
</html>
20 changes: 16 additions & 4 deletions tool/desktopCreator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,25 @@ const drawView = event => {
new Promise(resolve => imgInner.addEventListener('load', resolve))
]).then(() => {
context.clearRect(0, 0, canvas.width, canvas.height)
context.drawImage(img, 122, 122, 780, 780)
context.drawImage(
img,
(122 / 1024) * canvas.width,
(122 / 1024) * canvas.height,
(780 / 1024) * canvas.width,
(780 / 1024) * canvas.height
)
context.fillStyle = `#000000`
context.globalAlpha = darknessRange.value / 100
context.fillRect(0, 0, canvas.width, canvas.height)
context.globalAlpha = 1
context.drawImage(imgInner, 122, 122, 780, 780)
context.drawImage(imgDesktopBorder, 0, 0, 1024, 1024)
context.drawImage(
imgInner,
(122 / 1024) * canvas.width,
(122 / 1024) * canvas.height,
(780 / 1024) * canvas.width,
(780 / 1024) * canvas.height
)
context.drawImage(imgDesktopBorder, 0, 0, canvas.width, canvas.height)

contextPreview.clearRect(0, 0, canvasPreview.width, canvasPreview.height)
contextPreview.drawImage(
Expand Down Expand Up @@ -128,7 +140,7 @@ saveAndInstall.addEventListener('click', event => {
}
fs.writeFileSync(path.join(dirPath, 'mod.json'), JSON.stringify(modInfo))
const desktopData = canvas
.toDataURL('image/jpeg')
.toDataURL('image/jpeg', 1)
.replace(/^data:image\/\w+;base64,/, '')
const previewData = canvasPreview
.toDataURL('image/jpeg')
Expand Down

0 comments on commit d4a8717

Please sign in to comment.