Beispiel #1
0
void MVListBase::vScrollTo(int j,ibool redraw)
/****************************************************************************
*
* Function:     MVListBase::vScrollTo
* Parameters:   j       - New cell to scroll to in vertical direction
*               redraw  - True if list should be redrawn
*
* Description:  Scrolls the list to start at the new cell 'j' in the
*               vertical direction, redrawing all necessary cells to do
*               this.
*
]****************************************************************************/
{
    if (visible.top() != j) {
        // Setup the viewport for redrawing the list directly, and redraw
        // it.
        MVRect   v(visible & range);
        MVRect  b(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.left()+leftIndent+cellSize.x*(visible.right()-visible.left()),
                  bounds.top()+topIndent+cellSize.y*(visible.bottom()-visible.top()));
        int     dy = (v.top() - j) * cellSize.y;

        if (b.right() > (bounds.right()-rightIndent))
            b.right() = bounds.right()-rightIndent;
        if (b.bottom() > (bounds.bottom()-botIndent))
            b.bottom() = bounds.bottom()-botIndent;

        visible.moveTo(hScroll ? hScroll->getValue() : 0,j);
        vScroll->setValue(j);

        if (redraw) {
            CHECK(owner != NULL);
            setupOwnerViewport();
            MS_obscure();

            if (j < v.top()) {
                b.bottom() -= dy;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,b.left(),bounds.top()+topIndent+dy,MGL_REPLACE_MODE);
                for (int y = j; y < v.top(); y++)
                    for (int x = v.left(); x < v.right(); x++)
                        drawCell(x,y);
                }
            else {
                b.top() -= dy;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,b.left(),bounds.top()+topIndent,MGL_REPLACE_MODE);
                j -= v.top();
                for (int y = 0; y < j; y++)
                    for (int x = v.left(); x < v.right(); x++)
                        drawCell(x,v.bottom()+y);
                }
            MS_show();
            resetViewport();
            }
        }
}
Beispiel #2
0
void MVListBase::hScrollTo(int i,ibool redraw)
/****************************************************************************
*
* Function:     MVListBase::hScrollTo
* Parameters:   i       - New cell to scroll to in horizontal direction
*               redraw  - True if list should be redrawn
*
* Description:  Scrolls the list to start at the new cell 'i' in the
*               horizontal direction, redrawing all necessary cells to do
*               this.
*
****************************************************************************/
{
    if (visible.left() != i) {
        // Setup the viewport for redrawing the list directly, and redraw
        // it.
        MVRect  v(visible & range);
        MVRect  b(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.right()-rightIndent,
                  bounds.bottom()-botIndent);
        int     dx = (v.left() - i) * cellSize.x;

        visible.moveTo(i,vScroll ? vScroll->getValue() : 0);
        hScroll->setValue(i);

        if (redraw) {
            CHECK(owner != NULL);
            setupOwnerViewport();
            MS_obscure();

            if (i < v.left()) {
                b.right() -= dx;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,bounds.left()+leftIndent+dx,b.top(),MGL_REPLACE_MODE);
                for (int y = v.top(); y < v.bottom(); y++)
                    for (int x = i; x < v.left(); x++)
                        drawCell(x,y);
                }
            else {
                b.left() -= dx;
                if (!b.isEmpty())
                    dc.bitBlt(dc,b,bounds.left()+leftIndent,b.top(),MGL_REPLACE_MODE);
                i -= v.left();
                for (int y = v.top(); y < v.bottom(); y++)
                    for (int x = 0; x < i; x++)
                        drawCell(v.right() + x,y);
                }
            MS_show();
            resetViewport();
            }
        }
}
    virtual void onDrawContent(SkCanvas* canvas) {
        const SkRect bounds = SkRect::MakeWH(W, H);
        static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };

        canvas->translate(SkIntToScalar(4), SkIntToScalar(4));

        for (int alpha = 0; alpha < 4; ++alpha) {
            canvas->save();
            canvas->save();
            for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); ++i) {
                if (6 == i) {
                    canvas->restore();
                    canvas->translate(W * 5, 0);
                    canvas->save();
                }
                SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
                
                canvas->drawRect(bounds, fBGPaint);
                canvas->saveLayer(&bounds, NULL);
                SkScalar dy = drawCell(canvas, mode,
                                       gAlphaValue[alpha & 1],
                                       gAlphaValue[alpha & 2]);
                canvas->restore();

                canvas->translate(0, dy * 5 / 4);
                SkSafeUnref(mode);
            }
            canvas->restore();
            canvas->restore();
            canvas->translate(W * 5 / 4, 0);
        }
    }
Beispiel #4
0
void drawCells() {
  uchar x,y;
  for(y=0; y<9; y++)
    for(x=0; x<9; x++)
      drawCell(x,y);
  drawCursor();
}
Beispiel #5
0
void MVListBase::drawCell(int i,int j)
/****************************************************************************
*
* Function:     MVListBase::drawCell
* Parameters:   i,j - Location of the cell to draw
*
* Description:  Draws the cell, clipped to the bounds of the list. This
*               routine assumes that the list is entirely visible.
*
****************************************************************************/
{
    MS_obscure();

    if (visible.includes(i,j)) {
        // Compute the bounding box for the cell
        int dx = (i-visible.left()) * cellSize.x;
        int dy = (j-visible.top()) * cellSize.y;

        MVRect r(bounds.left()+leftIndent+dx,
                 bounds.top()+topIndent+dy,
                 bounds.left()+leftIndent+dx+cellSize.x,
                 bounds.top()+topIndent+dy+cellSize.y);
        r &= MVRect(bounds.left()+leftIndent,
                    bounds.top()+topIndent,
                    bounds.right()-rightIndent,
                    bounds.bottom()-botIndent);
        if (!r.isEmpty()) {
            dc.setClipRect(r);
            drawCell(i,j,r);
            }
        }

    MS_show();
}
void GridGraphRenderer::render() {
	for (int row=0; row < m_graph->getNumRows(); row++) {
		for (int col=0; col < m_graph->getNumCols(); col++) {
			drawCell(row, col);
		}
	}
}
Beispiel #7
0
void PuzzlePrinter::drawBlocks (const ksudoku::Puzzle * puzzle,
				const SKGraph * graph)
{
    QVector<int> edges (graph->size(), 0);	// One bitmap per cell.
    int order = graph->order();

    for (int n = 0; n < graph->cliqueCount(); n++) {
        // Find out which groups are blocks of cells, not rows or columns.
        QVector<int> clique = graph->clique (n);
        int x = graph->cellPosX (clique.at (0));
        int y = graph->cellPosY (clique.at (0));
        bool isRow = true;
        bool isCol = true;
        for (int k = 1; k < order; k++) {
            if (graph->cellPosX (clique.at (k)) != x) isRow = false;
            if (graph->cellPosY (clique.at (k)) != y) isCol = false;
        }
        if (isRow || isCol) continue;	// Skip rows and columns.

        // Mark the outside edges of each block.
	markEdges (clique, puzzle, graph, edges);
    }

    // Draw each cell in the puzzle.
    for (int n = 0; n < graph->size(); n++) {
        if (puzzle->value (n) < 0) {
            continue;				// Do not draw unused cells.
	}
	drawCell (graph->cellPosX (n), graph->cellPosY (n), edges.at (n));
    }
}
void AgentsVisualization::drawTcell(const AgentType a_t, int x, int y, int p) const
{
  switch(a_t) {
    case TGAM:
    {
      if(!_drawTgam) return;
      glColor4f(1.0f, 0.71f, 0.76f, _gridAlpha);
      break;
    }
    case TREG:
    {
      if(!_drawTreg) return;
      glColor4f(0.0f, 1.0f, 1.0f, _gridAlpha);
      break;
    }
    case TCYT:
    {
      if(!_drawTcyt) return;
      glColor4f(0.5f, 0.0f, 0.5f, _gridAlpha);
      break;
    }
    default:
    {
      qWarning("Not a valid tcell type!"); return;
    }
  }
  if(_drawSquares)
    drawQuad(x, y);
  else
  {
    float rngx = stratify[x][y][p]*0.25f+0.75f;
    float rngy = stratify[x][y][1-p]*0.25f+0.75f;
    drawCell((x+rngx*(2*p-1)*(0.5f-0.3f)), (y+rngy*(2*p-1)*(0.5f-0.3f)), 0.005f, 0.3f);
  }
}
Beispiel #9
0
void Monitor::drawStartUp() {
    const int MID_X = (sim::MONITOR_CELLS_PER_SCREEN_WIDTH / 2) - 1;
    const int MID_Y = (sim::MONITOR_CELLS_PER_SCREEN_HEIGHT / 2) - 1;
    const int NUM_LINES = 4;

    fill( BackgroundColor { 0x9 } );

    auto drawCentered = [&] ( int lineIndex, const std::uint8_t* line, std::size_t length ) {
        for ( std::size_t i = 0; i < length; ++i ) {
            drawCell( MID_X - (length / 2) + i,
                      MID_Y - (NUM_LINES / 2) + lineIndex,
                      Character { line[i] },
                      ForegroundColor { 0xe },
                      BackgroundColor { 0x9 } );
        }
    };

    const std::array<std::uint8_t, 14> LINE1 = { 'N', 'Y', 'A', ' ', 'E', 'L', 'E', 'K', 'T', 'R', 'I', 'S', 'K', 'A'};
    const std::array<std::uint8_t, 7 > LINE2 = { 'L', 'E', 'M', '1', '8', '0', '2' };
    const std::array<std::uint8_t, 18> LINE3 = {'L', 'o', 'w', ' ', 'E', 'n', 'e', 'r', 'g', 'y', ' ', 'M', 'o', 'n', 'i', 't', 'o', 'r' };

    drawCentered( 0, LINE1.data(), LINE1.size() );
    drawCentered( 2, LINE2.data(), LINE2.size() );
    drawCentered( 3, LINE3.data(), LINE3.size() );
}
Beispiel #10
0
/*
 * widget events
 */
void KkrBoardView::paintEvent(QPaintEvent * /*e*/)
{
    QPainter p{this};

    const auto C = m_pBoardData->getNumCols();
    if(C < 3)
        return;

    // frame
    p.fillRect(MARGIN, MARGIN, m_frame_width, FRAME_THICK, Qt::SolidPattern);
    p.fillRect(MARGIN, MARGIN+m_frame_height-FRAME_THICK, m_frame_width, FRAME_THICK, Qt::SolidPattern);
    p.fillRect(MARGIN, MARGIN, FRAME_THICK, m_frame_height, Qt::SolidPattern);
    p.fillRect(MARGIN+m_frame_width-FRAME_THICK, MARGIN, FRAME_THICK, m_frame_height, Qt::SolidPattern);

    // cell borders
    const int TL = MARGIN + FRAME_THICK;
    for(int yi = 1; yi < m_pBoardData->getNumRows(); ++yi) {
        const int y = TL - BORDER_THICK + yi * (BORDER_THICK+CELL_WIDTH);
        p.fillRect(TL, y, m_inner_width, BORDER_THICK, Qt::SolidPattern);
    }

    for(int xi = 1; xi < m_pBoardData->getNumCols(); ++xi) {
        const int x = TL - BORDER_THICK + xi * (BORDER_THICK+CELL_WIDTH);
        p.fillRect(x, TL, BORDER_THICK, m_inner_height, Qt::SolidPattern);
    }

    for(int c = 0; c < m_pBoardData->getNumCols(); ++c) {
        for(int r = 0; r < m_pBoardData->getNumRows(); ++r) {
            drawCell(p, c, r);
        }
    }
}
Beispiel #11
0
void drawDiscoveredField()
{
  for (int x=0; x<boardSize; x++) {
    for (int y=0; y<boardSize; y++) { 
      drawCell(x, y, discoveredField[x][y]);	
    }
  }
}
Beispiel #12
0
void render(int cells[], int size)
{
	int c;
	for(c = 0; c < size; c++)
	{
		if(cells[c] == 0) eraseCell(c % ys, c / ys);
		else drawCell(c % ys, c / ys);
	}
}
bool AgentsVisualization::drawMac(const Mac* pMac, int x, int y, int p, const double minRatio, const double maxRatio) const
{
  if(!pMac) return false;
  if(pMac->getAgentType() != MAC) return false;
  char state = (pMac->getNFkB() << AgentsWidget::NFKB) | (pMac->getStat1() << AgentsWidget::STAT1) | (pMac->isDeactivated() << AgentsWidget::DEACT);
  state |= (state == 0) << AgentsWidget::OTHER;
  state &= (_macFilter[pMac->getState()][AgentsWidget::NFKB] << AgentsWidget::NFKB)
           | (_macFilter[pMac->getState()][AgentsWidget::STAT1] << AgentsWidget::STAT1)
           | (_macFilter[pMac->getState()][AgentsWidget::DEACT] << AgentsWidget::DEACT)
           | (_macFilter[pMac->getState()][AgentsWidget::OTHER] << AgentsWidget::OTHER);
  if(!(state && _macFilter[pMac->getState()][AgentsWidget::ENBL]))
    return false; //Don't draw macs in a disabled state

  if(_drawm1m2 == 1)
  {
    if(pMac->getM1M2Ratio() > _m1m2thres)
      glColor4f(0,1,0, _gridAlpha);   //Green if over the threshold
    else
      glColor4f(1,0,0, _gridAlpha);    //Red otherwise
  }
  else if(_drawm1m2 != 0)
  {
    if(minRatio != maxRatio)
    {
      const double ratio = (pMac->getM1M2Ratio() - minRatio) / (maxRatio - minRatio);
      glColor4f(1-ratio, ratio, 0, _gridAlpha);
    }
    else
      glColor4f(1, 0, 0, _gridAlpha);
  }
  else {
    switch(pMac->getState())
    {
      case Mac::MAC_RESTING:
        glColor4f(0.0f, 1.0f, 0.0f, _gridAlpha); break;
      case Mac::MAC_INFECTED:
        glColor4f(1.0f, 0.65f, 0.0f, _gridAlpha); break;
      case Mac::MAC_CINFECTED:
        glColor4f(1.0f, 0.0f, 0.0f, _gridAlpha); break;
      case Mac::MAC_ACTIVE:
        glColor4f(0.0f, 0.0f, 1.0f, _gridAlpha); break;
      default:
        qWarning("Unknown state '%d' for mac", pMac->getState()); return false;
    }
  }
  if(_drawSquares)
    drawQuad(x, y);
  else
  {
    float rngx = stratify[x][y][p]*0.25f+0.75f;
    float rngy = stratify[x][y][1-p]*0.25f+0.75f;
    drawCell((x+rngx*(2*p-1)*(0.5f-0.375f)), (y+rngy*(2*p-1)*(0.5f-0.375f)), 0.00f, 0.375f);
  }
  return true;
}
Beispiel #14
0
void
draw_wire(ModeInfo * mi)
{
	int         offset, i, j, found = 0;
	unsigned char *z, *znew;
	circuitstruct *wp;

	if (circuits == NULL)
		return;
	wp = &circuits[MI_SCREEN(mi)];
	if (wp->newcells == NULL)
		return;

	MI_IS_DRAWN(mi) = True;

	/* wires do not grow so min max stuff does not change */
	for (j = wp->minrow; j <= wp->maxrow; j++) {
		for (i = wp->mincol; i <= wp->maxcol; i++) {
			offset = j * wp->bncols + i;
			z = wp->oldcells + offset;
			znew = wp->newcells + offset;
			if (*z != *znew) {	/* Counting on once a space always a space */
				found = 1;
				*z = *znew;
				if (!addtolist(mi, i - 2, j - 2, *znew - 1)) {
					free_wire(MI_DISPLAY(mi), wp);
					return;
				}
			}
		}
	}
	for (i = 0; i < COLORS - 1; i++)
		if (!draw_state(mi, i)) {
			free_wire(MI_DISPLAY(mi), wp);
			return;
		}
	if (++wp->generation > MI_CYCLES(mi) || !found) {
		init_wire(mi);
		return;
	} else
		do_gen(wp);

	if (wp->redrawing) {
		for (i = 0; i < REDRAWSTEP; i++) {
			if ((*(wp->oldcells + wp->redrawpos))) {
				drawCell(mi, wp->redrawpos % wp->bncols - 2,
					 wp->redrawpos / wp->bncols - 2, *(wp->oldcells + wp->redrawpos) - 1);
			}
			if (++(wp->redrawpos) >= wp->bncols * (wp->bnrows - 2)) {
				wp->redrawing = 0;
				break;
			}
		}
	}
}
void Renderer::drawForeground (cairo_t *cr)
{
	int x, y;

	cairo_scale(cr, 1.0 * pxwidth / width, 1.0 * pxheight / height);

	for (y = 0; y<height; y++) {
		for (x = 0; x<width; x++) {
			drawCell (cr, x, y);
		}
	}
}
Beispiel #16
0
void Dstar::draw() {

  ds_ch::iterator iter;
  ds_oh::iterator iter1;
  state t;

  list<state>::iterator iter2;

  glBegin(GL_QUADS);
  for(iter=cellHash.begin(); iter != cellHash.end(); iter++) {
    if (iter->second.cost == 1) glColor3f(0,1,0);
    else if (iter->second.cost < 0 ) glColor3f(1,0,0);
    else glColor3f(0,0,1);
    drawCell(iter->first,0.45);
  }

  glColor3f(1,1,0);
  drawCell(s_start,0.45);
  glColor3f(1,0,1);
  drawCell(s_goal,0.45);

  for(iter1=openHash.begin(); iter1 != openHash.end(); iter1++) {
    glColor3f(0.4,0,0.8);
    drawCell(iter1->first, 0.2);
  }


  glEnd();

  glLineWidth(4);
  glBegin(GL_LINE_STRIP);
  glColor3f(0.6, 0.1, 0.4);

  for(iter2=path.begin(); iter2 != path.end(); iter2++) {
    glVertex3f(iter2->x, iter2->y, 0.2);
  }
  glEnd();

}
Beispiel #17
0
void Cell::paintEvent(QPaintEvent *)
{
    if(isSelect)    {
        QPainter painter(this);
        painter.setBrush(QColor(120,65,15));
        painter.drawRect(0, 0, width(), height());
        drawChecker();
    }
    else {
        drawCell();
    }
    update();
}
Beispiel #18
0
void AStarAlgo::drawAll(SDL_Renderer* renderer)
{
	//Open nodes
	for (auto iter = openList.begin(); iter != openList.end(); iter++)
		drawCell(renderer, iter->first.x, iter->first.y, OPEN);

	//Closed nodes
	for (auto iter = closedList.begin(); iter != closedList.end(); iter++)
		drawCell(renderer, iter->first.x, iter->first.y, CLOSED);

	//Found path
	if (complete)
	{
		SDL_Point node = *endLoc;
		//cout << "endLoc: " << node.x << ", " << node.y << endl;
		drawCell(renderer, node.x, node.y, PATH);
		while (node.x != startLoc->x || node.y != startLoc->y)
		{
			drawCell(renderer, node.x, node.y, PATH);
			node = closedList[node].parent;
		}
	}
}
Beispiel #19
0
void Board::draw()//GLfloat scale, GLfloat translate_x, GLfloat translate_y)
{
	//glLoadIdentity();
	//glScalef(scale, scale, scale);
	//glTranslatef(translate_x, translate_y, 0);
	glBegin(GL_QUADS);
	for (int x = 0; x < BOARD_WIDTH; x++)
	{
		for (int y = 0; y < BOARD_HEIGHT; y++)
		{
			drawCell(x, y);
		}
	}
	glEnd();
}
Beispiel #20
0
void View::drawWorld()
{
	int maxRow = model->getWorld()->getMaxRows();
	int maxCol = model->getWorld()->getMaxCols();

	glColor3f(0, 0, 1);	// couleur du labyrinthe
	for(int i = 0; i < maxRow; i++) 
	{
		for(int j = 0; j < maxCol; j++) 
		{
			if(i == 0 || j == 0 || i == maxRow-1 || j == maxCol-1) 
				continue;

			drawCell(*model->getWorld()->getMap()[i][j],i,j);
		}
	}
}
Beispiel #21
0
void Game::Cycle(){
	char c;
	while (!_kbhit()) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0);
		drawCell(FrameA);
		update(FrameA, FrameB);
		Sleep(200);
	}
	_getch();
	c = _getch();
	if (c == 'e')
		return;
		
	for (int i = 0; i < 40; i++)
		FrameA[rand() % 25][rand() % 80] = FrameB[rand() % 25][rand() % 80] = 1;
	Cycle();
}
Beispiel #22
0
void redrawScreen(unsigned char force)
{
    int i, j;

    for(i=0; i<H_NUMCELLS; i++)
    {
        for(j=0; j<V_NUMCELLS; j++)
        {
            if(force || (pattern[i][j].val != dispPattern[i][j].val || pattern[i][j].color != dispPattern[i][j].color))
            {
                drawCell(i, j);
                dispPattern[i][j].val = pattern[i][j].val;
                dispPattern[i][j].color = pattern[i][j].color;
            }
        }
    }
    rb->lcd_update();
}
Beispiel #23
0
void Monitor::drawFromMemory() {
    Word w;

    for ( int y = 0; y < sim::MONITOR_CELLS_PER_SCREEN_HEIGHT; ++y ) {
        for ( int x = 0; x < sim::MONITOR_CELLS_PER_SCREEN_WIDTH; ++x ) {
            auto loc = (y * sim::MONITOR_CELLS_PER_SCREEN_WIDTH) + x + _state.videoOffset;
            w = _memory->read( loc );

            bool doBlink = (w & 0x0080) != 0;
            auto ch = static_cast<std::uint8_t>( w & 0x007f );
            auto fg = static_cast<std::uint8_t>( (w & 0xf000) >> 12 );
            auto bg = static_cast<std::uint8_t>( (w & 0x0f00) >> 8 );

            if ( doBlink ) {
                _state.isBlinking[index( x, y )] = true;
            }

            drawCell( x, y,
                      Character { ch },
                      ForegroundColor { fg },
                      BackgroundColor { bg } );
        }
    }
}
Beispiel #24
0
void PuzzlePrinter::drawCages (const ksudoku::Puzzle * puzzle,
			       const SKGraph * graph, bool killerStyle)
{
    QVector<int> edges (graph->size(), 0);	// One bitmap per cell.
    for (int n = 0; n < graph->cageCount(); n++) {
        // Mark the outside edges of each cage.
	markEdges (graph->cage (n), puzzle, graph, edges);
    }
    if (killerStyle) {
	drawKillerSudokuCages (graph, edges);
    }
    else {
	// Draw each cell in the puzzle.
	for (int n = 0; n < graph->size(); n++) {
	    if (puzzle->value (n) < 0) {
		continue;			// Do not draw unused cells.
	    }
	    drawCell (graph->cellPosX (n), graph->cellPosY (n), edges.at (n));
	}
    }
    for (int n = 0; n < graph->cageCount(); n++) {
	drawCageLabel (graph, n, killerStyle);
    }
}
Beispiel #25
0
void CSolverView::OnDraw(CDC* pDC)
{
	CSolverDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	int shift_x = pDoc->max_row_blocks() * cell_size;
	int shift_y = pDoc->max_col_blocks() * cell_size;

	pDC->SetViewportOrg(shift_x, shift_y);

	// grid
	drawGrid(pDC, cell_size, 1, RGB(200, 200, 200), pDoc->max_row_blocks(), pDoc->max_col_blocks());
	drawGrid(pDC, cell_size, 5, RGB(0, 0, 0));

	// numbers
	drawNumbers(pDC);

	// field
	for (size_t y = 0; y < pDoc->rows(); ++y)
		for (size_t x = 0; x < pDoc->cols(); ++x)
			drawCell(pDC, cell_size, x, y);
}
Beispiel #26
0
int main(int argc, char *argv[])
{
	if(argc >= 2)
	{
		if(strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0)
		{
			printf("\nConway\n");
			printf("Copyright 2015 Harley Wiltzer\n\n");
			printf("conway:\t\tOpen conway with a random color\n");
			printf("conway 1:\tOpen conway blue theme\n");
			printf("conway 2:\tOpen conway red theme\n");
			printf("conway 3:\tOpen conway green theme\n");
			printf("conway 4:\tOpen conway yellow theme\n");
			printf("conway 5:\tOpen conway light blue theme\n");
			printf("conway 6:\tOpen conway orange theme\n");
			printf("conway 7:\tOpen conway white theme\n");
			printf("\n");
			printf("While running conway...\n");
			printf("=======================\n");
			printf("q:\t\tClose conway\n");
			printf("space:\t\tActivate/Kill cell\n");
			printf("enter:\t\tStart ticking\n");
			printf("h:\t\tMove cursor left\n");
			printf("j:\t\tMove cursor down\n");
			printf("k:\t\tMove cursor up\n");
			printf("l:\t\tMove cursor right\n");
			printf("d:\t\tClear all cells\n");
			printf("=:\t\tIncrease the amount of ticks by 10\n");
			printf("-:\t\tDecrease the amount of ticks by 10\n");
			printf("+:\t\tIncrease the amount of ticks by 1\n");
			printf("_:\t\tDecrease the amount of ticks by 1\n");
			return 0;
		}
	}
	int i, c;
	
	initCurses();
	showSplash();
	totalTicks = 0;	
	refresh();
	getch();

	win = createWindow(WIN_WIDTH,rows,0,cols - WIN_WIDTH - 1);
	cols = cols - WIN_WIDTH - 1;
	xs = rows;
	ys = cols / 2;
	area = rows * cols;
	game = createWindow(cols - 1,rows,0,0);
	ticks = DEFAULT_TICKS;
	
	int cells[area / 2];
	for(i = 0; i < area/2; i++)
	{
		cells[i] = 0;
	}

	x = y = row = col = 0;
	if(has_colors() == 0) wprintw(game,"NO COLORS\n");

	if(argc < 2)
	{
		srand(time(NULL));
		color = rand()%7 + 1;
	}
	else
	{
		if(atoi(argv[1]) > 7 || atoi(argv[1]) < 1)
		{
			srand(time(NULL));
			color = rand()%7 + 1;
		}
		else 
		{
			color = atoi(argv[1]);
		}
	}

	x = ys/2;
	y = xs/2;
	wmove(game,y, x * 2);
	x = 2;
	y = 2;
	wrefresh(game);
	updateWin(cells,area/2);
	wmove(game,y,x * 2);

	x = ys/2;
	y = xs/2;

	wmove(game,y,x * 2);

	while((ch = getch()) != 'q')
	{
		wclear(game);
		wclear(win);
		int r, c;
		
		render(cells,area/2);	
		wmove(game,y, x * 2);

		switch(ch)
		{
			case 'h':
				if (x % ys == 0) break;
				x -= 1;
				wmove(game,y, x * 2);
				wrefresh(game);
				break;
			case 'j':
				if ((y + 1) % xs == 0) break;
				y += 1;
				wmove(game,y, x * 2);
				wrefresh(game);
				break;
			case 'k':
				if (y % xs == 0) break;
				y -= 1;
				wmove(game,y, x * 2);
				wrefresh(game);
				break;
			case 'l':
				if((x+1)%ys == 0) break;
				x += 1;
				wmove(game,y, x * 2);
				wrefresh(game);
				break;
			case ' ':
				cells[y * ys + x] = !cells[y * ys + x];
				if(cells[y * ys + x]) drawCell(x,y);
				else eraseCell(x,y);
				updateWin(cells,area/2);
				break;
			case '\n':
				update(cells, area/2);
				break;
			case 'd':
				memset(cells,0,area/2);
				int q;
				for(q = 0; q < area/2; q++)
				{
					cells[q] = 0;
				}
				totalTicks = 0;
				render(cells, area/2);
				updateWin(cells,area/2);
				break;
			case '=':
				ticks += 10;
				updateWin(cells,area/2);
				break;
			case '-':
				if(ticks >= 20) ticks -= 10;
				updateWin(cells,area/2);
				break;
			case '+':
				ticks++;
				updateWin(cells,area/2);
				break;
			case '_':
				if(ticks > 2) ticks--;
				updateWin(cells, area/2);
				break;
			default:
				break;
		}
		updateWin(cells,area/2);
		wrefresh(game);
	}
	destroyWindow(game);
	destroyWindow(win);
	endwin();
	return 0;
}
Beispiel #27
0
void clearCursor() {
  drawCell(cursorX, cursorY);
}
Beispiel #28
0
void GUITable::draw()
{
	if (!IsVisible)
		return;

	gui::IGUISkin *skin = Environment->getSkin();

	// draw background

	bool draw_background = m_background.getAlpha() > 0;
	if (m_border)
		skin->draw3DSunkenPane(this, m_background,
				true, draw_background,
				AbsoluteRect, &AbsoluteClippingRect);
	else if (draw_background)
		skin->draw2DRectangle(this, m_background,
				AbsoluteRect, &AbsoluteClippingRect);

	// get clipping rect

	core::rect<s32> client_clip(AbsoluteRect);
	client_clip.UpperLeftCorner.Y += 1;
	client_clip.UpperLeftCorner.X += 1;
	client_clip.LowerRightCorner.Y -= 1;
	client_clip.LowerRightCorner.X -= 1;
	if (m_scrollbar->isVisible()) {
		client_clip.LowerRightCorner.X =
				m_scrollbar->getAbsolutePosition().UpperLeftCorner.X;
	}
	client_clip.clipAgainst(AbsoluteClippingRect);

	// draw visible rows

	s32 scrollpos = m_scrollbar->getPos();
	s32 row_min = scrollpos / m_rowheight;
	s32 row_max = (scrollpos + AbsoluteRect.getHeight() - 1)
			/ m_rowheight + 1;
	row_max = MYMIN(row_max, (s32) m_visible_rows.size());

	core::rect<s32> row_rect(AbsoluteRect);
	if (m_scrollbar->isVisible())
		row_rect.LowerRightCorner.X -=
			skin->getSize(gui::EGDS_SCROLLBAR_SIZE);
	row_rect.UpperLeftCorner.Y += row_min * m_rowheight - scrollpos;
	row_rect.LowerRightCorner.Y = row_rect.UpperLeftCorner.Y + m_rowheight;

	for (s32 i = row_min; i < row_max; ++i) {
		Row *row = &m_rows[m_visible_rows[i]];
		bool is_sel = i == m_selected;
		video::SColor color = m_color;

		if (is_sel) {
			skin->draw2DRectangle(this, m_highlight, row_rect, &client_clip);
			color = m_highlight_text;
		}

		for (s32 j = 0; j < row->cellcount; ++j)
			drawCell(&row->cells[j], color, row_rect, client_clip);

		row_rect.UpperLeftCorner.Y += m_rowheight;
		row_rect.LowerRightCorner.Y += m_rowheight;
	}

	// Draw children
	IGUIElement::draw();
}
Beispiel #29
0
void Dstar::draw() const {

  ds_ch::const_iterator iter;
  ds_oh::const_iterator iter1;
  state t;

  list<state>::const_iterator iter2;
  

  glBegin(GL_QUADS);
  for(iter=cellHash.begin(); iter != cellHash.end(); iter++) {
    if (iter->second.cost == 1) glColor3f(0,1,0);
    else if (iter->second.cost < 0 ) glColor3f(1,0,0);
    else glColor3f(0,0,1);
    drawCell(iter->first,0.5);
  }

  glColor3f(1,1,0);
  drawCell(s_start,0.5);
  glColor3f(1,0,1);
  drawCell(s_goal,0.5);

  for(iter1=openHash.begin(); iter1 != openHash.end(); iter1++) {
    if (iter1->second.v[0] < iter1->second.v[1]) glColor3f(0.9,0.9,0.9);
    else glColor3f(0.0,0.0,0.0);
    drawCell(iter1->first, 0.2);
  }
 /*
  ds_pq Q = openList;
  while(!Q.empty()) {
    t = Q.top();
    Q.pop();
  
    glColor3f(0.0,0.0,1.0);
    drawCell(t, 0.15);
  }
  */

  glColor3f(0,0,1);
  drawCell(qstate, .45);

  glEnd();

  
  char str[256];

  iter1 = openHash.find(qstate);
  iter  = cellHash.find(qstate);
  
  float cury=0.01;

  ds_pq Q = openList;
  while(!Q.empty()) {
    t = Q.top();
    Q.pop();
    
    if (t == qstate) {
      sprintf(str,"openList: %d [%f,%f] \n", t.num, t.k.first, t.k.second);
      DisplayStr(str,GLUT_BITMAP_HELVETICA_12,1,1,1,0.01,cury+=0.02);
    }
  }
  
  if (iter1 == openHash.end()) sprintf(str,"openHash: NO [0,0] \n");
  else sprintf(str,"openHash: YES [%d,%d] \n", iter1->second.v[0], iter1->second.v[1]);
  DisplayStr(str,GLUT_BITMAP_HELVETICA_12,1,1,1,0.01,cury+=0.02);

  if (iter == cellHash.end()) sprintf(str,"cellHash: NO g,rhs,cost: [%f,%f,%f] \n", getG(qstate), getRHS(qstate), C1);
  else sprintf(str,"cellHash: YES g,rhs,cost: [%f,%f,%f] \n", iter->second.g, iter->second.rhs, iter->second.cost);  
  DisplayStr(str,GLUT_BITMAP_HELVETICA_12,1,1,1,0.01,cury+=0.02);


  sprintf(str,"cell: (%d,%d)\n", qstate.x, qstate.y);
  DisplayStr(str,GLUT_BITMAP_HELVETICA_12,1,1,1,0.01,cury+=0.02);



  glLineWidth(4);
  glBegin(GL_LINE_STRIP);
  glColor3f(0.6, 0.1, 0.4);

  for(iter2=path.path.begin(); iter2 != path.path.end(); iter2++) {
    glVertex3f(iter2->x, iter2->y, 0.2);
  }
  glEnd();

}
Beispiel #30
0
void MVListBase::draw(const MVRect&)
/****************************************************************************
*
* Function:     MVListBase::draw
* Parameters:   clip    - Clipping rectangle to use when drawing
*
* Description:  Draws the representation of the list.
*
****************************************************************************/
{
    MS_obscure();

    MVRect  clipBounds(bounds.left()+leftIndent,
                       bounds.top()+topIndent,
                       bounds.right()-rightIndent,
                       bounds.bottom()-rightIndent);

    // Clear the background for the list
    dc.setColor(getColor(scListInterior));
    dc.fillRect(bounds);
    MV_setBorderColors(getColor(scShadow),getColor(scHighlight));
    MV_drawBorder(bounds,MV_BDR_OUTSET,1);
    MV_setBorderColors(getColor(scBlack),getColor(scButtonFace));
    MV_drawBorder(bounds.insetBy(1,1),MV_BDR_OUTSET,1);

    // Draw each of the items in the list. Note that we set up the clip
    // rectangle to clip everything to the bounds of the list correctly,
    // and that we only draw those items that are visible and within the
    // range of selectable items.
    MVRect  v(visible & range);
    MVRect  start(bounds.left()+leftIndent,
                  bounds.top()+topIndent,
                  bounds.left()+leftIndent+cellSize.x,
                  bounds.top()+topIndent+cellSize.y);

    for (int i = v.left(); i < v.right(); i++) {
        MVRect r(start);
        for (int j = v.top(); j < v.bottom(); j++) {
            MVRect c(r);
            c &= clipBounds;
            if (!c.isEmpty()) {
                dc.setClipRect(c);
                drawCell(i,j,r);
                }
            r.top() += cellSize.y;  r.bottom() += cellSize.y;
            }
        start.left() += cellSize.x; start.right() += cellSize.x;
        }

    if (range.isEmpty()) {
        // There is nothing to draw in the list (it is currently empty),
        // but if the list is selected then we should draw a dotted outline
        // around the first empty cell to ensure the user knows when the
        // list is selected.
        if ((state & sfFocused)) {
            attributes_t attr;
            dc.getAttributes(attr);
            dc.setColor(getColor(scListCell));
            dc.setPenStyle(MGL_BITMAP_TRANSPARENT);
            dc.setPenBitmapPattern(0,MGL_GRAY_FILL);
            dc.usePenBitmapPattern(0);
            drawRect(bounds.left()+leftIndent,
                     bounds.top()+topIndent,
                     bounds.left()+leftIndent+cellSize.x,
                     bounds.top()+topIndent+cellSize.y);
            dc.restoreAttributes(attr);
            }
        }

    MS_show();
}