0

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.

knezi
  • 247
  • 1
  • 12

1 Answers1

0

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();
}
Community
  • 1
  • 1
Jason Weathersby
  • 1,071
  • 5
  • 5
  • Thank you for your reply, but I draw it via Canvas and when I draw just 640*360 rectangle, it is not fullscreen. Does it mean that device pixel ratio doesn't work for canvas? – knezi May 29 '14 at 14:20
  • Can you try the code I added? What version Firefox OS are you using? – Jason Weathersby May 29 '14 at 18:18
  • Thank you and sorry for late reply. The problem was, I am using FFOS 1.4 and there is automatic zoom (APZ), so it automatically change scale of my screen. I add this `` and everything works. – knezi Jun 03 '14 at 12:26