This question already has answers here:
Horizontally mirror a SKSpriteNode texture
(4 answers)
Closed 9 years ago.
Is there a way to create a SKSpriteNode and pass it an image name, but have it reflect the image horizontally?
You mean you want to flip the image?
node.xScale = node.xScale * -1;
or
node.yScale = node.yScale * -1;
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to find the CGColor at a CGPoint in a CGImage. There are multiple Stack Overflow posts that have something similar (like UIImage instead of CGImage or Objective C instead of Swift), but nothing specific enough to help me.
Does anyone know how to get the color at a point? Thanks.
Im assuming based on your macOS tag that you want to do this on macOS and thus can use NSImage and NSBitmapImageRep:
let cgImage = //your CGImage
let bitmap = NSBitmapImageRep(cgImage: cgImage)
if let colorAtPoint = bitmap.colorAt(x: 0, y: 0) {
let cgColor = colorAtPoint.cgColor
print(cgColor)
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am currently studying ARKit and I wish to display a 2d image in 3D environment. The image I want to display is a .png file.
Is there a way to convert this into an .obj file?
There's no way to convert a 2D .png raster file into 3D .obj geometry file. These formats are different like green apple and small button...
Although, the simplest way to see your image in ARKit's or SceneKit's 3D environment is to assign it on a 3D plane as a texture. Here's how you can do it:
#IBOutlet var sceneView: ARSCNView!
sceneView.scene = SCNScene()
let config = ARWorldTrackingConfiguration()
sceneView.session.run(config)
let node = SCNNode()
node.geometry = SCNPlane(width: 1.0, height: 1.0)
node.geometry?.firstMaterial?.isDoubleSided = true
node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "dir/image.png")
sceneView.scene.rootNode.addChildNode(node)
This question already has answers here:
Scale gameobject on just one side
(2 answers)
Closed 4 years ago.
I want to scale the 3d ibject from one side this problem I am going to elaborate by taking slider example.
As per the image when I am scaling it is scaled through center. I want to fix the left side as static and scale the slider to only right side.
Set this objects pivot point to the left side.
I'm asuming you are talking about the Image component. It uses a RectTransform where you can set the pivot points like this:
or simply open that menu, hold Shift + Alt and click there:
Or alternative make this object a child of another empty GameObject.
Set this objects position so that the left point matches the parent's pivot point. Than scale the new parent object instead.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've a UIBezierPath drawing this
And I want the red point to move on the blue path infinitely (from right to left, from left to right)
How can I do that?
You can use CAKeyFrameAnimation. Assign your path to the path property of the animation object, then run the animation on the view's layer.
Edit:
A little snippet as a hint:
let path = ... // the UIBezierPath
let animation = CAKeyFrameAnimation()
animation.path = path.CGPath
animation.calculationMode = kCAAnimationPaced // This give the animation an even pace
animation.repeatCount = HUGE // This makes the animation repeat forever
viewToAnimation.layer.addAnimation(animation, forKey: nil)
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I apply a perspective transform to a UIView?
How to change the perspective, 3D Transform, skew ,distortion, rotation of the image view? Any sample projects for this.Thanks in Advance
3D transforms, rotations, skews, etc are usually done with CATransform3D.
As per the documentation (Core Animation Programming Guide):
The CATransform3D data structure defines a homogenous
three-dimensional transform (a 4 by 4 matrix of CGFloat values) that
is used to rotate, scale, offset, skew, and apply perspective
transformations to a layer.
As an example, to do a 3D rotation towards the bottom right, you would do something like:
myImageView.layer.transform = CATransform3DRotate(CATransform3DIdentity, 1.75, 0.85, 0, 0);
and don't forget to
#import <QuartzCore/QuartzCore.h>
A fantastic sample project is Mark Pospesel's Enter the Matrix. The code is on GitHub, also check out the explanatory slides.