tests/arthur/common/paintcommands.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   585                       "image_load :/images/face.png myImage");
   585                       "image_load :/images/face.png myImage");
   586     DECL_PAINTCOMMAND("image_setColor", command_image_setColor,
   586     DECL_PAINTCOMMAND("image_setColor", command_image_setColor,
   587                       "^image_setColor\\s+([\\w.:\\/]*)\\s+([0-9]*)\\s+#([0-9]*)$",
   587                       "^image_setColor\\s+([\\w.:\\/]*)\\s+([0-9]*)\\s+#([0-9]*)$",
   588                       "image_setColor <imageName> <index> <color>",
   588                       "image_setColor <imageName> <index> <color>",
   589                       "image_setColor myImage 0 black");
   589                       "image_setColor myImage 0 black");
   590     DECL_PAINTCOMMAND("image_setNumColors", command_image_setNumColors,
   590     DECL_PAINTCOMMAND("image_setColorCount", command_image_setColorCount,
   591                       "^image_setNumColors\\s+([\\w.:\\/]*)\\s+([0-9]*)$",
   591                       "^image_setColorCount\\s+([\\w.:\\/]*)\\s+([0-9]*)$",
   592                       "image_setNumColors <imageName> <nbColors>",
   592                       "image_setColorCount <imageName> <nbColors>",
   593                       "image_setNumColors myImage 128");
   593                       "image_setColorCount myImage 128");
   594 
   594 
   595     DECL_PAINTCOMMANDSECTION("transformations");
   595     DECL_PAINTCOMMANDSECTION("transformations");
   596     DECL_PAINTCOMMAND("resetMatrix", command_resetMatrix,
   596     DECL_PAINTCOMMAND("resetMatrix", command_resetMatrix,
   597                       "^resetMatrix$",
   597                       "^resetMatrix$",
   598                       "resetMatrix",
   598                       "resetMatrix",
   972     if (th == 0) th = -1;
   972     if (th == 0) th = -1;
   973     if (sw == 0) sw = -1;
   973     if (sw == 0) sw = -1;
   974     if (sh == 0) sh = -1;
   974     if (sh == 0) sh = -1;
   975 
   975 
   976     if (m_verboseMode)
   976     if (m_verboseMode)
   977         printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%d, %d, %d, %d), (%d, %d, %d, %d)\n",
   977         printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
   978                qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(),
   978                qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(),
   979                tx, ty, tw, th, sx, sy, sw, sh);
   979                tx, ty, tw, th, sx, sy, sw, sh);
   980 
   980 
   981     m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh));
   981     m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh));
   982 }
   982 }
  1020     if (th == 0) th = -1;
  1020     if (th == 0) th = -1;
  1021     if (sw == 0) sw = -1;
  1021     if (sw == 0) sw = -1;
  1022     if (sh == 0) sh = -1;
  1022     if (sh == 0) sh = -1;
  1023 
  1023 
  1024     if (m_verboseMode)
  1024     if (m_verboseMode)
  1025         printf(" -(lance) drawImage('%s' dim=(%d, %d), (%d, %d, %d, %d), (%d, %d, %d, %d)\n",
  1025         printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
  1026                qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh);
  1026                qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh);
  1027 
  1027 
  1028     m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither);
  1028     m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither);
  1029 }
  1029 }
  1030 
  1030 
  2243 
  2243 
  2244     m_imageMap[name] = image;
  2244     m_imageMap[name] = image;
  2245 }
  2245 }
  2246 
  2246 
  2247 /***************************************************************************************************/
  2247 /***************************************************************************************************/
  2248 void PaintCommands::command_image_setNumColors(QRegExp re)
  2248 void PaintCommands::command_image_setColorCount(QRegExp re)
  2249 {
  2249 {
  2250     QStringList caps = re.capturedTexts();
  2250     QStringList caps = re.capturedTexts();
  2251 
  2251 
  2252     QString name = caps.at(1);
  2252     QString name = caps.at(1);
  2253     int count = convertToInt(caps.at(2));
  2253     int count = convertToInt(caps.at(2));
  2254 
  2254 
  2255     if (m_verboseMode)
  2255     if (m_verboseMode)
  2256         printf(" -(lance) image_setNumColors(%s), %d -> %d\n",
  2256         printf(" -(lance) image_setColorCount(%s), %d -> %d\n",
  2257                qPrintable(name), m_imageMap[name].numColors(), count);
  2257                qPrintable(name), m_imageMap[name].colorCount(), count);
  2258 
  2258 
  2259     m_imageMap[name].setNumColors(count);
  2259     m_imageMap[name].setColorCount(count);
  2260 }
  2260 }
  2261 
  2261 
  2262 /***************************************************************************************************/
  2262 /***************************************************************************************************/
  2263 void PaintCommands::command_image_setColor(QRegExp re)
  2263 void PaintCommands::command_image_setColor(QRegExp re)
  2264 {
  2264 {