本文整理汇总了C++中QPainter::drawChord方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::drawChord方法的具体用法?C++ QPainter::drawChord怎么用?C++ QPainter::drawChord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::drawChord方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawShape
void ECNand::drawShape(QPainter &p) {
if (m_logicSymbolShape == Rectangular) {
MultiInputGate::drawShape(p);
return;
}
initPainter(p);
int _x = (int)x() + offsetX();
int _y = (int)y() + offsetY();
p.drawChord(_x - width() + 6, _y, 2 * width() - 12, height(), -16 * 90, 16 * 180);
p.drawEllipse(_x + width() - 6, _y + (height() / 2) - 3, 6, 6);
deinitPainter(p);
}
示例2: paintIntersection
void paintIntersection(QPainter &p){
QColor c(60,60,60);
QPen p1;
p1.setColor(c);
p1.setWidth(2);
p.setPen(p1);
p.setBrush(Qt::transparent);
p.drawEllipse(-5,-5,10,10);
p.drawEllipse(0,-5,10,10);
p.setPen(Qt::transparent);
p.setBrush(c);
p.drawChord(-5,-5,10,10,(360-60)*16,120*16);
p.drawChord(0,-5,10,10,(180-60)*16,120*16);
p.setPen(p1);
p.drawLine(3,-2,3,2);
}
示例3: createFrame
void TurnAndBank::createFrame(void){
QImage _frameImage = QImage(QSize(600,600), QImage::Format_ARGB32);
_frameImage.fill(0x00ff0000);
int outerR = _frameImage.width()/2;
const int innerR = _frameImage.width()/2-60;
QPainter p;
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
p.begin(&_frameImage);
p.translate(300, 300);
p.setPen(Qt::NoPen);
p.setBrush(Qt::SolidPattern);
p.setBrush(QColor(225,225,225));
QRadialGradient gradient(0, 0, outerR, 0, 0);
gradient.setSpread(QGradient::ReflectSpread);
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::black);
QBrush gbrush(gradient);
p.setBrush(gbrush);
p.drawChord(-outerR, -outerR, 2*outerR, 2*outerR, 0, 360*16);
//Ring outside of intstrument with white line:
if (0){
p.setPen(QPen(QColor(225,225,225), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.setBrush(Qt::NoBrush);
p.drawChord(-outerR, -outerR, 2*outerR, 2*outerR, 0, 360*16);
}
// Create black inner core:
p.setBrush(Qt::black);
p.setPen(Qt::NoPen);
p.drawChord(-innerR, -innerR, 2*innerR, 2*innerR, 0, 360*16);
// Put horizontal and 2minute lines on outside:
p.setPen(QPen(Qt::white, 7, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
const float angle = 15.;
outerR = outerR-20;
p.drawLine(innerR*cos(angle/180*M_PI), innerR*sin(angle/180*M_PI),
outerR*cos(angle/180*M_PI), outerR*sin(angle/180*M_PI));
p.drawLine(-innerR*cos(angle/180*M_PI), innerR*sin(angle/180*M_PI),
-outerR*cos(angle/180*M_PI), outerR*sin(angle/180*M_PI));
p.drawLine(innerR, 0, outerR, 0);
p.drawLine(-innerR, 0, -outerR, 0);
// Little vacuum text line
p.setPen(QColor(200,200,200));
QFont topLabelFont = defaultFont;
topLabelFont.setBold(true);
p.setFont(topLabelFont);
QString legend = "NO PITCH";
int width = p.fontMetrics().width(legend);
int height = p.fontMetrics().height();
p.drawText(0-width/2,245,width, height, Qt::AlignCenter, legend);
legend = "INFORMATION";
width = p.fontMetrics().width(legend);
p.drawText(0-width/2,267,width, height, Qt::AlignCenter, legend);
legend = "D. C. ELEC.";
width = p.fontMetrics().width(legend);
height =p.fontMetrics().height();
p.drawText(0-width/2,-275,width, height, Qt::AlignCenter, legend);
legend = "2 MIN";
width = p.fontMetrics().width(legend);
height =p.fontMetrics().height();
p.drawText(0-width/2,205,width, height, Qt::AlignCenter, legend);
legend = "TURN COORDINATOR";
width = p.fontMetrics().width(legend);
height =p.fontMetrics().height();
p.drawText(0-width/2,-150,width, height, Qt::AlignCenter, legend);
QFont lrFont = defaultFont;
lrFont.setPointSizeF(defaultFont.pointSizeF() * 2);
lrFont.setBold(true);
p.setFont(lrFont);
legend = "L";
width = p.fontMetrics().width(legend);
height = p.fontMetrics().height();
p.drawText(-265*cos(18./180.*M_PI)-width/2+5, 265*sin(18./180.*M_PI),
width, height, Qt::AlignCenter, legend);
legend = "R";
width = p.fontMetrics().width(legend);
height = p.fontMetrics().height();
//.........这里部分代码省略.........
示例4: createGlass
void TurnAndBank::createGlass(void){
QImage _glassImage = QImage(QSize(500,500), QImage::Format_ARGB32);
_glassImage.fill(0x00ffffff);
QPainter p;
p.setRenderHint(QPainter::Antialiasing, true);
p.begin(&_glassImage);
//p.scale(1./2.5, 1./2.5);
// Cosmetics on glass: yellow arrows:
p.setPen(QPen(QColor(79, 106, 25), 0, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
p.setBrush(Qt::SolidPattern);
p.setBrush(Qt::yellow);
static const QPointF bigArrow[] = {
QPointF(250, 250),
QPointF(362.5, 287.5),
QPointF(137.5, 287.5)
};
int bigArrowNPts = sizeof(bigArrow)/sizeof(bigArrow[0]);
p.drawConvexPolygon(bigArrow, bigArrowNPts);
static const QPointF leftArrow[] = {
QPointF(125, 375-10),
QPointF(237.5, 320-10),
QPointF(240, 322.5-10),
QPointF(137.5, 387.5-10),
QPointF(125,387.5-10)
};
int leftArrowNPts = sizeof(leftArrow)/sizeof(leftArrow[0]);
p.drawConvexPolygon(leftArrow, leftArrowNPts);
static const QPointF rightArrow[] = {
QPointF(375, 375-10),
QPointF(262.5, 320-10),
QPointF(260, 322.5-10),
QPointF(362.5,387.5-10),
QPointF(375,387.5-10)
};
p.drawConvexPolygon(rightArrow, leftArrowNPts);
// Upwards facing orange arrow at vertical up:
static const QPointF orangeArrow[] = {
QPointF(250, 50),
QPointF(233, 88),
QPointF(267, 88)
};
p.setBrush(QColor(255,116,0));
p.drawConvexPolygon(orangeArrow, 3);
// Little black pyramid and chord at bottom:
p.setBrush(QColor(25,25,25));
static const QPointF pyramid[] = {
QPointF(250-19-60, 417+20),
QPointF(250+19+60, 417+20),
QPointF(250+25, 250+63+20),
QPointF(250-25, 250+63+20)
};
p.drawConvexPolygon(pyramid, 4);
p.setPen(QPen(Qt::black, 0, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
p.setBrush(QColor(76,76,76));
p.drawChord(_glassImage.rect(), -40*16, -100*16);
p.setBrush(QColor(25,25,25));
p.drawChord(_glassImage.rect(), -42*16, -96*16);
// Little vacuum text line
p.setPen(QColor(200,200,200));
p.setFont(QFont(QString("Helvetica"), 24, QFont::Bold, false));
int width = p.fontMetrics().width(QString("VACUUM"));
int height =p.fontMetrics().height();
p.drawText(250-width/2,385,width, height, Qt::AlignCenter, "VACUUM");
p.end();
_glass = QPixmap::fromImage(_glassImage, Qt::AutoColor);
}
示例5: drawOnionSkinSelection
void FilmstripFrameHeadGadget::drawOnionSkinSelection(QPainter &p, const QColor &lightColor, const QColor &darkColor)
{
int currentRow = getCurrentFrame();
TPixel frontPixel, backPixel;
bool inksOnly;
Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly);
QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128);
QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128);
OnionSkinMask osMask = TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();
int mosCount = osMask.getMosCount();
int i;
//OnionSkinの円の左上座標のy値
int onionDotYPos = m_dy / 2 - 5;
p.setPen(Qt::red);
//--- OnionSkinが有効なら実線、無効なら点線
if (!osMask.isEnabled()) {
QPen currentPen = p.pen();
currentPen.setStyle(Qt::DashLine);
currentPen.setColor(QColor(128, 128, 128, 255));
p.setPen(currentPen);
}
//カレントフレームにOnionSkinを伸ばすハンドルを描画
{
int angle180 = 16 * 180;
QRectF handleRect(0, 0, 30, 30);
//上向きのハンドル:1フレーム目のときは描画しない
if (currentRow > 0) {
int y0 = index2y(currentRow) - 15;
p.setBrush(QBrush(backColor));
p.drawChord(handleRect.translated(0, y0), 0, angle180);
}
//下向きのハンドル:最終フレームの時は描画しない
std::vector<TFrameId> fids;
m_filmstrip->getLevel()->getFids(fids);
int frameCount = (int)fids.size();
if (currentRow < frameCount - 1) {
int y1 = index2y(currentRow + 1) - 15;
p.setBrush(QBrush(frontColor));
p.drawChord(handleRect.translated(0, y1), angle180, angle180);
}
//--- 動く Onion Skinの描画 その1
//先に線を描く
//まず OnionSkinの最大/最小値を取得
int minMos = 0;
int maxMos = 0;
for (i = 0; i < mosCount; i++) {
int mos = osMask.getMos(i);
if (minMos > mos)
minMos = mos;
if (maxMos < mos)
maxMos = mos;
}
p.setBrush(Qt::NoBrush);
//min/maxが更新されていたら、線を描く
if (minMos < 0) //上方向に伸ばす線
{
int y0 = index2y(currentRow + minMos) + onionDotYPos + 10; //10は●の直径
int y1 = index2y(currentRow) - 15;
p.drawLine(15, y0, 15, y1);
}
if (maxMos > 0) //下方向に伸ばす線
{
int y0 = index2y(currentRow + 1) + 15;
int y1 = index2y(currentRow + maxMos) + onionDotYPos;
p.drawLine(15, y0, 15, y1);
}
}
//--- Fix Onion Skinの描画
for (i = 0; i < osMask.getFosCount(); i++) {
int fos = osMask.getFos(i);
//if(fos == currentRow) continue;
int y = index2y(fos) + onionDotYPos;
p.setPen(Qt::red);
//OnionSkinがDisableなら中空にする
p.setBrush(osMask.isEnabled() ? QBrush(QColor(0, 255, 255, 128)) : Qt::NoBrush);
p.drawEllipse(0, y, 10, 10);
}
//---
//--- 動く Onion Skinの描画 その2
//続いて、各OnionSkinの●を描く
p.setPen(Qt::red);
for (i = 0; i < mosCount; i++) {
//mosはOnionSkinの描かれるフレームのオフセット値
int mos = osMask.getMos(i);
//100312 iwasawa ハイライトする場合は後で描くのでスキップする
if (currentRow + mos == m_highlightedMosFrame)
continue;
int y = index2y(currentRow + mos) + onionDotYPos;
//.........这里部分代码省略.........
示例6: drawRobot
void FieldView::drawRobot(QPainter& painter, bool blueRobot, int ID,
QPointF pos, float theta, bool hasBall, bool faulty) {
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);
painter.save();
painter.translate(pos.x(), pos.y());
if (faulty) {
painter.save();
painter.setPen(redPen);
painter.setBrush(QBrush{Qt::red, Qt::SolidPattern});
auto r = Robot_Radius + 0.025;
painter.drawEllipse(QPointF(0, 0), r, r);
painter.restore();
}
if (blueRobot) {
painter.setPen(bluePen);
painter.setBrush(Qt::blue);
} else {
painter.setPen(yellowPen);
painter.setBrush(Qt::yellow);
}
painter.rotate(RadiansToDegrees(theta) + 90);
int span = 40;
int start = span * 16 + 90 * 16;
int end = 360 * 16 - (span * 2) * 16;
const float r = Robot_Radius;
painter.drawChord(QRectF(-r, -r, r * 2, r * 2), start, end);
if (showDotPatterns) {
painter.setPen(Qt::NoPen);
for (int i = 0; i < 4; i++) {
painter.setBrush(QBrush(Dot_Pattern_Colors[ID][i]));
QPointF center;
center.setX((i >= 2) ? Dots_Small_Offset : Dots_Large_Offset);
center.setX(center.x() * ((i == 1 || i == 2) ? -1 : 1));
center.setY((i <= 1) ? Dots_Small_Offset : Dots_Large_Offset);
center.setY(center.y() * ((i <= 1) ? -1 : 1));
painter.drawEllipse(center, Dots_Radius, Dots_Radius);
}
}
if (hasBall) {
painter.setPen(redPen);
const float r = Robot_Radius * 0.75f;
painter.drawChord(QRectF(-r, -r, r * 2, r * 2), start, end);
}
painter.restore();
// draw shell number
painter.save();
painter.translate(pos.x(), pos.y());
if (blueRobot) {
painter.setPen(whitePen);
} else {
painter.setPen(blackPen);
}
drawText(painter, QPointF(), QString::number(ID));
painter.restore();
}
示例7: createCard
void HSI::createCard(void){
QImage _cardImage = QImage(QSize(600,600), QImage::Format_ARGB32);
_cardImage.fill(0x00ff0000);
//_cardImage.moveTo(10,10);
uint midx, midy, width, height;
width = _cardImage.width();
midx = width/2;
height = _cardImage.height();
midy = height/2;
QPainter p;
p.setRenderHint(QPainter::Antialiasing, true);
p.begin(&_cardImage);
p.translate(midx, midy);
p.setPen(Qt::black);
p.setBrush(Qt::black);
p.drawChord(-midx,-midy,width,height,0,360*16);
p.setPen(Qt::white);
p.setBrush(Qt::white);
if(_thickBars > 0) {
for (float i = 0 ; i <= 360; i+=_thickBars) {
p.save();
p.rotate(value2Angle(i));
p.drawRect(-2.5, -300, 5.0, 30);
p.restore();
}
}
if(_thinBars > 0) {
for (float i = 0 ; i <= 360; i+=_thinBars) {
p.save();
p.rotate(value2Angle(i));
p.drawRect(-1.0, -300, 2.0, 20);
p.restore();
}
}
p.setPen(QColor(200,200,200));
p.setFont(QFont(QString("Helvetica"), 48, QFont::Bold, false));
if(1) {
for (float i = 0 ; i < 360; i+=_numbers) {
p.save();
p.rotate(value2Angle(i));
p.save();
QString lineNumber;
switch (int(i)) {
case 0:
lineNumber = QString("N");
break;
case 90:
lineNumber = QString("E");
break;
case 180:
lineNumber = QString("S");
break;
case 270:
lineNumber = QString("W");
break;
default:
lineNumber = QString::number(i/10);
break;
}
p.translate(0,-234);
int width = p.fontMetrics().width(lineNumber);
int height = p.fontMetrics().height();
p.drawText(-width/2,-height/2,width,height, Qt::AlignCenter, lineNumber);
p.restore();
p.restore();
}
}
p.end();
_card = QPixmap::fromImage(_cardImage, Qt::AutoColor);
}
示例8: drawContent
void KviCanvasChord::drawContent(QPainter &p)
{
int iStartAngle = m_properties["iStartAngle"].asInt() * 16;
int iEndAngle = m_properties["iExtensionAngle"].asInt() * 16;
p.drawChord((int)x(),(int)y(),width(),height(),iStartAngle,iEndAngle);
}
示例9: drawOnionSkinSelection
void RowArea::drawOnionSkinSelection(QPainter &p)
{
TApp *app = TApp::instance();
OnionSkinMask osMask = app->getCurrentOnionSkin()->getOnionSkinMask();
TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
assert(xsh);
int currentRow = m_viewer->getCurrentRow();
// get onion colors
TPixel frontPixel, backPixel;
bool inksOnly;
Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly);
QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128);
QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128);
int onionDotDiam = 8;
int onionHandleDiam = RowHeight - 1;
int onionDotYPos = (RowHeight - onionDotDiam) / 2;
// If the onion skin is disabled, draw dash line instead.
if (osMask.isEnabled())
p.setPen(Qt::red);
else
{
QPen currentPen = p.pen();
currentPen.setStyle(Qt::DashLine);
currentPen.setColor(QColor(128, 128, 128, 255));
p.setPen(currentPen);
}
// Draw onion skin extender handles.
QRectF handleRect(3, m_viewer->rowToY(currentRow) + 1, onionHandleDiam, onionHandleDiam);
int angle180 = 16 * 180;
p.setBrush(QBrush(backColor));
p.drawChord(handleRect, 0, angle180);
p.setBrush(QBrush(frontColor));
p.drawChord(handleRect, angle180, angle180);
//-- draw movable onions
// draw line between onion skin range
int minMos = 0;
int maxMos = 0;
int mosCount = osMask.getMosCount();
for (int i = 0; i < mosCount; i++) {
int mos = osMask.getMos(i);
if (minMos > mos)
minMos = mos;
if (maxMos < mos)
maxMos = mos;
}
p.setBrush(Qt::NoBrush);
if (minMos < 0) // previous frames
{
int y0 = m_viewer->rowToY(currentRow + minMos) + onionDotYPos + onionDotDiam;
int y1 = m_viewer->rowToY(currentRow);
p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1);
}
if (maxMos > 0) // foward frames
{
int y0 = m_viewer->rowToY(currentRow + 1);
int y1 = m_viewer->rowToY(currentRow + maxMos) + onionDotYPos;
p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1);
}
// draw onion skin dots
p.setPen(Qt::red);
for (int i = 0; i < mosCount; i++) {
// mos : frame offset from the current frame
int mos = osMask.getMos(i);
// skip drawing if the frame is under the mouse cursor
if (m_showOnionToSet == Mos && currentRow + mos == m_row)
continue;
int y = m_viewer->rowToY(currentRow + mos) + onionDotYPos;
if (osMask.isEnabled())
p.setBrush(mos < 0 ? backColor : frontColor);
else
p.setBrush(Qt::NoBrush);
p.drawEllipse(onionDotDiam, y, onionDotDiam, onionDotDiam);
}
//-- draw fixed onions
for (int i = 0; i < osMask.getFosCount(); i++)
{
int fos = osMask.getFos(i);
if (fos == currentRow) continue;
// skip drawing if the frame is under the mouse cursor
if (m_showOnionToSet == Fos && fos == m_row)
continue;
int y = m_viewer->rowToY(fos) + onionDotYPos;
if (osMask.isEnabled())
p.setBrush(QBrush(QColor(0, 255, 255, 128)));
else
p.setBrush(Qt::NoBrush);
p.drawEllipse(0, y, onionDotDiam, onionDotDiam);
}
//.........这里部分代码省略.........
示例10: createCard
void AttitudeIndicator::createCard(float w, float h){
// Init dimensions
double size = 0.85;
double targetW = qMin(w*size,h*size);
double targetH = targetW*0.70;
double realH = targetH*1.3;
double midX = targetW / 2.0;
double midY = targetH / 2.0;
// Create image
QImage _cardImage = QImage(QSize(targetW,realH), QImage::Format_ARGB32);
_cardImage.fill(0x00ff0000);
QPainter p;
p.begin(&_cardImage);
setupPainter(&p);
p.translate(0,(realH-targetH)/2.0);
// Shadow
p.save(); {
double shadowSize = 0.86;
p.setPen(Qt::NoPen);
double shadowRH = realH/2.0*shadowSize;
QRadialGradient radial(QPointF(midX, midY), shadowRH);
p.scale(1.8,1.0);
p.translate(-midX*0.4,0);
radial.setColorAt(0.6, Qt::black); //I want the center to be black
radial.setColorAt(1, Qt::transparent); //I want the sides to be white
p.setBrush(QBrush(radial));
p.setOpacity(0.4);
p.drawEllipse(QPointF(midX,midY),targetW/2.0*0.8,shadowRH);
} p.restore();
// Draw upper horizon
QLinearGradient gradient(5, midY-5,midX,midY-5);
gradient.setSpread(QGradient::ReflectSpread);
gradient.setColorAt(0, ATTITUDE_COLOR_BLUE_DARK);
gradient.setColorAt(1, ATTITUDE_COLOR_BLUE_LIGHT);
QBrush gbrush(gradient);
p.setPen(QPen(QColor(0,0,0,50),targetW*0.004));
p.setBrush(gbrush);
p.drawChord(0,0,targetW, targetH, 0, 180*16);
// Draw lower ground
gradient.setColorAt(0, ATTITUDE_COLOR_BROWN_DARK);
gradient.setColorAt(1, ATTITUDE_COLOR_BROWN_LIGHT);
QBrush gbrush2(gradient);
p.setBrush(gbrush2);
p.drawChord(0,0, targetW, targetH, 180*16, 180*16);
p.save(); {
// Original drawing code was 510x360, so we to keep that code we need to scale for it
double origW = 510.0;
double origH = 360;
double origMidX = origW / 2.0;
double origMidY = origH / 2.0;
double scale = targetW/origW;
p.scale(scale,scale);
// Draw horizon and angle cues
p.setPen(QPen(Qt::white, 7, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.drawLine(0,origMidY,origW-1,origMidY);
p.setPen(QPen(Qt::white, 5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
float sl = origMidX*0.72;
float ll = origMidX*0.84;
p.drawLine(origMidX,origMidY,origMidX+cos(30./180.*3.14159)*ll,origMidY+sin(30./180.*3.14159)*ll);
p.drawLine(origMidX,origMidY,origMidX+cos(60./180.*3.14159)*sl,origMidY+sin(60./180.*3.14159)*sl);
p.drawLine(origMidX,origMidY,origMidX-cos(30./180.*3.14159)*ll,origMidY+sin(30./180.*3.14159)*ll);
p.drawLine(origMidX,origMidY,origMidX-cos(60./180.*3.14159)*sl,origMidY+sin(60./180.*3.14159)*sl);
// Draw pitch up and down lines
p.setPen(QPen(QColor(0,0,15), 5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.drawLine(origMidX-45, origMidY-60*pitchPixelsPerDegree, origMidX+45,origMidY-60*pitchPixelsPerDegree);
p.drawLine(origMidX-24, origMidY-30*pitchPixelsPerDegree, origMidX+24,origMidY-30*pitchPixelsPerDegree);
p.setPen(QPen(Qt::white, 5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.drawLine(origMidX-35, origMidY+80*pitchPixelsPerDegree, origMidX+35,origMidY+80*pitchPixelsPerDegree);
p.drawLine(origMidX-17, origMidY+46*pitchPixelsPerDegree, origMidX+17,origMidY+46*pitchPixelsPerDegree);
} p.restore();
// Save as pixmap
p.end();
_card = QPixmap::fromImage(_cardImage, Qt::AutoColor);
}
示例11: createGlass
void AttitudeIndicator::createGlass(float w, float h){
// Init dimensions
double origW = 500.0;
double targetW = qMin(w,h);
double targetH = targetW;
// Create image
QImage _glassImage = QImage(QSize(targetW,targetH), QImage::Format_ARGB32);
_glassImage.fill(0x00ff0000);
// Init painter and scale to the original drawing size at 500x500
QPainter p;
p.begin(&_glassImage);
setupPainter(&p);
double scale = targetW/origW;
p.scale(scale,scale);
// Cosmetics on glass: yellow arrows:
p.setPen(QPen(QColor(0, 0, 0,50), 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.setBrush(QColor(255,116,0));
static const QPointF bigArrow[] = {
QPointF(250, 250),
QPointF(362.5, 287.5),
QPointF(137.5, 287.5)
};
int bigArrowNPts = sizeof(bigArrow)/sizeof(bigArrow[0]);
p.drawConvexPolygon(bigArrow, bigArrowNPts);
p.setBrush(Qt::yellow);
static const QPointF leftArrow[] = {
QPointF(125, 375-10),
QPointF(237.5, 320-10),
QPointF(240, 322.5-10),
QPointF(137.5, 387.5-10),
QPointF(125,387.5-10)
};
int leftArrowNPts = sizeof(leftArrow)/sizeof(leftArrow[0]);
p.drawConvexPolygon(leftArrow, leftArrowNPts);
static const QPointF rightArrow[] = {
QPointF(375, 375-10),
QPointF(262.5, 320-10),
QPointF(260, 322.5-10),
QPointF(362.5,387.5-10),
QPointF(375,387.5-10)
};
p.drawConvexPolygon(rightArrow, leftArrowNPts);
// Upwards facing orange arrow at vertical up:
static const QPointF orangeArrow[] = {
QPointF(250, 50),
QPointF(233, 88),
QPointF(267, 88)
};
p.setBrush(QColor(255,116,0));
p.drawConvexPolygon(orangeArrow, 3);
// Little black pyramid and chord at bottom:
p.setBrush(QColor(25,25,25));
static const QPointF pyramid[] = {
QPointF(250-19-60, 417+20),
QPointF(250+19+60, 417+20),
QPointF(250+25, 250+63+20),
QPointF(250-25, 250+63+20)
};
p.drawConvexPolygon(pyramid, 4);
p.setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p.setBrush(QColor(76,76,76));
p.drawChord(QRect(0,0,origW,origW), -40*16, -100*16);
p.setBrush(QColor(25,25,25));
p.drawChord(QRect(0,0,origW,origW), -42*16, -96*16);
// Little vacuum text line
p.setPen(QColor(200,200,200));
QFont font(defaultFont);
font.setPixelSize(20);
font.setBold(true);
p.setFont(font);
int width = p.fontMetrics().width("VACUUM");
int height = p.fontMetrics().height();
p.drawText(250-width/2, 385, width, height, Qt::AlignCenter, "VACUUM");
// Save as pixmap
p.end();
_glass = QPixmap::fromImage(_glassImage, Qt::AutoColor);
}