void draw(void *userData) { /* Draw rectangle */ setPenColor(POLO_TRANSPARENT); setFillColor(POLO_MIDNIGHT); drawRect(0, 0, 120, 44); /* Draw hello world */ setPenColor(POLO_WHITE); drawText(10, 10, "Hello world"); }
void draw(void *userData) { DemoData *d = (DemoData *) userData; char buf[256]; int x, y; /* Exit on key press */ if (getKey()) exitPolo(); /* Clear screen with right mouse button */ if (isMouseButtonPressed(1)) clearScreen(); /* Paint with left mouse button */ if (isMouseButtonPressed(0)) { if ((getMouseX() < 128) && (getMouseY() < 128)) setDrawTint(getColorFromHSVA(getMouseX() / 128, getMouseY() / 128, 1, BRUSH_ALPHA)); else drawImage(getMouseX() - getImageWidth(d->brush) / 2, getMouseY() - getImageHeight(d->brush) / 2, d->brush); } /* Draw left bar */ setPenColor(POLO_STEEL); setFillGradient(POLO_SILVER, POLO_TUNGSTEN); drawRect(-1, -1, TOOLBAR_WIDTH, getScreenHeight() + 2); /* Draw frames per second and time display */ setPenColor(POLO_BLACK); sprintf(buf, "FPS: %.3f", d->frame / (getTime() + 0.001)); drawText((TOOLBAR_WIDTH - getTextDrawWidth(buf)) / 2, getScreenHeight() - getTextDrawHeight(buf) - 10, buf); /* Increment frame number */ d->frame++; /* Paint color palette */ for (x = 0; x < 128; x++) for (y = 0; y < 128; y++) { setPenColor(getColorFromHSV(x / 128.0, y / 128.0, 1.0)); drawPoint(x, y); } }
void VisualizeSquareMazeRunner::drawInitialWindow (void) { int windowWidth,windowHeight; windowWidth=maze->getWidth()*PixelsPerNode; windowHeight=maze->getHeight()*PixelsPerNode; setPenColor(BackgroundColor); drawRect(0,0,windowWidth,windowHeight,0); // draw boundary lines setPenColor(WallColor); drawLine(0,0,windowWidth,0,1); drawLine(windowWidth,0,windowWidth,windowHeight,1); drawLine(windowWidth,windowHeight,0,windowHeight,1); drawLine(0,windowHeight,0,0,1); // draw walls int x,y; for (y=0; y<maze->getHeight(); y++) { for (x=0; x<maze->getWidth(); x++) { SquareMaze::SquareMazeNode *node=maze->getNodeAt(x,y); if (!node->canGoLeft()) { drawLine(x*PixelsPerNode,y*PixelsPerNode,x*PixelsPerNode,(y+1)*PixelsPerNode,1); } if (!node->canGoUp()) { drawLine(x*PixelsPerNode,y*PixelsPerNode,(x+1)*PixelsPerNode,y*PixelsPerNode,1); } } } MazeNode* startNode = maze->getStartMazeNode(); // draw squares for (y=0; y<maze->getHeight(); y++) { for (x=0; x<maze->getWidth(); x++) { SquareMaze::SquareMazeNode *node=maze->getNodeAt(x,y); drawNode(x,y,getColor(node->getVisitationState())); if (node->isExitNode()) { // capture exit node location xfin = x; yfin = y; } if (startNode == node){ xstart = x; ystart = y; } } } // NEW: Draw start and stop nodes drawSpNode(xfin,yfin,VisualizeSquareMazeRunner::StartEndColor); drawSpNode(xstart,ystart, VisualizeSquareMazeRunner::StartEndColor ); }
void paint() { static const int ox = 150; static const int oy = 150; static const int hl = 46; static const int ml = 74; static const int sl = 120; int i; beginPaint(); clearDevice(); // circle setPenWidth(2); setPenColor(BLACK); setBrushColor(WHITE); ellipse(25, 25, 275, 275); // label setPenWidth(1); setPenColor(BLACK); for (i = 0; i < 12; ++i) { moveTo(ox + 115 * sin(RAD(180 - i * 30)), oy + 115 * cos(RAD(180 - i * 30))); lineTo(ox + 125 * sin(RAD(180 - i * 30)), oy + 125 * cos(RAD(180 - i * 30))); } // hour setPenWidth(8); setPenColor(BLACK); moveTo(ox, oy); lineTo(ox + hl * sin(RAD(180 - h * 30)), oy + hl * cos(RAD(180 - h * 30))); // minute setPenWidth(4); setPenColor(GREEN); moveTo(ox, oy); lineTo(ox + ml * sin(RAD(180 - m * 6)), oy + ml * cos(RAD(180 - m * 6))); // second setPenWidth(2); setPenColor(RED); moveTo(ox, oy); lineTo(ox + sl * sin(RAD(180 - s * 6)), oy + sl * cos(RAD(180 - s * 6))); endPaint(); }
void main() { lcdInit(); spiOn(); spiOff(); sendByte(out); sendArray(array); lcdOn(); lcdOff(); sendBuffer(); sendPart(3, 7, LCD_Buffer); clear(); clearPart(5, 76); clearPartColor(5, 76, clBLACK); setPenColor(clBLACK); setBackColor(clWHITE); delay_nsek(40); scsOn(); scsOff(); i = getValue(LCD_Buffer, 23, 266); setValue(LCD_Buffer, 23, 266, 0x3F); setCharge(); resetCharge(); drawPixel(5, 5, LCD_Buffer); drawVLine(5, 5, 5, LCD_Buffer); drawHLine(5, 5, 5, LCD_Buffer); drawLine(5, 5, 55, 55, LCD_Buffer); drawRect(5, 5, 55, 55, LCD_Buffer); drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer); drawCircle(10, 10, 5, LCD_Buffer); }
void setPenStyle(ACL_Pen_Style newStyle) { ACL_ASSERT_BEGIN_PAINT; switch(newStyle) { case PEN_STYLE_SOLID: g_penStyle = PS_SOLID; break; case PEN_STYLE_DASH: g_penStyle = PS_DASH; break; case PEN_STYLE_DOT: g_penStyle = PS_DOT; break; case PEN_STYLE_DASHDOT: g_penStyle = PS_DASHDOT; break; case PEN_STYLE_DASHDOTDOT: g_penStyle = PS_DASHDOTDOT; break; case PEN_STYLE_NULL: g_penStyle = -1; setPenColor(EMPTY); return; default: break; } updatePen(); }
void drawAllSquares() { std::cout << "drawAllSquares" << std::endl; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); setPenColor(0, 0, 1); GLdouble size = std::min(g_width, g_height) / OBJECT_COUNT; GLdouble doubleSize = size * 2; GLdouble widthMax = g_width + size; GLdouble heightMax = g_height + size; GLdouble delta = 0; for(GLdouble i = size / 2; i < widthMax; i += doubleSize) { for(GLdouble j = size / 2; j < heightMax; j += size) { delta = 0; if(static_cast<int>((i + j) / size) % 2) delta = size; drawSquare(point(i + delta, j), size); } } }
void drawAllTriangles() { std::cout << "drawAllTriangles" << std::endl; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); setPenColor(0, 0, 1); GLdouble size = std::min(g_width, g_height) / OBJECT_COUNT; GLdouble height = sqrt(size * size - size / 2 * size / 2); GLdouble widthMax = g_width + size; GLdouble heightMax = g_height + height; int rowCounter = 0; for(GLdouble heightUpPosition = 0; heightUpPosition < heightMax; heightUpPosition += height) { GLdouble heightDownPosition = heightUpPosition + height; GLdouble delta = rowCounter % 2 ? size / 2 : 0; for(GLdouble upPosition = delta; upPosition < widthMax; upPosition += size) { GLdouble downLeftPosition = upPosition + -size / 2; GLdouble downRightPosition = upPosition + size / 2; drawTriangle(point(upPosition, heightUpPosition), point(downLeftPosition, heightDownPosition), point(downRightPosition, heightDownPosition)); } rowCounter++; } }
void DkPaintViewPort::init() { panning = false; cancelTriggered = false; isOutside = false; defaultCursor = Qt::CrossCursor; setCursor(defaultCursor); pen = QColor(0,0,0); pen.setCapStyle(Qt::RoundCap); pen.setJoinStyle(Qt::RoundJoin); pen.setWidth(1); paintToolbar = new DkPaintToolBar(tr("Paint Toolbar"), this); connect(paintToolbar, SIGNAL(colorSignal(QColor)), this, SLOT(setPenColor(QColor)), Qt::UniqueConnection); connect(paintToolbar, SIGNAL(widthSignal(int)), this, SLOT(setPenWidth(int)), Qt::UniqueConnection); connect(paintToolbar, SIGNAL(panSignal(bool)), this, SLOT(setPanning(bool)), Qt::UniqueConnection); connect(paintToolbar, SIGNAL(cancelSignal()), this, SLOT(discardChangesAndClose()), Qt::UniqueConnection); connect(paintToolbar, SIGNAL(undoSignal()), this, SLOT(undoLastPaint()), Qt::UniqueConnection); connect(paintToolbar, SIGNAL(applySignal()), this, SLOT(applyChangesAndClose()), Qt::UniqueConnection); loadSettings(); paintToolbar->setPenColor(pen.color()); paintToolbar->setPenWidth(pen.width()); }
void DrawingPolyItem::setPen(const QPen& pen) { setPenColor(pen.brush().color()); setPenWidth(pen.widthF()); setPenStyle(pen.style()); setPenCapStyle(pen.capStyle()); setPenJoinStyle(pen.joinStyle()); }
void Item::setPenBrush(const QString& penStyle, int width, const QString& penColor, const QString& brushStyle, const QString& brushColor) { setPenStyle(penStyle); setPenWidth(width); setPenColor(penColor); setBrushStyle(brushStyle); setBrushColor(brushColor); }
void VisualizeSquareMazeRunner::drawNode (int x,int y,int color) { setPenColor(color); drawRect(x*PixelsPerNode+1,y*PixelsPerNode+1,PixelsPerNode-1,PixelsPerNode-1,0); // draw start and stop nodes whenever we update any other nodes. drawSpNode(xfin,yfin,VisualizeSquareMazeRunner::StartEndColor); drawSpNode(xstart,ystart,VisualizeSquareMazeRunner::StartEndColor); pause(); // added pause here to allow user control of inter node pause draw times. }
DrawWindow(int w, int h, std::string name) { // constructor width=w; height=h; window_name = name; cv::namedWindow(window_name, CV_WINDOW_AUTOSIZE ); winx=0; winy=0; grid = cv::Mat( height, width, CV_8UC3 ); // 3 channel color setLineType("solid"); setLineThickness(2); setPenColor(0,0,0); clearWindow(255,255,255); }
void drawAllHexagons() { std::cout << "drawAllHexagons" << std::endl; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); GLdouble size = std::min(g_width, g_height) / OBJECT_COUNT; GLdouble stepSize = size * 1.5; GLdouble height = sqrt(size * size - size / 2 * size / 2); GLdouble widthMax = g_width + size; GLdouble heightMax = g_height + height; int rowCounter = 0; for(GLdouble horizontalPosition = 0; horizontalPosition < heightMax; horizontalPosition += height) { int rowCounterOst = rowCounter % 3; if(rowCounterOst == 0) { setPenColor(1, 0, 0); } else if(rowCounterOst == 1) { setPenColor(0, 1, 0); } else { setPenColor(0, 0, 1); } for(GLdouble verticalPosition = 0; verticalPosition < widthMax; verticalPosition += stepSize) { drawHexagon(point(verticalPosition, horizontalPosition), size, height); } rowCounter++; } rowCounter = 0; for(GLdouble horizontalPosition = height / 2; horizontalPosition < heightMax; horizontalPosition += height) { int rowCounterOst = rowCounter % 3; if(rowCounterOst == 0) { setPenColor(0, 0, 1); } else if(rowCounterOst == 1) { setPenColor(1, 0, 0); } else { setPenColor(0, 1, 0); } for(GLdouble verticalPosition = stepSize / 2; verticalPosition < widthMax; verticalPosition += stepSize) { drawHexagon(point(verticalPosition, horizontalPosition), size, height); } rowCounter++; } }
void Eraser::MouseMove(LPARAM lparam, WPARAM wparam){ hdc = GetDC(hwnd); if (IsDrawing == true) { //SetROP2(hdc, R2_XORPEN); MoveToEx(hdc, EndX, EndY, NULL); EndX = LOWORD(lparam); EndY = HIWORD(lparam); setupPaintingTools(hdc); setPenColor(RGB(255,255,255)); LineTo(hdc, EndX, EndY); }; ReleaseDC(hwnd, hdc); };
int RenderArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: setFillRule((*reinterpret_cast< Qt::FillRule(*)>(_a[1]))); break; case 1: setFillGradient((*reinterpret_cast< const QColor(*)>(_a[1])),(*reinterpret_cast< const QColor(*)>(_a[2]))); break; case 2: setPenWidth((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: setPenColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break; case 4: setRotationAngle((*reinterpret_cast< int(*)>(_a[1]))); break; } _id -= 5; } return _id; }
void DrawingPolyItem::readXmlAttributes(QXmlStreamReader& xmlReader, const QList<DrawingItem*>& items) { QXmlStreamAttributes attributes = xmlReader.attributes(); DrawingItem::readXmlAttributes(xmlReader, items); if (attributes.hasAttribute("penColor")) setPenColor(Drawing::colorFromString(attributes.value("penColor").toString())); if (attributes.hasAttribute("penWidth")) setPenWidth(attributes.value("penWidth").toString().toDouble()); if (attributes.hasAttribute("penStyle")) setPenStyle((Qt::PenStyle)attributes.value("penStyle").toString().toUInt()); if (attributes.hasAttribute("penCapStyle")) setPenCapStyle((Qt::PenCapStyle)attributes.value("penCapStyle").toString().toUInt()); if (attributes.hasAttribute("penJoinStyle")) setPenJoinStyle((Qt::PenJoinStyle)attributes.value("penJoinStyle").toString().toUInt()); }
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) { setupUi(this); qDebug()<< settings.fileName(); loadSettings(); connect (penPB,SIGNAL(clicked()),this, SLOT( setPenColor())); connect (brushPB,SIGNAL(clicked()),this, SLOT( setBrushColor())); ///@todo create own button to change color //connect (sheetPenPB,SIGNAL(clicked()),this, SLOT( setMyColor())); //connect (sheetBrushPB,SIGNAL(clicked()),this, SLOT( setMyColor())); connect (sheetPenPB,SIGNAL(clicked()),this, SLOT( setSheetPenColor())); connect (sheetBrushPB,SIGNAL(clicked()),this, SLOT( setSheetBrushColor())); connect (setTextPB,SIGNAL(clicked()),this, SLOT( setTextFont())); connect (texturePB,SIGNAL(clicked()),this, SLOT( setInner())); connect (okButton,SIGNAL(clicked()),this, SLOT( save())); }
ItemSettings::ItemSettings(ItemProperties *prop,QWidget *parent):QWidget(parent,Qt::Tool) { setupUi(this); this->prop = prop; this->fontColor = prop->fontColor; this->penColor = prop->itemPen.color(); this->brushColor = prop->itemBrush.color(); QPixmap penColor(45,11); penColor.fill(prop->itemPen.color()); QIcon penIcon(penColor); this->pb_penColor->setIcon(penIcon); this->pb_penColor->setIconSize(QSize(45,11)); this->sd_penWidth->setValue(prop->itemPen.width()); this->cb_penStyle->setCurrentIndex(this->prop->itemPen.style() - 1); QPixmap brushColor(45,11); brushColor.fill(prop->itemBrush.color()); QIcon brushIcon(brushColor); this->pb_brushColor->setIcon(brushIcon); this->pb_brushColor->setIconSize(QSize(45,11)); this->cb_brushStyle->setCurrentIndex(this->prop->itemBrush.style()); QPixmap fontColor(45,11); fontColor.fill(prop->fontColor); QIcon fontIcon(fontColor); this->pb_fontColor->setIcon(fontIcon); this->pb_fontColor->setIconSize(QSize(45,11)); connect(pb_penColor,SIGNAL(released()),this,SLOT(setPenColor())); connect(pb_brushColor,SIGNAL(released()),this,SLOT(setBrushColor())); connect(pb_done,SIGNAL(released()),this,SLOT(saveSettings())); connect(pb_selectFont,SIGNAL(released()),this,SLOT(selectFont())); connect(pb_fontColor,SIGNAL(released()),this,SLOT(setFontColor())); int p_midX = parent->x() + 100; int p_midY = parent->y() + 150; this->move(p_midX , p_midY) ; this->activateWindow(); }
int StickMan::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGraphicsObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 2) qt_static_metacall(this, _c, _id, _a); _id -= 2; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QColor*>(_v) = penColor(); break; case 1: *reinterpret_cast< QColor*>(_v) = fillColor(); break; case 2: *reinterpret_cast< bool*>(_v) = isDead(); break; } _id -= 3; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setPenColor(*reinterpret_cast< QColor*>(_v)); break; case 1: setFillColor(*reinterpret_cast< QColor*>(_v)); break; case 2: setIsDead(*reinterpret_cast< bool*>(_v)); break; } _id -= 3; } else if (_c == QMetaObject::ResetProperty) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 3; } #endif // QT_NO_PROPERTIES return _id; }
/** * NEW METHOD : 20110125 * call this with the coordinates of node and parentnode. Note matrix row and colum * are both zero based. * @param xOne is x coordinate of current node (in matrix columns) * @param yOne is y coordinate of current node (in matrix rows) * @param xTwo is the x coordinate of the parent node (in matrix columns) * @param yTwo is the y coordinate of the parent node (in matrix rows) */ void VisualizeSquareMazeRunner::drawParentLink(int xOne, int yOne, int xTwo, int yTwo, int color) { setPenColor(color); if (xOne == xTwo){ // vertical line if (yOne > yTwo){ drawRect (xOne*PixelsPerNode + PixelsPerNode/2, yTwo*PixelsPerNode + PixelsPerNode/2, 4, PixelsPerNode,0); }else{ drawRect (xOne*PixelsPerNode + PixelsPerNode/2, yOne*PixelsPerNode + PixelsPerNode/2, 4, PixelsPerNode,0); } }else{ // horizontal line if (xOne>xTwo){ drawRect (xTwo*PixelsPerNode + PixelsPerNode/2, yOne*PixelsPerNode + PixelsPerNode/2, PixelsPerNode,4,0); }else{ drawRect (xOne*PixelsPerNode + PixelsPerNode/2, yOne*PixelsPerNode + PixelsPerNode/2, PixelsPerNode,4,0); } } }
/* NEW METHOD: 20110125 Paint circles at the start and end node. Given a Node, there seems to be no support for finding its maze co-ordinates so this brute forces it from the maze side by iterating through all maze nodes until the start and stop nodes are identified. */ void VisualizeSquareMazeRunner::drawSpNode(int x,int y,int color) { setPenColor(color); drawOval(x*PixelsPerNode+5,y*PixelsPerNode+5,PixelsPerNode-7,PixelsPerNode-7,0); }
void toolbar_key_selected(int iconID, int iconState,PScribbleUICtx pScribbleUICtx) { if( iconState_grey==iconState ) { return;//donothing. } SB_IPCPRINTF("\n====iconID=%d[mode=%d,pensize=%d,color=%d]\n", iconID,getOperationMode(),getPenSize(),getPenColor()); gboolean bNeedFlushWithFullQlt=FALSE; //need full update when return from erase mode. if( getOperationMode()== MODE_ERASE) { //every erase stroke ,we do it, so it's useless //core_redrawBgAndStrks(pScribbleUICtx); bNeedFlushWithFullQlt=TRUE; } //we should add deal to pageup/pagedown switch (iconID) { case iconID_pen: //we switch by whether or not user is drawing if( !toolbar_is_drawing() ) { setOperationMode(MODE_DRAW); } else { setOperationMode(MODE_INVALID); } break; case iconID_pen1pixel: case iconID_pen3pixel: case iconID_pen5pixel: case iconID_pen7pixel: //enter select mode setOperationMode(MODE_SELSIZE); break; case iconID_pen1pixelLow: case iconID_pen3pixelLow: case iconID_pen5pixelLow: case iconID_pen7pixelLow: //confirm the select setPenSize(getPenSizefromIcon(iconID)); setOperationMode(MODE_DRAW); break; case iconID_penwhite://WHITE case iconID_penlightgrey://LIGHT_GRAY case iconID_pendarkgrey://DARK_GRAY case iconID_penblack://BLACK //enter select mode setOperationMode(MODE_SELCOLOR); break; case iconID_penwhiteLow://WHITE case iconID_penlightgreyLow://LIGHT_GRAY case iconID_pendarkgreyLow://DARK_GRAY case iconID_penblackLow://BLACK //confirm the select setPenColor(getPenColorfromIcon(iconID)); setOperationMode(MODE_DRAW); break; case iconID_eraseline: if( MODE_ERASE==getOperationMode()) { setOperationMode(MODE_DRAW); } else { setOperationMode(MODE_ERASE); } break; case iconID_trashcan://delete page if(MODE_DELPAGE==getOperationMode()) { setOperationMode(MODE_DRAW); if(ispagedel_confirmed) { //delete page delOnepage(pScribbleUICtx); ispagedel_confirmed=FALSE; return;//tool bar will be updated when jumping } ispagedel_confirmed=FALSE; } else { SB_IPCPRINTF("enter MODE_DELPAGE\n"); setOperationMode(MODE_DELPAGE); ispagedel_confirmed=FALSE; } break; case iconID_npage: addOnepage(pScribbleUICtx); return;//tool bar will be updated when jumping default: SB_IPCPRINTF("Unknown iconID [%d]\n", iconID); return; } drawIconsByMode(getTotalPage(&pScribbleUICtx->fileManager)); //flush the pixmap to gdk_buffer,but now every stroke is flush,so it's useless. //flushPixMap(pScribbleUICtx); if(bNeedFlushWithFullQlt) { display_update_request_screen_refresh (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQFull); } else { display_update_request_screen_refresh (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQTyping); } SB_IPCPRINTF("\n===end===[mode=%d,pensize=%d,color=%d]\n", getOperationMode(),getPenSize(),getPenColor()); return; }