Triangle with TextView and backgroud color - android-canvas

I want to make the triangle with textView inside that triangle in android studio, I know it can be drawn on the canvas but I am at a very beginner level.
Here is the first image of the triangle sample:
and here is the second complete image:

Related

Draw rectangle on image in Avalonia

Problem : I have an image with zoom and pan attached. I need to draw rectangles over it.
What I have done : I created a Canvas as an overlay over the image and made rectangle the children of canvas. Everything works well with zoom and pan etc but if the user resizes my the window then the added rectangles starts moving from their places because the rectangle position is set with respect to top and left of canvas.
I am thinking of drawing rectangles over the image and overriding the render. Any suggestions how can I achieve it easily?

Draw with mouse and save the drawn region as separate image

Please see following picture:
background picture
The image Abc in red color is the background picture, maybe preloaded on some control, for example a picturebox control.
The black rectangle region is drawn using mouse. What I want to achieve is to copy out the drawn region as separate image.
My goal is the winform will display each mouse drawing stroke until there is a closed region being formed or enclosed. That means a closing contact point need to be tracked.
Could you advise me on the key classes that I need to look into?

Objective C: Creating rotated Image inside square?

For an arduino drawing robot i want to rotate an image by 45 degrees in an iOS app, so that the new (rotated image) is inside a white box. Imagine the blue rectangle in the picture was the original image, and the image. As you can see it is rotated an inside a white square. How could I do this? It is important not only to have a rotated image, or a rotated image which has a white box behind it on the screen. It actually has to be a new image, so that if i get the color of pixel (1,1) it is white.
You can try to do this with having a white UIView superview, and blue UIView subview. And then do:
subview.transform = CGAffineTransformMakeRotation(M_PI/4);
superview.bound = subview.frame;
I think it should work.

draw a rectangle then draw a line clipped to that rectangle

Can someone explain the concepts/actions required to do the following:
On my stage I add a myShape then draw a rectangle using the its .graphics. Then I want to draw lines on that rectangle but have them clip automatically to the rectangle i.e. so they don't leak onto the rest of the stage.
It looks as if I could do this using a mask but I am wondering if there is something much simpler I am not understanding.

fill UIBezierPath but keep path clear

Can't find solution for fill closed UIBezierPath with some color and some width, but keep the path line transparent.
[[UIColor clearColor] setStroke] does not work.
What i have:
What i want:
Shared line of two rectangles have same coordinates, that's why i need some shift when i draw them.
If what you are trying to do is erase everything within the thick outline of a path, use CGContextReplacePathWithStrokedPath to convert the stroke to a path. Then fill it with a clear blend mode, thus erasing the drawing along the thick path. Alternatively, just stroke the path, again using a clear blend mode.
In this drawing, the thick yellow ellipse is not stroked or filled yellow; the ellipse is clear, and the yellow is the view behind, seen through the red rectangle. In other words, the ellipse erases an elliptical shape through the red rectangle.
Here's the code that drew the ellipse:
CGContextAddEllipseInRect(con, CGRectMake(100,100,200,50))
CGContextSetLineWidth(con, 10)
CGContextSetBlendMode(con, kCGBlendModeClear)
CGContextReplacePathWithStrokedPath(con)
CGContextFillPath(con)
Or you could do it this way:
CGContextAddEllipseInRect(con, CGRectMake(100,100,200,50))
CGContextSetLineWidth(con, 10)
CGContextSetBlendMode(con, kCGBlendModeClear)
CGContextStrokePath(con)
stroking with [UIColor clearColor] is not the same thing as taking an eraser to the fill you've already done, it is just drawing over it with a pen with transparent ink.
You could make a second path with pathByStrokingPath and then use an EOClip to 'mask' this area from your fill, or you can just stroke your path with whatever backgroundColor is behind...