Make controls of multiple objects visible - fabricjs

I try to implement a rotation around a movable rotation point:
I got so far:
here's some snipped
https://jsfiddle.net/Lwg6fkhs/60/
In the example you can select the blue rotation point and the red rect will rotate around that point. You can also move the rotation point somewhere else and the rect will continue rotating around that point.
At the moment the resize controls are only visible if the red rectangle is focused or the rotate control is visible when the rotation point is focused. I would like to make all controls (grab handles) of the red rectangle and the rotation rectangle visible at the same time. Is that possible? Or is there another way to implement that behavior with less or similar amount of code by modifying the behavior of the red rectangles rotation control?

Related

What is the Godot way to define (and refer) custom rectangle areas?

I'm coming from Phaser + Tiled world, where, if I need some rectangle area in game world (like Player's area, spawning area, and so on) I can just draw rectangle in Tiled and then get it coordinates from Phaser.js and use as I need. And I seem to stuck to do similar things in Godot.
For some of tasks I can use Area2D with rectangle inside and collision events. But it is not always enough.
How can I just define rectangle on screen, and get its coordinates? For Sprite object and for Node2D I cannot get bounding rectangle. I can use Area2D + Rectangle and refer to rectangle's 'extent' property to get width/height, but that seems to be overhead for me - Area2D is used in collision detection.
What can I do in general? And what could be done in Godot for following scenarios?
Camera limits. I have Sprite with background gradient which I scale to needed world size, and I'd like to set camera limits on that Sprite's width/height.
Hero movement limits. Half of world is not accessible for player, so any move to x > MIDDLE shall be denied. I can just setup constant MIDDLE in the code, but I'd like to draw allowed area as rectangle and refer to it coordinates.
Spawn area. Mark some place of world (that could be just point, not rectangle) where new objects shall be created by code.
You could use the Rect2 class in a script to define custom rectangles. You can then use it to check whether it contains a Vector2 or another Rect2.

Libgdx sprite ring object passing through it

How is it possible object can pass through ring spirte like in the image below?
Please can you help me I have no idea how can i do that.
I think you posted a incorrect image. To get the image you posted you just have to draw the red bar on top of the black ring.
I guess you want the ring on the left side to be on top and the right side to be over so it visually goes through. Well this is simply not so easy in 2D since draw order.
I have a couple of suggestion you can explore.
Always draw the ring on top of the bar but when a collision is happening you calculate where the bar overlaps and don't draw the pixels in that place. You can use a Pixmap for calculations like this. Depending on the size of your images this could be very expensive to calculate each frame.
A faster but slightly more hacky way could be to split red bar in multiple images and if a certain part of it should be overlapped by the ring draw it first otherwise draw it after the ring. Depending on what the red bar is going to look in your end product and how much possible angles the bar could have I can imagine this can be very tricky to get right.
Use 3D for this. You could have a billboard with a slight angle for the ring and have the bar locked on the distance axis at the rings center. However, on certain angles of entrance and exit you will get Z fighting since the pixels will be at the same distance from the camera. This might or might not be noticable and I have no idea how LibGDX would handle Z fighting.
I wanna add this solution :
if the object gonna pass through the ring horizontally i propose to devise sprite ring in to to sprite (sprite 1 & sprite 2)
you just have to draw sprites in that order :
Sprite1
Sprite Object
Sprite2
You can do the same if the object is gonna pass through ring vertically
PS : this solution don't work if the object is going to passs through ring both Vertically and Horizontally
Hope this was helpfull
Good luck

Cairo: Drawing with clip set gives fuzzy ornaments

I am programming a tool that has a custom canvas in it derived from Gtk::DrawingArea. The drawing does not happen directly on the DrawingArea. I have two Cairo::Surfaces. One surface is the Background (mostly an image) and the other surface is stuff that was drawn by the user.
When the user draws, I do not redraw the whole surface, I just set a clip on the Cairo context to only draw what is necessary. The Problem is, that when I have the clip set on the image background I can see a white frame around the clipped area. Is there a flag or a workaround, so the image would look good instead of having fuzzy frame ornaments around it?

How to determine the radius of a circle from the scale of the sprite?

I am making this game where a sprite of a circle( origin set at the center of the sprite) is being up-scaled and rotated simultaneously. What I need to determine is the change in the radius of the circle in relation to scaling.How do I go about doing that? What exactly does scaling do? I mean what does 2x scale mean? does it mean my sprite has twice the area than previous? Btw , I am using LibGDX.
I figured it out myself.The problem was that the bounding rectangle of a sprite changes in size as the sprite is being rotated.So the raidous of the circle can not be determined using the with of the rectangle at that time. What I found was that the width of the bounding rectangle is the product of the scale and the initial width .So I can calculate what the width would be at any instance from that even if the sprite is rotating. And I get the radius from that.

Change rect destination in XNA

hy guys, im newbie and im confused with XNA rectangle
I draw something and rotate it, but the rectangle destination its still same, how to change the destination rectangle so i can check the collision with intersect method
You cannot rotate a Rectangle.
Instead, what you want to do is a Bounding Box. It will not provide you with pixel perfect collision, but it will provide you with a quick intersect check that could be paired with a more refined collision check.
Refer to this question on how to create a Bounding Box:
https://gamedev.stackexchange.com/questions/2438/how-do-i-create-bounding-boxes-with-xna-4-0

Resources