Example #1
0
//-----------------------------------------------------------------------------
void CGDrawContext::drawLines (const LineList& lines)
{
    if (lines.size () == 0)
        return;
    CGContextRef context = beginCGContext (true, getDrawMode ().integralMode ());
    if (context)
    {
        applyLineStyle (context);

        CGPoint* cgPoints = new CGPoint[lines.size () * 2];
        uint32_t index = 0;
        VSTGUI_RANGE_BASED_FOR_LOOP(LineList, lines, LinePair, line)
        cgPoints[index] = CGPointFromCPoint (line.first);
        cgPoints[index+1] = CGPointFromCPoint (line.second);
        if (getDrawMode ().integralMode ())
        {
            cgPoints[index] = pixelAlligned (cgPoints[index]);
            cgPoints[index+1] = pixelAlligned (cgPoints[index+1]);
        }
        index += 2;
        VSTGUI_RANGE_BASED_FOR_LOOP_END

        if (getDrawMode ().integralMode ())
        {
            int32_t frameWidth = static_cast<int32_t> (currentState.frameWidth);
            if (frameWidth % 2)
                CGContextTranslateCTM (context, 0.5, 0.5);
        }

        CGContextStrokeLineSegments (context, cgPoints, lines.size () * 2);
        delete [] cgPoints;

        releaseCGContext (context);
    }
}
//-----------------------------------------------------------------------------
void GdiplusDrawContext::drawLines (const LineList& lines)
{
	if (lines.size () == 0)
		return;
	for (const auto& line : lines)
		drawLine (line);
}