2022-10-07 23:02:40 +09:00
|
|
|
<template>
|
2023-01-29 04:39:18 +09:00
|
|
|
<div v-if="config">
|
|
|
|
<div :style="styles.bg" />
|
|
|
|
<div :class="previewCssClass" :style="styles.root" >
|
|
|
|
<div v-for="style, i in styles.chars" :key="i" class="char-ctn" :style="style.ctn">
|
|
|
|
<div class="char-bg" :style="style.bg" />
|
|
|
|
<div class="char-mask" :style="style.mask" />
|
|
|
|
</div>
|
2022-10-07 23:02:40 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-01-29 04:39:18 +09:00
|
|
|
import {rgbaI2S} from './codes/utils.js';
|
|
|
|
import {measureText} from './codes/text.js';
|
|
|
|
|
2022-10-07 23:02:40 +09:00
|
|
|
export default {
|
|
|
|
props: {
|
2023-01-29 04:39:18 +09:00
|
|
|
config: {type: Object},
|
|
|
|
version: {type: String},
|
2022-10-07 23:02:40 +09:00
|
|
|
},
|
|
|
|
computed: {
|
2023-01-29 04:39:18 +09:00
|
|
|
previewCssClass() {
|
2023-05-17 22:28:41 +09:00
|
|
|
return `preview-str preview-${this.version.startsWith('GMSJ') ? 'JP' : this.version === 'GMSE01' ? 'US' : 'EU'}`;
|
2023-01-29 04:39:18 +09:00
|
|
|
},
|
2022-10-07 23:02:40 +09:00
|
|
|
styles() {
|
2023-01-29 04:39:18 +09:00
|
|
|
const {config, version} = this;
|
|
|
|
const {x: x0, y: y0, fontSize, fgRGB, fgA, fgRGB2, fgA2, bgRGB, bgA, bgLeft, bgRight, bgTop, bgBot, text} = config;
|
|
|
|
const fgColor = rgbaI2S(fgRGB, fgA);
|
|
|
|
const {width, height, chars} = measureText(text, version);
|
2022-10-07 23:02:40 +09:00
|
|
|
|
|
|
|
return {
|
|
|
|
root: {
|
|
|
|
transform: `translate(${x0}px, ${y0-fontSize}px) scale(${fontSize/20})`,
|
|
|
|
},
|
|
|
|
chars: chars.map(({x, y, u, v}) => {
|
|
|
|
const offset = `${-u}px ${-v}px`;
|
|
|
|
return {
|
|
|
|
ctn: {
|
|
|
|
left: x+'px',
|
|
|
|
top: y+'px',
|
|
|
|
},
|
|
|
|
bg: {
|
|
|
|
'background-position': offset,
|
|
|
|
},
|
|
|
|
mask: {
|
|
|
|
'mask-position': offset,
|
|
|
|
'-webkit-mask-position': offset,
|
2023-01-29 04:39:18 +09:00
|
|
|
background: fgRGB2 == null || fgA2 == null ? fgColor :
|
|
|
|
`linear-gradient(180deg, ${fgColor}, ${rgbaI2S(fgRGB2, fgA2)})`,
|
2022-10-07 23:02:40 +09:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}),
|
2023-01-29 04:39:18 +09:00
|
|
|
bg: {
|
|
|
|
left: x0 - bgLeft + 'px',
|
|
|
|
top: y0 - fontSize - bgTop + 'px',
|
|
|
|
width: (width * fontSize) / 20 + bgLeft + bgRight + 'px',
|
|
|
|
height: (height * fontSize) / 20 + bgTop + bgBot + 'px',
|
|
|
|
background: rgbaI2S(bgRGB, bgA),
|
|
|
|
},
|
2022-10-07 23:02:40 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2023-01-29 04:39:18 +09:00
|
|
|
* {
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
|
2022-10-07 23:02:40 +09:00
|
|
|
.preview-str {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.preview-str * {
|
|
|
|
position: absolute;
|
|
|
|
}
|
2023-01-29 04:39:18 +09:00
|
|
|
.char-ctn {
|
2022-10-07 23:02:40 +09:00
|
|
|
isolation: isolate;
|
|
|
|
}
|
2023-01-29 04:39:18 +09:00
|
|
|
.char-ctn > div {
|
2022-10-07 23:02:40 +09:00
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
}
|
2023-01-29 04:39:18 +09:00
|
|
|
.char-mask {
|
2022-10-07 23:02:40 +09:00
|
|
|
mask-repeat: no-repeat;
|
|
|
|
-webkit-mask-repeat: no-repeat;
|
|
|
|
mix-blend-mode: multiply;
|
|
|
|
}
|
2023-01-29 04:39:18 +09:00
|
|
|
|
|
|
|
.preview-JP .char-bg {
|
|
|
|
background: url(/img/preview/font-JP.png);
|
|
|
|
}
|
|
|
|
.preview-JP .char-mask {
|
|
|
|
mask-image: url(/img/preview/font-JP.png);
|
|
|
|
-webkit-mask-image: url(/img/preview/font-JP.png);
|
|
|
|
}
|
2023-05-17 22:28:41 +09:00
|
|
|
.preview-US .char-bg {
|
|
|
|
background: url(/img/preview/font-US.png);
|
|
|
|
}
|
|
|
|
.preview-US .char-mask {
|
|
|
|
mask-image: url(/img/preview/font-US.png);
|
|
|
|
-webkit-mask-image: url(/img/preview/font-US.png);
|
|
|
|
}
|
2023-01-29 04:39:18 +09:00
|
|
|
.preview-EU .char-bg {
|
|
|
|
background: url(/img/preview/font-EU.png);
|
|
|
|
}
|
|
|
|
.preview-EU .char-mask {
|
|
|
|
mask-image: url(/img/preview/font-EU.png);
|
|
|
|
-webkit-mask-image: url(/img/preview/font-EU.png);
|
|
|
|
}
|
|
|
|
/* TODO US */
|
2022-10-07 23:02:40 +09:00
|
|
|
</style>
|