How to set initial size of OpenFL window on native targets, while allowing the html5 target fill the entire browser window? - haxe

In my OpenFL project.xml file, I set the initial dimensions of the window:
<window width="960" height="640"/>
This works great on native targets (windows, mac, linux, hl, and neko). The window is initially 960x640, and it can be resized by the user by dragging the corner. However, with the html5 target, my graphics look blurry, and OpenFL is letterboxed with black borders when the user resizes the browser window. Additionally, the OpenFL stage doesn't dispatch Event.RESIZE when the browser window is resized.
How do I ensure that it can be resized on the html5 target like other targets?

Setting the window's width and height on OpenFL's html5 target causes it to scale to fit the available space, but only visually. It maintains the original dimensions internally. This can cause blurry graphics from GPU smoothing, and it prevents your project from being able to utilize all of the available space in the window. However, for other targets, setting the width and height in project.xml affects the initial window dimensions only, while allowing the stage to resize automatically when the window is resized.
You can adjust your project.xml file to exclude the window width and height from only the html5 target, while keeping it for other targets.
<window width="960" height="640" unless="html5"/>

Related

How can clipping be prevented on a Qt QLabel?

I have a dialog created in Qt Designer with contents that resize when the window is resized.
When the window height is made too small, the text in the window clips as follows:
How do I prevent the labels from being clipped?
Most specifically, the window must not resize any smaller than the size of the word wrapped text without clipping.

What is the safe zone in Android Image Asset Studio

In Android Studio, while creating a Launcher Icon, there is a preview of a "Safe zone" circle that defines a certain padding around the edge of the displayed boundaries.
What does it specifically define?
Adaptive Icons, which are introduced in Android O, allows the system to apply a shape mask on top of your icons, which gives users a more consistent icon theme. Instead of a mixed bag of square & circle icons, users can now be shown all square or all circle icons.
The question is, how big a mask can systems make? Can they clip away 40px (10px from each side) of your icon? How about 80px? 120px? Even 400px? So Google created a rule:
A device OEM can specify a mask that may include a radius that is as short as 33 dp along certain points of the shape.
So the "safe zone" is the area that is guaranteed to not be clipped.
It looks like Android is planning on introducing parallax effects on icons when scrolling in the home screen, when they do, icons that are not completely in the "safe zone" may get see unnatural motion with the background when they are being animated. (See the "Clock" icon, and how it "escapes" the bounds of the background)

IE10 does not scale background SVG correctly when zoomed (on Surface/Windows 8 phone)

Does anyone know if there is a workaround for this? Internet Explorer 10 and Window phone 8 are not able to correctly scale background SVG images when a user zooms. Looks like IE rasterizes the SVG on load.
Here is an example: The first image is the SVG as a background image. Zoom in on a MS Surface or Windows 8 phone and you'll see it blurs horribly.
The second image is the same SVG as an img tag. Zoom this on a Surface or Windows 8 mobile phone and it scales as you would expect (nice and clean).
Is there any property that can be added to make IE10 behave? Or is it merely a case of waiting for the folks at Redmond to fix it?
The problem is that IE, and other browsers such as Firefox rasterise the SVG before displaying it, so it will become blocky when zoomed.
The easiest way to fix this is to make the SVG file larger than is needed. For example double the size, or more if the user is likely to zoom in further. You can then resize the SVG image with CSS to display it at the correct size. This way the image will be naturally larger, so wont become blocky, unless you zoom in even further. At default zoom level the image is scaled down rather than up, which browsers usually handle better.
Edit: You can find further info on this issue under the “SVG and CSS Backgrounds” heading at http://dbushell.com/2012/03/11/svg-all-fun-and-games/

how can one resize portions of a css-sprite?

I'd like to improve upon jQuery's dialog code by using CSS-sprites, and thus also add animations of the dialog borders.
To do this, i'd like all the artwork to be in 1 png file, a css sprite.
My problem is that in order to support a dialog that maximizes to 2 or 3 monitors, i think i'd have to put 5000px wide / high border graphics in the css sprite file. Because i can't find a way to resize a selected portion of a css sprite image.
Basically i want to resize from the sprite image a region (t,l,w,h) to a DIV or IMG on my page with a different width and height.
I'd like to know, is this even possible? It seems background-position does not support this at all.
I've tried the first solution in How can I scale an image in a CSS sprite, but could not get it to work using that.
I've tried using the new background-size property in conjunction with background-position, but that also does not produce the results i want.
Spent another few hours twiddling with css, but could not get sprites to work for dialogs.
But my animated dialogs don't need many frames (not unless you want to put actual video as a dialog backdrop online), so for the dialog theme i'm designing now i have 8 312x312 png's as frames, 8 requests, 386kb total. Just enough to create a glowing animation for when the dialog is in a "highlighted" state. It's do-able.
I'm using the technique from How can I scale an image in a CSS sprite
See http://mediabeez.ws in about a month for the opensource release of animated dialogs.
I will be developing and testing this standalone component when it's used by my own homegrown CMS, so it will have the ability do be themed, dragged and dropped, things like that.

More iPhone 4 resolution scaling fun

So I have two images set to fill the screen - one at 320x480 (iPhone 3) and the other at 640x960 (iPhone 4).
img.png (320x480)
img#2x.png (640x960)
In Interface Builder, I have img.png set to fill the view (it shouldn't be filling the iPhone 4 view, though, right?), and when I build and run, it is notably too small.
So, when I do the opposite, setting img#2x.png as the img, a giant blue question mark fills the view. The project still builds and the image fills the screen, but is very pixelated as if it has been rescaled. It shouldn't have been rescaled, though, as it is the higher resolution.
Now using...
img.png (640x960)
img#2x.png (320x480)
I've also tried switching which file takes the #2x suffix, but that has not helped either. With the smaller file taking the #2x suffix, and setting the image view to img.png, it shows up way larger than the view canvas, but way too small when on the phone. With the smaller file still having the #2x suffix, I tried switching the view to the new img#2x.png and once again got the oversized, pixelated question mark in IB and a low res full-screen image when deployed to the phone.
I also made sure that my view size was set to 640x960 in the size inspector. What else should I be doing?
Don't use #2x when specifying the image name. Just use the base name of the image (so in your case, just img). iOS will do the magic behind the scenes to use the 2x version if it's on a retina display and the regular version otherwise (including when you use a xib to lay out your interface).
The displayed dimensions of the image will always be the dimensions of the non-2x image. The retina display just displays 2 pixels for every 1 which is why the scale is 2.0 and you have to double the dimensions of the original image. So your view size in IB should be 320x480.
Edit
If IB is being finicky, especially in Xcode 4, just try deleting the xib and starting over. Sometimes it gets a bit corrupted and doesn't know what to do with itself. I've had to do this on one or two occasions, and it seems that it worked for the OP as well.

Resources