Transformation Sprite with finger move - iphone

I am making an Drawing App in someway like Paint in Windows
I have a toolbar with many shapes button such as Rectangle, Circle, Triangle, etc. When tap a button i add a sprite with shape with button's name.
I want to add functions like this
- When tap on shape it show four 4 points each corner of shape that i can touch and drag to skew or scale.
Same as we do with an image in photoshop or MSWord
anyone have sample code or tutorial ?

Use this code for your app.
Paint
Drawing
Drawing2

Related

flutter) I want to know how to drag & draw shapes through Custom Paint

I'm making a whiteboard app.
I learned how to draw lines using GestureDetector() and CustomPaint(). Now I'm going to draw the shapes, but I don't know how to draw the location and size of the shape by touching and dragging them after selecting the shape tool.
The image below is an example of another whiteboard app.
Can you tell me how to draw by dragging the shape as below?

Swift SKCropNode can someone explain this behavior?

I have a grid of 16 SKCropNode objects. Each contains a SKShapeNode used as a mask, and a SKSpriteNoe. In this image with the mask not set you can see all 16 object appear in a grid.
https://github.com/soggybag/Grid
Interaction is strange also. Tapping makes the image sprite move down and disappear moving out of the mask. You can tap the area below the orange, where a sprite would be hidden, and it recognizes the tap event.
Even stranger you not tap the sprite in the upper right?

ios game make a mask layer effect

I need a 'mask' layer that covers the whole screen, with the center part (a circle) to be transparent. Then I can move the mask layer around using touch. User are only able to see the transparent part in the middle.
I don't think a png file can help because the file need to be very large to cover the whole screen.
So is it possible to do it by coding?
i found this online, but don't know much about openGL. http://www.cocos2d-iphone.org/forum/topic/7921.
it would be great if i can use a CCMaskLayer and input with the radius. i can handle the touch event by my self.
the attached png file is expected result, the center part is transparent. i need this to cover my screen, and only show the middle part. the red part is covered.
I write a CCMaskLayer to do the exactly same thing.
https://github.com/smilingpoplar/CCMaskLayer
You may solve this task with cropped circle texture in two ways:
1) Draw sprite with circle texture in screen center and draw another 4 sprites around (on top, bottom, left and right sides) with small red texture but scaled to cover all screen.
2) (more elegant but harder to implement) Make your mask layer fullscreen but adjust texture coordinates. In details:
set wrap mode to GL_CLAMP_TO_EDGE to your circle texture
adjust texture coordinates of your layer vertices (to do this you need to subclass base CCLayer):
Here v means vertex position and t - texture coordinates. You need to set correct texture coordinates for four corner vertices of layer. For future if you will want to drag circle you will need to add some offset values to texture coordinates.

Free bitmaps for iOS custom buttons and sliders?

First, I'm not talking about icon libraries or mockup tools/libraries.
I'm familiar with various icon libraries that people have created, but other than the stuff from the example code like UICatalog, I'm wondering if anyone knows of anyone who has created free libraries of custom button bitmaps (stretchable button images), slider handle/track bitmaps, etc Basically bitmaps to customize the look of standard controls for those controls (like buttons and sliders) that allow you to specify such bitmaps.
I'm also interested in any photoshop tutorials/templates on/for creating stretchable custom button images, bitmaps for slider parts, etc. (Afraid I'm not a huge PS god or anything.)
Anyone know of any resources like this for fancying up the standard controls?
I've been able to find several stretchable buttons by searching through my collections of sample code for: "stretchableImageWithLeftCapWidth"
From the Apple sample code, the UICatalog, BubbleLevel, iPhoneMultichannelMixerTest, avTouch, AQOffilineRenderTest, and TouchCells sample code all contain buttons with stretchable images.
Hope this helps!
Stretchable buttons is no problem - there's nothing special you need to do in Photoshop. Just make the image of the button stretchable and set the radius to that of any rounded corners you have on the button graphic.
Slider parts - I'm pretty sure you'd have to make your own UIControl from scratch.
To make a button in Photoshop, create a new file with transparent background, select the Shape tool, rectangle near the bottom of the tools, drag out a rectangle. Size doesn't matterâ„¢. For a rounded rectangle, click and hold the same tool, choose the rounded rect shape and set a corner radies (same radius as in stretchableImage later).
Double-click the layer right of the layer name to get the layer style popup. Check Color Overlay and set the color you want. Check Inner Bevel and make its size somewhere below half the height of the rectangle - I think 90 degrees for the Global Angle works well. A lower opacity and larger size makes the bevel look less chunky.
Ctrl-click (option-click) the graphics rectangle in your layer to select the button's outline. Deselect the bottom half of it by using the marquee tool (M) at the top of the tools. Select a light gray foreground color, nearly white. Create a new layer with the square icon under the layer list (Windows->Layers if not visible). Fill the selection of the new layer with the paint bucket, and drag down opacity for the layer until the 'matte laquer' effect of it looks right.
A simple button, but that's the gist of it.

How to handle exact UITouch of image?

I have an image for example triangle and place it inside UIImageView, and I have a touch and drag application, I can already drag the triangle but my problem is I can still drag the triangle even if I'm not actually touching the triangle, (Im touching the upper left of the triangle image) I think this is because the UIImageView itself is a square so although I have not touch the triangle image but I have touch the square UIImageView that's why I can still drag it w/o touching the triangle,
So the question would be how can I make this accurate, like I can only drag it if I have touch the triangle image and not really the square ImageView?
Hopeful for all your help.
Instead of using UIButton, try using CGPath and testing for CGPathContainsPoint.
Also, try LaMarche's Improved Irregular UIButton.
Otherwise, you could use some trigonometry to determine where the touch occurred and whether or not it is within your internal shape.