SRL Archive - Help and Support

DDTM Help!


Tim0suprem0

2007-09-01 17:20:09

So I want to get Colors from FindColorsSpiralTolerance like this:
FindColorsSpiralTolerance(x,y,Trees,Color,650, 46, 745, 161,30)

and then use the colors in the array Trees to make a DDTM. However, depending on how many examples of the color it finds, the DDTM could be 7 points or it could be 15 points. Is there a way to make it flexible? Or do I just have to use like 3 or 4 subpoints of the 7-12 that it returns, and make a failsafe if it returns less than that?

EDIT: It's probably a problem with arrays… since I stink at them :p

Killerdou

2007-09-01 17:25:06

subpoints is an array right? so you could do a 'for to length(array) do' loop for the subpoints:)

R0b0t1

2007-09-01 17:39:37

Heres some things I made in reference to I-Bots EdgeRGBarrays, but they don't compile, fix em and change em.


program ColorClusters;
{.Include SRL\SRL.scar}

Function MakeColorCluster(Colors: TIntegerArray): Integer;
Var I, B: Integer;
Var DTMMain: TDTMPointDef;
Var DTMSub: Array of TDTMPointDef;
Var Skeleton: TDTM;
begin;
SetLength(DTMSub, Length(Colors) - 1);
For I:=0 to Length(DTMSub) do
begin;
B:= I + 1;
If (I = 0) Then
begin;
With DTMMain do
begin;
x:= 0;
y:= 0;
AreaSize:= 0;
AreaShape:= 0;
Color:= Colors[I];
Tolerance:= DTol;
end;
end;
If (Round(I / 2) > Length(Colors)) Then
B:= 0;
With DTMSub[I] do
begin;
x:= B;
y:= I + 1;
AreaSize:= 1;
AreaShape:= 0;
Color:= Colors[I];
Tolerance:= DTol;
end;
end;
Skeleton.MainPoint:= DTMMain;
Skeleton.SubPoints:= DTMSub;
Result:= AddDTM(Skeleton);
end;

Function MakeRGBCluster(RGBs: TRGBArray; DTol: Integer): Integer;
Var I, B: Integer;
Var DTMMain: TDTMPointDef;
Var DTMSub: Array of TDTMPointDef;
Var Skeleton: TDTM;
begin;
SetLength(DTMSub, Length(RGBs) - 1);
For I:=0 to Length(DTMSub) do
begin;
B:= I + 1;
If (I = 0) Then
begin;
With DTMMain do
begin;
x:= 0;
y:= 0;
AreaSize:= 0;
AreaShape:= 0;
Color:= RGBToColor(Colors[I]);
Tolerance:= DTol;
end;
end;
If (Round(I / 2) > Length(RGBs)) Then
B:= 0;
With DTMSub[I] do
begin;
x:= B;
y:= I + 1;
AreaSize:= 1;
AreaShape:= 0;
Color:= RGBToColor(Colors[I]);
Tolerance:= DTol;
end;
end;
Skeleton.MainPoint:= DTMMain;
Skeleton.SubPoints:= DTMSub;
Result:= AddDTM(Skeleton);
end;

Function MakeHSLCluster(HSLs: THSLArray; DTol: Integer): Integer;
Var I, B: Integer;
Var DTMMain: TDTMPointDef;
Var DTMSub: Array of TDTMPointDef;
Var Skeleton: TDTM;
begin;
SetLength(DTMSub, Length(HSls) - 1);
For I:=0 to Length(DTMSub) do
begin;
B:= I + 1;
If (I = 0) Then
begin;
With DTMMain do
begin;
x:= 0;
y:= 0;
AreaSize:= 0;
AreaShape:= 0;
Color:= HSLToColor(Colors[I]);
Tolerance:= DTol;
end;
end;
If (Round(I / 2) > Length(Colors)) Then
B:= 0;
With DTMSub[I] do
begin;
x:= B;
y:= I + 1;
AreaSize:= 1;
AreaShape:= 0;
Color:= HSLToColor(Colors[I]);
Tolerance:= DTol;
end;
end;
Skeleton.MainPoint:= DTMMain;
Skeleton.SubPoints:= DTMSub;
Result:= AddDTM(Skeleton);
end;

begin
end.

Tim0suprem0

2007-09-01 18:06:42

From: iloveit8
subpoints is an array right? so you could do a 'for to length(array) do' loop for the subpoints:)


I was doing that and got an "could not call proc" error.

@robot
Thanks I'll check these out.

mastaraymond

2007-09-01 18:10:52

This might help ;http://www.villavu.com/forum/showthread.php?t=13306

Allows you to create ddtms 'on the run'.

Tim0suprem0

2007-09-01 18:11:59

Masta I've been using that as guidelines ;) Got it from fizzi's Soft Clay maker. It's awesome!

Tim0suprem0

2007-09-01 18:13:01

Ok here's what I've been playing around with :
program New;
{.include SRL/SRL.scar}
var
x,y,theTrees,Thecolor:integer;


procedure Mainloop;

Var
A,I,Color: Integer;
TreeSP: TDTM;
DDTM: tintegerarray;
Trees: TPointArray;

begin
Activateclient;
SetupSRL;
Begin
for A := 0 to 2 do
begin
case A of

0: Color:=2319658;

1: Color:=285473;

2: Color:=1338427;

end;

FindColorsSpiralTolerance(x,y,Trees,Color,650, 46, 745, 161,30)

For I := 0 To GetArrayLength(Trees) - 1 Do
Begin
x := x + Trees[I].X;
y := y +Trees[I].Y;
End;
If GetArrayLength(Trees) <> 0 Then
Begin
x := x Div GetArrayLength(Trees);
y := y Div GetArrayLength(Trees);
Writeln(inttostr(color));
theColor:=GetColor(x,y)
writeln(inttostr(thecolor));
Break;
End;
end;
end;
begin
SetArrayLength(TreeSP, 0);
while i <= GetArrayLength(Trees)-1 do
begin

SetArrayLength(TreeSP,Length(TreeSP)+1);


DDTM[(i*6)+0]:=Trees[i].x;
DDTM[(i*6)+1]:=Trees[i].y;
DDTM[(i*6)+2]:=2;
DDTM[(i*6)+3]:=0;
DDTM[(i*6)+4]:=TheColor;
DDTM[(i*6)+5]:=5;

TreesP.mainpoint.x:=DDTM[0]
TreesP.mainpoint.y:=DDTM[1]
TreesP.mainpoint.areasize:=DDTM[2]
TreesP.mainpoint.areashape:=DDTM[3]
TreesP.mainpoint.color:=DDTM[4]
TreesP.mainpoint.tolerance:=DDTM[5]

TreeSP.subpoints[Length(TreeSP)-1].x:=DDTM[(I+1)*6 + 0]
TreeSP.subpoints[Length(TreeSP)-1].y:=DDTM[(I+1)*6 + 1]
TreeSP.subpoints[Length(TreeSP)-1].areasize:=DDTM[(I+1)*6 + 2]
TreeSP.subpoints[Length(TreeSP)-1].areashape:=DDTM[(I+1)*6 + 3]
TreeSP.subpoints[Length(TreeSP)-1].color:=DDTM[(I+1)*6 + 4]
TreeSP.subpoints[Length(TreeSP)-1].tolerance:=DDTM[(I+1)*6 + 5]

end;

TheTrees:=AddDTM(TreeSp);

end;
end;

begin
Mainloop;
if DTMRotated(TheTrees,x,y,MMx1,MMy1,MMx2,MMy2) then
MMouse(x,y,0,0);

end.

I get "could not call proc in line 50" (which is SetArrayLength(TreeSp,0))

R0b0t1

2007-09-01 22:44:04

No one except maybe freddy1990 knows what that means.


Can't help much.

Tim0suprem0

2007-09-01 23:43:52

haha ok, I'll find another way to do it. Thanks r0b0t, you're much better at these things than I am ;)