rounded-corners

How to draw rounded rectangle with variable width border inside of specific bounds

浪尽此生 提交于 2019-11-28 23:14:41
I have a method that draws a rounded rectangle with a border. The border can be any width, so the problem I'm having is the border is extending past the given bounds when it's thick because it's drawn from the center of a path. How would I include the width of the border so that it fits perfectly in the given bounds? Here's the code I'm using to draw the rounded rectangle. private void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Color FillColor) { GraphicsPath gfxPath = new GraphicsPath(); DrawPen.EndCap = DrawPen.StartCap = LineCap.Round; gfxPath.AddArc

Qt drawing a filled rounded rectangle with border

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 23:11:07
I want to draw a rectangle with rounded corners (border radius same for all 4 corners) with a specific color filling the entire rectangle, and a separate border color (say border is 1 px wide). From my observation, Qt provides three methods - fillRect and drawRect and drawRoundedRect . I have tried them, they don't work like I want to. There is no method like fillRoundedRect . Which means that I can draw a rounded rectangle but it won't be filled with the color I want. How do I do it? And also, I read that due to some aliasing problems, the corners are often rendered as unequal. How do I set

Draw round corners on top left top right bottom left bottom right using Path and RectF in Android

戏子无情 提交于 2019-11-28 22:06:45
By making a custom ImageView and override the onDraw method with the following will make the ImageView to have rounded corners. Reference @Override protected void onDraw(Canvas canvas) { float radius = getContext().getResources().getDimension(R.dimen.round_corner_radius); Path path = new Path(); RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight()); path.addRoundRect(rect, radius, radius, Path.Direction.CW); canvas.clipPath(path); super.onDraw(canvas); } How can I selectively make the round corners instead of making all four corners round. For example, only making the top left and

Rounded corners in a UITableView (iOS7)

拜拜、爱过 提交于 2019-11-28 19:13:06
In iOS7, how can I draw cell's rounded corners in a UITableView? See an example: Hussain Shabbir Your UITableview contains UIView , so just use this below lines of code for making it rounded corners. Also write this below line of code inside your tableview methods //If iOS version < 10 For Objective-C: cell.contentView.layer.cornerRadius = 5; cell.contentView.layer.masksToBounds = YES; For Swift: cell.contentView.layer.cornerRadius = 5 cell.contentView.layer.masksToBounds = true //If iOS version >= 10 For Objective-C: cell.layer.cornerRadius = 5; cell.layer.masksToBounds = YES; For Swift: cell

CSS to create curved corner between two elements?

 ̄綄美尐妖づ 提交于 2019-11-28 18:38:56
My UI has an unordered list on the left. When a list item is selected, a div appears on the right of it. I'd like to have a curved outer corner where the <li> and the <div> meet. Some people call this a negative border radius or an inverted corner . See the white arrow in the image below. To extend the blue <li> to the edge of the <ul> , I'm planning to do something like this: li { right-margin: 2em; border-radius: 8px; } li.active { right-margin: 0; border-bottom-right-radius: 0; border-top-right-radius: 0; } Is there a better way to extend the <li> to the edge of the <ul> ? Obviously, I'll

How do I make an UIImage/-View with rounded corners CGRect (Swift)

前提是你 提交于 2019-11-28 17:09:50
How do I make a UIImageView with rounded corners on a Swift iOS Playground? Inside it needs to be filled with a color. let imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100)) imageView.backgroundColor = UIColor.redColor() imageView.layer.cornerRadius = 8.0 imageView.clipsToBounds = true Result: For rounded circle image frame in swift, what it worked for me was: self.profileImageView.image = UIImage(named:"profileUser") self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2 self.profileImageView.clipsToBounds = true And for adding a shadow: self

UINavigationBar Rounded Two Corners

折月煮酒 提交于 2019-11-28 15:52:33
问题 I want to round the top right and top left of the UINavigationBar. I know that there are functions for changing the views corner radius, but is it possible to do something similar to the standard UINavigationBar? If you don't know what I'm talking about, check out this: Thanks! 回答1: The best way is to override drawRect in UINavigationBar and use a custom image. 回答2: the following code works for me (tested on iOS5). The following code rounds the top left/right corners of the main navigation

Setting Corner Radius on UIImageView not working

拟墨画扇 提交于 2019-11-28 13:43:17
问题 I'm at a bit of a loss. I've used the layer property of UIView to round the corners of multiple elements in my app. However, this one UIImageView is simply not complying. Not sure what I am missing. The UIImageView (called previewImage) is contained in a Table View Cell. I've tried setting the cornerRadius property multiple location (in the cell itself and in the controller that creates the cell) to no avail. static NSString *CellIdentifier = @"MyTableViewCell"; MyTableViewCell *cell =

Drawing rounded rect in core graphics

此生再无相见时 提交于 2019-11-28 11:39:23
I want to replicate the event markers of the default iPad calendar, which look like this: I'm trying to use coregraphics for this, painting a path of a rounded rect. This is the result I could come up with: As you can see, iPad's version looks much smoother on the rounded corners. I tried to use a bigger line width, which looks like this: My code looks like this (got it from this website): UIColor* fillColor= [self.color colorByMultiplyingByRed:1 green:1 blue:1 alpha:0.2]; CGContextSetLineWidth(ctx, 1.0); CGContextSetStrokeColorWithColor(ctx, self.color.CGColor); CGContextSetFillColorWithColor

How to create image with rounded corners in C#?

霸气de小男生 提交于 2019-11-28 09:22:25
I'd like to create image (from another one) with rounded corners with GDI+. What's the best way to do this? PS: it's not for web, so I cannot make use of client CSS Gary Willoughby This function seems to do what you want. It can also easily be modified to return a Bitmap if needed. You'll also need to clean up any images you no longer want, etc.. Adapted from: http://www.jigar.net/howdoi/viewhtmlcontent98.aspx using System.Drawing; using System.Drawing.Drawing2D; public Image RoundCorners(Image StartImage, int CornerRadius, Color BackgroundColor) { CornerRadius *= 2; Bitmap RoundedImage = new