In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Brush brush instructions
WxPen is used as a brush to render contour lines, and wxBrush as a brush to render the fill color of the shape. When brushes and brushes are used at the same time, you can render shapes with different outline colors and fill colors. The first argument to the wxPen constructor is the color, and the second argument is the thickness of the brush. Wx provides many common color macro definitions for brushes and brushes, avoiding the need to manually set RGB components and greatly reducing the burden on developers. For example, brush color wxBLACK_PEN wxGREEN_PEN wxWHITE_PEN wxBLUE_PEN, brush color wxBLACK_BRUSH wxGREEN_BRUSH wxWHITE_BRUSH wxBLUE_BRUSH, etc.
There are already examples.
WxBufferedPaintDC dc (this)
Dc.SetBrush (wxBrush (wxColour (255,255,255)
Existing examples
WxBufferedPaintDC dc (this)
Dc.SetBrush (* wxWHITE_BRUSH)
Be careful
Dc.SetBrush (wxNullBrush)
Dc.SetPen (wxNullPen)
The above two lines of code can clear the colors of the currently set brushes and brushes to avoid affecting subsequent rendering
Code
# include "wx/wx.h"
Hollow rectangle wxPen
Void CFlightInstrumentPanel::OnPaint (wxPaintEvent& event)
{
WxClientDC dc (this)
WxPen pen (* wxRED,1)
Dc.SetPen (pen)
Dc.DrawRectangle (0,0,200,300)
Dc.SetPen (wxNullPen)
}
Solid rectangle wxBrush
Void CFlightInstrumentPanel::OnPaint (wxPaintEvent& event)
{
WxClientDC dc (this)
WxColor strokeColor (0,255,255,255)
WxColor fillColor (0,0,255,255)
WxBrush brush (fillColor)
WxPen pen (strokeColor)
Dc.SetPen (pen)
Dc.SetBrush (brush)
Dc.DrawRectangle (0,0,200,300)
Dc.SetBrush (wxNullBrush)
Dc.SetPen (wxNullPen)
}
Can be set dc.SetBrush (* wxTRANSPARENT_BRUSH); transparent brush to achieve, render hollow contour lines
Description of DrawEllipse rendering ellipse
# include "wx/dcclient.h"
WxPaintDC dc (this)
WxColor color (15,57,121)
WxBrush brush (color)
Dc.SetBrush (brush)
Dc.DrawEllipse (0,0, width, height)
Dc.SetBrush (wxNullBrush)
DrawEllipse renders an ellipse, which is inscribed in a rectangle, and renders a circle when width equals height
The first and second parameters are the X and Y axis coordinates of the upper left corner of the rectangle, and the third and fourth parameters are rectangles.
Length and width of
DrawPoint render point description
The render point uses a brush wxPen, so it is considered that the size of the render point can be modified by modifying the width of the brush. In fact, the size of the render point is always 1 pixel, so it will be created.
It becomes the following phenomenon: just rendering a point cannot be seen with the naked eye on the screen.
Example code: associate the rendering event OnPaint, render the point on the screen (100100)
Void CFlightInstrumentPanel::OnPaint (wxPaintEvent& event)
{
WxClientDC dc (this)
WxPen pen (* wxBLACK, 5)
Dc.SetPen (pen)
Dc.DrawPoint (100,100)
Dc.SetPen (wxNullPen)
}
Example code: verify that it has indeed been rendered and visible to the naked eye, and multiple adjacent points can be continuously rendered to form a straight line. Associate the mouse drag event OnMotion
Void CFlightInstrumentPanel::OnMotion (wxMouseEvent& event)
{
If (event.Dragging ())
{
WxClientDC dc (this)
WxPen pen (* wxBLACK, 5)
Dc.SetPen (pen)
Int x = event.GetPosition () .x
Int y = event.GetPosition () .y
Dc.DrawPoint (x, y)
Dc.SetPen (wxNullPen)
}
}
Conclusion:
To be able to render a point large enough, you can use the method of rendering a circle
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.