This tutorial demonstrates how to perform all the most important vector graphics operations using the vl::VectorGraphics class.
class App_VectorGraphics: public BaseDemo
{
public:
virtual void initEvent()
{
ghostCameraManipulator()->setEnabled(false);
rendering()->
as<
vl::Rendering>()->setNearFarClippingPlanesOptimized(
false);
for(int x=0; x<=100; x+=4)
for(int y=0; y<=100; y+=4)
int scissor_w = 200;
int scissor_h = 200;
vg->
setScissor(256-scissor_w/2,256+128-scissor_h/2,scissor_w,scissor_h);
std::vector<vl::dvec2> points;
for(int i=0; i<1000; ++i)
{
points.push_back(
vl::dvec2(rand()%128-64,rand()%128-64));
points[i].normalize();
points[i] *= (rand()%1280) / 10.0f;
}
points.clear();
for(int i=0; i<200; ++i)
{
points.push_back(
vl::dvec2(rand()%128-64,rand()%128-64));
points[i].normalize();
points[i] *= (rand()%1280) / 10.0f;
}
points.clear();
for(int i=0; i<100; ++i)
{
points.push_back(
vl::dvec2(rand()%128-64,rand()%128-64));
points[i].normalize();
points[i] *= (rand()%640) / 10.0f;
}
points.clear();
for(int i=0; i<100; ++i)
{
points.push_back(
vl::dvec2(rand()%128-64,rand()%128-64));
points[i].normalize();
points[i] *= (rand()%640) / 10.0f;
}
rendering()->
as<
vl::Rendering>()->transform()->addChild(mRoseTransform.get());
for(int i=0; i<400; ++i)
vg->
drawEllipse(rand()%512,rand()%512 , rand()%20+10,rand()%20+10);
for(int i=0; i<256/4; ++i)
vg->
setFont(
"/font/bitstream-vera/Vera.ttf", 14,
false);
vg->
setFont(
"/font/bitstream-vera/VeraMono.ttf", 14,
true);
rendering()->
as<
vl::Rendering>()->transform()->addChild( mStarTransform.get() );
std::vector<vl::dvec2> star_line_loop;
for(int i=0; i<5; ++i)
{
star_line_loop.push_back(v.
xy());
}
std::vector<vl::dvec2> star_lines;
for(int i=0; i<5; ++i)
{
star_lines.push_back(v1.
xy());
star_lines.push_back(v2.
xy());
}
}
virtual void updateScene()
{
mRoseTransform->setLocalMatrix(mat);
mStarTransform->setLocalMatrix(mat);
}
void resizeEvent(int w, int h)
{
}
protected:
};