开发者

MFC: Drawing lines of different colors

I have two series of N points I want to graph in two different colors. I can't find anything that explicitly states the best way to go about this simple task when using MFC CDC and CPen objects, and as bunch of CDC::MoveTo/CDC::LineTo calls.

It seems each device context can only have one pen object selected at a time, so am开发者_开发知识库 I best to select a pen, draw one line, select another pen, draw the other line... or run through my data once, somehow swapping between pens at each point (either continually selecting each pen, or changing the pen color somehow).


I think your best bet would be to do as you said and draw the first series of N points with the first pen, then select the second pen and draw the second series of N points.


There's no way to change a pen color once you've created it. However you did miss one option, which is to draw all segments of a given color with a pen of that color, then switch pens and draw all segments of the other color. That option may not deliver identical results as the overlap of two segments will depend on which is drawn first.

As unpleasant as it may seem, I think your best option is to switch pens for each new color and go through the points in order.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜