Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. void GradientTriangle( HDC MemDC,
  2. LONG x1, LONG y1,
  3. LONG x2, LONG y2,
  4. LONG x3, LONG y3,
  5. COLORREF top, COLORREF bottom )
  6. {
  7. TRIVERTEX vertex[3];
  8.  
  9. vertex[0].x = x1;
  10. vertex[0].y = y1;
  11. vertex[0].Red = GetRValue(bottom) << 8;
  12. vertex[0].Green = GetGValue(bottom) << 8;
  13. vertex[0].Blue = GetBValue(bottom) << 8;
  14. vertex[0].Alpha = 0x0000;
  15.  
  16. vertex[1].x = x3;
  17. vertex[1].y = y3;
  18. vertex[1].Red = GetRValue(bottom) << 8;
  19. vertex[1].Green = GetGValue(bottom) << 8;
  20. vertex[1].Blue = GetBValue(bottom) << 8;
  21. vertex[1].Alpha = 0x0000;
  22.  
  23. vertex[2].x = x2;
  24. vertex[2].y = y2;
  25. vertex[2].Red = GetRValue(top) << 8;
  26. vertex[2].Green = GetGValue(top) << 8;
  27. vertex[2].Blue = GetBValue(top) << 8;
  28. vertex[2].Alpha = 0x0000;
  29.  
  30. // Create a GRADIENT_TRIANGLE structure that
  31. // references the TRIVERTEX vertices.
  32.  
  33. GRADIENT_TRIANGLE gTriangle;
  34.  
  35. gTriangle.Vertex1 = 0;
  36. gTriangle.Vertex2 = 1;
  37. gTriangle.Vertex3 = 2;
  38.  
  39. // Draw a shaded triangle.
  40.  
  41. GradientFill( MemDC, vertex, 3, &gTriangle, 1, GRADIENT_FILL_TRIANGLE);
  42. }
  43.  
  44. // bottom triangle --> need help with this one!!
  45. GradientTriangle( (HDC)wParam,
  46. r.left, r.top,
  47. r.left, r.bottom - r.top,
  48. r.right, r.bottom - r.top,
  49. RGB( 0x0, 0x0, 0xFF ), RGB( 0xFF, 0xFF, 0x0 ) );
  50.  
  51. // top triangle --> this one is fine !
  52. GradientTriangle( (HDC)wParam,
  53. r.right, r.bottom - r.top,
  54. r.right, r.top,
  55. r.left, r.top,
  56. RGB( 0xFF, 0x0, 0x0 ), RGB( 0x0, 0xFF, 0x0 ) );
  57. }
  58. return 1L;
  59.  
  60. // I have modified parametters for bottom triangle
  61. GradientTriangle( (HDC)wParam,
  62. r.left, r.top,
  63. r.right, r.bottom - r.top, // switched places
  64. r.left, r.bottom - r.top, // of these two coordinates
  65. RGB( 0x0, 0x0, 0xFF ), RGB( 0xFF, 0xFF, 0x0 ) ); // but color has changed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement