Add ui::triangle_shape
This commit is contained in:
parent
6ad43ff0a5
commit
c54a9944f1
2 changed files with 47 additions and 0 deletions
25
libs/ui/include/psemek/ui/triangle_shape.hpp
Normal file
25
libs/ui/include/psemek/ui/triangle_shape.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/ui/shape.hpp>
|
||||
|
||||
#include <psemek/geom/simplex.hpp>
|
||||
|
||||
namespace psemek::ui
|
||||
{
|
||||
|
||||
struct triangle_shape
|
||||
: shape
|
||||
{
|
||||
geom::triangle<geom::point<float, 2>> triangle{{{0.f, 0.f}, {0.f, 0.f}, {0.f, 0.f}}};
|
||||
|
||||
triangle_shape() = default;
|
||||
|
||||
triangle_shape(geom::triangle<geom::point<float, 2>> triangle)
|
||||
: triangle{triangle}
|
||||
{}
|
||||
|
||||
bool contains(geom::point<float, 2> const & point) const override;
|
||||
geom::box<float, 2> bbox() const override;
|
||||
};
|
||||
|
||||
}
|
||||
22
libs/ui/source/triangle_shape.cpp
Normal file
22
libs/ui/source/triangle_shape.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <psemek/ui/triangle_shape.hpp>
|
||||
|
||||
#include <psemek/geom/contains.hpp>
|
||||
|
||||
namespace psemek::ui
|
||||
{
|
||||
|
||||
bool triangle_shape::contains(geom::point<float, 2> const & point) const
|
||||
{
|
||||
return geom::contains(triangle, point);
|
||||
}
|
||||
|
||||
geom::box<float, 2> triangle_shape::bbox() const
|
||||
{
|
||||
geom::box<float, 2> b;
|
||||
b |= triangle[0];
|
||||
b |= triangle[1];
|
||||
b |= triangle[2];
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue