Dragon curve/D/DFL: Difference between revisions

Content added Content deleted
(Created page with "{{libheader|DFL}} Translation of Java <lang d>// dfl dragoncurve -gui -release -O private import dfl.all; import std.math; class DrawForm: Form { private int[] turns; ...")
 
(updated)
Line 4: Line 4:


private import dfl.all;
private import dfl.all;
import std.math;
import std.math, std.range;


class DrawForm: Form {
class DrawForm: Form {
Line 11: Line 11:
private double startingAngle;
private double startingAngle;
private double side;
private double side;
private const iter = 14;
private immutable iter = 14;


this() {
this() {
Line 27: Line 27:
}
}


public int[] getSequence(int iterations) {
public int[] getSequence(in int iterations) {
int[] turnSequence;
int[] turnSequence;
for (int i = 0; i < iterations; i++) {
foreach (_; 0 .. iterations) {
auto copy = turnSequence.dup.reverse;
auto copy = turnSequence.retro;
turnSequence ~= 1;
turnSequence ~= 1;
foreach (turn; copy) {
foreach (turn; copy) {
Line 67: Line 67:
Application.run(new DrawForm);
Application.run(new DrawForm);
}
}
catch(Object o) {
catch(Exception e) {
msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
msgBox(e.msg, "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
result = 1;
result = 1;
}
}