コード例 #1
0
ファイル: mainWindow.cpp プロジェクト: kyeah/Genetic-Fractals
void Repaint() {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (!waiting) {
    fadeAlpha -= fadeSpeed;
    if (fadeAlpha <= 0) {
      glShadeModel(GL_FLAT);
      glDisable(GL_LIGHTING);
      glDisable(GL_LIGHT0);
      glDisable(GL_COLOR_MATERIAL);
    }

    adjustBounds(*mainFractal);
    if (mainFractal->paint()) {
      if (rendering) {
        TwDraw();
      } else {
        return;
      }
    } else {
      waiting = true;
    }
  }

  if (waiting) {
    fadeAlpha = 1.0;
  }

  if (rendering && fadeAlpha > 0) {
    drawLoader();
  }

  glFlush();
  glutSwapBuffers();
}
コード例 #2
0
ファイル: ShapeEntity.cpp プロジェクト: thogrim/Radar
void ShapeEntity::setVertices(const Vertices& vertices){
	shape_.setPointCount(vertices.size());
	int i = 0;
	for (auto& v : vertices){
		shape_.setPoint(i, sf::Vector2f(v.x, v.y));
		++i;
	}
	adjustBounds();
	shape_.setTextureRect(static_cast<sf::IntRect>(bounds_));
}
コード例 #3
0
void LineMove::mouseMoveEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_haveLineItem)
	{
		doResize();
		double angle = rotation();
		if (angle > 0)
			angle = 360 - angle;
		m_canvas->displaySizeHUD(m->globalPos(), length(), fabs(angle), true);
	}
	m->accept();
	m_canvas->repaint();
}
コード例 #4
0
void LineMove::mouseReleaseEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_haveLineItem)
	{
		doResize();
		m_doc->setRedrawBounding(m_line);
		m_view->resetMousePressed();
		m_line->checkChanges();
		m_line->update();
	}
	m->accept();
	m_canvas->update();
//	qDebug() << "LineMove::mouseRelease" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
	m_view->stopGesture();
}
コード例 #5
0
void ResizeGesture::mouseMoveEvent(QMouseEvent *m)
{
	adjustBounds(m);
	FPoint where = m_canvas->globalToCanvas(m->globalPos());
	if (// directly after a create the shape of an item isnt really usable, so we fix here
		m_origBounds.width() < 20 || m_origBounds.height() < 20 ||
		// and if we resize outside of the current canvas dimensions, we need to enlarge it
		where.x() < m_doc->minCanvasCoordinate.x() || where.y() < m_doc->minCanvasCoordinate.y() ||
		where.x() > m_doc->maxCanvasCoordinate.x() || where.y() > m_doc->maxCanvasCoordinate.y())
	{
		doResize(m->modifiers() & Qt::AltModifier);
	}
	m->accept();
	QPoint point = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0)));
	m_view->ensureVisible(point.x(), point.y(), 20, 20);
	m_canvas->repaint();
	QRectF newBounds = m_bounds.normalized();
	m_canvas->displaySizeHUD(m->globalPos(), newBounds.width() - m_extraWidth, newBounds.height() - m_extraHeight);
}
コード例 #6
0
void ResizeGesture::mouseReleaseEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_doc->m_Selection->count() != 0)
	{
		PageItem* currItem = m_doc->m_Selection->itemAt(0);
//		qDebug() << "ResizeGesture::release: new bounds" << m_bounds;
		if (m_bounds != m_mousePressBounds)
		{
			doResize(m->modifiers() & Qt::AltModifier);
			m_doc->setRedrawBounding(currItem);
			if (currItem->asImageFrame())
				currItem->AdjustPictScale();
		}
		m_view->resetMousePressed();
		// necessary since mousebutton is still recorded pressed, and otherwise checkchanges() will do nothing
		// we must check changes on whole selection otherwise resize operation won't undo correctly on groups
		if (m_bounds != m_mousePressBounds)
		{
			for (int i = 0; i < m_doc->m_Selection->count(); ++i)
				m_doc->m_Selection->itemAt(i)->checkChanges();
			m_doc->invalidateRegion(m_mousePressBounds.unite(m_bounds));
			m_doc->regionsChanged()->update(m_mousePressBounds.unite(m_bounds));
			m_doc->changed();
		}
	}
//	qDebug() << "ResizeGesture::release: transaction" << m_transactionStarted;
	if (m_transactionStarted)
	{
		m_transactionStarted->commit();
		delete m_transactionStarted;
		m_transactionStarted = NULL;
	}
	m->accept();
	m_canvas->update();
	m_view->stopGesture();
}
コード例 #7
0
ファイル: design.cpp プロジェクト: Strangerke/scummvm
void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in) {
	int numBytes = in.readSint16BE();
	int y1 = in.readSint16BE();
	int x1 = in.readSint16BE();
	int y2 = in.readSint16BE();
	int x2 = in.readSint16BE();
	int w = x2 - x1;
	int h = y2 - y1;
	Graphics::ManagedSurface tmp;

	tmp.create(w, h, Graphics::PixelFormat::createFormatCLUT8());

	numBytes -= 10;

	int x = 0, y = 0;
	while (numBytes > 0 && y < h) {
		int n = in.readSByte();
		int count;
		int b = 0;
		int state = 0;

		numBytes--;

		if ((n >= 0) && (n <= 127)) { // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
			count = n + 1;
			state = 1;
		} else if ((n >= -127) && (n <= -1)) { // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
			b = in.readByte();
			numBytes--;
			count = -n + 1;
			state = 2;
		} else { // Else if n is -128, noop.
			count = 0;
		}

		for (int i = 0; i < count && y < h; i++) {
			byte color = 0;
			if (state == 1) {
				color = in.readByte();
				numBytes--;
			} else if (state == 2)
				color = b;

			for (int c = 0; c < 8; c++) {
				if (_boundsCalculationMode) {
					adjustBounds(x1 + x, y1 + y);
				} else if (x1 + x >= 0 && x1 + x < surface->w && y1 + y >= 0 && y1 + y < surface->h)
					*((byte *)tmp.getBasePtr(x, y)) = (color & (1 << (7 - c % 8))) ? kColorBlack : kColorWhite;
				x++;
				if (x == w) {
					y++;
					x = 0;
					break;
				}
			}
		}
	}

	in.skip(numBytes);

	if (_boundsCalculationMode)
		return;

	FloodFill ff(&tmp, kColorWhite, kColorGreen);
	for (int yy = 0; yy < h; yy++) {
		ff.addSeed(0, yy);
		ff.addSeed(w - 1, yy);
	}
	for (int xx = 0; xx < w; xx++) {
		ff.addSeed(xx, 0);
		ff.addSeed(xx, h - 1);
	}
	ff.fill();

	for (y = 0; y < h && y1 + y < surface->h; y++) {
		byte *src = (byte *)tmp.getBasePtr(0, y);
		byte *dst = (byte *)surface->getBasePtr(x1, y1 + y);
		for (x = 0; x < w; x++) {
			if (*src != kColorGreen)
				*dst = *src;
			src++;
			dst++;
		}
	}

	tmp.free();
}