AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Radial CGGradient

Ein Thema von Crocotronic · begonnen am 27. Jan 2014 · letzter Beitrag vom 6. Feb 2014
 
Crocotronic

Registriert seit: 9. Mai 2013
258 Beiträge
 
#2

AW: Radial CGGradient

  Alt 5. Feb 2014, 20:32
Ich hab nun gefunden was ich brauche, aber leider nur in Objective-C.
Hier ist der Code.
In Delphi übersetzt sieht das so aus:
Delphi-Quellcode:
procedure TForm1.UIView1DrawRect(Sender: TObject; ARect: TRectF);
var context: CGContextRef;
    dim: Double;
    subdiv: Integer;
    r,g: Double;
    halfinteriorPerim: Double;
    halfexteriorPerim: Double;
    smallBase: Double;
    largeBase: Double;
    cell: UIBezierPath;
    incr: Double;
    n: Integer;
    rect: CGrect;
begin
 rect:= CGrectMake(aRect.Location.X,aRect.Location.Y,aRect.Size.Width,aRect.Size.Height);

 context:= UIGraphicsGetCurrentContext();

 TUIColor.Wrap(TUIColor.OCClass.whiteColor).setFill;
 UIRectFill(rect);
 dim:= MIN(rect.size.width, rect.size.height);
 subdiv:= 512;
 r:= dim/4;
 g:= dim/2;

 halfinteriorPerim:= PI*r;
 halfexteriorPerim:= PI*g;
 smallBase:= halfinteriorPerim/subdiv;
 largeBase:= halfexteriorPerim/subdiv;

 cell:= TUIBezierPath.Wrap(TUIBezierPath.Alloc.CGPath);
 cell.moveToPoint(CGPointMake(-smallBase/2,r));
 cell.addLineToPoint(CGPointMake(smallBase/2,r));

 cell.addLineToPoint(CGPointMake(largeBase/2,g));
 cell.addLineToPoint(CGPointMake(-largeBase/2,g));
 cell.closePath;

 incr:= PI/subdiv;

 //[[NSColor whiteColor]set];
// CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort];
 CGContextTranslateCTM(context, rect.size.width/2, rect.size.height/2);

 CGContextScaleCTM(context, 0.9, 0.9);
 CGContextRotateCTM(context,PI/2);
 CGContextRotateCTM(context,-incr/2);
 for n:= 0 to subdiv do
 begin
  TUIColor.Wrap(TUIColor.OCClass.blueColor).setFill;
  cell.fill;
  cell.stroke;
  CGContextRotateCTM(context,-incr);
 end;
end;
Funktioniert nur nicht ^^
Weiß jemand warum?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz