Changeset View
Changeset View
Standalone View
Standalone View
tools/rectangular/kpToolEllipse.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | 49 | | |||
50 | //--------------------------------------------------------------------- | 50 | //--------------------------------------------------------------------- | ||
51 | 51 | | |||
52 | void kpToolEllipse::drawEllipse(kpImage *image, | 52 | void kpToolEllipse::drawEllipse(kpImage *image, | ||
53 | int x, int y, int width, int height, | 53 | int x, int y, int width, int height, | ||
54 | const kpColor &fcolor, int penWidth, | 54 | const kpColor &fcolor, int penWidth, | ||
55 | const kpColor &bcolor) | 55 | const kpColor &bcolor) | ||
56 | { | 56 | { | ||
57 | if ( (width == 0) || (height == 0) ) | 57 | if ( (width == 0) || (height == 0) ) { | ||
58 | return; | 58 | return; | ||
59 | } | ||||
59 | 60 | | |||
60 | QPainter painter(image); | 61 | QPainter painter(image); | ||
61 | painter.setRenderHint(QPainter::Antialiasing, kpToolEnvironment::drawAntiAliased); | 62 | painter.setRenderHint(QPainter::Antialiasing, kpToolEnvironment::drawAntiAliased); | ||
62 | 63 | | |||
63 | if ( ((2 * penWidth) > width) || ((2 * penWidth) > height) ) | 64 | if ( ((2 * penWidth) > width) || ((2 * penWidth) > height) ) { | ||
64 | penWidth = qMin(width, height) / 2; | 65 | penWidth = qMin(width, height) / 2; | ||
66 | } | ||||
65 | 67 | | |||
66 | painter.setPen(QPen(fcolor.toQColor(), penWidth)); | 68 | painter.setPen(QPen(fcolor.toQColor(), penWidth)); | ||
67 | 69 | | |||
68 | if ( bcolor.isValid() ) | 70 | if ( bcolor.isValid() ) { | ||
69 | painter.setBrush(QBrush(bcolor.toQColor())); | 71 | painter.setBrush(QBrush(bcolor.toQColor())); | ||
70 | else | 72 | } | ||
73 | else { | ||||
71 | painter.setBrush(Qt::NoBrush); | 74 | painter.setBrush(Qt::NoBrush); | ||
75 | } | ||||
72 | 76 | | |||
73 | int offset = painter.testRenderHint(QPainter::Antialiasing) ? 1 : 0; | 77 | int offset = painter.testRenderHint(QPainter::Antialiasing) ? 1 : 0; | ||
74 | 78 | | |||
75 | painter.drawEllipse( | 79 | painter.drawEllipse( | ||
76 | x + penWidth / 2 + offset, | 80 | x + penWidth / 2 + offset, | ||
77 | y + penWidth / 2 + offset, | 81 | y + penWidth / 2 + offset, | ||
78 | qMax(1, width - penWidth - offset), | 82 | qMax(1, width - penWidth - offset), | ||
79 | qMax(1, height - penWidth - offset)); | 83 | qMax(1, height - penWidth - offset)); | ||
80 | } | 84 | } | ||
81 | 85 | | |||
82 | //--------------------------------------------------------------------- | 86 | //--------------------------------------------------------------------- |