Skip to content

stage/canvas dimensions #12

@meibegger

Description

@meibegger

What is the logic behind the setting of the stage and canvas dimensions?
If i, for instance, set

<canvas id="stage" width="720" height="800"></canvas>

it will result in

<canvas id="stage" width="1440" height="1600" tabindex="1" style="outline: none; width: 720px; height: 800px;"></canvas>

Why is the width & height doubled?
And how can i prevent StageXL from setting the tabindex? Maybe i don't want people to be able to tab to the stage (because there's nothing to tab to), or maybe i would need a tabindex="0" ... (i think, tabindex=1 will almost never be convenient ...?)


If i now set

<canvas id="stage"></canvas>

and

stage = new Stage(canvas, width: 720, height: 490);

then the canvas is set to this

<canvas id="stage" tabindex="1" width="600" height="300" style="outline: none; width: 300px; height: 150px;"></canvas>

which looks like some default value and has nothing to do with the stage dimensions ...
Wouldn't it in this case make sense to set the canvas width and height attributes according to the stage width/height?
This would be very convenient, because then i could specify the dimensions (aspect ratio) once in the dart project, and the canvas would be prepared accordingly (now i have to set those dimensions twice, even if they are the same).
I could set

<canvas style="width:100%;height:auto;background:#FFF;"></canvas>

and

stage = new Stage(canvas, width: 400, height: 300);

this would/should/could transform to

<canvas width="400" height="300" style="width:100%;height:auto;background:#FFF;"></canvas>

and voila: everything perfectly scalable :)


And i found a bug:
setting

<canvas id="stage" width="100%" height="100%"></canvas>

results in

<canvas id="stage" width="200" height="200" tabindex="1" style="outline: none; width: 100px; height: 100px;"></canvas>

Thanks! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions