[haiku-commits] haiku: hrev47557 - src/tests/servers/app/gradients

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Jul 2014 18:00:49 +0200 (CEST)

hrev47557 adds 1 changeset to branch 'master'
old head: 5f6a39cabead38d0129049791f6410fdd670b8e2
new head: d1a5f9098111929d00d31506c2d45bd1b3689f9e
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d1a5f90+%5E5f6a39c

----------------------------------------------------------------------------

d1a5f90: More test cases for gradients with alpha channel
  
  * Swapping the opaque and transparent ends leads to different results,
  * Linear gradients are also affected.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev47557
Commit:      d1a5f9098111929d00d31506c2d45bd1b3689f9e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d1a5f90
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Jul 23 15:59:37 2014 UTC

----------------------------------------------------------------------------

1 file changed, 32 insertions(+), 3 deletions(-)
src/tests/servers/app/gradients/main.cpp | 35 +++++++++++++++++++++++++---

----------------------------------------------------------------------------

diff --git a/src/tests/servers/app/gradients/main.cpp 
b/src/tests/servers/app/gradients/main.cpp
index ebc8a58..6e1a132 100644
--- a/src/tests/servers/app/gradients/main.cpp
+++ b/src/tests/servers/app/gradients/main.cpp
@@ -12,6 +12,7 @@
 #include <string.h>
 
 #include <Application.h>
+#include <GradientLinear.h>
 #include <GradientRadial.h>
 #include <LayoutBuilder.h>
 #include <List.h>
@@ -79,13 +80,41 @@ public:
 
        virtual void Draw(BView* view, BRect updateRect)
        {
+               view->SetDrawingMode(B_OP_ALPHA);
+
+               // These draw as almost transparent
+
+               // Radial gradient
                BPoint center(50, 50);
                float radius = 50.0;
                BGradientRadial g(center, radius);
-               g.AddColor((rgb_color){ 0, 0, 0, 255 }, 0.0);
-               g.AddColor((rgb_color){ 0, 0, 0, 0 }, 255.0);
-               view->SetDrawingMode(B_OP_ALPHA);
+               g.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0);
+               g.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
                view->FillEllipse(center, radius, radius, g);
+
+               // Linear gradient
+               BPoint from(100, 0);
+               BPoint to(200, 0);
+               BGradientLinear l(from, to);
+               l.AddColor((rgb_color){ 255, 0, 0, 0 }, 0.0);
+               l.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
+               view->FillRect(BRect(100, 0, 200, 100), l);
+
+               // These draw as opaque or almost opaque
+               
+               view->SetOrigin(BPoint(0, 100));
+
+               // Radial gradient
+               BGradientRadial go(center, radius);
+               go.AddColor((rgb_color){ 255, 0, 0, 0 }, 0.0);
+               go.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
+               view->FillEllipse(center, radius, radius, go);
+
+               // Linear gradient
+               BGradientLinear lo(from, to);
+               lo.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0);
+               lo.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
+               view->FillRect(BRect(100, 0, 200, 100), lo);
        }
 };
 


Other related posts:

  • » [haiku-commits] haiku: hrev47557 - src/tests/servers/app/gradients - pulkomandy