How to pin a Rectangle to directly above the Effect Picker UI in Spark AR Studio? - spark-ar-studio

We are designing an experience in Spark AR Studio and have run into a conundrum. Basically, our goal is to pin a Rectangle element containing an image texture so that it always lies just above the effect picker UI in Instagram across all devices, as in the placement in this image:
Goal Placement
We are attempting to accomplish this via pinning the Rectangle item item to the bottom and left side of a Canvas element set to Camera Space and Safe Touch Area. This seems to create a successful positioning like in the Goal Image on some devices, but on others (especially the iPhone 8 and iPhone 11) the image is still partially obscured by the UI, which is counter to our goal.
Here is our scene setup:
Rectangle element properties
The Rectangle element in the Scene panel
The Rectangle's position in the 2D Scene editor
An example of undesired behavior:
The Rectangle is obscured by the Effect UI
We have also tried to achieve this via placing the Rectangle dynamically using the Device Insets patch, but this also seems to not help and only provides an accurate pinning above the UI in some circumstances.
Any advice is greatly appreciated!

Related

What controls coordinate system origin in 2d rendering scene

If I create new "Empty (2d)" project then a scene with 1 camera is pre-created there.
The camera default position and rotation is more like 3d scene though: position=-10,10,10 rotation=-35,-45,0 projection="Perspective".
If I add a label in the scene then new Canvas is created with another camera with these properties: (pos=0,0,1000, rot=0,0,0, projection=ortho). This camera is more like 2d way.
The default project settings is: design size=960x640 with fixed width.
Now, the label is shown in the middle of the canvas/screen even though the label's position=0,0.
Canvas grid shows the origin at bottom-left corner.
I assume that only the second camera with ortho projection is used because it has higher priority. The main camera is of no use at this moment. Is this correct? Is there any purpose for the main camera in 2d application?
why is the label shown in the center of the canvas? It's center position is at (480,320). The label is direct child of the canvas. What controls the origin in the canvas?
if I create a node and place another label (pos=0,0) in that node then again the label is in the center of the node. Where do I set the parent node coordinate system origin?
little off topic question: where do I set the scene which is shown at app startup?

Cocos2dx scene in child window

The application I am writing is not a game, but does require many of the features one would use in a game... displaying a 2D scene, moving the camera to pan and zoom, rotating or otherwise animating objects within the scene. But the display of the scene will be controlled via numerous regular windows controls.
The best comparison I can think of right now is a level editor. The majority of the user interface is a standard window with panes that contain different controls. The scene is contained in another child window. When the user makes adjustments such as camera location, the scene responds accordingly.
So far, everything I've seen about cocos is geared around a single window. Is it possible to embed a scene into a child window as I've described?
You can add your custom layer to your main scene using Director::getInstance()->getRunningScene()->addChild(...) function

How to get the current position of my screen in Cocos2d?

I'm doing a platformer game using cocos2d-x v3 in c++, where the maps are usually very large, the visible screen follows the object through the map but I can't find a way to get the position of the visible screen in the map.
Using Size visibleSize = Director::getInstance()->getVisibleSize();gives me the dimensions of the entire map.
Let's say I want to show a sprite in the top right corner os the screen whenever the object reaches a point in the map, and this sprite would be always in the top right corner os the screen.
Using the object position doesn't do it.
Is there a way to get the position of the current screen?
Or is there a way to show a sprite or whatever in the screen and it would be in the screen even when the screen is moving?
Ps. I'm super noob in game development
There is a simple resolution:
You need two layer:
1: gamelayer
2: uilayer
Gamelayer is the one which you can move.Your map is added on gamelayer and when you need move the map you can just move the gamelayer.
Uilayer doesnt't move and its zorder is larger than the gamelayer.The sprite that shuold be always in the top right corner of the screen is on this layer.
Also:
There is a more complicated way:
You doesn't need to move the gamelayer.Just bind a camera to gamelayer and bind another camera to uilayer.
When you need to see the rest of your big map,you just move the camera of the gamelayer where you want.
BTW:
This is my first answer on stackoverflow.
English is not my first language,not very fluent.
Hope this can help you :)
I answered this question for you, which is a duplicate of the current question. The exact same solution applies to both situations. Add your sprite to the HudLayer as described in this question.

Zoom or slice a section of canvas HTML5

I working on HTML Canvas library to construct a "PIE Chart" Now to finish it I need the
given section of PIE Chart to Zoom or Slice once clicked on the section.
I almost done with the PIE Chart with the above exception only
Please do not recommend me to use any charting library available already
What you want cannot directly be done: when you draw on the canvas, you paint pixels that instantly dry onto the canvas. If you want to "zoom in" you'll have to erase the canvas (ctx.clearRect(...)) and re-paint your pie chart using more pixels. This is what a non-retained drawing mode (or immediate drawing mode) graphics API like Canvas requires.
Contrast this with SVG, a retained drawing mode graphics system, where the commands to draw content result in elements being created that you may track events for, adjust properties on, and see the visual results updated for you.
You can "zoom in"--redraw your pie chart larger--either by changing your drawing commands (bigger arc radius, lineWidth, etc.) or by transforming your context (changing the scale and translation) and then issuing the same drawing commands again.
There is also one non-option: if you leave the width and height attributes of the canvas unchanged but change the CSS to height and width properties you can 'zoom in' on your canvas without re-drawing. This is going to cause each virtual pixel on the canvas to grow on your screen, however, resulting in pixelation.

How to drag and drop from one HTML5 canvas to another

I'm trying to figure out how to drag and drop an image from one canvas to another canvas. Assuming the canvases are next to each other, would it be possible to seamlessly drag something across the border? If not, is it a better idea to drag a div over the canvas, get its ID, and place it by responding to the mouseup location on the canvas?
You don't drag items on a canvas. A canvas is a non-retained mode (or immediate mode) graphics API. You issue draw commands and you get pixels. Simulating dragging is comprised of tracking the user's mouse movements and choosing to repeatedly clear and re-draw the canvas with different parameters to make some subset of the pixels appear to move as a cohesive object.
Contrast this with HTML or SVG where you actually change position/transform properties of a real DOM object and the watch as the visual representation of your document updates automatically.
If you have two canvases and want to drag something from one to the other, what I would do is:
On mouse down on the 'menu' canvas, create a new canvas programmatically just as large as the object, and (using absolute CSS positioning) place it over top of the item the user clicked on.
Draw the item onto that canvas.
Track the mousemove event on the document, and update the position of the canvas relative to the mouse.
When the user releases the mouse over the destination canvas, throw away (or hide) your tiny 'dragging' canvas, and re-draw the main canvas with the item that was dragged in the appropriate location.
Though, what I'd probably really do here is use SVG. ;)
Check this answer.
It is for multiple select drag & drop, but maybe will be useful.
Why does this need to be 2 canvases? The canvas is your drawing area, you control it. Why do you need 2?