blob: 82cb9e9c11b4d322cee73468d53bcb23582fb34e [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "garnet/testing/views/coordinate_test_view.h"
namespace scenic {
CoordinateTestView::CoordinateTestView(ViewContext context,
const std::string& debug_name)
: BackgroundView(std::move(context), debug_name) {}
void CoordinateTestView::Draw(float cx, float cy, float sx, float sy) {
BackgroundView::Draw(cx, cy, sx, sy);
EntityNode root_node(session());
view()->AddChild(root_node);
static const float pane_width = sx / 2;
static const float pane_height = sy / 2;
for (uint32_t i = 0; i < 2; i++) {
for (uint32_t j = 0; j < 2; j++) {
Rectangle pane_shape(session(), pane_width, pane_height);
Material pane_material(session());
pane_material.SetColor(i * 255.f, 0, j * 255.f, 255);
ShapeNode pane_node(session());
pane_node.SetShape(pane_shape);
pane_node.SetMaterial(pane_material);
pane_node.SetTranslation((i + 0.5) * pane_width, (j + 0.5) * pane_height,
-20);
root_node.AddChild(pane_node);
}
}
Rectangle pane_shape(session(), sx / 4, sy / 4);
Material pane_material(session());
pane_material.SetColor(0, 255, 0, 255);
ShapeNode pane_node(session());
pane_node.SetShape(pane_shape);
pane_node.SetMaterial(pane_material);
pane_node.SetTranslation(0.5 * sx, 0.5 * sy, -40);
root_node.AddChild(pane_node);
}
} // namespace scenic