question is....
i need to handle tap gesture.
Now, i have a lot of paths builded by CGPath (each path has an ID), and by CGContextAddPath i create and fill my planimetry. Whether i tap on a path, i wish that right ID is shown.
So, i'm using CGPathContainsPoint in touchbegin to do this but, if i scale up or down my planimetry by CGAffineTransform, CGPathContainsPoint method returns wrong information (FALSE) also if i touch on a (scaled) path.
How can i fix it ?!
I tried by adding CGAffineTransform element as second argument of CGPathContainsPoint method but point touched isn't scaled too, so, nothing happens (instead, the same problem with translation is fixed by this same way!).
Here you can find the CODE semplified
Sorry for my english ( i'm italian ) :P
Thx in advance
OK! I found the problem !!!
I have to apply the inverse function!!
If i scale by 10, i have to scale the point by 1 / 10.
For translation if i drag by 10, i have to drag back by -10 (for rotating the same i think).
Related
I’m working on a complex project in threejs.
Trying to cut the corner:
I have to load an obj, create some pivot point to use as parent of the mesh inside this obj, let the user move and rotate the pivots.
It takes somewhere about 10 to 15 seconds to load due to its complexity.
My problem is that it is working flawlessly if I load the page and don’t change the focus, but if I change the browser tab or collapse the browser window I got a very specific problem:
geometry.computeBoundingBox() gives different results.
Is there someone who can help me figure out what’s happening?
To help you better understand the situation: at loading time I have to rotate the obj to -90° on the X axis (inverting Y and Z as a consequence); I think it’s relevant because the boundingBox calculation somehow inverts Y and Z and changes its min and max also, but as I said only if I switch tab or collapse the browser.
p.s. No matter the OS nor the browser. It’s a super consistent bug
Ok, I somehow solved the issue, but take it with a grain of salt:
the problem can be tracked back to the execution stack of javascript:
the first function computes the bounding box, the second uses this computation, but if the first function is somehow slower to execute, the second could not have what it needs.
What I did is to force javascript to execute functions in a given order and only when the previous is finished.
The problem occurred only when changing the tab because browsers optimize resources of non visible tabs, but the code I wrote was anyway too much entropic to work properly.
I hope what I found will be understandable and useful to someone else in future.
It seems not possible to view the exact margin between font-elements in XD (dev-view). Below you'll find a screenshot of a situation where we need to measure the exact distance between two Font-elements (XD developer-view).
It needs to bypass the line-height, but it doesn't. To be able to do this, we need the line-height to be zero. But when we edit the line-height in XD for a word or sentence on a single row, XD does not change that line-height.
Anybody encountered the same situation?
In this example the line-height is 32. We go to XD. Change it to zero, save it and SHARE FOR DEVELOPMENT. But the line-height remains 32. Also changing it to 1 instead of zero won't make any difference.
To fix this issue, you have to select the Text within Adobe XD. Right Click and select Path > Convert to Path. The margins around the Text will disappear and when in DEVELOPMENT view it becomes possible to see the right margin. A small problem remains. When you want to edit the text when it's a shape, you have to delete it and place a new text and turn it into a shape again. the text when converted to a shape
The default selector in Adobe XD will not give you the exact margin between two text. You have to convert the text layer into paths (Convert to Outlines) to get the exact margin.
But remember after converting text layer into path the text cannot be edited because now the letter are separate vector shapes.
To convert text layer into Path, select the layer and goto Object>Path>Click Convert to Path
You can use the Guides to drag one below your text and another one on top of the second text, and then you can see the distance between the 2 guides.
Check this youtube video for a quick tutorial on it. This is going to be a manual action. I don't think there's a key to press to check the distance automatically.
I am trying to make an animation that will fill a tube with liquid and then start moving the liquid inside. I am using an SVG with 3 main paths, the first one is liquid with short height, which then I morph to become the liquid with long height, then I want to "repeat" the morph between the other 2 paths to make it look like the liquid is moving, however when i move from one path to the other using morphSVG, I can't go back to the previous path, so my other morphSVG statement isn't executed.
Here's link to my code:
https://codepen.io/BrittanyR/pen/rJvOyX
As can be seen, I am able to move from one path to the other using:
TweenMax.to("#redSecondary", 2, {morphSVG: "#redPrimary", delay: 2})
But I can't then use this: TweenMax.to("#redPrimary", 2, {morphSVG: "#redSecondary"})
Any idea will be helpful.
Thanks.
It seems like it was just a logic issue in your code - your setTimeout() was alternating between animating #redPrimary and #redSecondary (targets), but you never changed what they were animating TO. So it worked the first time...and that's it. Every subsequent call was just duplicating the exact same movement (tweening to the current values...thus no motion).
I wonder if this is what you were looking for: https://codepen.io/GreenSock/pen/gvzMLG?editors=0010
Note: as a convenience, MorphSVGPlugin automatically records the original path data for the element so that if you ever want to animate back to it (like to("#redPrimary", 2, {morphSVG:"#redPrimary"}), it knows to grab that. It's all automatic :)
So if you want to repeatedly bounce between those morphs, a simple TimelineMax is probably the easiest way. Get rid of all that setTimeout() stuff and just do this:
var tl = new TimelineMax({repeat:-1, delay:2});
tl.to("#redPrimary", 2, {morphSVG:"#redSecondary", ease:Power1.easeInOut})
.to("#redPrimary", 2, {morphSVG:"#redPrimary", ease:Power1.easeInOut});
Does that help? I'm not entirely sure that I understood your goal properly with the animation, but hopefully this nudges you in the right direction.
Happy tweening!
Note: I looked at the other questions similar to this one, and they were either outdated or not useful.
Unfortunately there are so many different screen sizes and that makes auto layout really confusing for me. I want to have a simple UIImageView to cover the entire screen no matter what screen size it is. So the dimensions of the UIImageView should change accordingly.
I tried adding constraints to squish the image and it worked fine. But an error in the debugger said that there was an error: UIViewAlertForUnsatisfiableConstraints
Is this a big deal? And if it is, how do I get the Image to fill the entire screen?
Edit: The game will have squares going down the screen, which the user must tap
It might be, or it might not be a big deal, depending on what you're doing and if you know what you're trying to accomplish. In my experience, this is usually an issue if you're trying to programmatically alter the frame of a view which already has set constraints (you shouldn't alter the frame by hand unless you really need it).
Without more detail, it's hard to say what the exact issue is.
I know it seems like it's a fairly easy to do, but i can't seem to figure it out and i've researched a lot of places but really what i want it's no where.
i'm creating a puzzle game and the images are moved around using UIGestureRecognizers but let's say if the puzzle piece does not fit into the right location, i want it to move to it's original position or previous position where i got it from. Can someone please shed some light on this on ho to do this? Thanks
The easiest thing to do would be to add a property to your view controller to store the CGPoint of the puzzle piece before you move it. Check for UIGestureRecognizerStateBegan in the state of the recogniser(which i think you must already be doing in order to start moving the puzzle piece) and update the property with the touch location from the view.