Ejemplo n.º 1
1
    // static
    void CanvasGdiplus::InitializeDC(HDC context)
    {
        // Enables world transformation.
        // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the
        // counterclockwise direction in logical space. This is equivalent to the
        // statement that, in the GM_ADVANCED graphics mode, both arc control points
        // and arcs themselves fully respect the device context's world-to-device
        // transformation.
        BOOL res = SetGraphicsMode(context, GM_ADVANCED);
        DCHECK(res != 0);

        // Enables dithering.
        res = SetStretchBltMode(context, HALFTONE);
        DCHECK(res != 0);
        // As per SetStretchBltMode() documentation, SetBrushOrgEx() must be called
        // right after.
        res = SetBrushOrgEx(context, 0, 0, NULL);
        DCHECK(res != 0);

        // Sets up default orientation.
        res = SetArcDirection(context, AD_CLOCKWISE);
        DCHECK(res != 0);

        // Sets up default colors.
        res = SetBkColor(context, RGB(255, 255, 255));
        DCHECK(res != CLR_INVALID);
        res = SetTextColor(context, RGB(0, 0, 0));
        DCHECK(res != CLR_INVALID);
        res = SetDCBrushColor(context, RGB(255, 255, 255));
        DCHECK(res != CLR_INVALID);
        res = SetDCPenColor(context, RGB(0, 0, 0));
        DCHECK(res != CLR_INVALID);

        // Sets up default transparency.
        res = SetBkMode(context, OPAQUE);
        DCHECK(res != 0);
        res = SetROP2(context, R2_COPYPEN);
        DCHECK(res != 0);
    }
Ejemplo n.º 2
0
/* ‘ункци¤ рисовани¤ глаза.
 * ј–√”ћ≈Ќ“џ:
 *   - дескриптор окна:
 *       HWND hWnd;
 *   - контекст устройства:
 *       HDC hDC;
 *   - координаты центра:
 *       INT X, Y;
 *   - радиусы:
 *       INT R, R1;
 * ¬ќ«¬–јўј≈ћќ≈ «Ќј„≈Ќ»≈: Ќет.
 */
VOID DrawEye( HWND hWnd, HDC hDC, INT X, INT Y, INT R, INT R1 )
{
  INT px, py, len2;
  POINT pt;

  GetCursorPos(&pt);
  ScreenToClient(hWnd, &pt);

  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(255, 0, 0));
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCBrushColor(hDC, RGB(255, 255, 0));

  Ellipse(hDC, X - R, Y - R, X + R, Y + R);
  px = pt.x;
  py = pt.y;
  SetDCPenColor(hDC, RGB(255, 0, 255));
  SetDCBrushColor(hDC, RGB(0, 0, 0));

  len2 = sqrt((px - X) * (px - X) + (py - Y) * (py - Y));
  if (len2 < (R - R1))
    len2 = (R - R1);
  px = (px - X) * (R - R1) / len2 + X;
  py = (py - Y) * (R - R1) / len2 + Y;

  Ellipse(hDC, px - R1, py - R1, px + R1, py + R1);
} /* End of 'DrawEye' function */
Ejemplo n.º 3
0
void MyField::SetColor(CPaintDC &dc)
{
	SelectObject(dc, GetStockObject(DC_PEN));
	SetDCPenColor(dc, RGB(70, 30, 90));
	SelectObject(dc, GetStockObject(DC_BRUSH));
	SetDCPenColor(dc, RGB(0, 0, 0));
	SetDCBrushColor(dc, RGB(255, 255, 255));
	SetDCBrushColor(dc, RGB(70, 30, 90));
}
Ejemplo n.º 4
0
void CDateBanner::CRightArrowButton::PaintForeground(HDC dc, int w, int h)
{
    DWORD lc1 = c1;
    DWORD lc2 = c2;
    DWORD lc3 = c3;
	DWORD blk = 0;
	DWORD dash = dashColor;
    if(m_state & ButtonMouseOver)
    {
		SetDCPenColor(dc, hiliteFill);
		SetDCBrushColor(dc, hiliteFill);
        Rectangle(dc, 1, 1, w - 1, h - 1);
        if(m_state & ButtonPressed)
		{
			lc1 = lc2 = lc3 = blk;
			dash = hiliteDash;
		}
    }
	SetDCPenColor(dc, dash);
	MoveToEx(dc, 2, 2, 0);
	POINT pts[] = { { w - 2, 2 }, { w - 2, h - 2 }, { 2, h - 2 }, { 2, 2 } };
	PolylineTo(dc, pts, 4);

    HPEN p2 = CreatePen(PS_DASH, 2, lc3);
	HGDIOBJ oldPen = SelectObject(dc, p2);

    MoveToEx(dc, 5, 5, 0);
	LineTo(dc, 15, 20);
	LineTo(dc, 5, 35);

	HPEN p1 = CreatePen(PS_DASH, 2, lc2);
	SelectObject(dc, p1);
	DeleteObject(p2);
	
	MoveToEx(dc, 5, 10, 0);
	LineTo(dc, 25, 20);
	LineTo(dc, 5, 30);

	p2 = CreatePen(PS_DASH, 2, lc1);
	SelectObject(dc, p2);
	DeleteObject(p1);

	MoveToEx(dc, 5, 15, 0);
	LineTo(dc, 35, 20);
    LineTo(dc, 5, 25);

	SelectObject(dc, oldPen);
	DeleteObject(p2);
}
Ejemplo n.º 5
0
/* Функция отрисовки геометрического объекта.
 * АРГУМЕНТЫ:
 *   - указатель на структуру для загружаемой геометрии:
 *       as4GOBJ *GObj;
 *   - контекст устройства вывода:
 *       HDC hDC;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID AS4_RndGObjDraw( as4GOBJ *GObj, HDC hDC )
{
  INT i;
  POINT *pts;

  if ((pts = (POINT *) malloc(sizeof(POINT) * GObj->NumOfV)) == NULL)
    return;

  AS4_RndMatrSetup();

  for (i = 0; i < GObj->NumOfV; i++)
  {
    pts[i] = AS4_RndWorldToScreen(GObj->V[i]);
    /*Ellipse(hDC, pts[i].x - s, pts[i].y - s, pts[i].x + s, pts[i].y + s);/**/
  }
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCBrushColor(hDC, RGB(24, 55, 24));
  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(255, 153, 24));
  for (i = 0; i < GObj->NumOfF; i++)
  {
    INT n0 = GObj->F[i][0], n1 = GObj->F[i][1], n2 = GObj->F[i][2];
    MoveToEx(hDC, pts[n0].x, pts[n0].y, NULL);
    LineTo(hDC, pts[n1].x, pts[n1].y);
    LineTo(hDC, pts[n2].x, pts[n2].y);
    LineTo(hDC, pts[n0].x, pts[n0].y);/**/
    /*Polygon(hDC, pt, 3);/**/
  }
  free(pts);
} /* End of 'AS4_RndGObjDraw' function */
Ejemplo n.º 6
0
Archivo: help.c Proyecto: YokoZar/wine
static LRESULT Child_OnPaint(HWND hWnd)
{
    PAINTSTRUCT ps;
    HDC hdc;
    RECT rc;

    hdc = BeginPaint(hWnd, &ps);

    /* Only paint the Navigation pane, identified by the fact
     * that it has a child window
     */
    if (GetWindow(hWnd, GW_CHILD))
    {
        GetClientRect(hWnd, &rc);

        /* set the border color */
        SelectObject(hdc, GetStockObject(DC_PEN));
        SetDCPenColor(hdc, GetSysColor(COLOR_BTNSHADOW));

        /* Draw the top border */
        LineTo(hdc, rc.right, 0);

        SelectObject(hdc, GetStockObject(WHITE_PEN));
        MoveToEx(hdc, 0, 1, NULL);
        LineTo(hdc, rc.right, 1);
    }

    EndPaint(hWnd, &ps);

    return 0;
}
Ejemplo n.º 7
0
void CGradientEditor::OnDraw(HDC hDC, const LPRECT clientRect)
{
	this->clientRect = clientRect;

	for (int x = clientRect->left; x < clientRect->right; x++) {
		double point = Interpolate(x, clientRect->left, clientRect->right, 0.0, 1.0);
		COLORREF color = MultiplyColors(tint, gradient->ColorAtPoint(point));
		SelectObject(hDC, GetStockObject(DC_PEN));
		SetDCPenColor(hDC, color);
		MoveToEx(hDC, x, clientRect->bottom - 23, NULL);
		LineTo(hDC, x, clientRect->bottom);
		SetPixel(hDC, x, clientRect->bottom - 24, InterpolateColor(color, 0xFFFFFF, 0.125));
	}

	SetTextColor(hDC, 0xFFFFFF);
	int count = bitmap.GetCellCount();
	for (int i = 1; i < count; i++) {
		int x = i * (clientRect->right - clientRect->left) / count;
		BitBlt(hDC, x - 3, clientRect->bottom - 4, 7, 4, cellMarkerBmpDC, 0, 0, SRCINVERT);
	}

	for (std::vector<CStepHandle*>::iterator i = stepHandles.begin(); i != stepHandles.end(); i++) {
		(*i)->SetPositioningInfo(clientRect->left, clientRect->right, clientRect->bottom - 24);
	}

	CCompoundDispItem::OnDraw(hDC, clientRect);
}
Ejemplo n.º 8
0
__int64 PaintRectangle(HWND hwnd, HDC dc, long x, long y, long w, long h, int color)
{
		//HGDIOBJ origItem = SelectObject(dc, brush);
	COLORREF oldPen = SetDCPenColor(dc, color);
		
	POINT point ={0, 0};
	MoveToEx(dc, x, y, &point);

	LineTo(dc, x+w, y);
	LineTo(dc, x+w, y+h);
	LineTo(dc, x, y+h);
	LineTo(dc, x, y);

	SetDCPenColor(dc, oldPen);
	return GetTickCount();
}
Ejemplo n.º 9
0
/* Unit clock render function.
 * ARGUMENTS:
 *   - self-pointer to unit object:
 *       vg4UNIT_CLOCK *Uni;
 *   - animation context:
 *       vg4ANIM *Ani;
 * RETURNS: None.
 */
static VOID VG4_UnitRender( vg4UNIT_CLOCK *Uni, vg4ANIM *Ani )
{
  DBL a, r;
  SYSTEMTIME t;

  GetLocalTime(&t);

  a = (t.wSecond) * 2 * 3.1415926535 / 60;
  r = Ani->W / 2.2;

  if (Ani->JBut[0])
    SetDCPenColor(Ani->hDC, RGB(255, 0, 0));
  else
    SetDCPenColor(Ani->hDC, RGB(0, 0, 0));

  MoveToEx(Ani->hDC, Ani->W / 2 + Ani->JX * 30, Ani->H / 2 + Ani->JY * 30, NULL);
  LineTo(Ani->hDC, Ani->W / 2 + Ani->JX * 30 + sin(a) * r, Ani->H / 2 + Ani->JY * 30 - cos(a) * r);
} /* End of 'VG4_UnitRender' function */
Ejemplo n.º 10
0
void Test_SetDCPenColor()
{
	HDC hScreenDC, hDC;
	HBITMAP hbmp, hbmpOld;

	// Test an incorrect DC
	SetLastError(ERROR_SUCCESS);
	ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID, "\n");
	ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");

	// Get the Screen DC
	hScreenDC = GetDC(NULL);
	ok(hScreenDC != 0, "GetDC failed, skipping tests\n");
	if (hScreenDC == NULL) return;

	// Test the screen DC
	SetDCPenColor(hScreenDC, RGB(1,2,3));
	ok(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3), "\n");

	// Create a new DC
	hDC = CreateCompatibleDC(hScreenDC);
	ReleaseDC(0, hScreenDC);
	ok(hDC != 0, "CreateCompatibleDC failed, skipping tests\n");
	if (!hDC) return;

	// Select the DC_PEN and check if the pen returned by a new call is DC_PEN
	SelectObject(hDC, GetStockObject(DC_PEN));
	ok(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN), "\n");

	// Test an incorrect color, yes windows sets the color!
	SetDCPenColor(hDC, 0x21123456);
	ok(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456, "\n");

	// Test CLR_INVALID, it sets CLR_INVALID!
	SetDCPenColor(hDC, CLR_INVALID);
	ok(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID, "\n");

	hbmp = CreateBitmap(10, 10, 1, 32, NULL);
	ok(hbmp != 0, "CreateBitmap failed, skipping tests\n");
	if (!hbmp) return;
	hbmpOld = SelectObject(hDC, hbmp);
#if 0 // this only works on 32 bpp screen resolution
	ok(hbmpOld != NULL, "\n");
	SelectObject(hDC, GetStockObject(DC_PEN));
	SetDCPenColor(hDC, 0x123456);
	MoveToEx(hDC, 0, 0, NULL);
	LineTo(hDC, 10, 0);
	ok(GetPixel(hDC, 5, 0) == 0x123456, "\n");
#endif

	// Delete the DC
	SelectObject(hDC, hbmpOld);
	DeleteDC(hDC);
}
Ejemplo n.º 11
0
void TreeEntryWidget::PaintBufferPre(HWND, HDC dc, int width, int height)
{
    SelectObject(dc, GetStockObject(DC_PEN));
    SelectObject(dc, GetStockObject(DC_BRUSH));
    SetDCBrushColor(dc, brush);
    SetDCPenColor(dc, pen);
    Rectangle(dc, 0, 0, width, height);
    SetDCBrushColor(dc, 0x00e3d9e4);
    Rectangle(dc, 3, 3, width - 3 , height - 3);
}
Ejemplo n.º 12
0
void Test_CreateCompatibleDC()
{
	HDC hdcScreen, hOldDC, hdc, hdc2;
	HPEN hOldPen;
	COLORREF color;

	/* Get screen DC */
	hdcScreen = GetDC(NULL);

	/* Test NULL DC handle */
	SetLastError(ERROR_SUCCESS);
	hdc = CreateCompatibleDC(NULL);
	ok(hdc != NULL, "CreateCompatibleDC(NULL) failed\n");
	ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
	if(hdc) DeleteDC(hdc);

	/* Test invalid DC handle */
	SetLastError(ERROR_SUCCESS);
	hdc = CreateCompatibleDC((HDC)0x123456);
	ok(hdc == NULL, "Expected NULL, got %p\n", hdc);
	ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
	if(hdc) DeleteDC(hdc);

	hdc = CreateCompatibleDC(hdcScreen);
	ok(hdc != NULL, "CreateCompatibleDC failed\n");

	// Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?)
	hOldPen = SelectObject(hdc, GetStockObject(DC_PEN));
	ok (hOldPen == GetStockObject(BLACK_PEN), "hOldPen == %p\n", hOldPen);
	hOldPen = SelectObject(hdc, GetStockObject(BLACK_PEN));
	ok (hOldPen == GetStockObject(DC_PEN), "hOldPen == %p\n", hOldPen);

	/* Test for the starting Color == RGB(0,0,0) */
	color = SetDCPenColor(hdc, RGB(1,2,3));
	ok(color == RGB(0,0,0), "color == %lx\n", color);

	/* Check for reuse counter */
	hOldDC = hdc;
	DeleteDC(hdc);
	hdc = CreateCompatibleDC(hdcScreen);
	hdc2 = CreateCompatibleDC(hOldDC);
	ok(hdc2 == NULL, "Expected NULL, got %p\n", hdc);
	if (hdc2 != NULL) DeleteDC(hdc2);

    /* Check map mode */
	hdc = CreateCompatibleDC(hdcScreen);
	SetMapMode(hdc, MM_ISOTROPIC);
	hdc2 = CreateCompatibleDC(hdc);
    ok(GetMapMode(hdc2) == MM_TEXT, "GetMapMode(hdc2)==%d\n", GetMapMode(hdc2));

	/* cleanup */
	DeleteDC(hdc);

	ReleaseDC(NULL, hdcScreen);
}
Ejemplo n.º 13
0
Archivo: T02WIN.C Proyecto: AP6/SUM2014
void DrawEye(HDC hDC, INT Xm, INT Ym, INT Xc, INT Yc, INT W, INT H, INT R)
{
  int xe, ye;
  double len = sqrt((Xc - Xm) * (Xc - Xm) + (Yc - Ym) * (Yc - Ym)), si, co;
  SelectObject(hDC, GetStockObject(NULL_PEN));
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCPenColor(hDC, RGB(255, 255, 255));
  SetDCBrushColor(hDC, RGB(255, 255, 255));
  

}
void Grid::Render(HDC targetDC,
	const Matrix& view,
	const Matrix& projection,
	const Matrix& viewport)
{
	Matrix pipeline = view * projection * viewport;
	for ( auto iter = lines.cbegin(); iter != lines.cend(); ++iter )
	{
		Vector3D start = (*iter).start;
		Vector3D end = (*iter).end;

		start = pipeline * start;
		end = pipeline * end;

		COLORREF oldColor = SetDCPenColor(targetDC, ( *iter ).color);
		MoveToEx(targetDC, (int)start.x, (int)start.y, nullptr);
		LineTo(targetDC, (int)end.x, (int)end.y);
		SetDCPenColor(targetDC, oldColor);
	}
}
Ejemplo n.º 15
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       od6UNIT_COW *Unit;
 *   - указатель на контекст анимации:
 *       od6ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID CowUnitRender( od6UNIT_COW *Unit, od6ANIM *Ani )
{
  INT i, N = 0;
  VEC p = {1, 0, 0};
  POINT pt;
  static DBL Delta = 0.1;

  Delta += Ani->JZ * Ani->GlobalDeltaTime;


  OD6_RndMatrView = MatrViewLookAt(VecMulMatr(VecSet(0, 0, Ani->JX * Delta + 15), MatrRotateX(90 * Ani->JY)), VecSet(0, 0, 0), VecSet(0, 1, 0));
  OD6_RndMatrWorld = MatrRotateZ(-Ani->Time);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(255, 255, 255));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 255));

  srand(30);
  for (i = 0; i < N; i++)
  {
    p.X = 2.0 * rand() / RAND_MAX - 1 ;
    p.Y = 2.0 * rand() / RAND_MAX - 1 ;
    p.Z = 2.0 * rand() / RAND_MAX - 1 ;
    pt = OD6_RndWorldToScreen(p);
    if (i == 0)
      MoveToEx(Ani->hDC, pt.x , pt.y, NULL);
    else
      LineTo(Ani->hDC, pt.x , pt.y);
  }
  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);
 /*
  OD6_RndMatrWorld = MatrRotateZ(-Ani->GlobalTime / 60);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(0, 255, 255));
  SetDCPenColor(Ani->hDC, RGB(0, 255, 255));

  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);

  OD6_RndMatrWorld = MatrRotateZ(-Ani->GlobalTime / 60 / 60);
  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));

  SetDCBrushColor(Ani->hDC, RGB(255, 255, 0));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 0));

  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC);

  OD6_RndMatrWorld = MatrRotateY(Ani->Time * 30);

  OD6_RndMatrWorld = MatrMulMatr(OD6_RndMatrWorld, MatrScale(0.30, 0.30, 0.30));
  OD6_RndMatrWorld = MatrMulMatr(MatrTranslate(0.0, 0.0, 3 * 3.30), OD6_RndMatrWorld);
  OD6_RndGObjDraw(&Unit->Cow, Ani->hDC); */  
} /* End of 'CowUnitRender' function */
Ejemplo n.º 16
0
void MyField::DrawField(CPaintDC &dc)
{
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			SetDCPenColor(dc, RGB(0, 0, 0));
			SetDCBrushColor(dc, RGB(255, 255, 255));
			dc.Rectangle(i * RectSize, j * RectSize,
				i * RectSize + RectSize, j * RectSize + RectSize);
			if (arrVector[row*j + i] == 1) 
			{
				SetColor(dc);
				DrawRectByCoordanates(dc, i, j);
				SetDefaultColor(dc);
			}
		}
	}
	SetDCPenColor(dc, RGB(0, 0, 0));
	SetDCBrushColor(dc, RGB(0, 0, 0));
}
Ejemplo n.º 17
0
/* Primitive draw function.
 * ARGUMENTS:
 *   - primtive to draw:
 *       mm3PRIM *Pr;
 * RETURNS: None.
 */
VOID MM3_RndPrimDraw( mm3PRIM *Pr )
{
  INT i;
  MATR M;
  POINT *pts;

  /* Build transform matrix */
  M = MatrMulMatr(MM3_RndMatrWorld,
    MatrMulMatr(MM3_RndMatrView, MM3_RndMatrProj));

  /* Transform all points */
  pts = malloc(sizeof(POINT) * Pr->NumOfP);
  if (pts == NULL)
    return;
  SelectObject(MM3_Anim.hDC, GetStockObject(DC_PEN));
  SetDCPenColor(MM3_Anim.hDC, RGB(255, 255, 255));

  for (i = 0; i < Pr->NumOfP; i++)
  {
    /* NDC */
    VEC p = PointTransform4(Pr->P[i], M);

    pts[i].x = (INT)((p.X + 1) * MM3_Anim.W / 2);
    pts[i].y = (INT)((-p.Y + 1) * MM3_Anim.H / 2);
  }

  /* Draw all lines */
  for (i = 0; i < Pr->NumOfE; i++)
  {
    INT n0 = Pr->Edges[i][0], n1 = Pr->Edges[i][1];

    SetDCPenColor(MM3_Anim.hDC, RGB(i * 255 / Pr->NumOfE, 0, 255 - i * 255 / Pr->NumOfE));

    MoveToEx(MM3_Anim.hDC, pts[n0].x, pts[n0].y, NULL);
    LineTo(MM3_Anim.hDC, pts[n1].x, pts[n1].y);
  }
  free(pts);
} /* End of 'MM3_RndPrimDraw' function */
Ejemplo n.º 18
0
void Arrow( HDC hDC, POINT c, double a, INT r, INT w, COLORREF col )
{
  POINT pt[3];
  double sn = sin(a), csn = cos(a);
  pt[0].x = c.x - w * sn; pt[0].y = c.y + w * csn;
  pt[1].x = c.x + w * sn; pt[1].y = c.y - w * csn;
  pt[2].x = csn * r + c.x;
  pt[2].y = sn * r + c.y;
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCBrushColor(hDC, col);
  SetDCPenColor(hDC, col);
  Polygon(hDC, pt, 3);
}
Ejemplo n.º 19
0
/* Функция построения объекта анимации.
 * АРГУМЕНТЫ:
 *   - указатель на "себя" - сам объект анимации:
 *       ak1UNIT_BALL *Uni;
 *   - указатель на контекст анимации:
 *       ak1ANIM *Ani;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
static VOID AK1_AnimCowRender( ak1UNIT_COW *Uni, ak1ANIM *Ani )
{
  int i, l = -1;
  DBL X1 = Ani->PosX;
  AK1_RndMatrWorld = MatrMulMatr(MatrMulMatr(MatrRotateX(Ani->AngleX), MatrRotateY(Ani->AngleY)), MatrScale(10, 10, 10));
  AK1_RndMatrView = MatrView(VecSet(8, 8, 8), VecSet(0, 0, 0), VecSet(0, 1, 0));
  SetDCPenColor(Ani->hDC, RGB(255, 255, 255));
//  AK1_RndGObjDraw(&Uni->Model);
  for (i = 0; i < 3; i++)
  {
    Ani->PosX = X1 + (i + l) * 600;
    AK1_RndGObjDraw(&Uni->Model);
  }
  Ani->PosX = X1;
} /* End of 'ak1_AnimUnitRender' function */
Ejemplo n.º 20
0
void RoundRect(HDC hdc, RECT *rect, int cx, int cy, COLORREF fg, COLORREF bg)
{
	SetDCBrushColor(hdc, bg);
	SetDCPenColor(hdc, fg);
//	HBRUSH hBr = CreateSolidBrush(bg);
//	HPEN   hPn = CreatePen(0, PS_SOLID, fg);

//	HANDLE hOldBr  = SelectObject(hdc, hBr);
//	HANDLE hOldPen = SelectObject(hdc, hPn);

	RoundRect(hdc, rect->left, rect->top, rect->right, rect->bottom, cx, cy);

//	SelectObject(hdc, hOldBr);
//	SelectObject(hdc, hOldPen);
//	DeleteObject(hBr);
//	DeleteObject(hPn);
}
Ejemplo n.º 21
0
void InspectResult::Paint(HDC hdc, int BrowserRealWidth, int BrowserRealHeight, int BrowserDrawWidth, int BrowserDrawHeight, int BrowserScrollX, int BrowserScrollY, int BrowserLeft, int BrowserTop)
{
    //worker_log(std::string("Paint<<") + std::to_string(x) + std::string("<<") + std::to_string(y));
    if(!active)
        return;

    POINT pt;
    SelectObject(hdc, GetStockObject(DC_PEN));
    SetDCPenColor(hdc, RGB(255,0,0));

    int     x1 = (float)x * (float)BrowserDrawWidth / (float)BrowserRealWidth
            ,y1 = (float)y * (float)BrowserDrawHeight / (float)BrowserRealHeight
            ,width1 = (float)width* (float)BrowserDrawWidth / (float)BrowserRealWidth
            ,height1 = (float)height* (float)BrowserDrawHeight / (float)BrowserRealHeight;

    if(x1<=0)
       x1 = 1;

    if(y1<=0)
       y1 = 1;

    if(x1 + width1 >= BrowserDrawWidth)
       width1 = BrowserDrawWidth - x1 - 1;

    if(y1 + height1 >= BrowserDrawHeight)
       height1 = BrowserDrawHeight - y1 - 1;

    MoveToEx(hdc, BrowserLeft + x1, BrowserTop + y1, &pt);
    LineTo(hdc, BrowserLeft + x1, BrowserTop + y1 + height1);

    MoveToEx(hdc, BrowserLeft + x1, BrowserTop + y1, &pt);
    LineTo(hdc, BrowserLeft + x1 + width1, BrowserTop + y1);

    MoveToEx(hdc, BrowserLeft + x1, BrowserTop + y1 + height1, &pt);
    LineTo(hdc, BrowserLeft + x1 + width1, BrowserTop + y1 + height1);

    MoveToEx(hdc, BrowserLeft + x1 + width1, BrowserTop + y1, &pt);
    LineTo(hdc, BrowserLeft + x1 + width1, BrowserTop + y1 + height1);

    /*MoveToEx(hdc, 0, 30, &pt);
    LineTo(hdc, 500, 30);

    MoveToEx(hdc, 502, 221, &pt);
    LineTo(hdc, WindowWidth, 221);*/
}
Ejemplo n.º 22
0
static void drawTest(Ihandle* ih)
{
  RECT rect;
  HDC hDC = (HDC)IupGetAttribute(ih, "PREVIEWDC");
  int w = IupGetInt(ih, "PREVIEWWIDTH");
  int h = IupGetInt(ih, "PREVIEWHEIGHT");

  SetRect(&rect, 0, 0, w, h);
  FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));

  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(255, 0, 0));

  MoveToEx(hDC, 0, 0, NULL);
  LineTo(hDC, w-1, h-1);
  MoveToEx(hDC, 0, h-1, NULL);
  LineTo(hDC, w-1, 0);
}
Ejemplo n.º 23
0
static bool
plot_block(COLORREF col, int x, int y, int width, int height)
{
	HRGN clipregion;
	HGDIOBJ original = NULL;

	/* Bail early if we can */
	if ((x >= plot_clip.right) ||
	    ((x + width) < plot_clip.left) ||
	    (y >= plot_clip.bottom) ||
	    ((y + height) < plot_clip.top)) {
		/* Image completely outside clip region */
		return true;	
	}	

	/* ensure the plot HDC is set */
	if (plot_hdc == NULL) {
		LOG("HDC not set on call to plotters");
		return false;
	}

	clipregion = CreateRectRgnIndirect(&plot_clip);
	if (clipregion == NULL) {
		return false;
	}

	SelectClipRgn(plot_hdc, clipregion);

	/* Saving the original pen object */
	original = SelectObject(plot_hdc,GetStockObject(DC_PEN)); 

	SelectObject(plot_hdc, GetStockObject(DC_PEN));
	SelectObject(plot_hdc, GetStockObject(DC_BRUSH));
	SetDCPenColor(plot_hdc, col);
	SetDCBrushColor(plot_hdc, col);
	Rectangle(plot_hdc, x, y, width, height);

	SelectObject(plot_hdc,original); /* Restoring the original pen object */

	DeleteObject(clipregion);

	return true;

}
Ejemplo n.º 24
0
void DrawHeader(HDC hdc, TCHAR *s, int y, int width) {

	SelectObject(hdc, hfontSegoe);

	TEXTMETRIC tm;
	GetTextMetrics(hdc, &tm);

	RECT r = {8, y, width, y + tm.tmHeight*3/2};

	SetBkMode(hdc, TRANSPARENT);
	SetTextColor(hdc, RGB(0, 51, 153));
	DrawTextEx(hdc, s, -1, &r, DT_LEFT | DT_VCENTER | DT_SINGLELINE, NULL);

	DrawTextEx(hdc, s, -1, &r, DT_LEFT | DT_CALCRECT | DT_VCENTER | DT_SINGLELINE, NULL);
	SelectObject(hdc, GetStockObject(DC_PEN));
	SetDCPenColor(hdc, RGB(176, 191, 222));
	MoveToEx(hdc, r.right + tm.tmAveCharWidth/2, (r.bottom - r.top)/2 + 1, NULL);
	LineTo(hdc, width - 28, (r.bottom - r.top)/2 + 1);
}
Ejemplo n.º 25
0
void Dot::drawDot()
{
	if (this->visible)
	{
		BeginPaint(this->hWnd, &this->ps);
		SelectObject(this->hdc, GetStockObject(DC_BRUSH));
		SelectObject(this->hdc, GetStockObject(DC_PEN));
		SetDCBrushColor(this->hdc, this->color);
		SetDCPenColor(this->hdc, this->color);
		if (!moving)
		{
			this->winCoord = matrixToWinCoord(this->matrixCoord);
		}
		Ellipse(this->hdc, this->winCoord.x - size / 2, this->winCoord.y - size / 2,
			this->winCoord.x + size / 2, this->winCoord.y + size / 2);
		EndPaint(this->hWnd, &ps);
	}
	
}
Ejemplo n.º 26
0
/* Функция рисования стрелки.
 * АРГУМЕНТЫ:
 *   - контекст:
 *       HDC hDC;
 *   - координаты центра:
 *       INT Xc, Yc;
 *   - длина и ширина стрелки:
 *       INT L, W;
 *   - угол рисования:
 *       FLOAT Angle;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID DrawArrow( HDC hDC, INT Xc, INT Yc, INT L, INT W, FLOAT Angle )
{
  INT i;
  POINT pts[] =
  {
    {0, -W}, {-W, 0}, {0, L}, {W, 0}
  }, pts_draw[sizeof pts / sizeof pts[0]];
  FLOAT si = sin(Angle), co = cos(Angle);

  for (i = 0; i < sizeof pts / sizeof pts[0]; i++)
  {
    pts_draw[i].x = Xc + (pts[i].x * co - pts[i].y * si);
    pts_draw[i].y = Yc - (pts[i].x * si + pts[i].y * co);
  }
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(0, 0, 0));
  SetDCBrushColor(hDC, RGB(255, 255, 255));
  Polygon(hDC, pts_draw, sizeof pts / sizeof pts[0]);
} /* End of 'DrawArrow' function */
Ejemplo n.º 27
0
/* Draw figure function */
VOID Draw( HDC hDC, INT X, INT Y, DOUBLE A )
{
  INT i;
  DOUBLE rad = A * 3.14159265358979323 / 180, si = sin(rad), co = cos(rad);
  static POINT pt[] =
  {
    {-10, 0}, {-10, 50}, {0, 59 * 3}, {10, 50}, {10, 0}
  };
  POINT pt1[sizeof(pt) / sizeof(pt[0])];

  for (i = 0; i < sizeof(pt) / sizeof(pt[0]); i++)
  {
    pt1[i].x = X + pt[i].x * co - pt[i].y * si;
    pt1[i].y = Y - (pt[i].x * si + pt[i].y * co);
  }
  SelectObject(hDC, GetStockObject(DC_PEN));
  SelectObject(hDC, GetStockObject(DC_BRUSH));
  SetDCPenColor(hDC, RGB(255, 0, 0));
  SetDCBrushColor(hDC, RGB(255, 220, 220));
  Polygon(hDC, pt1, sizeof(pt) / sizeof(pt[0]));
} /* End of 'Draw' function */
Ejemplo n.º 28
0
void CDateBanner::PaintPre(HWND, HDC dc, int w, int h)
{
	SelectObject(dc, GetStockObject(DC_PEN));
	SelectObject(dc, GetStockObject(DC_BRUSH));
	TCHAR str[1024];
	SecureZeroMemory(str, sizeof(TCHAR) * 1024);
	SYSTEMTIME date;
	SecureZeroMemory(&date, sizeof(SYSTEMTIME));
	unsigned __int64 date64 = m_pDayManager->GetActiveDate();
	FILETIME ft = { static_cast<DWORD>(date64), static_cast<DWORD>(date64 >> 32) };
	FileTimeToSystemTime(&ft, &date);
	GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &date, NULL, str, 1024);

	//make the banner indicate past, present, future
	unsigned __int64 today = m_pDayManager->GetToday();
	unsigned __int64 localOffset = today - loadngo::data::util::UTCToLocalTime(today);
	today += localOffset;

	unsigned long bgColor = 0x00ffffff; //default present
	if(today < date64)
	{
		bgColor = 0x00ddffee; //future
	}
	else if(today > date64)
	{
		bgColor = 0x00ddeedd;  //past
	}
	SetDCBrushColor(dc, bgColor);
	SetDCPenColor(dc, bgColor);
	Rectangle(dc, 0, 0, w, h);

	RECT r = { BUTTONWIDTH, 0, w - (BUTTONWIDTH * 2), h };
	HGDIOBJ oldFont = SelectObject(dc, s_hfont);
	SetBkMode(dc, TRANSPARENT);
	SetTextColor(dc, 0x0);
	DrawText(dc, str, -1, &r, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
	SelectObject(dc, oldFont);
}
Ejemplo n.º 29
0
static void drawTest(Ihandle *ih, int posx)
{
  RECT rect;
  int w, h;
  HWND hWnd = (HWND)IupGetAttribute(ih, "HWND");
  HDC hDC = GetDC(hWnd);

  IupGetIntInt(ih, "DRAWSIZE", &w, &h);

  SetRect(&rect, 0, 0, w, h);
  FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));

  SelectObject(hDC, GetStockObject(DC_PEN));
  SetDCPenColor(hDC, RGB(255, 0, 0));

  w = 600; /* virtual size */
  MoveToEx(hDC, -posx, 0, NULL);
  LineTo(hDC, w-posx, h);
  MoveToEx(hDC, -posx, h, NULL);
  LineTo(hDC, w-posx, 0);

  ReleaseDC(hWnd, hDC);
}
Ejemplo n.º 30
0
void CVirtualLCD::UpdateScreenContent()
{
/*
#pragma warning(disable : 4996) 
  	  HANDLE h= CreateFile("c:\\polys", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, NULL);
	    for (int i=0; i<400; i++)
	    {
  	    char s[100000]= "";
	      sprintf(s, "POLY=%d,", i);
        for (int p=0; p<table[i].nbPoly; p++)
        {
          strcat(s, "{");
          for (int pt= 0; pt<table[i].poly[p].nbPoints; pt++)
            sprintf(s, "%s%d,%d,", s, table[i].poly[p].points[pt].x, table[i].poly[p].points[pt].y);
          s[strlen(s)-1]='}';
        }
	      sprintf(s, "%s\npoly=%d,", s, i);
        for (int p=0; p<table_LCD[i].nbPoly; p++)
        {
          strcat(s, "{");
          for (int pt= 0; pt<table_LCD[i].poly[p].nbPoints; pt++)
            sprintf(s, "%s%d,%d,", s, table_LCD[i].poly[p].points[pt].x, table_LCD[i].poly[p].points[pt].y);
          s[strlen(s)-1]='}';
        }
        strcat(s, "\n");
        DWORD wrote;
	      WriteFile(h, s, strlen(s), &wrote, NULL);
	    }
	    CloseHandle(h);
	*/
  u64 *e= (u64 *)AT91C_SLCDC_MEM;
  RECT re={0, 0, Skin.HighResScreen.x, Skin.HighResScreen.y};
  FillRect(m_hMemDC, &re, m_hBrushRepaint);

  re.right=Skin.screen.right; re.bottom=Skin.screen.bottom;
  FillRect(m_hMyDC, &re, m_hBrushRepaint);

  SelectObject(m_hMemDC, GetStockObject(DC_PEN));
  SetDCPenColor(m_hMemDC, Skin.screenfore);

  SelectObject(m_hMyDC, GetStockObject(DC_PEN));
  SetDCPenColor(m_hMyDC, Skin.screenfore);

  if (Skin.NbHighResPoly<400 || Skin.NbLowResPoly<400) return;
  SetPolyFillMode(m_hMyDC, WINDING);
  SetPolyFillMode(m_hMemDC, WINDING);
  for (int r=0; r<10; r++)
    for (int c=0; c<40; c++)
      if ((e[r]&((u64)1<<c))!=0)	
      {
        if (Skin.lowres[r*40+c].NbPoly==-1)
        {
          TSourceGraphic *sg= (TSourceGraphic*)&Skin.lowres[r*40+c];
          BitBlt(m_hMyDC, sg->p[0], sg->p[1], sg->p[2], sg->p[3], Skin.dc, sg->p[4], sg->p[5], SRCCOPY);
        } else
          for (int n=0; n<Skin.lowres[r*40+c].NbPoly; n++)
            Polygon(m_hMyDC, Skin.lowres[r*40+c].poly[n].points, Skin.lowres[r*40+c].poly[n].NbPoints);
        if (Skin.highres[r*40+c].NbPoly==-1)
        {
          TSourceGraphic *sg= (TSourceGraphic*)&Skin.highres[r*40+c];
          BitBlt(m_hMemDC, sg->p[0], sg->p[1], sg->p[2], sg->p[3], Skin.dc, sg->p[4], sg->p[5], SRCCOPY);
        } else
          for (int n=0; n<Skin.highres[r*40+c].NbPoly; n++)
            Polygon(m_hMemDC, Skin.highres[r*40+c].poly[n].points, Skin.highres[r*40+c].poly[n].NbPoints);
      }
  HDC hdc= ::GetDC(m_hWnd);
  BitBlt(hdc, 0,0, Skin.screen.right,Skin.screen.bottom, m_hMyDC, 0,0, SRCCOPY);
  ::ReleaseDC(m_hWnd, hdc);
}