[Notice of Holidays]
Please note that our staff will not be available from 2024/Dec/28 - 2025/Jan/5 JST.
The Live2D Creators Forum will remain open during the holidays.
Submissions that require a response will be answered after we reopen for business.
Please note that it will take longer than usual to respond to your request.
Question - canvas size and scaling
How do I make the canvas fill the entire window width & height and keep the live2d model to it's original proportion?
I try adjusting
canvas.width = window.innerWidth
canvas.height= window.innerHeight
canvas.style.width = window.innerWidth + "px";
canvas.style.height= window.innerHeight+ "px";
The result keep coming out distorted.
I also don't understand this matrix:
var s = 2.0 / live2DModel.getCanvasWidth();
var matrix4x4 = [ s,0,0,0 , 0,-s,0,0 , 0,0,1,0 , -1.0,1,0,1 ];
live2DModel.setMatrix(matrix4x4);
Can someone please explain. Thank you in advance.
0 ·
Comments
The circles were originally perfect circles, but in the canvas they are distorted.
How do I adjust the matrix4x4, so that the width would fit into the screen, and the height would adjust proportionally to the width ???
Thank you
So if the width changes by 0.5, the height would also change by 0.5 ;
& if the width changes by 0.25, the height would also change by 0.25.
So that's what I want. Help please anyone?
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
#glcanvas{
position:absolute;
width:100%;
height:100%;
}
I know that the trick lies in Sy
var matrix4x4 = [ Sx,0,0,0 , 0,-Sy,0,0 , 0,0,1,0 , -1.0,1,0,1 ];
But what should Sy be ? Help me on this please.
[ Function ]
setWidth(scale) -> Scale change
setCenterPosition(x,y) -> Position change
[ Sample Code ] Please try to here as a reference ( This page is Japanese )
http://qiita.com/naotaro0123/items/013a9731755cb0a0537a
I got this error
Did you see even once the link page in my comment !?
There is a code that references Live2DFramework.js to HTML file
PS: my canvas isn't square
var mmat = new L2DModelMatrix(height, height);
and
canvas.width = window.innerHeight;
canvas.height = window.innerHeight;
The result is still distorted
However I did have to tweek the Live2DFramework.js
Here's was my solution for anyone who's interested:
Live2DFramework.js - line 850-ish Simple.js Apparently the ratio of
live2DModel.getCanvasWidth() / live2DModel.getCanvasHeight()
does not equalwindow.innerWidth / window.innerHeight
offsetX is change value .
The quality is good on Live2d Viewer, but the quality is not good on browser.
I noticed that the constant 2 is always used Does this constant 2 have anything to do with the reduced quality on browsers?
& How do I fix this quality problem?
Thank you
https://en.wikipedia.org/wiki/Orthographic_projection
And normalized to the easy-to-use value in WebGL and OpenGL .
LeftBottom(0, 0) → (-1, -1)
RightTop(413, 310) → (1, 1)