How can I move and change the size of a shape file in QGIS? - qgis

QGIS noob here. I have a shape file which I would like to duplicate, move, and increase in size. How may I go about doing this?

Related

Can you do pathfinding based on the pixelgrid of a .png file in Unity?

TL;DR: Can someone please help with pathfinding with no obstacles, fixed and known starting points, and edges based on transparency of the pixel grid of a .png file.
I'm trying to make a simple app for my students to teach them the correct stroke order and direction of the Chinese strokes.
So far I have achieved this by layering "start" and "end" game objects with CircleCollider2D components on top of the PolygonCollider2D generated by the sprite to check if they started the stroke, stayed within the stroke, and exited it correctly.
It does the job, yes, but it doesn't animate the fill in process like you'd expect from such an app, not to mention that I need to manually add "start" and "end" points myself.
Ideally I could just provide the stroke sprite, tell it which way I want the stroke to go (left to right, right to left etc.) and let the program create the ends based on the first/last 10% of the pixels, and of course animate it to fill in once completed correctly.
But baby steps!
First, I'd be grateful if someone could please tell me how to even get the pixel grid to begin with so I can perhaps attempt an A* approach.
Thank you!
This is the same case for validating AI racers if they are in racing in the correct way. You will have to indicate some sort of waypoint system that has is ordered by the way of strokes you want.
Imagine you're teaching them to write the number 2. You will have to create an array of nodes starting from the upper left most of the number until you get to the other end. You can validate the strokes if their fingers pass through the correct order or not.
No need for a complicated A* algorithm.
However, this won't do if you want to automate everything. This will require you to do some sort of image processing, editor tool, and loads of validations. I wouldn't suggest the automated one though.

Find the Exact Frame of a rotated SKSpriteNode

I really want to know how to find the EXACT frame of an SKSpriteNode if it is rotated. Currently, the frame of an SKSpriteNode looks like this:
This frame is the rect.frame.
However, this frame includes a lot of empty space due to its zRotation. I don't want this empty space and instead want the frame of exactly the SKSpriteNode.
This is what I want:
How can I achieve this? If you have any idea how to find this 'exact' frame of an SKSpriteNode, I would really like to know. Please use SWIFT.
Thank you
This can be done.
Put a dummy node at the bottom left of your sprite that you know the exact size of. Probably use a perfect square. Anchor it's bottom left to the bottom left of your parent. The parent is the one you want the exact size definition of.
From there, two ways:
Scale the dummy sprite to the size of the sprite you're curious about, and use those measurements to determine where the sprite is and what size it is at any point in time.
Put another dummy sprite at the top right of the parent. In this case you can use the midpoint of your two dummy objects, you don't need to use their edges perfectly. Now you can find the position of these two dummies, at any time, and figure out the size/shape/outline of your sprite in world space units.
Here's way 1 animated

How to flip a VRML file (.wrl), or flip the VR model in Matlab

I have a fairly complex VRML model of a prosthetic right hand in a .wrl file (3 Megabytes) which I am manipulating (animating according to commands) in Matlab. I'd like to make a mirror image (horizontal flip) of the file (to be a left hand). I do not mind whether I use a free program to process the file (which I imagine should just involve mirroring all the horizontal co-ordinates) or if there is a Matlab command that can flip a VR model, but I haven't been able to find a solution. There's nothing else in the "world" so everything within the file can be flipped.
There are named transforms in the file and I need them to keep their names, because those joints get animated, but it's not a problem if I have to change the sign of the rotations to get things moving in the correct mirrored direction.
I'm just looking for a simple and free solution.
Thanks!
I wouldn't suggest to do this manually. The easiest solution would be to export your model to a .max or any other file that you can open with a 3D modeling program (3dsmax, DeepExploration, Maya, etc.) Once you have the new file, that you can open with any of these programs, I think it's much easier to do your job. Usually you can do it using the interface by dragging or clicking buttons, not manually going through the coordinate values :)

Efficiently draw CGPath on CATiledLayer

How would I efficiently draw a CGPath on a CATiledLayer? I'm currently checking if the bounding box of the tile intersects the bounding box of the path like this:
-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
CGRect boundingBox = CGPathGetPathBoundingBox(drawPath);
CGRect rect = CGContextGetClipBoundingBox(context);
if( !CGRectIntersectsRect(boundingBox, rect) )
return;
// Draw path...
}
This is not very efficient as the drawLayer:inContext: is called multiple times from multiple threads and results in drawing the path many times.
Is there a better, more efficient way to do this?
The simplest option is to draw your curve into a large image and then tile the image. But if you're tiling, it probably means the image would be too large, or you would have just drawn the path in the first place, right?
So you probably need to split your path up. The simplest approach is to split it up element by element using CGPathApply. For each element, you can check its bounding box and determine if that element falls in your bounds. If not, just keep track of the last end point. If so, then move to the last end point you saw and add the element to a new path for this tile. When you're done, each tile will draw its own path.
Technically you will "draw" things that go outside your bounds here (such as a line that extends beyond the tile), but this is much cheaper than it sounds. Core Graphics is going to clip single elements very easily. The goal is to avoid calculating elements that are not in your bounding box at all.
Be sure to cache the resulting path. You don't need to calculate the path for every tile; just the ones you're drawing. But avoid recalculating it every time the tile draws. Whenever the data changes, dump your cache. If there are a very large number of tiles, you can also use NSCache to optimize this even better.
You don't show where the path gets created. If possible, you might try building the path up in the -drawLayer:inContext: method, only creating the portion of it needed for the tile being drawn.
As with all performance problems, you should use Instruments to profile your code and find out exactly where the bottlenecks are. Have you tried that already, and if so, what did you find?
As a side note, is there a reason you're using CGPath instead of UIBezierPath? From Apple's documentation:
For creating paths in iOS, it is recommended that you use UIBezierPath
instead of CGPath functions unless you need some of the capabilities
that only Core Graphics provides, such as adding ellipses to paths.
For more on creating and rendering paths in UIKit, see “Drawing Shapes
Using Bezier Paths.”

Placing objects around image highlights- coco2d /opengl / coregraphics?

I would like to extract the white areas/bright areas of an image and place a custom objects in those areas. I need to know which framework to work with. if anyone has done something similar, I would appreciate an answer. I know how to get Pixel values, however the hard part is creating a Bloom/star effect in those highlighted areas.
You could make a mask where the luminance value was above a threshold, then blur or whatever the mask and composite above the image.