本文整理汇总了C++中Painter::Translate方法的典型用法代码示例。如果您正苦于以下问题:C++ Painter::Translate方法的具体用法?C++ Painter::Translate怎么用?C++ Painter::Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Painter
的用法示例。
在下文中一共展示了Painter::Translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Path
void Path(Painter& sw)
{
sw.Translate(52, 52);
for(int i = 0; i < 2; i++) {
sw.Rectangle(20, 20, 60, 60);
sw.Move(0, 0);
sw.Cubic(99, 0, 50, 50, 99, 99);
sw.Cubic(0, 99, 50, 50, 0, 0);
sw.EvenOdd(i).Fill(Green());
sw.Stroke(1, Black());
sw.Translate(120, 0);
}
}
示例2: Div
void Div(Painter& sw)
{
sw.Character(100, 100, 'O', Arial(100))
.Character(100, 150, 'O', Arial(100))
.Fill(Black());
sw.Translate(200, 0);
sw.Character(100, 100, 'O', Arial(100))
.Div()
.Character(100, 150, 'O', Arial(100))
.Fill(Black());
}
示例3: Paint
void Paint(Painter& Painter, Portfolio& Portfolio)
{
/*For this example, we'll move the origin to the center to make things
a little easier to see. The most important thing to know is that by
default Belle uses the bottom-left corner of the canvas as the origin and
not the top-left corner (with reversed y) as many graphics libraries do.
While this is a bit unconventional, it allows for the x and y dimensions
to be treated the same and makes for clearer code.*/
Painter.Translate(Dimensions / 2.0);
//Draw a silhouette of the untransformed shape.
DrawShape(Painter, Colors::gray, Colors::lightgray);
//For each page show a different example of using affine transformations.
switch(Painter.GetPageNumber())
{
case 0: //Page 1
//Just show the gray coordinate axis...
break;
case 1: //Page 2
//Show a translation over 1.3 and up 1.8.
Painter.Translate(Vector(1.3, 1.8));
DrawShape(Painter);
Painter.Revert();
break;
case 2: //Page 3
//Show a rotation of 30 degrees.
Painter.Rotate(30.0 * Deg); /*(Deg is just a unit that converts degrees
to radians when multiplying and radians to degress when dividing).*/
DrawShape(Painter);
Painter.Revert();
break;
case 3: //Page 4
//Show a scaling of 1.5.
Painter.Scale(1.5);
DrawShape(Painter);
Painter.Revert();
break;
case 4: //Page 5
/*Scaling and translating is not the same as translating and scaling.
This is related to the fact that matrix multiplication is not generally
commutative.*/
Painter.Translate(Vector(1, 1)); //Translate-scale
Painter.Scale(2.0);
DrawShape(Painter, Colors::green);
Painter.Revert(2); /*(Revert defaults to undoing one transformation, but
you can specify any number of previous transformations to revert at
once.)*/
Painter.Scale(2.0); //Scale-translate
Painter.Translate(Vector(1, 1));
DrawShape(Painter, Colors::red);
Painter.Revert(2);
break;
case 5: //Page 6
/*For the same underlying reason, rotating and translating is not the
same as translating and rotating.*/
Painter.Translate(Vector(1, 1)); //Translate-rotate
Painter.Rotate(30.0 * Deg);
DrawShape(Painter, Colors::green);
Painter.Revert(2);
Painter.Rotate(30.0 * Deg); //Rotate-translate
Painter.Translate(Vector(1, 1));
DrawShape(Painter, Colors::red);
Painter.Revert(2);
break;
case 6: //Page 7
//However, scaling and rotation happen to be commutative.
Painter.Scale(2.0); //Scale-rotate
Painter.Rotate(30.0 * Deg);
DrawShape(Painter, Colors::green);
Painter.Revert(2);
Painter.Rotate(30.0 * Deg); //Rotate-scale
Painter.Scale(2.0);
DrawShape(Painter, Colors::green);
Painter.Revert(2);
break;
case 7: //Page 8
/*Occasionally, one may find a need to scale by different amounts in the
x- and y- dimensions. This is typically done to create a mirror image.*/
Painter.Scale(Vector(-1.0, 1.0)); //Horizontal mirror
DrawShape(Painter, Colors::lightgreen);
Painter.Revert();
DrawShape(Painter, Colors::green); //Original
break;
case 8: //Page 9
{
/*You can also create an affine transformation using the Affine object,
and call Transform with the object.
//.........这里部分代码省略.........