Files
rive-cpp/tests/gm/verycomplexgrad.cpp
csmartdalton 6efab9c56f feat: Update goldens and player to deploy in the browser (#10453) 827077b899
Set up http and websocket servers in deploy_tests.py that allow us to
communicate with the remote wasm app similarly to how we communicate
with android & ios devices. Add a "-w" target to check_golds.sh that
kicks tests off in the default browser.

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2025-08-27 02:58:49 +00:00

53 lines
1.5 KiB
C++

/*
* Copyright 2022 Rive
*/
#include "gm.hpp"
#include "gmutils.hpp"
#include "rive/renderer.hpp"
#include "common/rand.hpp"
using namespace rivegm;
using namespace rive;
constexpr int W = 1000;
constexpr int H = 400;
constexpr int N = 9999;
class VeryComplexGradGM : public GM
{
public:
VeryComplexGradGM() : GM(W, H) {}
ColorInt clearColor() const override { return 0xff000000; }
void onDraw(rive::Renderer* renderer) override
{
Rand rand;
std::vector<ColorInt> colors(N);
std::vector<float> stops(N);
for (size_t i = 0; i < N; ++i)
{
colors[i] = rand.u32() | 0xff808080;
stops[i] = std::round(rand.f32() * W) / W;
}
std::sort(stops.begin(), stops.end());
Paint paint;
paint->shader(
TestingWindow::Get()->factory()->makeLinearGradient(0,
0,
W,
0,
colors.data(),
stops.data(),
N));
Path fullscreen = PathBuilder().addRect({0, 0, W, H}).detach();
renderer->drawPath(fullscreen, paint);
}
};
GMREGISTER(verycomplexgrad, return new VeryComplexGradGM())