QT Graphics (simple strokes-draw cartoon ants)

Source: Internet
Author: User

Briefly

About the introduction of a lot of strokes, there are animals, fruits, vegetables, transportation, etc., usually to draw a step by step to split, combination. Then draw the results as we want.

Here's another category: Insect-cartoon ants.

    • Briefly
    • Draw
      • Effect
      • Source

Drawing effect

The specific effect is as follows, and we can do a better job of improving it.

Source

Mainly divided into the following three parts:

    • Draw Butt
    • Draw Belly
    • Draw Head

Note: When drawing, due to the different colors of the various parts, and the coordinates are not good positioning, so we use the way the graphics overlay.

void MainWindow::p aintevent (qpaintevent *) {qpainter painter (this);Painter. Setrenderhint(Qpainter:: antialiasing, True);    /***** Butt *****/Qpainterpath Path;Path. Addroundrect(Qrect ( $, -, Max, Max), +);Painter. Setbrush(Qt::white);Painter. Setpen(Qt::black);Painter. DrawPath(path);    /***** Belly *****/Leg path = Qpainterpath ();Path. MoveTo( the, the);Path. LineTo( -,260);Path. MoveTo(185, the);Path. LineTo(145,280);Path. MoveTo( $, the);Path. LineTo( the,290);Path. MoveTo( $, the);Path. LineTo( -,290);Path. MoveTo(215, the);Path. LineTo( -,280);Path. MoveTo( the, the);Path. LineTo(280,260);Painter. Setbrush(Qt::nobrush);Painter. Setpen(Qt::white);Painter. DrawPath(path);Belly path = Qpainterpath ();Path. Addroundrect(Qrect ( Max, the, -, -), +);Painter. Setbrush(Qt::white);Painter. Setpen(Qt::black);Painter. DrawPath(path);    /***** Head *****/Horn path = Qpainterpath ();Path. MoveTo( the, -);Path. LineTo( -, -);Path. MoveTo( $, -);Path. LineTo( the, -);Painter. Setbrush(Qt::nobrush);Painter. Setpen(Qt::white);Painter. DrawPath(path);Path = Qpainterpath ();Path. Addroundrect(Qrect ( -, the, -, -), +);Painter. Setbrush(Qt::white);Painter. Setpen(Qt::black);Painter. DrawPath(path);Left Eye path = Qpainterpath ();Path. Addroundrect(Qrect ( -, -, -, -), +);Painter. Setbrush(Qt::black);Painter. Setpen(Qt::nopen);Painter. DrawPath(path);Path = Qpainterpath ();Path. Addroundrect(Qrect ( the,126,Ten,Ten), +);Painter. Setbrush(Qt::white);Painter. Setpen(Qt::nopen);Painter. DrawPath(path);Right eye Path = Qpainterpath ();Path. Addroundrect(Qrect ( -, the, -, -), +);Painter. Setbrush(Qt::black);Painter. Setpen(Qt::nopen);Painter. DrawPath(path);Path = Qpainterpath ();Path. Addroundrect(Qrect ( the,118,Ten,Ten), +);Painter. Setbrush(Qt::white);Painter. Setpen(Qt::nopen);Painter. DrawPath(path);Mouth path = Qpainterpath ();Path. MoveTo( the,108);Path. ArcTo(Qrect ( the, -, -, -), the, -);Painter. Rotate( -);Painter. Setbrush(Qt::nobrush);Painter. Setpen(Qt::black);Painter. DrawPath(path);}

For the general drawing is relatively simple, because it is commonly used, regular, and comparative rules, such as circles, ellipses, rectangles, straight lines. If there are a variety of complex graphics, then the original drawing scheme is difficult to achieve, it takes a lot of time to toss back and forth, so here is no longer introduced.

QT Graphics (simple strokes-draw cartoon ants)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.