本文整理汇总了C++中boost::shared_ptr::DrawDot方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::DrawDot方法的具体用法?C++ shared_ptr::DrawDot怎么用?C++ shared_ptr::DrawDot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::DrawDot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawCanvas
void ribi::DrawCanvas::Test() noexcept
{
{
static bool is_tested = false;
if (is_tested) return;
is_tested = true;
}
TRACE("Starting ribi::DrawCanvas::Test");
//Drawing text
{
const int maxx = 90;
const int maxy = 18;
const boost::shared_ptr<DrawCanvas> canvas(new DrawCanvas(maxx,maxy,CanvasColorSystem::invert));
std::stringstream s_before;
s_before << (*canvas);
const std::string str_before {s_before.str() };
assert(static_cast<int>(str_before.size()) - maxy == maxx * maxy); //-maxy, as newlines are added
assert(std::count(str_before.begin(),str_before.end(),' ') == maxx * maxy); //Only spaces
canvas->DrawText(1,1,"Hello world");
std::stringstream s_after;
s_after << (*canvas);
const std::string str_after {s_after.str() };
assert(std::count(str_after.begin(),str_after.end(),' ') != maxx * maxy); //Line trly drawn
}
//Is a line that starts and ends beyond the canvas drawn?
{
const int maxx = 3;
const int maxy = 4;
const boost::shared_ptr<DrawCanvas> canvas(new DrawCanvas(maxx,maxy,CanvasColorSystem::invert));
std::stringstream s_before;
s_before << (*canvas);
const std::string str_before {s_before.str() };
assert(static_cast<int>(str_before.size()) - maxy == maxx * maxy); //-maxy, as newlines are added
assert(std::count(str_before.begin(),str_before.end(),' ') == maxx * maxy); //Only spaces
canvas->DrawLine(-maxx,-maxy,maxx*2.0,maxy*2.0);
std::stringstream s_after;
s_after << (*canvas);
const std::string str_after {s_after.str() };
assert(std::count(str_after.begin(),str_after.end(),' ') != maxx * maxy); //Line trly drawn
}
//Draw a smiley is all coordinat- and colorsystem combinations, Clear
for (int i=0; i!=4; ++i)
{
const int maxx = 79;
const int maxy = 23;
const boost::shared_ptr<DrawCanvas> canvas(new DrawCanvas(maxx,maxy));
canvas->SetColorSystem(
i % 2
? CanvasColorSystem::normal
: CanvasColorSystem::invert);
canvas->SetCoordinatSystem(
i / 2
? CanvasCoordinatSystem::screen
: CanvasCoordinatSystem::graph);
//Determine and calculate dimensions and coordinats of smiley
const double maxxD = static_cast<double>(maxx);
const double maxyD = static_cast<double>(maxy);
const double midX = 0.50 * maxxD;
const double midY = 0.50 * maxyD;
const double headRay = 0.50 * maxyD;
const double eyeLeftX = 0.50 * maxxD - (0.35 * headRay) ;
const double eyeLeftY = 0.50 * maxyD - (0.25 * headRay) ;
const double eyeRightX = 0.50 * maxxD + (0.35 * headRay) ;
const double eyeRightY = 0.50 * maxyD - (0.25 * headRay) ;
const double eyeRay = 0.30 * headRay;
const double mouthLeftX = 0.50 * maxxD - (0.7 * headRay) ;
const double mouthMidX = 0.50 * maxxD;
const double mouthRightX = 0.50 * maxxD + (0.7 * headRay) ;
const double mouthLeftY = 0.50 * maxyD + (0.2 * headRay) ;
const double mouthMidY = 0.50 * maxyD + (0.7 * headRay) ;
const double mouthRightY = 0.50 * maxyD + (0.2 * headRay) ;
//Draw the image on DrawCanvas
canvas->DrawCircle(midX, midY, headRay);
canvas->DrawCircle(eyeLeftX, eyeLeftY, eyeRay);
canvas->DrawDot(eyeLeftX, eyeLeftY);
canvas->DrawCircle(eyeRightX, eyeRightY, eyeRay);
canvas->DrawDot(eyeRightX, eyeRightY);
canvas->DrawLine(mouthLeftX, mouthLeftY, mouthMidX, mouthMidY);
canvas->DrawLine(mouthMidX, mouthMidY, mouthRightX, mouthRightY);
canvas->DrawLine(mouthRightX, mouthRightY, mouthLeftX, mouthLeftY);
{
std::stringstream s;
s << (*canvas);
assert(!s.str().empty());
}
canvas->Clear();
{
canvas->SetColorSystem(CanvasColorSystem::invert); //Background = Black
std::stringstream s;
s << (*canvas);
const std::string t { s.str() };
assert(std::count(t.begin(),t.end(),' ') == canvas->GetWidth() * canvas->GetHeight());
}
}
//.........这里部分代码省略.........