/usr/lib/Wt/examples/planner/Shape.C is in witty-examples 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /*
* Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include "Shape.h"
#include <Wt/WPainterPath>
#include <math.h>
using namespace Wt;
Shape::~Shape()
{
}
Circle::Circle(const WPointF& center,
const ShapeColor& color,
const double size)
: Shape(center, color, size)
{
}
bool Circle::contains(const WPointF& point) const
{
return distanceTo(center().x(),
center().y(),
point.x(),
point.y())
<= size();
}
WString Circle::shapeName() const
{
return WString::tr("captcha.circle");
}
double Circle::distanceTo(const double x1, const double y1,
const double x2, const double y2) const
{
return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}
void Circle::paint(Wt::WPainter& painter) const
{
WBrush b;
b.setStyle(SolidPattern);
b.setColor(color());
WPainterPath pp;
pp.addEllipse(center().x() - size(),
center().y() - size(),
size() * 2, size() * 2);
painter.fillPath(pp, b);
}
Rectangle::Rectangle(const WPointF& center,
const ShapeColor& color,
const double size)
: Shape(center, color, size)
{
}
bool Rectangle::contains(const WPointF& point) const
{
return WRectF(center().x(),
center().y(),
size(),
size()).
contains(point);
}
WString Rectangle::shapeName() const
{
return WString::tr("captcha.rectangle");
}
void Rectangle::paint(Wt::WPainter& painter) const
{
WBrush b;
b.setStyle(SolidPattern);
b.setColor(color());
WPainterPath pp;
pp.addRect(WRectF(center().x(), center().y(), size(), size()));
painter.fillPath(pp, b);
}
|