How I add circle on circle with cutting layer? - ios

I mean that I have custom view with one big circle and one smaller. But how I could cut corner (layer) of a big circle? Background is from parent view, not from custom, which have a clear color.
Icon, name label and label notifications I have been added in my custom view. So, problem still here with two intersecting circles.

I've suggested three approaches in my comments above. Here's a demonstration of one of them. Note that I didn't really do the math or try to approximate your drawing: it's just a demonstration of the principle:
That's actually three circles:
The big central circle (green) at lower left
The larger corner circle, used to "erase" the top right corner of the first circle
The second, smaller corner circle (green) at top left
Here's the code that generated that drawing (ignore the numbers; it's the principle that's important):
CGContextSetFillColorWithColor(con, UIColor.greenColor().CGColor)
CGContextFillEllipseInRect(con, CGRectMake(0,rect.height-130-10,130,130))
CGContextSetFillColorWithColor(con, UIColor.clearColor().CGColor)
CGContextSetBlendMode(con, kCGBlendModeClear) // erase
CGContextFillEllipseInRect(con, CGRectMake(rect.width-65, -5, 70, 70))
CGContextSetFillColorWithColor(con, UIColor.greenColor().CGColor)
CGContextSetBlendMode(con, kCGBlendModeNormal)
CGContextFillEllipseInRect(con, CGRectMake(rect.width-53,3,50,50))

Related

How do create a mask and draw on it

I have 2 rectangles like the image below :
now I want to only draw the part of yellow rectangle (B) that is inside the red rectangle. So i set clipchildreen=True to the rectangle A and I get this :
But it's not good as part of the yellow rectangle outside the red rectangle is still drawed. I want to obtain this :
How Can I do ? Eventually I can draw directly on the canvas but even like this I didn't find a simple way to achieve what I want to do
Here is a solution that might suit you, although I've made some assumptions about what your requirements are, and it's not a particularly straightforward approach. It involves using a rectangle with InnerRound corners to hide part of the yellow square.
For the steps below, I'm assuming that the form is white, the yellow square is 50 x 50, the red square is 150 x 150, the round corners have a radius of 20, and the whole thing is positioned on the form at 100,100.
I've described this as though you are manually positioning all the controls straight onto the form, but if I was doing it I'd add a couple of TLayouts and use Aligns everywhere (with negative margins in the case of the fourth step). And you might do this on a panel or other control instead of directly on the form.
Note that the z-order is important, which is why steps 2 to 5 below should be done in that order.
Set Fill.Kind of the form to Solid.
Place a TRectangle at 100,100. Set both XRadius and YRadius to 20, both Width and Height to 150, Fill.Color to Red and Stroke.Kind to None.
Place a TRectangle at 100,100. Set the Fill.Color to Yellow.
Place a TRectangle at 80,80. Set both XRadius and YRadius to 20, both Height and Width to 20, Fill.Color to White (the Fill.color of the form), Stroke.Kind to None, and CornerType to InnerRound.
Place a TRectangle at 100,100. Set both XRadius and YRadius to 20, both Height and Width to 150, and Fill.Kind to None.
This is the result:

What do the coordinates mean in love.graphics.polygon

I don't know which numbers do what in the coordinates example here. I imagine they mean things like place the top left corner at this position and the bottom right corner at this position, but I don't know which number corresponds to which position.
I've been trying to fool around with the numbers to get a small green rectangle but keep getting weird results like the following, and don't know which numbers need to be what is order to make the rectangle symmetrical and at the bottom
This is what the rectangle should look like
The height of the rectangle is 50, the height of the screen is 1000, and the width of the screen is 1700.
Here's my draw function
function love.draw()
love.graphics.setColor(0.28, 0.63, 0.05) -- set the drawing color to green for the ground
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints())) -- draw a "filled in" polygon using the ground's coordinates
-- These are the grounds coordinates. -11650 950 13350 950 13350 1000 -11650 1000
love.graphics.setColor(0.76, 0.18, 0.05) --set the drawing color to red for the ball
love.graphics.circle("fill", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius())
love.graphics.setColor(0.20, 0.20, 0.20) -- set the drawing color to grey for the blocks
love.graphics.polygon("fill", objects.block1.body:getWorldPoints(objects.block1.shape:getPoints()))
love.graphics.polygon("fill", objects.block2.body:getWorldPoints(objects.block2.shape:getPoints()))
print(objects.block1.body:getWorldPoints(objects.block1.shape:getPoints()))
end
As described at https://love2d.org/wiki/love.graphics, Löve's coordinate system has (0, 0) at the upper left corner of the screen. X values increase to the right, Y values increase down.
The polygon function expects the drawing mode as it's first parameter, and the the remaining (variable) parameters are the coordinates of the vertices of the polygon you wish to draw. Since you want to draw a rectangle you need four vertices/eight numbers. You do not have to list the upper left corner of the rectangle first, but that's probably the easiest thing to do.
So in your case, you want something like:
love.graphics.polygon('fill', 0, 950, 0, 1000, 1700, 1000, 1700, 950)
I've not worked with the physics system, so I'm not quite sure how it's coordinate system relates to "screen" coordinates. The values you show in the comment in your code listing seem like they should give a rectangle (although x = -11650 wouldn't be on screen). You might try experimenting without the physics system first.
Also, since the physics system in Löve is just a binding to Box2D, you might want to read its documentation (http://box2d.org/about/). Not really sure what you're trying to do with feeding shape:getPoints into body:getWorldPoints.

draw an coloured rectangle in CPTAxisLabel (core-plot)

What I want is to draw a small rectangle inside an CPTAxisLabel to display a colour, what I have all ready tried is to draw a rectangle in a layer and add it as sublayer, but it stretches the small sublayer all over the label and the text isn`t visible anymore, I also tried to make an CPTLegend and add it to the label but I did not found any method to position it in the right side of the label, it just sits in the center, I tried changing the legends position, frame, bounds, padding and nothing. Does anyone know a better way of adding a rectangle shape in an CPTAxisLabel and also keep the text in the label ?
I assume you're using a CPTTextLayer for the label's contentLayer. Use an image fill on the text layer that contains your rectangle. Make it a stretchable image and set the stretchable area to the right of the rectangle. Set the paddingLeft on the text layer to leave room for the rectangle to the left of the label text.
After some long researches I found issue 266 in core-plot and it seems to be the problem I have with positioning a sublayer inside a CPTAxisLabel... I will keep waiting for a fix, but I don`t know if it will be solved soon.

Indesign Bug? Choosing Fancy Corners Reverses Function of Align Stroke Inside/Outside

I think that this might be a bug in InDesign but I thought that it might be handy to know.
Here's how to recreate: Create a rectangle 200px x 200px, with a 4pt stroke. Set Align stroke to INSIDE. Set the top left xy pos of the rectangle to 100px,100px so that you can easily see changes, and leave the Reference Point in the top left. Now when you change stroke widths, everything is fine, and change corner types, everything is fine, EXCEPT the Fancy Corners. So if you choose Fancy Corners, the x/y becomes 96,96 and total width/height changes to 208 x 208 which is incorrect. Now change the Align Stroke to "OUTSIDE", and the x/y changes back to 100,100 and the rectangle size changes back to 200 x 200. Completely backwards, but just for the Fancy Corners.
Please comment if this is an expected response.

How can I avoid overlap of colors if my UIViews border color alpha is less than 1.0?

I have UIView's alpha set at .5, and its border color alpha is .5 as well, they are a similar shade of gray, but it shows up as a thicker gray on the outside. I am guessing this is because the two colors are being mixed together. Is there a way that instead of just adding a border on top, I can add a border that will displace the pixels underneath it?
You're correct, the only way around this would be to place your 0.5 alpha view inside a container view and inset it slightly and add the border to the container.
I decided to post this as an answer rather than a comment:
An alternate approach would be to subclass UIView to add a CALayer that is one pixel bigger than it's view's layer, and has a borderColor and borderWidth as desired. For a one-off you could add code to your view controller that would add a layer to the view through code rather than subclassing UIView. I doubt if a single pixel increase in width would necessitate adjusting the corner radius, unless the view is VERY small. – Duncan C 37 secs ago edit

Resources