scaleMode has no effect on html5 target

Hi guys.
I’ve found out that in html 5 target, this line:

Lib.current.stage.scaleMode

has no effect. So, setting it to “no scale” will not prevent it to not scale. I’ve discovered that in project.xml I can write:

<window fullscreen="true" resizable="false" borderless="false" vsync="false" />

But, shouldn’t this kind of behaviour be persistant with all the platforms? If it works on flash target, why wouldn’t it work on html?

The scale mode controls whether objects onscreen change size when the window changes size. It doesn’t prevent the window itself from being resized. If it helps, I made a demo to show the difference between each scale mode.

If that’s not the problem, could you provide some screenshots?

1 Like

The scale mode controls whether objects onscreen change size when the window changes size.

That’s exactly what I meant. The content of the window (maybe the div element that contains the canvas) should not be stretched when resizing the window.
Maybe It should somehow change the properties of the div to be absolute dimensions instead of relative.

I’m sorry, I can’t provide a screenshot right now, because I’m not at home.

scaleMode is not implemented on any target except Flash right now, I think. The default behavior for HTML5 is to 1.) stretch to the full window size if you use 100% size in your XML, 2.) in the default HTML5 template, to letterbox and scale up content that has a specific width/height size in XML, and 3.) to match whatever size DIV you give it in your HTML template, you can control the size of the project by leveraging different CSS in your page, or using openfl.embed on a different DIV or canvas element

Does this help?

Hi. Yes, I understand the reasoning.
However, in some cases, where a feature is only implemented for a certain platform, there is an error in the function itself. I’ve seen it when trying to compile a project using BitmapData’s perlin noise. I think something like this is worth implementing for scale mode, so future users will know it’s by design and not a mistake.

Using custom template to change the div’s css is the preferred way. Another suggestion is using scale mode to dynamically change the div’s style properties from relative (100%) to absolute (100px), but this is too far fetched, so “not implemented” is ok.
Thank you :slight_smile:

Hello,

I think something like this is worth implementing for scale mode, so future users will know it’s by design and not a mistake.

+1

Jonas

I’d be happy to hear ideas on how we make this clearer, I don’t want to add too much chatter to traces, and I don’t like adding unneeded runtime crashes with a throw

Perhaps, Warning: stage.scaleMode is not implemented

Something to communicate what’s happening, but not to break a project.

I wonder if there’s a way someone could write a macro, so where could push messages into the build log, instead of runtime, so you could get compatibility warnings when building somehow?

Tried it in Haxe 3.1.3 and got “Macro methods cannot be used as property accessor.”

Does a trace from a macro go to stdout?

Yep.

There’s also haxe.macro.Context.warning() if you want it appear as a warning rather than an informational message.

Maybe [this][1] could help?

edit: I really love this github feature!
[1]: https://github.com/HaxeFoundation/haxe/blob/5e154b2c049057efe874f0663fb0f529356992e4/std/cpp/cppia/Host.hx#L16

Nope:

if(false) {
    #error "SAMPLE ERROR"
}

Even though the code in the if block would never run, compilation fails with the message “SAMPLE ERROR.”

The only way to use #error is inside a #if statement, and the only thing #if is good for is checking compilation flags.

Oh, I was thinking we are talking about code inside

#if !flash

Sorry for the resurrection, but is this still not supported? I needed to have NO_BORDER scale/viewport in my app so it always fills the screen but crops a little from top and bottom based on app size/ratio & screen size/ratio, is this going to be implemented for all targets or should this be done with custom code manually?

Also for reference:


http://blog.vjeux.com/2013/image/css-container-and-cover.html

Could this also help to implement the modes?
https://player03.com/2015/05/19/scaling-strategy-2-stage-dimensions/

This is TODO

We currently use two different modes, one where we expect you to handle Event.RESIZE yourself, and one where we preserve the original width/height and scale/letterbox as needed. In the future I want to support more modes using stage.scaleMode, right now the property is a non-op