I have to use Image as Notification.For that Image boarder should be in elliptical shape.can any one help me to change my image boarder as a circle. I have mentioned an sample image 10 should be an image component.how can i get circle shape for it.
Thanks in advance. Yours Rakesh
The border-radius CSS property is what adds the rounded corners. You can experiment with different values to get it the way you like. border-radius: 75px; If you want it to be a circle, add border-radius: 50%; .
Complete HTML/CSS Course 2022 To display an image inside SVG circle, use the <circle> element and set the clipping path. The <clipPath> element is used to define a clipping path. Image in SVG is set using the <image> element.
const
BORDER = 3;
Var
Bmp : TBitmap;
w, h: Integer;
x, y: Integer;
begin
Bmp:=TBitmap.Create;
try
Bmp.PixelFormat:=pf24bit;
Bmp.Canvas.Font.Name :='Arial'; // set the font to use
Bmp.Canvas.Font.Size :=20; //set the size of the font
Bmp.Canvas.Font.Color := clWhite; //set the color of the text
w :=Bmp.Canvas.TextWidth(IntToStr(sped1.Value)); //calculate the width of the image
h :=Bmp.Canvas.TextHeight(IntToStr(sped1.Value)); //calculate the height of the image
Bmp.Width := Max(w, h) + BORDER * 2; // get a square
Bmp.Height := Max(w, h) + BORDER * 2; // get a square
x := (Bmp.Width - w) div 2; // center
y := (Bmp.Height - h) div 2; // center
Bmp.Canvas.Brush.Color := clBlue; //set the background
Bmp.Canvas.FillRect(Rect(0,0, Bmp.Width, Bmp.Height)); //paint the background which is transparent
Bmp.Canvas.Brush.Color := clRed; // circle in red
Bmp.Canvas.Pen.Color := clRed; // circle in red
Bmp.Canvas.Ellipse(0, 0, Bmp.Width, Bmp.Height); // draw the circle
Bmp.Canvas.TextOut(x, y, IntToStr(sped1.Value)); //draw the number
img1.Picture.Assign(bmp); // assign the bmp to the image ; image.transparent = true, .stretch = true;
finally
Bmp.Free;
end;
Adjust the different values to what you need...
Updated source from RRUZ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With