Autor Beitrag
aLeXanDer..
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mi 13.06.12 09:27 
Hallo Community,

Ich programmiere in Delphi mit RadStudio XE2 und benutze hierzu die Libary IGDI+,
Momentan hänge ich an den Funktionen AGraphics.TranslateTransform und AGraphics.RotateTransform

ich möchte gern mein eigenes Objekt , meinen eigenen Button, drehen. das heißt ich möchte eine Zentrale Zeichenroutine haben
und hier wird dann gesagt, du bist jetzt 45° gedreht, zeichne dich.

Mein Ansatz bis jetzt ist der hier

ausblenden volle Höhe Delphi-Quelltext
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:
...
var
//  AGraphics      : IGPGraphics;
  AFont          : IGPFont;
  ALeftTopCorner : TGPPointF;
  ARect          : TGPRectF;
  ARect1         : TGPRectF;
  APath          : IGPGraphicsPath;

  ABrush         : TGPBrush;
  APen            : TGPPen;

  AText      :String;
  Farbe1  : TGPColor;
  Farbe2  : TGPColor;

begin
  inherited;

//  AGraphics := TGPGraphics.Create( Canvas );
  AGraphics.SmoothingMode := SmoothingModeAntiAlias;
  AGraphics.TextRenderingHint := TextRenderingHintAntiAlias;

  APen := TGPPen.Create(aclGray);

  AGraphics.TranslateTransform(0,0); //TranslateTransform
  AGraphics.RotateTransform(45);     //Roate

  //ObjektGröße ?!?!??!

  if FValue then
    begin
      AText := FZustandsTextEin;
      Farbe1 := aclLime;
      Farbe2 := aclLime;
    end
  else
    begin
      AText := FZustandsTextAus;
      Farbe1 := aclTomato;
      Farbe2 := aclRed;
    end;

  ALeftTopCorner := MakePointF( 1010 );
  AFont := TGPFont.Create( 'Microsoft Sans Serif', FFontSize, [ fsBold ] );
  ARect := AGraphics.GetStringBoundingBoxF( AText, AFont, ALeftTopCorner );
  ARect1 := GPInflateRectF( ARect, 55 );

    AGraphics.DrawRoundRectangleF(
        TGPPen.Create( TGPLinearGradientBrush.Create( GPInflateRectF( ARect1, 22 ), aclGray, aclDimgray, LinearGradientModeVertical ), 4 ),
        TGPPathGradientBrush.Create(
          TGPGraphicsPath.Create().AddRoundRectangleF( ARect1, MakeSizeF( 10 ) )
           ).SetInterpolationColorArrays(
          [ aclGray, aclLightgray, aclGray ], [ 00.051 ] )
         .SetCenterPointF( MakePointF( 25050 ))
         .SetFocusScales( 0.10.8 ),
        ARect1, MakeSizeF( 10) );
    // Draw a text with semitransparent shadow.
  AGraphics.DrawStringF( AText,
             AFont,
             MakePointF( 1313 ),
             TGPSolidBrush.Create( MakeARGBColor( 50, aclBlack )) )
       .DrawStringF( AText,
             AFont,
             ALeftTopCorner,
             TGPLinearGradientBrush.Create( ARect, Farbe1, Farbe2, LinearGradientModeForwardDiagonal ));


Mein Problem ist allderdings, wenn ich den Rotate ausführe, das mein Objekt ja immernoch die Width und Height von vorher besitzt.
Folglich erhalte ich nur einen kleinen Teil meines Objekts sichtbar. der Rest ist ja außerhalb der größe gezeichnet.

Wie löse ich dieses Problem ? wie Berechne ich die neue Breite und Höhe? wo muss ich diese Setzen ?

Danke
Alex