简体   繁体   中英

screen resolution geeksphone peak

in specification of FFOS GP PEAK is written, that it's got qHD display (it is 960*540), but when I run JavaScript code:

console.log(screen.width)
console.log(screen.height)

I get 640*360. Is it JavaScript bug? Or anything else? Thank you.

I believe the Peak has a device pixel ratio of 1.5, which would be 640x360 logical pixels.

You may want to have a look at css - what exactly is device pixel ratio and Bug 838505

If I use the following HTML and JS this draws a square around the entire screen.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <!--<meta name = "viewport" content="user-scalable = no"> --> 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">    
    <link rel="stylesheet" type="text/css" href="css/background.css">  
    <title>Test</title>

    <script type="text/javascript" src="js/loop.js"></script>
    <style type="text/css">
    *
    {
        border: 0px;
        margin: 0px;
        padding: 0px;
    }


</style>
    </head>
  <body><canvas id="myCanvas"></canvas></body>

</html>

loop.js

//Main file for game logic
window.onload = init;

//Setup function to reset start location
function setup() {

    canvas = document.getElementById('myCanvas');
    canvas.height = window.innerHeight;
    canvas.width = window.innerWidth;
    context = canvas.getContext('2d');   
    context.beginPath();
    context.lineWidth="6";
    context.strokeStyle="red";
    context.rect(0,0,canvas.width,canvas.height);
    context.stroke();
}
//Initialize game and event handlers
function init() {
    setup();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM