I'm writing a macro for ImageJ and I just need to overlay an oval over a triangle - imagej

This seems to only work for the fourth set of code, and all of these circles centers are the same and im not sure why. here is the code:
//Circumcircle
run("Specify...", "width="+(r1*2)+" height="+(r1*2)+" x1="+cenX1+" y1="+cenY1+" oval centered");
Overlay.addSelection("cyan");
run("Specify...", "width="+(r2*2)+" height="+(r2*2)+" x2="+cenX2+" y2="+cenY2+" oval centered");
Overlay.addSelection("yellow");
run("Specify...", "width="+(r3*2)+" height="+(r3*2)+" x3="+cenX3+" y3="+cenY3+" oval centered");
Overlay.addSelection("magenta");
run("Specify...", "width="+(r4*2)+" height="+(r4*2)+" x4="+cenX4+" y4="+cenY4+" oval centered");
Overlay.addSelection("red");// this is the only one that seems to be oriented correctly.

Related

How I add circle on circle with cutting layer?

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))

Align dashes in the corner of a CAShapeLayer with a dashed border

I’ve got a CAShapeLayer with rounded corners and a dashed border that display line dashes. However, the dashes are not aligned to the corners. Is there a way to do this?
Here’s a diagram showing the kind of pattern I want (with the arrow pointing to it):
Try adjusting the 'phase' via https://developer.apple.com/library/ios/documentation/uikit/reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/instm/UIBezierPath/setLineDash:count:phase:

Cropping sharp edges from behind a UIBezierPath rounded rectangle

I'm learning my way through UIBezierPaths by creating a table from scratch, and having individual cells filled with different colours.
This is a custom object I'm building which is contained in a subclassed UIView.
At the moment, I'm constructing this in this order:
'Cell' fill colours
Column lines
Row lines
Outer box (rounded rect)
As the picture suggests, I'm having trouble getting rid of the sharp corner of the cell fill outside the orange rounded rectangle.
Can anyone point me in the right direction to get rid of these?
Cheers! :)
At the beginning of your drawing code you should add the outer rounded rect path to the clipping path using its addClip method. That way nothing will get drawn that is outside this path.

Xcode/iOS 5 - Rounding only bottom 2 corners of UITableView

For the UI of the app I'm working on, I'm trying to create rounded corners for the view controller. I have a UINavigationBar and a UITableView. I've already rounded the top 2 corners of the UINavigationBar manually by using a custom background with UIAppearance stuff. Now I want to round the bottom 2 corners of the UITableView so it looks nice. The code I have right now rounds all 4 corners. Anyone know how I can only round the bottom 2?
Here's what I have added right now in my ViewDidLoad method of the UITableViewController. And I have QuartzCore imported.
_tasksTableView.layer.cornerRadius=5;
Thanks a ton to anyone that can help out!
You could create new CAShapeLayer and set its path to be a bezierPath created with
+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect
byRoundingCorners:(UIRectCorner)corners
cornerRadii:(CGSize)cornerRadii
Byt setting the corners to (UIRectCornerBottomLeft | UIRectCornerBottomRight) your new layer will have rounded corners in the two bottom corners.
Next you mask the _tasksTableView.layer with the shape layer you just created by setting the mask property on the table view layer.
Note: the shape layer should not be have any super layer.
Note: the bezier path needs to be converted to a CGPathRef by calling CGPath on the bezier path before setting it as the path property of the shape layer.

Core Graphics - My triangle/arc is too pointy

I'm drawing the 'slices' in a custom pie chart in Core Graphics, using a UIBezierPath and the [path addArcWithCenter:radius:startAngle:endAngle:clockwise:] method. My problem is that often the pointy end of the slice actually juts past the center point, intruding into other slices space.
Is there a way to 'round' this edge?
Here is the code im using to draw the path
[path moveToPoint:center];
[path addArcWithCenter:center radius:radius startAngle:interiorAngle endAngle:totalAngle clockwise:YES];
[path addLineToPoint:center];
[path closePath];
Here is an image of the problem:
The white pointy end of the blue piece on the lower left intrudes slightly into the large blue piece in the upper right.
It's not "past" the center point. Your confusion lies in the fact that you're stroking the path. When you stroke a path, the stroke lies centered upon the path, and therefore half of the stroke is outside the path and half of the stroke is inside the path. If you want an accurate stroke, you have two options:
Fill your path with your stroke color, then construct another path that's inset into your first one by the desired line width, and then fill that path with your fill color. This will simulate an "inside" stroke, although it's not usable if your stroke or fill colors are semi-transparent.
Clip to your path, double the stroke width, and then stroke your path. The clipping will force the stroke to only draw inside the path. However, this may not look quite "accurate" at corners (not really sure) since it's doubling the stroke width rather than calculating the "desired" path.
Alternatively, you could try just setting the lineJoinStyle to something other than kCGLineJoinMiter. With the default miter style, the lines actually draw out as far as they need to from the corner in order to meet, which means they can go past 1/2 the line width. If you use kCGLineJoinRound or kCGLineJoineBevel they cannot go past 1/2 the line width. This may not be quite accurate, but it may be good enough for what you want.
I would suspect the problem is with the line width of the white line. For example, a line that is 8 points wide, would have 4 points on either side of the path.
I can't see the problem in that image (which slice is showing it?), but I can suggest that you remove the addLineToPoint: message. It isn't necessary; closePath will return to the center, since that's where you started.

Resources