简体   繁体   中英

How transparency works in drawing rectangle(border or whole area)(C#)?

I have a colormap plot and want to apply mesh dimensions on the picture plot. This request was successfully done by using the following code:

// draw mesh pattern
                        Pen transPen = new Pen(Color.FromArgb(128, 150, 150, 150),2);
                        g.DrawRectangle(transPen, (float)X,
                            (float)Y,
                            (float)dx,
                            (float)dy);

// draw contour square (brush , x , y , dx , dy)
                        g.FillRectangle(myContourBrush,
                            (float)X,
                            (float)Y,
                            (float)dx,
                            (float)dy);

Now my question is : the first transparent rectangle are transparent just in border area or all rectangle area? I don't want to affect colormap color, I just want to have mesh pattern.

The DrawRectangle method only draws the edge. If you want to fill it, you must use FillRectangle . Take a look for yourself. You might have to zoom in quite a bit to notice the color change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM