Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 31-01-2004, 06:44   #1 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
Post Gefüllten Kreis zeichnen -> Gibt Löcher

Hallo Leute,

Ich wollte mal versuchen ganz simpel einen gefüllten Kreis zu zeichnen : moveTo Mittelpunkt, und dann per Schleife 360 * immer eine Linie ziehen.

ActionScript:
  1. WGLtoRad = function (number) {
  2.     return number*Math.PI/180;
  3. };
  4. WGLObject = function (x, y) {
  5.     this.r = Math.random()*99999;
  6.     this.obj = _root.createEmptyMovieClip("WGLObject"+this.r, this.r);
  7.     this.x = x;
  8.     this.y = y;
  9. };
  10. WGLObject.prototype.WGLCircle = function(a, r) {
  11.     this.obj.lineStyle((this.t ? this.t : 1), (this.c ? this.c : "0x000000"), (this.a ? this.a : 100));
  12.     this.obj.moveTo(this.x, this.y);
  13.     this.obj.lineTo(this.x+Math.cos(WGLtoRad(a))*r, this.y+Math.sin(WGLtoRad(a))*r);
  14. };
  15.  
  16. a = new WGLObject(100, 200);
  17. for (var i=1;i<360;i+=1) {
  18.     a.WGLCircle(i,30);
  19. }

So hat es einige Löcher im Kreis. Wenn ich aber in der Schleife i+=0.2 wirds abgesehen von dem Schnecktempo einigermassen gut.

Wo happert's?

Geändert von MacEvil (31-01-2004 um 06:52 Uhr)
MacEvil ist offline   Mit Zitat antworten
Alt 31-01-2004, 07:08   #2 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
Ok ich habs, so gehts schneller und ohne Löcher..
ActionScript:
  1. WGLObject.prototype.WGLCircle = function(a, r) {
  2.     this.obj.lineStyle((this.t ? this.t : 1), (this.c ? this.c : "0x000000"), (this.a ? this.a : 100));
  3.     for (var i = 1; i<a; i++) {
  4.         this.x1 = this.x+Math.cos(WGLtoRad(i))*r;
  5.         this.y1 = this.y+Math.sin(WGLtoRad(i))*r;
  6.         this.x2 = this.x1+1+Math.cos(WGLtoRad((i<181 ? i+180 : i-180)))*r;
  7.         this.y2 = this.y1+1+Math.sin(WGLtoRad((i<181 ? i+180 : i-180)))*r;
  8.         this.obj.moveTo(this.x1, this.y1);
  9.         this.obj.lineTo(this.x1+1, this.y1+1);
  10.         this.obj.lineTo(this.x2, this.y2);
  11.     }
  12. };
MacEvil ist offline   Mit Zitat antworten
Alt 31-01-2004, 07:35   #3 (permalink)
Revived @ Sunday
 
Benutzerbild von MacEvil
 
Registriert seit: Apr 2003
Ort: Nowhereland
Beiträge: 3.244
Mist, zu früh gefreut. Leider hab ich es mit einem Radius von 40 getestet. Wenn ichs aber mit 100 mache sind die Löcher wieder da

Edit:
Ich glaube das beste ist, wenn man die Liniendicke erhöht, da spürt man fast keinen Geschwindikeitsunterschied..

Geändert von MacEvil (31-01-2004 um 07:42 Uhr)
MacEvil ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

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



Alle Zeitangaben in WEZ +1. Es ist jetzt 20:46 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele