FlattenPictureTest: add tests for Gradients.
None of the tests pass. BPicture currently doesn't have support for gradients. Also add DrawString with offsets test.
This commit is contained in:
@@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
#include "PictureTestCases.h"
|
#include "PictureTestCases.h"
|
||||||
|
|
||||||
|
#include <GradientLinear.h>
|
||||||
|
#include <GradientRadial.h>
|
||||||
|
#include <GradientRadialFocus.h>
|
||||||
|
#include <GradientDiamond.h>
|
||||||
|
#include <GradientConic.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static const rgb_color kBlack = {0, 0, 0};
|
static const rgb_color kBlack = {0, 0, 0};
|
||||||
@@ -66,6 +72,24 @@ static void testDrawStringWithLength(BView *view, BRect frame)
|
|||||||
view->DrawString("Haiku [ÖÜÄöüä]", 13, BPoint(frame.left, baseline));
|
view->DrawString("Haiku [ÖÜÄöüä]", 13, BPoint(frame.left, baseline));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void testDrawStringWithOffsets(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BFont font;
|
||||||
|
view->GetFont(&font);
|
||||||
|
font_height height;
|
||||||
|
font.GetHeight(&height);
|
||||||
|
float baseline = frame.bottom - height.descent;
|
||||||
|
// draw base line
|
||||||
|
view->SetHighColor(kGreen);
|
||||||
|
view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1));
|
||||||
|
|
||||||
|
view->SetHighColor(kBlack);
|
||||||
|
const BPoint pointArray[] = { BPoint(frame.left, baseline) };
|
||||||
|
view->DrawString("Haiku [ÖÜÄöüä]", pointArray, sizeof(pointArray) / sizeof(pointArray[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void testFillArc(BView *view, BRect frame)
|
static void testFillArc(BView *view, BRect frame)
|
||||||
{
|
{
|
||||||
frame.InsetBy(2, 2);
|
frame.InsetBy(2, 2);
|
||||||
@@ -154,6 +178,52 @@ static void testFillRect(BView *view, BRect frame)
|
|||||||
view->FillRect(frame);
|
view->FillRect(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void testFillRectGradientLinear(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BGradientLinear gradient(0, 0, frame.right, frame.bottom);
|
||||||
|
gradient.AddColor(kRed, 0);
|
||||||
|
gradient.AddColor(kBlue, 255);
|
||||||
|
frame.InsetBy(2, 2);
|
||||||
|
view->FillRect(frame, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testFillRectGradientRadial(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BGradientRadial gradient(10, 10, 10);
|
||||||
|
gradient.AddColor(kRed, 0);
|
||||||
|
gradient.AddColor(kBlue, 255);
|
||||||
|
frame.InsetBy(2, 2);
|
||||||
|
view->FillRect(frame, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testFillRectGradientRadialFocus(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BGradientRadialFocus gradient(0, 0, 10, 10, 5);
|
||||||
|
gradient.AddColor(kRed, 0);
|
||||||
|
gradient.AddColor(kBlue, 255);
|
||||||
|
frame.InsetBy(2, 2);
|
||||||
|
view->FillRect(frame, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testFillRectGradientDiamond(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BGradientDiamond gradient(0, 10);
|
||||||
|
gradient.AddColor(kRed, 0);
|
||||||
|
gradient.AddColor(kBlue, 255);
|
||||||
|
frame.InsetBy(2, 2);
|
||||||
|
view->FillRect(frame, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testFillRectGradientConic(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
BGradientConic gradient(0, 0, 10);
|
||||||
|
gradient.AddColor(kRed, 0);
|
||||||
|
gradient.AddColor(kBlue, 255);
|
||||||
|
frame.InsetBy(2, 2);
|
||||||
|
view->FillRect(frame, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
static void testStrokeRect(BView *view, BRect frame)
|
static void testStrokeRect(BView *view, BRect frame)
|
||||||
{
|
{
|
||||||
frame.InsetBy(2, 2);
|
frame.InsetBy(2, 2);
|
||||||
@@ -678,9 +748,9 @@ static void testSetOriginAndScale5(BView *view, BRect frame)
|
|||||||
view->FillRect(r);
|
view->FillRect(r);
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
view->SetScale(0.75);
|
view->SetScale(0.75);
|
||||||
view->SetHighColor(kGreen);
|
view->SetHighColor(kGreen);
|
||||||
view->FillRect(r);
|
view->FillRect(r);
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,6 +827,9 @@ static void testFontRotation(BView* view, BRect frame)
|
|||||||
fprintf(stderr, "Error: Rotation is %f but should be 90.0\n", font.Rotation());
|
fprintf(stderr, "Error: Rotation is %f but should be 90.0\n", font.Rotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - blending mode
|
// - blending mode
|
||||||
// - line mode
|
// - line mode
|
||||||
@@ -770,6 +843,8 @@ TestCase gTestCases[] = {
|
|||||||
{ "Test DrawChar", testDrawChar },
|
{ "Test DrawChar", testDrawChar },
|
||||||
{ "Test Draw String", testDrawString },
|
{ "Test Draw String", testDrawString },
|
||||||
{ "Test Draw String With Length", testDrawStringWithLength },
|
{ "Test Draw String With Length", testDrawStringWithLength },
|
||||||
|
{ "Test Draw String With Offsets", testDrawStringWithOffsets },
|
||||||
|
|
||||||
{ "Test FillArc", testFillArc },
|
{ "Test FillArc", testFillArc },
|
||||||
{ "Test StrokeArc", testStrokeArc },
|
{ "Test StrokeArc", testStrokeArc },
|
||||||
// testFillBezier fails under BeOS because the
|
// testFillBezier fails under BeOS because the
|
||||||
@@ -781,6 +856,11 @@ TestCase gTestCases[] = {
|
|||||||
{ "Test FillPolygon", testFillPolygon },
|
{ "Test FillPolygon", testFillPolygon },
|
||||||
{ "Test StrokePolygon", testStrokePolygon },
|
{ "Test StrokePolygon", testStrokePolygon },
|
||||||
{ "Test FillRect", testFillRect },
|
{ "Test FillRect", testFillRect },
|
||||||
|
{ "Test FillRectGradientLinear", testFillRectGradientLinear },
|
||||||
|
{ "Test FillRectGradientRadial", testFillRectGradientRadial },
|
||||||
|
{ "Test FillRectGradientRadialFocus", testFillRectGradientRadialFocus },
|
||||||
|
{ "Test FillRectGradientDiamond", testFillRectGradientDiamond },
|
||||||
|
{ "Test FillRectGradientConic", testFillRectGradientConic },
|
||||||
{ "Test StrokeRect", testStrokeRect },
|
{ "Test StrokeRect", testStrokeRect },
|
||||||
{ "Test FillRegion", testFillRegion },
|
{ "Test FillRegion", testFillRegion },
|
||||||
{ "Test FillRoundRect", testFillRoundRect },
|
{ "Test FillRoundRect", testFillRoundRect },
|
||||||
|
|||||||
Reference in New Issue
Block a user