IOS: Dynamically draw shape with wave divider in Swift (Bezier Curve) - ios

Initially I have 2 backgrounds images (I use here 2 rectangles for simplicity, a green one and a grey one) the rectangles height is dynamically adjustable and I need to draw the black wave divider (also a custom image with gradient) between them as you can see in the image. I've tried to simply crop the backgrounds with the divider and merge them, but because the height (first rectangle will have a different height than the second one) is adjustable it will mess up the wave divider. It is not enough to draw the divider, also the rectangles should be cropped to match the divider form. Everything should be done programmatically in Swift and a pdf document will be generated in the end. I can only think to Bezier Curve (CGMutablePath, UIBezierPath), but I don't know exactly how to achieve it. Thanks a lot!
Shape I need to obtain
Grey Rectangle
Green rectangle

Related

How to ensure a UIView with a transform fills a CGRect?

I have a view UIView that by default has a UIImageView (the blue square in the included image) that is centered in this main view (the gray square in the included image). The main view has an added CALayer that serves as a border (window or mask — the yellow rectangle in included image) through which the image can be seen. The user uses gesture recognizers to pan (translate), pinch (scale), and rotate the image view's transform, but I'd like to give them the option of transforming the image so it completely fills the yellow border (all four corners), much the same way the iOS crop tool does (see attached gif). I've tried to figure out how I can calculate the correct scale factor, but now I'm wondering — is there some simple formula or function that can help me solve this problem?

How to determine the scale of an Image

I have an image that I'm using which is 960x1280. I have coordinates for a rectangle of x:391 y:772, x:574 y:772, x:574 y:870, x:391 y:870 which allows me to put the rectangle in the proper spot IF the image is still 960x1280. Of course, when I'm in Xcode, the screen size is 375x667.
When drawing the rectangle with the above coordinates, the rectangle is no longer visible. If just use the screen scale of 3 (UIScreen.main.scale) it's not accurate either.
I create a UIImageView that has constraints of 0 for all four sides and using aspect .fit or .fill. How do I now know the proper scale of the image so the rectangle is drawn in the right spot?
Thanks

How to slicing image and make it stretchable with image assets

stretch image right and left side
centre arrow remain as it is
i tried with it but centre down arrow position is not properly set by me.
You can't do this with sliced images.
The area between the edges will stretch or repeat in order to fill the area. You can't also preserver the centre section of an image this way.
What you might be better doing is creating a custom drawn view using either CALayer or drawRect.

make button glyph have a transparent background in delphi 7?

I have four TSpeedButton objects, each with a BMP file assigned as a glyph for the button image. For whatever reason, delphi has decided that two of the button images should have a transparent background and two should have a white background. I created the bitmaps myself, so they are all saved at the same color depth and are using pure white (not some shade of almost white) for the background and have background color in all four corner pixels of the image.
Why would some of the glyph images show up with a transparent background and some not? What is the criterion for making the background transparent? How can I make my button images all have transparent backgrounds instead of half of them having transparent backgrounds?
Ken's comment
Delphi's glyph handling uses the pixel in the lower-left corner to determine the transparent color. All pixels that match that color should be shown as transparent. Does the lower-left pixel color match in all of the glyphs, and does it match the areas you want to be transparent? (Without the images, it's hard to tell what the problem is, but I thought I'd post this as a potential for investigation.)
appeared to hold the correct answer (sorry, can't accept a comment as the right answer!). The image I was using had a shadow reaching to the lower left corner so it was almost white in that corner and exactly white in all the other corners.
I had a similar problem with D5 and I cludged a fix for this as I never found out why it was happening.
Define the image size one Row taller than the actual image/glyph is. This will force the image to be written starting at the top left and stop just before the last row. That will force the use of a non-transparent color and the extra row below the image is not visually noticeable.

Detect single color overlay area with ImageMagick

I have a bunch of images that have a single color overlay with some text on it positioned at the bottom. Not all images have the overlay and the overlay is not of the same height on every picture.
I am looking for a way to detect the overlay rectangle, and crop only the part of the image without it.
Trim seems the logical way to go, but the text on the overlay makes trim remove only the part below the text.
Any ideas would be welcome.
Thanks!
Make a copy of the image and crop it to just the left-most 5 pixels (assuming that there's some left margin to the text), trim and find out the new height. Then use the height of that trim to crop the original.

Resources