pattern: fix
This commit is contained in:
@@ -17,15 +17,20 @@ const MOBILE_BIG = 19.5
|
||||
let small = NORMAL_SMALL
|
||||
let big = NORMAL_BIG
|
||||
|
||||
let dpr = window.devicePixelRatio || 1
|
||||
let IS_DESKTOP = true
|
||||
|
||||
function setupCanvas(canvas) {
|
||||
const dpr = window.devicePixelRatio || 1
|
||||
dpr = window.devicePixelRatio || 1
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
canvas.width = rect.width * dpr
|
||||
canvas.height = rect.height * dpr
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.scale(dpr, dpr)
|
||||
|
||||
if ((canvas.width / dpr) > 750) {
|
||||
IS_DESKTOP = (canvas.width / dpr) > 750
|
||||
|
||||
if (IS_DESKTOP) {
|
||||
small = NORMAL_SMALL
|
||||
big = NORMAL_BIG
|
||||
} else {
|
||||
@@ -102,18 +107,15 @@ function bg(colorIndex, canvas, ctx, randomColors) {
|
||||
}
|
||||
|
||||
function font(colorIndex, canvas, ctx) {
|
||||
if (canvas.width > 750) {
|
||||
if (IS_DESKTOP) {
|
||||
ctx.font = '195px Kobata'
|
||||
|
||||
kerningNormal = { R: -12, E: -27, C: -13, A: -13, P: -13, I: -13, T: -13, U: -13, L: -13, N: -13, G: -13 }
|
||||
kerningWide = { Q: 178.7, U: 178.7, E: 178.7 }
|
||||
} else {
|
||||
ctx.font = '74px Kobata'
|
||||
|
||||
kerningNormal = { R: -6, E: -13, C: -6, A: -6, P: -6, I: -6, T: -6, U: -6, L: -6, N: -6, G: -6 }
|
||||
kerningWide = { Q: 38, U: 38, E: 38 }
|
||||
}
|
||||
|
||||
let kerningNormal = { R: -12, E: -27, C: -13, A: -13, P: -13, I: -13, T: -13, U: -13, L: -13, N: -13, G: -13 }
|
||||
let kerningWide = { Q: 178.7, U: 178.7, E: 178.7 }
|
||||
|
||||
const patterns = [
|
||||
[0],
|
||||
[0, 1]
|
||||
@@ -131,7 +133,7 @@ function font(colorIndex, canvas, ctx) {
|
||||
|
||||
if (kerning[char]) {
|
||||
let k = kerning[char]
|
||||
if (canvas.width < 750) k = k * 0.51724138
|
||||
if (!IS_DESKTOP) k = k * (0.34482759 * (1 / dpr))
|
||||
x += k
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user