当前位置: 首页>>代码示例>>C++>>正文


C++ Painter::Scale方法代码示例

本文整理汇总了C++中Painter::Scale方法的典型用法代码示例。如果您正苦于以下问题:C++ Painter::Scale方法的具体用法?C++ Painter::Scale怎么用?C++ Painter::Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Painter的用法示例。


在下文中一共展示了Painter::Scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Stroke

void Stroke(Painter& sw)
{
	const char *txt = "GRM";
	Font fnt = Arial(100).Bold();
	Size tsz = GetTextSize(txt, fnt);
	sw.Scale(3, 3);
	sw.Text(100, 100, txt, fnt)
	  .Stroke(10, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed())
	  .Stroke(0.25, White());
	sw.Path("M 100 100 L 200 100 L 210 90 L 220 40 L 230 90 L 240 100 L 400 100")
	  .Stroke(24, Blue());
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:12,代码来源:Stroke.cpp

示例2: 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.
//.........这里部分代码省略.........
开发者ID:pgblu,项目名称:Belle,代码行数:101,代码来源:Tutorial2.cpp


注:本文中的Painter::Scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。