Why does the scale Velocity hook animate more than once in mobile browsers? - velocity.js

The scale Velocity hook animates as expected in Firefox and Chrome, but it seems to animate twice in mobile Firefox and mobile Chrome:
Example scale animation
When duration is set to small values (try 1), the element scales once and the scaling is undone.
Why does this happen?

Related

fabricjs - Less Image quality on setting ClipPath

I am trying to implement a fabricjs application, in which I need to set clipPath for image. ClipPath is svg clipPath (not rect). Clipping using clipPath is working fine, but once clipped the image quality is getting reduced.
I referred to the discussion https://github.com/fabricjs/fabric.js/issues/5639 and set objectCaching to false. Still making no difference
Both the output files are given below
without clipping,
with clipping
I am able to get back the quality while scaling, but back to low quality image on scale complete
Since the clipPath is an SVG I cannot use inbuild CropX, CropY as well.
Thanks in advance

How to view individual screen pixels on a web page

Anyone know of a convenient way to zoom in and look at individual pixels on a web page without scaling the page ?
I want to be able to see a representation of the individual pixels as rendered at 100% but with the naked eye - as you can in various drawing/paint programs.
Ideally I'd like to be able to do this from chrome developer tools but there doesn't seem to be a way.
Chrome zooming doesn't do it ; it scales the image eg. so a 4 pixel square becomes 9 pixels, 16 pixels etc.
Windows magnifier doesn't do it - it also scales the image not the pixels (though differently to the chrome zoom ; you end up with blurring).

How to make image fit screen in Godot

I am new in godot engine and I am trying to make mobile game (portrait mode only). I would like to make background image fit screen size. How do I do that? Do i have to import images with specific sizes and implement them all for various screens? If I import image to big, it will just cut out parts that don't fit screen.
Also, while developing, which width and height values should I use for these purposes?
With Godot 3, I am able to set size and position of sprite / other UI elements using script. I am not using the stretch mode for display window.
Here is how you can easily make the sprite to match viewport size -
var viewportWidth = get_viewport().size.x
var viewportHeight = get_viewport().size.y
var scale = viewportWidth / $Sprite.texture.get_size().x
# Optional: Center the sprite, required only if the sprite's Offset>Centered checkbox is set
$Sprite.set_position(Vector2(viewportWidth/2, viewportHeight/2))
# Set same scale value horizontally/vertically to maintain aspect ratio
# If however you don't want to maintain aspect ratio, simply set different
# scale along x and y
$Sprite.set_scale(Vector2(scale, scale))
Also for targeting mobile devices I would suggest importing a PNG of size 1080x1920 (you said portrait).
Working with different screen sizes is always a bit complicated. Especially for mobile games due to the different screen sizes, resolutions and aspect ratios.
The easiest way I can think of, is scaling of the viewport. Keep in mind that your root node is always a viewport. In Godot you can stretch the viewport in the project settings (you have to enable the stretch mode option). You can find a nice little tutorial here.
However, viewport stretching might result in an image distortion or black bars at the edges.
Another elegant approach would be to create an image that is larger than you viewport and just define an area that has to be shown on every device no matter whats the resolution. Here is someone showing what I am meaning.
I can't really answer your second question about the optimal width and height but I would look for the most typical mobile phone resolutions and ratios and go with that settings. In the end you probably should start with using the width and height ratio of the phone you want to use for testing and debugging.
Hope that helps.

Fabric.js FPS test

Where can I find tests of the fabricjs rendering performance with many animated object?
I have opened this page but I can't see the current number of FPS
http://fabricjs.com/animation/

Android: complex UI design

I have to make the Android app with this screen (it'll be Android version of existing iOS app):
You can see that there're several images, buttons and text label in very specific positions relative to each other.
The problem is that Android devices are very various in screen sizes and dimensions. How to keep the elements' relative sizes on different screens?
Taking this picture as an example, I can calculate, for example, ratio between screen width and circle radius. However, how to keep this ratio with the multitude of Android screens?
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
Here's a general guide:
put layouts for small, medium, large and extra large in your res/ folder as follows:
res/layout/sample_layout.xml // default layout
res/layout-small/sample_layout.xml // layout for small screen size
res/layout-large/sample_layout.xml // layout for large screen size
res/layout-xlarge/sample_layout.xml // layout for extra large screen size
you can also use
res/layout-land/sample_layout.xml for landscape orientation for all screen sizes or you can target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
note that all the layouts have the same name.
once you have your layouts ready, you need to take care of image resolutions also
once again in your res/ folder add images like this:
res/drawable-ldpi/sample_image.png // low density
res/drawable-mdpi/sample_image.png // medium density
res/drawable-hdpi/sample_image.png // high density
res/drawable-xhdpi/sample_image.png // extra high density
once again, all the images have the same name.
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
https://developer.android.com/guide/practices/screens_support.html
For units of measurement, you can use density independent pixels (dp or dip) which will maintain your relative heights, distances etc across multiple resolutions in a stable fashion.

Resources