Ejemplo n.º 1
0
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);
		}
}
Ejemplo n.º 2
0
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;
}