Sierpinski triangle/Graphical: Difference between revisions
Content added Content deleted
(ActionScript) |
|||
Line 6: | Line 6: | ||
=={{header|ActionScript}}== |
=={{header|ActionScript}}== |
||
SierpinskiTriangle class: |
|||
<lang ActionScript3> |
<lang ActionScript3> |
||
package { |
package { |
||
Line 14: | Line 14: | ||
/** |
/** |
||
* A |
* A Sierpinski triangle. |
||
*/ |
*/ |
||
public class SierpinskiTriangle extends Sprite { |
public class SierpinskiTriangle extends Sprite { |
||
/** |
/** |
||
* Creates a new |
* Creates a new SierpinskiTriangle object. |
||
* |
* |
||
* @param n The order of the |
* @param n The order of the Sierpinski triangle. |
||
* @param c1 The background colour. |
* @param c1 The background colour. |
||
* @param c2 The foreground colour. |
* @param c2 The foreground colour. |
||
Line 34: | Line 34: | ||
* Generates the triangle. |
* Generates the triangle. |
||
* |
* |
||
* @param n The order of the |
* @param n The order of the Sierpinski triangle. |
||
* @param c1 The background colour. |
* @param c1 The background colour. |
||
* @param c2 The foreground colour. |
* @param c2 The foreground colour. |
||
Line 65: | Line 65: | ||
return; |
return; |
||
// Recursively generate three |
// Recursively generate three Sierpinski triangles of half the size and order n - 1 and position them appropriately. |
||
var sub1:SierpinskiTriangle = new SierpinskiTriangle(n - 1, c1, c2, width / 2, height / 2); |
var sub1:SierpinskiTriangle = new SierpinskiTriangle(n - 1, c1, c2, width / 2, height / 2); |