示例#1
0
SquareMatrix::~SquareMatrix() {
  Erase();
}
示例#2
0
// This function returns the number of pixels of the text that
// were clipped if the text does not fit into the clipping rect.
// If the text all fit, it returns 0.
int
BeOSCanvas::RenderText( int iFontHeight, Rect& oClipRect,
                        string& oText, AlignEnum eAlign,
                        Font* pFont, const Color& oColor,
                        bool bBold, bool bItalic, bool bUnderline )
{
    Erase( oClipRect );

    BView* v = m_pBufferBitmap->OffscreenView();
    if ( !v ) return 0;

    BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();
    assert( bitmap );

    BFont font;
    font_height fontHeight;
    BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
                    float(oClipRect.x2-1), float(oClipRect.y2-1) );
    BRegion clipRegion;
    clipRegion.Set( clipRect );

    if ( !bitmap->Lock() )
    {
        puts( "lock failed" );
        return 0;
    }

    v->ConstrainClippingRegion( &clipRegion );
    v->SetDrawingMode( B_OP_OVER );
    if ( bBold )
    {
        v->SetFont( be_bold_font );
    }
    else
    {
        v->SetFont( be_plain_font );
    }
    v->SetFontSize( (float)iFontHeight - 1 );
    v->GetFont( &font );
    font.GetHeight( &fontHeight );
    
    float width = v->StringWidth(oText.c_str(), oText.size());
    
    if(eAlign == eCenter)
        v->MovePenTo( float(oClipRect.x1) +
                      (float(oClipRect.x2 - oClipRect.x1) - width)/2,
                      float(oClipRect.y2-fontHeight.descent) );	
    else if (eAlign == eRight)
        v->MovePenTo( float(oClipRect.x2) - width,
                      float(oClipRect.y2-fontHeight.descent) );
    else
        v->MovePenTo( float(oClipRect.x1),
                      float(oClipRect.y2-fontHeight.descent) );

    v->DrawString( oText.c_str() );
    v->Sync();

    bitmap->Unlock();

    Invalidate( oClipRect );

    return (width < oClipRect.Width()) ? 0 : int(width - oClipRect.Width());
}
示例#3
0
文件: mouse.c 项目: rmallof/reactos
void
whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_FREESEL:
            if (ptSP == 0)
                newReversible();
            ptSP++;
            if (ptSP % 1024 == 0)
                ptStack = HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, ptStack, sizeof(POINT) * (ptSP + 1024));
            ptStack[ptSP].x = max(0, min(x, imgXRes));
            ptStack[ptSP].y = max(0, min(y, imgYRes));
            resetToU1();
            Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
            break;
        case TOOL_RECTSEL:
        {
            POINT temp;
            resetToU1();
            temp.x = max(0, min(x, imgXRes));
            temp.y = max(0, min(y, imgYRes));
            rectSel_dest[0] = rectSel_src[0] = min(start.x, temp.x);
            rectSel_dest[1] = rectSel_src[1] = min(start.y, temp.y);
            rectSel_dest[2] = rectSel_src[2] = max(start.x, temp.x) - min(start.x, temp.x);
            rectSel_dest[3] = rectSel_src[3] = max(start.y, temp.y) - min(start.y, temp.y);
            RectSel(hdc, start.x, start.y, temp.x, temp.y);
            break;
        }
        case TOOL_RUBBER:
            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, fg, 1);
            break;
        case TOOL_BRUSH:
            Brush(hdc, last.x, last.y, x, y, fg, brushStyle);
            break;
        case TOOL_AIRBRUSH:
            Airbrush(hdc, x, y, fg, airBrushWidth);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
            break;
        case TOOL_BEZIER:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            switch (pointSP)
            {
                case 1:
                    Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg,
                         lineWidth);
                    break;
                case 2:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth);
                    break;
                case 3:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth);
                    break;
            }
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            if (pointSP + 1 >= 2)
                Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE);
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
    }

    last.x = x;
    last.y = y;
}
示例#4
0
bool CWalletDB::EraseTx(uint256 hash)
{
    nWalletDBUpdateCounter++;
    return Erase(std::make_pair(std::string("tx"), hash));
}
示例#5
0
	void PopFront()
	{
		Erase(Begin());
	}
示例#6
0
void Line::DeleteChar()
{
    if( all )
        Erase( active - 1, active );
}
示例#7
0
bool CWalletDB::ErasePool(int64_t nPool)
{
    nWalletDBUpdateCounter++;
    return Erase(std::make_pair(std::string("pool"), nPool));
}
示例#8
0
/// @todo Check boundaries
bool
Console::AnsiEscFilter(const char c)
{
	if (_ansiBufferPos == 0 && c == (char)0x9B) {
		_ansiBufferPos = 2;
		return true;
	}else if (_ansiBufferPos == 0 && c == (char)0x1B) {
		_ansiBufferPos = 1;
		return true;
	}else if (_ansiBufferPos == 1) {
		if (c == '[') {
			_ansiBufferPos = 2;
			return true;
		} else {
			_ansiBufferPos = 0;
			return false;
		}
	}else if (_ansiBufferPos > 1) {
		if (isdigit(c) || c == ';') {
			_ansiBuffer[_ansiBufferPos++] = c;
		} else {
			_ansiBuffer[_ansiBufferPos] = '\0';
			_ansiBufferPos = 0;

			long params[10] = {0};
			const int parQty = AnsiEscParseParams(&_ansiBuffer[2], params);
			switch(c) {
				case 'c':	// Reset Device
					ResetAttributes();
					Erase(BOTH, false);
					break;
				case 'h':
					if (parQty == 1 && params[0] == 7)
						SetLineWrap(true);
					break;
				case 'l':
					if (parQty == 1 && params[0] == 7)
						SetLineWrap(false);
					break;
				case 'A':	// [nA Cursor Up
					if (!parQty)
						params[0] = 1;
					//
					_cursor -= _canvas.Size().x*params[0];
					UpdateCursor();
					break;
				case 'B':	// [nB Cursor Down
					if (!parQty)
						params[0] = 1;
					//
					_cursor += _canvas.Size().x*params[0];
					UpdateCursor();
					break;
				case 'C':	// [nC Cursor Forward
					if (!parQty)
						params[0] = 1;
					//
					_cursor += params[0];
					UpdateCursor();
					break;
				case 'D':	// [nD Cursor Backward
					if (!parQty)
						params[0] = 1;
					//
					_cursor -= params[0];
					UpdateCursor();
					break;
				case 'H':	// [y;xH Cursor Home
				case 'f':	// [y;xf Force Cursor Position
					if (parQty < 2) {
						params[0] = 0;	// Y
						params[1] = 0;	// X
					}
					//
					_cursor = _canvas.Buffer() + _canvas.Size().x*params[0] + params[1];
					UpdateCursor();
					break;
				case 's':	// [s Save Cursor
					_ansiCursorStack.Push(_cursor);
					break;
				case 'u':	// [u Unsave Cursor
					_cursor = _ansiCursorStack.Pop();
					UpdateCursor();
					break;
				case 'J':	// [nJ
					if (parQty == 0)
						params[0] = 0;
					Erase(static_cast<EraseDirection>(params[0]), false);
					break;
				case 'K':	// [nK
					if (parQty == 0)
						params[0] = 0;
					Erase(static_cast<EraseDirection>(params[0]), true);
					break;
				case 'm':	// [p1;..;pNm
					if (!parQty) {
						ResetAttributes();
					} else {
						for(int i=0; i<parQty; ++i) {
							switch(params[i]) {
								case  0:	ResetAttributes();		break;
								case  1:	SetBold(true);			break;
								//case  2:	SetFaint(true);			break;
								//case  3:	SetItalic(true);		break;
								//case  4:	SetUnderline(true);		break;
								case  5:	SetBlink(true);			break;
								//case  6:	SetRapidBlink(true);	break;
								case  7:	SetReverseVideo(true);	break;
								//case  8:	SetInvisible(true);		break;
								//case 48:	SetSubscript(true);		break;
								//case 49:	SetSuperscript(true);	break;

								case 30:	Foreground(BLACK);	break;
								case 31:	Foreground(RED);	break;
								case 32:	Foreground(GREEN);	break;
								case 33:	Foreground(BROWN);	break;
								case 34:	Foreground(BLUE);	break;
								case 35:	Foreground(MAGENTA);break;
								case 36:	Foreground(CYAN);	break;
								case 37:	Foreground(WHITE);	break;
								case 90:	Foreground(GRAY);	break;
								case 91:	Foreground(RED_B);	break;
								case 92:	Foreground(LIME);	break;
								case 93:	Foreground(YELLOW);	break;
								case 94:	Foreground(BLUE_B);	break;
								case 95:	Foreground(MAGENTA_B);break;
								case 96:	Foreground(CYAN_B);	break;
								case 97:	Foreground(WHITE_B);break;

								case 40:	Background(BLACK);	break;
								case 41:	Background(RED);	break;
								case 42:	Background(GREEN);	break;
								case 43:	Background(BROWN);	break;
								case 44:	Background(BLUE);	break;
								case 45:	Background(MAGENTA);break;
								case 46:	Background(CYAN);	break;
								case 47:	Background(WHITE);	break;
								case 100:	Background(GRAY);	break;
								case 101:	Background(RED_B);	break;
								case 102:	Background(LIME);	break;
								case 103:	Background(YELLOW);	break;
								case 104:	Background(BLUE_B);	break;
								case 105:	Background(MAGENTA_B);break;
								case 106:	Background(CYAN_B);	break;
								case 107:	Background(WHITE_B);break;
							}
						}
					}
					break;
				default:		//the command was not recognized
					char* p = _ansiBuffer;
					while(*p)
						PutChar(*p++);
					break;
			}
		}
		return true;
	}
	return false;
}
示例#9
0
void CIniFile::Clear()
{
   Erase();
}
示例#10
0
bool BlockMergePass::MergeBlocks(Function* func) {
  bool modified = false;
  for (auto bi = func->begin(); bi != func->end();) {
    // Find block with single successor which has no other predecessors.
    auto ii = bi->end();
    --ii;
    Instruction* br = &*ii;
    if (br->opcode() != SpvOpBranch) {
      ++bi;
      continue;
    }

    const uint32_t lab_id = br->GetSingleWordInOperand(0);
    if (cfg()->preds(lab_id).size() != 1) {
      ++bi;
      continue;
    }

    bool pred_is_merge = IsMerge(&*bi);
    bool succ_is_merge = IsMerge(lab_id);
    if (pred_is_merge && succ_is_merge) {
      // Cannot merge two merges together.
      ++bi;
      continue;
    }

    Instruction* merge_inst = bi->GetMergeInst();
    bool pred_is_header = IsHeader(&*bi);
    if (pred_is_header && lab_id != merge_inst->GetSingleWordInOperand(0u)) {
      bool succ_is_header = IsHeader(lab_id);
      if (pred_is_header && succ_is_header) {
        // Cannot merge two headers together when the successor is not the merge
        // block of the predecessor.
        ++bi;
        continue;
      }

      // If this is a header block and the successor is not its merge, we must
      // be careful about which blocks we are willing to merge together.
      // OpLoopMerge must be followed by a conditional or unconditional branch.
      // The merge must be a loop merge because a selection merge cannot be
      // followed by an unconditional branch.
      BasicBlock* succ_block = context()->get_instr_block(lab_id);
      SpvOp succ_term_op = succ_block->terminator()->opcode();
      assert(merge_inst->opcode() == SpvOpLoopMerge);
      if (succ_term_op != SpvOpBranch &&
          succ_term_op != SpvOpBranchConditional) {
        ++bi;
        continue;
      }
    }

    // Merge blocks.
    context()->KillInst(br);
    auto sbi = bi;
    for (; sbi != func->end(); ++sbi)
      if (sbi->id() == lab_id) break;
    // If bi is sbi's only predecessor, it dominates sbi and thus
    // sbi must follow bi in func's ordering.
    assert(sbi != func->end());

    // Update the inst-to-block mapping for the instructions in sbi.
    for (auto& inst : *sbi) {
      context()->set_instr_block(&inst, &*bi);
    }

    // Now actually move the instructions.
    bi->AddInstructions(&*sbi);

    if (merge_inst) {
      if (pred_is_header && lab_id == merge_inst->GetSingleWordInOperand(0u)) {
        // Merging the header and merge blocks, so remove the structured control
        // flow declaration.
        context()->KillInst(merge_inst);
      } else {
        // Move the merge instruction to just before the terminator.
        merge_inst->InsertBefore(bi->terminator());
      }
    }
    context()->ReplaceAllUsesWith(lab_id, bi->id());
    context()->KillInst(sbi->GetLabelInst());
    (void)sbi.Erase();
    // Reprocess block.
    modified = true;
  }
  return modified;
}
示例#11
0
文件: hudgauge.cpp 项目: Bengt/vdrift
void HUDGAUGE::Set(
	SCENENODE & parent,
	const FONT & font,
	const std::string & name,
	float hwratio,
	float centerx,
	float centery,
	float radius,
	float startangle,
	float endangle,
	float startvalue,
	float endvalue,
	float valuedelta)
{
	// calculate number of segments (max 9)
	float segments = (endvalue - startvalue) / valuedelta;
	float factor = ceil(segments / 9.0f);
	segments = ceil(segments / factor);
	valuedelta = valuedelta * factor;
	endvalue = startvalue + segments * valuedelta;

	this->centerx = centerx;
	this->centery = centery;
	this->scalex = radius * hwratio;
	this->scaley = radius;
	this->offset = startangle;
	this->scale = (endangle - startangle) / (endvalue - startvalue);

	// reset
	Erase(parent, pointer_draw);
	Erase(parent, dialnum_draw);
	Erase(parent, dial_draw);
	pointer_rotated.Clear();
	pointer.Clear();
	dial_label.Clear();
	dial_marks.Clear();

	// dial marks
	{
		// big marker
		float pb[] = {-0.02, 1, 0, 0.02, 1, 0, 0.02, 0.92, 0, -0.02, 0.92, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		VERTEXARRAY bm;
		bm.SetVertices(pb, 12);
		bm.SetTexCoordSets(1);
		bm.SetTexCoords(0, t, 8);
		bm.SetFaces(f, 6);

		// small marker
		float ps[] = {-0.01, 1, 0, 0.01, 1, 0, 0.01, 0.95, 0, -0.01, 0.95, 0};
		VERTEXARRAY sm;
		sm.SetVertices(ps, 12);
		sm.SetTexCoordSets(1);
		sm.SetTexCoords(0, t, 8);
		sm.SetFaces(f, 6);

		float delta = (endangle - startangle) / (3 * segments);
		float angle = startangle;
		for (int i = 0; i <= 3 * segments; ++i)
		{
			VERTEXARRAY temp = (i % 3) ? sm : bm;
			temp.Rotate(angle, 0, 0, -1);
			dial_marks = dial_marks + temp;
			angle = angle + delta;
		}
		dial_marks.Scale(radius * hwratio, radius, 1);
		dial_marks.Translate(centerx, centery, 0.0);

		dial_draw = AddDrawable(parent);
		DRAWABLE & drawref = GetDrawable(parent, dial_draw);
		drawref.SetVertArray(&dial_marks);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// dial label
	{
		VERTEXARRAY temp;
		float w = 0.25 * radius * hwratio;
		float h = 0.25 * radius;
		float x = centerx;
		float y = centery - 0.5 * radius;
		float xn = TEXT_DRAW::RenderText(font, name, x, y, w, h, temp);
		temp.Translate((x - xn) * 0.5, 0, 0);
		dial_label = dial_label + temp;

		float angle = startangle;
		float angle_delta = (endangle - startangle) / segments;
		float value = startvalue;
		float value_delta = (endvalue - startvalue) / segments;
		for (int i = 0; i <= segments; ++i)
		{
			std::stringstream sstr;
			std::string text;
			sstr << value;
			sstr >> text;
			x = centerx + 0.75 * sin(angle) * radius * hwratio;
			y = centery + 0.75 * cos(angle) * radius;
			xn = TEXT_DRAW::RenderText(font, text, x, y, w, h, temp);
			temp.Translate((x - xn) * 0.5, 0, 0);
			dial_label = dial_label + temp;
			angle += angle_delta;
			value += value_delta;
		}

		dialnum_draw = AddDrawable(parent);
		DRAWABLE & drawref = GetDrawable(parent, dialnum_draw);
		drawref.SetDiffuseMap(font.GetFontTexture());
		drawref.SetVertArray(&dial_label);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// pointer
	{
		float p[] = {-0.015, 0.92, 0, 0.015, 0.92, 0, 0.025, -0.1, 0, -0.025, -0.1, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		pointer.SetVertices(p, 12);
		pointer.SetTexCoordSets(1);
		pointer.SetTexCoords(0, t, 8);
		pointer.SetFaces(f, 6);
/*		pointer.Scale(radius, radius, 1);

		pointer_node = parent.AddNode();
		SCENENODE & noderef = parent.GetNode(pointer_node);
		QUATERNION<float> rot(startangle, 0, 0, 1);
		MATHVECTOR<float,3> pos(centerx, centery, 0);
		noderef.GetTransform().SetRotation(rot);
		noderef.GetTransform().SetTranslation(pos);
*/
		pointer_draw = AddDrawable(parent);//noderef);
		DRAWABLE & drawref = GetDrawable(parent, pointer_draw);//noderef, pointer_draw);
		drawref.SetVertArray(&pointer_rotated);//pointer);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(2);
	}
}
示例#12
0
int
main( int ArgC, char *ArgV[] )
{
  int BDMHandle;
  unsigned int Base;
  unsigned int Chips;
  unsigned int Bytes;
  char *Operation;
  FlashError_t Error;

  if (ArgC < 6)
    Usage( ArgV[0] );

  if((BDMHandle = bdm_init(ArgV[1]))<0) 
      {
	  fprintf( stderr, 
		   "Problem opening bdm device %s, error code %d.\n", ArgV[1], BDMHandle );
	  return (EXIT_FAILURE);
      }

  Base = (unsigned int) strtoul( ArgV[2], NULL, 0 );
  Chips = (unsigned int) strtoul( ArgV[3], NULL, 0 );
  Bytes = (unsigned int) strtoul( ArgV[4], NULL, 0 );
  Operation = ArgV[5];

  Error = BDMFlashConfigSet( BDMHandle, Base, Chips, Bytes );
  if (Error != FlashErrorOkay_c)
    {
      fprintf( stderr, 
	       "Problem configuring flash; error code = %d '%s'.\n", 
	       (int) Error,
	       FlashErrorDescriptionEnglish[Error] );
    }

  if (strcasecmp( Operation, "erase" ) == 0)
    {
	Erase( ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "SectorErase" ) == 0)
    {
	SectorErase( ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "BlockErase" ) == 0)
    {
	BlockErase( ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "write" ) == 0)
    {
	Write( ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "read" ) == 0)
    {
	Read( BDMHandle, ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "probe" ) == 0)
    {
	Probe( ArgC, ArgV );
    }
  else if (strcasecmp( Operation, "detect" ) == 0)
    {
	Detect( ArgC, ArgV );
    }
  else
    Usage( ArgV[0] );

  bdm_release( BDMHandle );

  return (EXIT_SUCCESS);
}
void cone::SetupShape(void)
{
	Erase(4 * (resolution + 1), 2 * resolution);  // The vertices need to be doubled for the caps, and the extra 2 sets are for the centers of the caps 
												  // which need to have many copies of the same vertex with different texture coordinates

	float thetaInc =  2 * PIf / resolution;
	float thetaLimit = 2 * PIf + thetaInc / 2.0f;
	int i;
	float theta;
	int bottomCapStart;

	nVerts = 0;

	vector a, v0, v1;

	if (axis == 0)
	{
		a = vector(1, 0, 0);
		v0 = vector(0, 1, 0);
		v1 = vector(0, 0, 1);
	}
	if (axis == 1)
	{
		a = vector(0, 1, 0);
		v0 = vector(0, 0, 1);
		v1 = vector(1, 0, 0);
	}
	else
	{
		a = vector(0, 0, 1);
		v0 = vector(1, 0, 0);
		v1 = vector(0, 1, 0);
	}

	// First we do the body of the cone
	for (i = 0, theta = 0.0f; i <= resolution; i++, theta += thetaInc)
	{
		float cTheta = cos(theta), sTheta = sin(theta);

		vertices[nVerts].position = base + radius * (cTheta * v0 + sTheta * v1);
		vertices[nVerts].normal = height * (cTheta * v0 + sTheta * v1) + radius * a;
		vertices[nVerts].uv = vector(theta / (2 * PIf), 0.0);
		vertices[nVerts].dPdu = radius * (-sTheta * v0 + cTheta * v1);
		vertices[nVerts++].dPdv = -radius * (cTheta * v0 + sTheta * v1) + height * a;

		vertices[nVerts].position = base + height * a;
		vertices[nVerts].normal = height * (cTheta * v0 + sTheta * v1) + radius * a;
		vertices[nVerts].uv = vector(theta / (2 * PIf), 0.0);
		vertices[nVerts].dPdu = radius * (-sTheta * v0 + cTheta * v1);
		vertices[nVerts++].dPdv = -radius * (cTheta * v0 + sTheta * v1) + height * a;
	}

	// Now we do the cap
	if (capped)
	{
		bottomCapStart = nVerts;
		for (i = 0, theta = 2 * PIf; i <= resolution; i++, theta -= thetaInc)  // negative direction to preserve right handedness on the bottom
		{
			float cTheta = cos(theta), sTheta = sin(theta);

			vertices[nVerts].position = base;
			vertices[nVerts].normal = -a;
			vertices[nVerts].uv = vector(theta / (2 * PIf), 1.0);
			vertices[nVerts].dPdu = vector(0, 0, 0);
			vertices[nVerts++].dPdv = radius * (cTheta * v0 + sTheta * v1);

			vertices[nVerts].position = base + radius * cTheta * v0 + radius * sTheta * v1;
			vertices[nVerts].normal = -a;
			vertices[nVerts].uv = vector(theta / (2 * PIf), 0.0);
			vertices[nVerts].dPdu = radius * (-sTheta * v0 + cTheta * v1);
			vertices[nVerts++].dPdv = radius * (cTheta * v0 + sTheta * v1);
		}
	}

	nFaces = 0;
	for (int i = 0; i < resolution; i++)
	{
		faces[nFaces].vertices[0] = 2 * i;
		faces[nFaces].vertices[1] = 2 * i + 1;
		faces[nFaces++].vertices[2] = 2 * i + 2;
	}

	if (capped)
	{
		for (int i = 0; i < resolution; i++)
		{
			faces[nFaces].vertices[0] = bottomCapStart + 2 * i;
			faces[nFaces].vertices[1] = bottomCapStart + 2 * i + 1;
			faces[nFaces++].vertices[2] = bottomCapStart + 2 * i + 3;
		}
	}
}
void sphere::SetupShape(void)
{
	Erase((2 * resolution + 1) * (resolution + 1), 4 * (resolution + 1) * resolution); 
	// To Do
	// 
	// Setup the data for a sphere

	float pi = 3.14159265358979323846f;

	/*
	Strips refer to the "columns" of the sphere,
	where as, rings, refer to the "rows" of the sphere.
	*/



	int longitudeLines = resolution + 1;
	int latitudeLines = resolution + 1;
	nVerts = longitudeLines*latitudeLines;
	int numTriangleVerts = resolution*resolution * 2 * 3;
	int currentVertexIdx = 0;
	float currentPhi = 0.0f;
	float phiIncrement = (pi / (float)(resolution));
	float currentTheta = 0.0f;
	float thetaIncrement = 2.0f * (pi / (float)(resolution));

	for (int i = 0; i < longitudeLines; i++) //for each strip
	{
		currentPhi = 0.0f; //reset Phi since its a new strip
		for (int j = 0; j < latitudeLines; j++) //for each ring
		{
			//Note: Each face has four vertices...which will be used to make 

			vertices[currentVertexIdx].position = point(cosf(currentTheta)*sinf(currentPhi), sinf(currentTheta)*sinf(currentPhi), cosf(currentPhi)) * radius;
			vertices[currentVertexIdx].normal = vector(cosf(currentTheta)*sinf(currentPhi), sinf(currentTheta)*sinf(currentPhi), cosf(currentPhi));
			if (IsZero(vertices[currentVertexIdx].normal)){
				vertices[currentVertexIdx].normal.Normalize();
			}

			currentVertexIdx++; //skip forward to next idx for new face
			currentPhi += phiIncrement;
		}

		currentTheta += thetaIncrement; //go to next strip
	}

	for (int i = 0; i < resolution; i++) //for each strip
	{

		for (int j = 0; j < resolution; j++) //for each ring
		{
			//Note: Each face has four vertices...which will be used to make 

			faces[nFaces].vertices[0] = j + (i*latitudeLines);
			faces[nFaces].vertices[1] = j + (i*latitudeLines) + 1;
			faces[nFaces++].vertices[2] = j + ((i + 1)*latitudeLines);

			faces[nFaces].vertices[0] = j + ((i + 1)*latitudeLines);
			faces[nFaces].vertices[1] = j + (i*latitudeLines) + 1;
			faces[nFaces++].vertices[2] = j + ((i + 1)*latitudeLines) + 1;

		}
	}
}
示例#15
0
void main(int argc, char *argv[]){
	char keypress = START;
	int ch=0;
	int moves=0;
	char mc[10];

	set_graphics(VGA_320X200X256);

	PrintArrow(80, 105);

	do{	//Game loop
		PrintBorder();
		PrintMenu();
		keypress = (char)getch();

		if(keypress == QUIT){
			keypress = START;					//special condition so that it will not exit on Q press at menu
		}else if(keypress == UP || keypress == UP2){
			Erase(80, 120, 15, 15);
			PrintArrow(80, 105);
			ch = 0;
		}else if(keypress == DOWN || keypress == DOWN2){
			Erase(80, 100, 15, 15);
			PrintArrow(80, 125);
			ch = 1;
		}else if(keypress == ENTER || keypress == SPACE){
			switch(ch){
				case 0:
						EraseAll();
						NewGame(board);
						do{	//Inside-the-game loop
							PrintInstructions(180, 30);
							PrintBoard(30, 30);										//* Always prints update version of board at coordinates
							PrintBorder();														//* Always prints border
							sprintf(mc, "%d", moves);
							Erase(55, 175, 150, 15);
							write_text("Moves: ", 55, 175, WHITE, 0);
							write_text(mc, 120, 175, WHITE, 0);
							ShowHint();

							keypress=(char)getch();

							if(keypress == UP || keypress == UP2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == LEFT || keypress == LEFT2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == RIGHT || keypress == RIGHT2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == DOWN || keypress == DOWN2){
								//Erase(15, 15, 150, 150);
								MovePiece(keypress);
								moves++;
							}else if(keypress == QUIT){
								Erase(55, 175, 150, 15);
								write_text("Really exit? Y/N", 55, 175, WHITE, 0);
								do{
									keypress=(char)getch();
									if(keypress == YES){
										moves = 0;
										keypress = QUIT;
										break;
									}else if(keypress == NO){
										keypress = YES;
										Erase(55, 175, 150, 15);
										break;
									}
								}while(1);
							}else{
								Erase(55, 175, 150, 15);
								write_text("Invalid button!", 55, 175, WHITE, 0);
							}
							if(CheckWin(board)){
								EraseAll();
								write_text("You win!", 125, 85, WHITE, 0);
								moves = 0;
								keypress = QUIT;
							}
						}while(keypress != QUIT);
						EraseAll();
						PrintArrow(80, 105);
						keypress = START;
						break;
				case 1: keypress = QUIT;
						break;
				default: break;
			}
		}
		
	}while(keypress != QUIT);
	
	set_graphics(VGA_TEXT80X25X16);
	clrscr();
}
示例#16
0
void CIniFile::Reset()
{
   Erase();
}
示例#17
0
void QueueListBox::EnsurePromptHiddenSlot(iterator it) {
    if (m_showing_prompt) {
        Erase(begin(), false, false); // if the prompt is shown, it must be the only row in the ListBox
        m_showing_prompt = false;
    }
}
示例#18
0
BOOL CHashDatabase::DeleteED2K(DWORD nIndex)
{
	CSingleLock pLock( &m_pSection, TRUE );
	if ( m_bOpen == FALSE ) return FALSE;
	return Erase( nIndex, HASH_ED2K );
}
	/*
	public ZBasicString<A>::Erase

	Erase function.  Erases the character at the provided index.

	@param _index - the index of the character to erase
	@return (void)
	*/
	void Erase(const size_t _index)
	{
		size_t index = BoundsCheck(_index, Length());
		Erase(index, index + 1);
	}
示例#20
0
void Game_Picture::Update() {
	RPG::SavePicture& data = GetData();

	if (data.name.empty())
		return;

	if (data.fixed_to_map) {
		// Instead of modifying the Ox/Oy offset the real position is altered
		// based on map scroll because of savegame compatibility with RPG_RT

		if (old_map_x != Game_Map::GetDisplayX()) {
			double mx = (old_map_x - Game_Map::GetDisplayX()) / (double)TILE_SIZE;

			data.finish_x = data.finish_x + mx;
			data.current_x = data.current_x + mx;
		}
		if (old_map_y != Game_Map::GetDisplayY()) {
			double my = (old_map_y - Game_Map::GetDisplayY()) / (double)TILE_SIZE;

			data.finish_y = data.finish_y + my;
			data.current_y = data.current_y + my;
		}

		old_map_x = Game_Map::GetDisplayX();
		old_map_y = Game_Map::GetDisplayY();
	}

	if (data.time_left == 0) {
		SyncCurrentToFinish();
	} else {
		auto interpolate = [=](double current, double finish) {
			double d = data.time_left;
			return (current * (d - 1) + finish) / d;
		};

		data.current_x = interpolate(data.current_x, data.finish_x);
		data.current_y = interpolate(data.current_y, data.finish_y);
		data.current_red = interpolate(data.current_red, data.finish_red);
		data.current_green = interpolate(data.current_green, data.finish_green);
		data.current_blue = interpolate(data.current_blue, data.finish_blue);
		data.current_sat = interpolate(data.current_sat, data.finish_sat);
		data.current_magnify = interpolate(data.current_magnify, data.finish_magnify);
		data.current_top_trans = interpolate(data.current_top_trans, data.finish_top_trans);
		data.current_bot_trans = interpolate(data.current_bot_trans, data.finish_bot_trans);
		if (data.effect_mode != 0) {
			data.current_effect = interpolate(data.current_effect, data.finish_effect);
		}

		data.time_left = data.time_left - 1;
	}

	// Update rotation
	if (data.current_rotation >= 256.0) {
		data.current_rotation = data.current_rotation - 256.0;
	}
	bool is_rotating_but_stopping =
		data.effect_mode == 0 && (
			data.current_rotation != 0.0 ||
			data.current_effect * data.time_left >= 256.0
		);
	bool is_rotating =
		data.effect_mode == 1 ||
		is_rotating_but_stopping;
	if (is_rotating) {
		data.current_rotation = data.current_rotation + data.current_effect;
		if (is_rotating_but_stopping && data.current_rotation >= 256.0) {
			data.current_rotation = 0.0;
		}
	}

	// Update waver phase
	if (data.effect_mode == 2) {
		data.current_waver = data.current_waver + 10;
	}

	// RPG Maker 2k3 1.12: Spritesheets
	if (HasSpritesheet()) {
		if (data.spritesheet_speed > 0) {
			if (data.frames % data.spritesheet_speed == 0) {
				data.spritesheet_frame = data.spritesheet_frame + 1;

				if (data.spritesheet_frame > data.spritesheet_rows * data.spritesheet_cols) {
					if (data.spritesheet_play_once) {
						Erase(true);
						return;
					}

					data.spritesheet_frame = 1;
				}
			}
		}

		data.frames = data.frames + 1;
	}

	UpdateSprite();
}
示例#21
0
bool CWalletDB::ErasePurpose(const std::string& strPurpose)
{
    nWalletDBUpdateCounter++;
    return Erase(make_pair(std::string("purpose"), strPurpose));
}
示例#22
0
文件: Array.cpp 项目: lailongwei/llbc
LLBC_Array::Iter LLBC_Array::Erase(LLBC_Array::difference_type n0, LLBC_Array::difference_type n1)
{
    return Erase(Begin() + n0, Begin() + n1);
}
示例#23
0
	void PopBack()
	{
		Erase(--End());
	}
示例#24
0
文件: Array.cpp 项目: lailongwei/llbc
void LLBC_Array::PopFront()
{
    Erase(Begin());
}
示例#25
0
int
BeOSCanvas::RenderOffsetText( int iFontHeight, Rect& oClipRect,
                              string& oText, int iOffset,
                              Font* pFont, const Color& oColor,
                              bool bBold, bool bItalic,
                              bool bUnderline )
{
    Erase( oClipRect );

    BView* v = m_pBufferBitmap->OffscreenView();
    if ( !v ) return 0;

    BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();

    BFont font;
    font_height fontHeight;
    BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
                    float(oClipRect.x2-1), float(oClipRect.y2-1) );
    BRegion clipRegion;
    clipRegion.Set( clipRect );

    if ( !bitmap->Lock() )
    {
        puts( "Lock Failed" );
        return 0;
    }

    v->ConstrainClippingRegion( &clipRegion );
    if ( bBold )
    {
        v->SetFont( be_bold_font );
    }
    else
    {
        v->SetFont( be_plain_font );
    }
    v->SetFontSize( (float)iFontHeight - 1 );
    v->GetFont( &font );
    font.GetHeight( &fontHeight );

    float width = v->StringWidth(oText.c_str(), oText.size());
    width += iMarqueeSpacer;

    if ( iOffset > width )
    {
        bitmap->Unlock();
        return int( width ) - iOffset;
    }

    v->MovePenTo( float(oClipRect.x1 - iOffset),
                  float(oClipRect.y2 - fontHeight.descent) );
    v->DrawString( oText.c_str() );
    int ret = int( width ) - iOffset - oClipRect.Width();
    if ( ret < 0 )
    {
        v->MovePenTo( float(oClipRect.x1 - iOffset + width),
                      float(oClipRect.y2 - fontHeight.descent) );
        v->DrawString( oText.c_str() );
    }

    v->Sync();
    bitmap->Unlock();

    Invalidate( oClipRect );

    return MAX( 0, ret );
}
示例#26
0
文件: Array.cpp 项目: lailongwei/llbc
void LLBC_Array::Clear()
{
    Erase(Begin(), End());
}
示例#27
0
文件: mouse.c 项目: RPG-7/reactos
void
startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    start.x = x;
    start.y = y;
    last.x = x;
    last.y = y;
    switch (activeTool)
    {
        case TOOL_FREESEL:
            ShowWindow(hSelection, SW_HIDE);
            if (ptStack != NULL)
                HeapFree(GetProcessHeap(), 0, ptStack);
            ptStack = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * 1024);
            ptSP = 0;
            ptStack[0].x = x;
            ptStack[0].y = y;
            break;
        case TOOL_LINE:
        case TOOL_RECT:
        case TOOL_ELLIPSE:
        case TOOL_RRECT:
            newReversible();
            break;
        case TOOL_RECTSEL:
        case TOOL_TEXT:
            newReversible();
            ShowWindow(hSelection, SW_HIDE);
            rectSel_src.right = rectSel_src.left;
            rectSel_src.bottom = rectSel_src.top;
            break;
        case TOOL_RUBBER:
            newReversible();
            Erase(hdc, x, y, x, y, bg, rubberRadius);
            break;
        case TOOL_FILL:
            newReversible();
            Fill(hdc, x, y, fg);
            break;
        case TOOL_PEN:
            newReversible();
            SetPixel(hdc, x, y, fg);
            break;
        case TOOL_BRUSH:
            newReversible();
            Brush(hdc, x, y, x, y, fg, brushStyle);
            break;
        case TOOL_AIRBRUSH:
            newReversible();
            Airbrush(hdc, x, y, fg, airBrushWidth);
            break;
        case TOOL_BEZIER:
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if (pointSP == 0)
            {
                newReversible();
                pointSP++;
            }
            break;
        case TOOL_SHAPE:
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if (pointSP + 1 >= 2)
                Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE, FALSE);
            if (pointSP == 0)
            {
                newReversible();
                pointSP++;
            }
            break;
    }
}
示例#28
0
FreeTypeFontCache::~FreeTypeFontCache()
{
	Erase();
	g_pFTEngine->SubMemUsedObj(this);
}
示例#29
0
文件: mouse.c 项目: rmallof/reactos
void
endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_FREESEL:
        {
            POINT *ptStackCopy;
            int i;
            rectSel_src[0] = rectSel_src[1] = 0x7fffffff;
            rectSel_src[2] = rectSel_src[3] = 0;
            for (i = 0; i <= ptSP; i++)
            {
                if (ptStack[i].x < rectSel_src[0])
                    rectSel_src[0] = ptStack[i].x;
                if (ptStack[i].y < rectSel_src[1])
                    rectSel_src[1] = ptStack[i].y;
                if (ptStack[i].x > rectSel_src[2])
                    rectSel_src[2] = ptStack[i].x;
                if (ptStack[i].y > rectSel_src[3])
                    rectSel_src[3] = ptStack[i].y;
            }
            rectSel_src[2] += 1 - rectSel_src[0];
            rectSel_src[3] += 1 - rectSel_src[1];
            rectSel_dest[0] = rectSel_src[0];
            rectSel_dest[1] = rectSel_src[1];
            rectSel_dest[2] = rectSel_src[2];
            rectSel_dest[3] = rectSel_src[3];
            if (ptSP != 0)
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                ptStackCopy = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * (ptSP + 1));
                for (i = 0; i <= ptSP; i++)
                {
                    ptStackCopy[i].x = ptStack[i].x - rectSel_src[0];
                    ptStackCopy[i].y = ptStack[i].y - rectSel_src[1];
                }
                Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE);
                HeapFree(GetProcessHeap(), 0, ptStackCopy);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                MaskBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                        rectSel_src[1], hSelMask, 0, 0, MAKEROP4(SRCCOPY, WHITENESS));
                Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE);
                newReversible();

                MaskBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                        0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            HeapFree(GetProcessHeap(), 0, ptStack);
            ptStack = NULL;
            break;
        }
        case TOOL_RECTSEL:
            resetToU1();
            if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0))
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                Rect(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], 0x00ffffff, 0x00ffffff, 1, 2);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                       rectSel_src[1], SRCCOPY);
                Rect(hdc, rectSel_src[0], rectSel_src[1], rectSel_src[0] + rectSel_src[2],
                     rectSel_src[1] + rectSel_src[3], bgColor, bgColor, 0, TRUE);
                newReversible();

                BitBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                       0, SRCCOPY);

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            break;
        case TOOL_RUBBER:
            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, fg, 1);
            SetPixel(hdc, x, y, fg);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
            break;
        case TOOL_BEZIER:
            pointSP++;
            if (pointSP == 4)
                pointSP = 0;
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            pointSP++;
            if (pointSP >= 2)
            {
                if ((pointStack[0].x - x) * (pointStack[0].x - x) +
                    (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1)
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE);
                    pointSP = 0;
                }
                else
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE);
                }
            }
            if (pointSP == 255)
                pointSP--;
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
    }
}
示例#30
0
void CmdLineView::Render (const char * str)
{
  Erase();
  Print(str);
  Refresh();
}