Main Site Documentation

Drawing a filled rectangle


#1

Hi,

I tried using the method DrawRectangle which has various overloads, includign a gradient fill option and opacity. No matter what I try, I am only able to get a rectangle with an outline and no fill or gradient. Actually I just want a solid filled rectangle, but the DrawRectangle doesn’t seem to work.

Is this a known issue?

Thanks, Philip


Background.DrawImage(0, 0, Image_resource, 0, 0, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
LCD.DrawImage(0, 0, Background, 0, 0, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
// This should draw filled rectangle with 100% percent opacity, but just get an unfilled rectangle...
LCD.DrawRectangle(Colors.Yellow, 1, 10, 60, 300, 170, 3, 3, Colors.Red, 50, 50, Colors.White, 100, 100, 0xFF);


#2

Gradient fills with any sort of rounded rectangle do not work.
Try below:


LCD.DrawRectangle(Colors.Yellow, 0, 10, 60, 300, 170, 3, 3, Colors.Red, 50, 50, Colors.White, 100, 100, 0xFF);

#3

To draw a solid white filled rectangle, with the upper left corner at 0,0 and a width and height of 100, try the following code:

bmp.DrawRectangle(Color.White, 0, 0, 100, 100, 0, 0, Color.White, 0, 0, Color.White, 0, 0, Bitmap.OpacityOpague);

#4

Hi,

Yes it is setting the corner radius overload to 0 that makes it work.

Thanks, Philip