From 4dbdd497db5477f9557fde7d4a263f2e4157a890 Mon Sep 17 00:00:00 2001 From: mmyduckx <308303735@qq.com> Date: Wed, 5 Jul 2023 17:53:22 +0800 Subject: [PATCH 1/2] add constrain for wechat logo default ratio --- templates/wechatgame/first-screen.ejs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/wechatgame/first-screen.ejs b/templates/wechatgame/first-screen.ejs index c172c69c2bb..29ed2e69a2a 100644 --- a/templates/wechatgame/first-screen.ejs +++ b/templates/wechatgame/first-screen.ejs @@ -179,9 +179,10 @@ function initProgressVertexBuffer() { } function updateVertexBuffer() { - // the ratio value may be adjusted according to the expected image display effect - const widthRatio = image.width / canvas.width * 1.35 * displayRatio; - const heightRatio = image.height / canvas.height * 1.35 * displayRatio; + // By default, maintain aspect ratio by constraining display at 200px height + const defaultRatio = 200 / image.width; + const widthRatio = image.width / canvas.width * 1.35 * defaultRatio * displayRatio; + const heightRatio = image.height / canvas.height * 1.35 * defaultRatio * displayRatio; const heightOffset = 1/6; // canvas:(-1,1) -> (button, top); heightOffset = (5/12) * (-2) + 1 = 1/6 const vertices = new Float32Array([ widthRatio, heightOffset - heightRatio, 1.0, 1.0, From 3c8b433966addd5a5f680232a60997fcefab0978 Mon Sep 17 00:00:00 2001 From: mmyduckx <308303735@qq.com> Date: Wed, 5 Jul 2023 18:42:46 +0800 Subject: [PATCH 2/2] fix typo --- templates/wechatgame/first-screen.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/wechatgame/first-screen.ejs b/templates/wechatgame/first-screen.ejs index 29ed2e69a2a..1e25ee187fe 100644 --- a/templates/wechatgame/first-screen.ejs +++ b/templates/wechatgame/first-screen.ejs @@ -180,7 +180,7 @@ function initProgressVertexBuffer() { function updateVertexBuffer() { // By default, maintain aspect ratio by constraining display at 200px height - const defaultRatio = 200 / image.width; + const defaultRatio = 200 / image.height; const widthRatio = image.width / canvas.width * 1.35 * defaultRatio * displayRatio; const heightRatio = image.height / canvas.height * 1.35 * defaultRatio * displayRatio; const heightOffset = 1/6; // canvas:(-1,1) -> (button, top); heightOffset = (5/12) * (-2) + 1 = 1/6