采用C++编写的纯算法,底层封装了CMyPen类,含有4种笔,分别是毛笔,画笔,荧光笔,水笔.
非常容易调用,只用响应鼠标消息
笔锋签名 毛笔签名 毛笔签名效果算法
void CDrawProView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
if (m_bPickPoint)
{
m_myPen.DrawLine(m_ptLastEnd, point);
m_bPickPoint = FALSE;
}
else
{
m_myPen.DrawPoint(point);
m_ptLastEnd = point;
m_bPickPoint = TRUE;
}
}
else if (m_nCmd == CMD_BRUSH_PEN)
{
m_myPen.PushStart(point);
}
else if (m_nCmd == CMD_OTHER_PEN)
{
}
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
if (m_bPickPoint)
{
m_myPen.DrawLine(m_ptLastEnd, point);
m_bPickPoint = FALSE;
}
else
{
m_myPen.DrawPoint(point);
m_ptLastEnd = point;
m_bPickPoint = TRUE;
}
}
else if (m_nCmd == CMD_BRUSH_PEN)
{
m_myPen.PushStart(point);
}
else if (m_nCmd == CMD_OTHER_PEN)
{
}
Invalidate(FALSE);
}
m_bMouseDown = TRUE;
CView::OnLButtonDown(nFlags, point);
}
}
m_bMouseDown = TRUE;
CView::OnLButtonDown(nFlags, point);
}
void CDrawProView::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
}
else if (m_nCmd == CMD_BRUSH_PEN)
{
m_myPen.PushEnd(point);
}
else if (m_nCmd == CMD_OTHER_PEN)
{
else if (m_nCmd == CMD_BRUSH_PEN)
{
m_myPen.PushEnd(point);
}
else if (m_nCmd == CMD_OTHER_PEN)
{
}
Invalidate(FALSE);
}
m_bMouseDown = FALSE;
CView::OnLButtonUp(nFlags, point);
}
}
m_bMouseDown = FALSE;
CView::OnLButtonUp(nFlags, point);
}
void CDrawProView::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
{
if (m_nCmd != CMD_NULL)
{
if (m_nCmd == CMD_LINE_PEN)
{
}
else if (m_nCmd == CMD_BRUSH_PEN)
{
if (m_bMouseDown)
{
m_myPen.Push(point);
}
}
else if (m_nCmd == CMD_OTHER_PEN)
{
else if (m_nCmd == CMD_BRUSH_PEN)
{
if (m_bMouseDown)
{
m_myPen.Push(point);
}
}
else if (m_nCmd == CMD_OTHER_PEN)
{
}
Invalidate(FALSE);
}
CView::OnMouseMove(nFlags, point);
}
}
CView::OnMouseMove(nFlags, point);
}
void CDrawProView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
{
CView::OnSize(nType, cx, cy);
size_draw();
// TODO: 在此处添加消息处理程序代码
}
// TODO: 在此处添加消息处理程序代码
}
demo效果图,
http://www.etfsoft.com/other/downsgoogle/maobi.rar 毛笔算法
13762930029 QQ77211022