Спасибо вам Леонид за пример. Наверное я не правильно объяснился. На картинке http://s020.radikal.ru/i707/1512/f9/de8d6b82f2a5.jpg нарисованы 20 пикселей соединённых между собой, разрывов нет. В моей программе получается 20, попробовал вашу получилось 16. Add(MainForm,2953706,14,49) { Width=212 Height=102 } Add(StrList,9951875,434,189) { Point(doGetString) Point(onGetString) Point(onGetIndex) Point(doGetIndex) link(onGetString,9035953:doWork2,[]) link(onGetIndex,16395531:doValue,[]) } Add(Repeat,6642214,385,343) { Type=2 Op2=Integer(1) link(onRepeat,7214070:doEvent1,[]) link(Op1,9951875:Count,[(391,310)(447,310)]) } Add(Hub,7214070,434,343) { OutCount=3 link(onEvent1,13198537:doWork,[]) link(onEvent2,1493002:doData,[(533,356)(533,321)(275,321)(275,237)]) link(onEvent3,10583503:doWork2,[]) } Add(DoData,1493002,287,231) { Data=Integer(0) link(onEventData,13297126:doEvent1,[]) } Add(Hub,13297126,336,231) { link(onEvent1,9951875:doGetString,[]) link(onEvent2,10531884:doWork3,[(363,244)]) } Add(StrList,1722997,728,196) { } Add(ArrayEnum,10247569,560,357) { link(onItem,8402603:doWork1,[]) link(onEndEnum,10156134:doEvent1,[(625,370)(625,489)]) link(Array,1722997:Array,[(566,292)(748,292)]) } Add(LineBreakEx,13198537,462,343) { Caption="clear 1" } Add(LineBreakEx,2052391,609,203) { Caption="clear 1" Type=1 link(OnEvent,1722997:doClear,[]) } Add(MultiElement,8402603,672,357) { link(onEvent1,16290235:doEvent1,[]) } BEGIN_SDK Add(EditMulti,2873611,21,21) { EventCount=1 WorkCount=1 Width=328 Height=445 link(doWork1,15163423:doSplit,[(36,27)(36,83)]) } Add(MultiElement,4811846,259,77) { link(onEvent1,3059594:doWork2,[]) link(Data1,5631873:getVar,[]) link(Data2,11051137:getVar,[]) } BEGIN_SDK Add(EditMulti,15714572,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,980659:doEvent1,[(350,111)(350,153)]) } Add(Math,4968716,427,147) { OpType=1 Op2=1 ResultType=0 link(Op1,15714572:Data1,[(433,133)(314,133)]) } Add(Math,5953876,476,196) { OpType=1 Op2=1 ResultType=0 link(Op1,15714572:Data2,[(482,122)(321,122)]) } Add(Hub,980659,364,147) { OutCount=3 link(onEvent1,4968716:doOperation,[]) link(onEvent2,5953876:doOperation,[(414,160)(414,202)]) link(onEvent3,5502851:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,5502851,427,273) { Delimiter=";" link(onStrCatDlm,15714572:onEvent1,[(519,279)(519,111)]) link(Str1,4968716:Result,[]) link(Str2,5953876:Result,[(440,251)(482,251)]) } END_SDK Add(MultiStrPart,15163423,56,77) { link(onSplit,2540821:doEvent1,[]) } Add(LineBreakEx,5631873,259,35) { Caption="x" Type=2 } Add(LineBreakEx,11051137,266,49) { Caption="y" Type=2 } Add(LineBreakEx,5364197,56,147) { Caption="x" Type=3 link(_Data,15163423:Part1,[]) } Add(LineBreakEx,4087501,63,126) { Caption="y" Type=3 link(_Data,15163423:Part2,[]) } Add(Hub,2540821,112,77) { OutCount=8 link(onEvent1,4811846:doWork1,[]) link(onEvent2,13381842:doWork1,[(207,90)(207,132)]) link(onEvent3,12619126:doWork1,[(201,97)(201,181)]) link(onEvent4,308752:doWork1,[(190,104)(190,230)]) link(onEvent5,13430955:doWork1,[(179,111)(179,279)]) link(onEvent6,12614835:doWork1,[(167,118)(167,328)]) link(onEvent7,15426429:doWork1,[(158,125)(158,377)]) link(onEvent8,4305568:doWork1,[(148,132)(148,426)]) } Add(MultiElement,13381842,217,126) { link(onEvent1,12914808:doWork2,[]) link(Data1,15073103:getVar,[]) link(Data2,4608675:getVar,[]) } BEGIN_SDK Add(EditMulti,891228,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,6390898:doEvent1,[(350,111)(350,153)]) } Add(Math,374091,476,196) { OpType=1 Op2=1 ResultType=0 link(Op1,891228:Data2,[(482,122)(321,122)]) } Add(Hub,6390898,364,147) { OutCount=3 link(onEvent1,6534169:doValue,[]) link(onEvent2,374091:doOperation,[(414,160)(414,202)]) link(onEvent3,16543897:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,16543897,427,273) { Delimiter=";" link(onStrCatDlm,891228:onEvent1,[(519,279)(519,111)]) link(Str1,6534169:Value,[]) link(Str2,374091:Result,[(440,251)(482,251)]) } Add(Memory,6534169,427,147) { Point(Data) link(Data,891228:Data1,[(433,131)(314,131)]) } END_SDK Add(LineBreakEx,15073103,217,84) { Caption="x" Type=2 } Add(LineBreakEx,4608675,224,98) { Caption="y" Type=2 } Add(HubEx,3059594,304,77) { Angle=3 link(onEvent,2873611:onEvent1,[(308,27)]) } Add(MultiElement,12619126,259,175) { link(onEvent1,3925314:doWork2,[]) link(Data1,8307258:getVar,[]) link(Data2,3089604:getVar,[]) } BEGIN_SDK Add(EditMulti,3154371,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,2398493:doEvent1,[(350,111)(350,153)]) } Add(Math,6803852,427,147) { Op2=1 ResultType=0 link(Op1,3154371:Data1,[(433,133)(314,133)]) } Add(Math,5499886,476,196) { OpType=1 Op2=1 ResultType=0 link(Op1,3154371:Data2,[(482,122)(321,122)]) } Add(Hub,2398493,364,147) { OutCount=3 link(onEvent1,6803852:doOperation,[]) link(onEvent2,5499886:doOperation,[(414,160)(414,202)]) link(onEvent3,10738012:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,10738012,427,273) { Delimiter=";" link(onStrCatDlm,3154371:onEvent1,[(519,279)(519,111)]) link(Str1,6803852:Result,[]) link(Str2,5499886:Result,[(440,251)(482,251)]) } END_SDK Add(LineBreakEx,8307258,259,133) { Caption="x" Type=2 } Add(LineBreakEx,3089604,266,147) { Caption="y" Type=2 } Add(HubEx,12914808,304,126) { Angle=3 link(onEvent,3059594:doWork3,[]) } Add(MultiElement,308752,217,224) { link(onEvent1,2497410:doWork2,[]) link(Data1,9636307:getVar,[]) link(Data2,3907515:getVar,[]) } BEGIN_SDK Add(EditMulti,12549954,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,7395146:doEvent1,[(350,111)(350,153)]) } Add(Math,9729312,427,147) { OpType=1 Op2=1 ResultType=0 link(Op1,12549954:Data1,[(433,133)(314,133)]) } Add(Hub,7395146,364,147) { OutCount=3 link(onEvent1,9729312:doOperation,[]) link(onEvent2,14073893:doValue,[(416,160)(416,202)]) link(onEvent3,642038:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,642038,427,273) { Delimiter=";" link(onStrCatDlm,12549954:onEvent1,[(519,279)(519,111)]) link(Str1,9729312:Result,[]) link(Str2,14073893:Value,[(440,251)(475,251)]) } Add(Memory,14073893,469,196) { Point(Data) link(Data,12549954:Data2,[(475,123)(321,123)]) } END_SDK Add(LineBreakEx,9636307,217,182) { Caption="x" Type=2 } Add(LineBreakEx,3907515,224,196) { Caption="y" Type=2 } Add(MultiElement,13430955,259,273) { link(onEvent1,12317355:doWork2,[]) link(Data1,8077707:getVar,[]) link(Data2,11258761:getVar,[]) } BEGIN_SDK Add(EditMulti,6568777,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,10073197:doEvent1,[(350,111)(350,153)]) } Add(Math,11040924,427,147) { Op2=1 ResultType=0 link(Op1,6568777:Data1,[(433,133)(314,133)]) } Add(Hub,10073197,364,147) { OutCount=3 link(onEvent1,11040924:doOperation,[]) link(onEvent2,9548067:doValue,[(416,160)(416,202)]) link(onEvent3,12246408:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,12246408,427,273) { Delimiter=";" link(onStrCatDlm,6568777:onEvent1,[(519,279)(519,111)]) link(Str1,11040924:Result,[]) link(Str2,9548067:Value,[(440,251)(475,251)]) } Add(Memory,9548067,469,196) { Point(Data) link(Data,6568777:Data2,[(475,123)(321,123)]) } END_SDK Add(LineBreakEx,8077707,259,231) { Caption="x" Type=2 } Add(LineBreakEx,11258761,266,245) { Caption="y" Type=2 } Add(HubEx,3925314,304,175) { Angle=3 link(onEvent,12914808:doWork3,[]) } Add(MultiElement,12614835,217,322) { link(onEvent1,2971527:doWork2,[]) link(Data1,1445664:getVar,[]) link(Data2,4956906:getVar,[]) } BEGIN_SDK Add(EditMulti,9446282,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,9198978:doEvent1,[(350,111)(350,153)]) } Add(Math,7890550,427,147) { OpType=1 Op2=1 ResultType=0 link(Op1,9446282:Data1,[(433,133)(314,133)]) } Add(Math,897191,476,196) { Op2=1 ResultType=0 link(Op1,9446282:Data2,[(482,122)(321,122)]) } Add(Hub,9198978,364,147) { OutCount=3 link(onEvent1,7890550:doOperation,[]) link(onEvent2,897191:doOperation,[(414,160)(414,202)]) link(onEvent3,14970684:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,14970684,427,273) { Delimiter=";" link(onStrCatDlm,9446282:onEvent1,[(519,279)(519,111)]) link(Str1,7890550:Result,[]) link(Str2,897191:Result,[(440,251)(482,251)]) } END_SDK Add(LineBreakEx,1445664,217,280) { Caption="x" Type=2 } Add(LineBreakEx,4956906,224,294) { Caption="y" Type=2 } Add(HubEx,2497410,304,224) { Angle=3 link(onEvent,3925314:doWork3,[]) } Add(HubEx,12317355,304,273) { Angle=3 link(onEvent,2497410:doWork3,[]) } Add(MultiElement,15426429,252,371) { link(onEvent1,9849457:doWork2,[]) link(Data1,986929:getVar,[]) link(Data2,3340156:getVar,[]) } BEGIN_SDK Add(EditMulti,5683178,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,13382222:doEvent1,[(350,111)(350,153)]) } Add(Math,6158855,476,196) { Op2=1 ResultType=0 link(Op1,5683178:Data2,[(482,122)(321,122)]) } Add(Hub,13382222,364,147) { OutCount=3 link(onEvent1,12040355:doValue,[]) link(onEvent2,6158855:doOperation,[(414,160)(414,202)]) link(onEvent3,7947478:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,7947478,427,273) { Delimiter=";" link(onStrCatDlm,5683178:onEvent1,[(519,279)(519,111)]) link(Str1,12040355:Value,[]) link(Str2,6158855:Result,[(440,251)(482,251)]) } Add(Memory,12040355,427,147) { Point(Data) link(Data,5683178:Data1,[(433,131)(314,131)]) } END_SDK Add(LineBreakEx,986929,252,329) { Caption="x" Type=2 } Add(LineBreakEx,3340156,259,343) { Caption="y" Type=2 } Add(HubEx,2971527,304,322) { Angle=3 link(onEvent,12317355:doWork3,[]) } Add(MultiElement,4305568,210,420) { link(onEvent1,9849457:doWork3,[(308,426)]) link(Data1,14486413:getVar,[]) link(Data2,13415698:getVar,[]) } BEGIN_SDK Add(EditMulti,6841152,308,105) { EventCount=1 WorkCount=1 DataCount=2 Width=244 Height=221 link(doWork1,1648981:doEvent1,[(350,111)(350,153)]) } Add(Math,739820,427,147) { Op2=1 ResultType=0 link(Op1,6841152:Data1,[(433,133)(314,133)]) } Add(Math,15989373,476,196) { Op2=1 ResultType=0 link(Op1,6841152:Data2,[(482,122)(321,122)]) } Add(Hub,1648981,364,147) { OutCount=3 link(onEvent1,739820:doOperation,[]) link(onEvent2,15989373:doOperation,[(414,160)(414,202)]) link(onEvent3,15060899:doStrCatDlm,[(402,167)(402,279)]) } Add(StrCatDelim,15060899,427,273) { Delimiter=";" link(onStrCatDlm,6841152:onEvent1,[(519,279)(519,111)]) link(Str1,739820:Result,[]) link(Str2,15989373:Result,[(440,251)(482,251)]) } END_SDK Add(LineBreakEx,14486413,210,378) { Caption="x" Type=2 } Add(LineBreakEx,13415698,217,392) { Caption="y" Type=2 } Add(HubEx,9849457,304,371) { Angle=3 link(onEvent,2971527:doWork3,[]) } END_SDK Add(LineBreak,6125117,287,287) { Caption="get ind." link(Out,9951875:doGetIndex,[(376,293)(376,244)]) Primary=[2341778,483,70] } Add(If_else,12421808,553,203) { Op2=Integer(-1) link(onFalse,10498727:doEvent1,[(599,216)(599,125)]) } Add(Hub,10498727,728,119) { link(onEvent1,10531884:doWork1,[(778,125)(778,100)(363,100)]) link(onEvent2,415692:doNext,[]) } Add(CounterEx,415692,882,126) { Min=1 Max=10000000 Default=1 Point(doReset) } Add(HubEx,10531884,359,203) { link(onEvent,9951875:doDelete,[]) } Add(StrList,11222846,1008,371) { } Add(LineBreakEx,3176606,882,378) { Caption="clear 2" Type=1 link(OnEvent,11222846:doClear,[]) } Add(LineBreakEx,16392375,896,539) { Caption="clear 2" } Add(Hub,10156134,658,483) { link(onEvent1,12391086:In,[]) link(onEvent2,3302385:doCompare,[]) } Add(Label,15981204,1155,126) { Left=175 Top=15 Width=10 Height=17 Caption="0" } Add(Memory,6860879,1022,126) { Default=Integer(1) link(onData,15981204:doText,[]) } Add(If_else,17175,882,224) { Type=2 link(onTrue,5091251:doData,[]) link(Op1,12281924:Var2,[]) link(Op2,6860879:Value,[(895,191)(1028,191)]) } Add(DoData,5091251,938,224) { link(onEventData,6860879:doValue,[(994,230)(994,132)]) link(Data,12281924:Var3,[(944,173)]) } Add(GetDataEx,12281924,882,168) { link(Data,415692:Count,[]) } Add(LineBreak,3799350,833,224) { Caption="if >" link(Out,17175:doCompare,[]) Primary=[12391086,-140,259] } Add(If_else,3302385,728,490) { Op2=Integer(0) link(onTrue,13026563:doEvent1,[]) link(onFalse,16218118:doEvent1,[(776,503)(776,531)]) link(Op1,11222846:Count,[(734,446)(1021,446)]) } Add(LineBreak,350378,826,133) { Caption="reset" link(Out,415692:doReset,[]) Primary=[7556010,14,357] } Add(ArrayEnum,4316930,980,532) { link(onItem,3827402:In,[]) link(Array,11222846:Array,[(986,493)(1028,493)]) } Add(LineBreakEx,1500460,882,497) { Caption="clear 1" } Add(Hub,13026563,798,490) { link(onEvent1,7556010:In,[]) link(onEvent2,1500460:doWork,[]) } Add(LineBreakEx,8255816,826,525) { Caption="clear 1" } Add(Hub,16218118,791,525) { OutCount=4 link(onEvent1,8255816:doWork,[]) link(onEvent2,4316930:doEnum,[]) link(onEvent3,16392375:doWork,[]) link(onEvent4,10583503:doWork3,[(826,552)(826,568)(536,568)]) } Add(HubEx,9035953,672,196) { link(onEvent,1722997:doAdd,[]) } Add(LineBreak,10131664,623,175) { Caption="add 1" link(Out,9035953:doWork3,[(676,181)]) Primary=[3827402,427,357] } Add(HubEx,10583503,532,357) { link(onEvent,10247569:doEnum,[]) } Add(Memory,16395531,504,203) { link(onData,12421808:doCompare,[]) } Add(Hub,16290235,728,357) { link(onEvent1,2341778:In,[]) link(onEvent2,8614847:doCompare,[]) } Add(If_else,8614847,840,364) { Op2=Integer(-1) link(onFalse,11222846:doAdd,[]) link(Op1,11322039:Var,[]) } Add(LineBreak,11556866,504,252) { Caption="ind. or -1" Type=1 link(Data,16395531:Value,[]) Primary=[11322039,336,84] } Add(Button,2597406,28,147) { Left=5 Top=10 Caption="Find" link(onClick,643611:doWork1,[]) } Add(InfoTip,14862498,399,147) { Info=#9:Все точки| Width=92 Height=137 } Add(InfoTip,15944173,693,161) { Info=#16:Соседи 1 уровень| Width=113 Height=109 } Add(InfoTip,5137383,980,343) { Info=#16:Соседи 2 уровень| Width=99 Height=88 } Add(MultiElement,643611,112,147) { link(onEvent1,9951875:doAdd,[(289,153)(289,195)]) link(onEvent2,6642214:doRepeat,[(264,160)(264,349)]) } BEGIN_SDK Add(EditMulti,7123208,21,21) { EventCount=2 WorkCount=1 Width=524 Height=340 link(doWork1,13989739:doEvent1,[(49,27)(49,132)]) } Add(Bitmap,12806069,182,49) { Picture=[ZIP769C000078DAEDD8BB098030144051B389A513588BBD5B3883D3386BE2070B9B348221CA091C04EDDEE5813A4ECBDA9CA7DF75BBF9129AF6BC3F5CCFEF27A5040000000000000000000000000000000000000000000000000000000000542CC6680E6057800F3A8E397CAB8966E51BE466AE45B916B9AB16F5ED8916F5F4D1A29E6F3F2DBCFBF2AC857F28EF0B21D80B0000801FD80018F98697] Point(Width) Point(Height) } Add(Math,4768702,189,126) { OpType=1 Op2=1 ResultType=0 link(Op1,12806069:Width,[]) } Add(Math,14223679,238,168) { OpType=1 Op2=1 ResultType=0 link(Op1,12806069:Height,[(244,116)(202,116)]) } Add(Hub,13989739,77,126) { OutCount=3 link(onEvent1,4768702:doOperation,[]) link(onEvent2,14223679:doOperation,[(178,139)(178,174)]) link(onEvent3,5737337:doFor,[(115,146)(115,230)]) } Add(For,5737337,133,224) { link(onEvent,11821509:doFor,[(187,230)(187,300)]) link(onStop,7123208:onEvent2,[(392,237)(392,34)]) link(End,14223679:Result,[(146,215)(244,215)]) } Add(For,11821509,210,294) { link(onEvent,9100117:doGetPixel,[]) link(End,4768702:Result,[(223,193)(195,193)]) } Add(Img_GetPoint,9100117,343,294) { link(onGetPixel,11337094:doCompare,[]) link(Bitmap,12806069:Bitmap,[(349,103)(188,103)]) link(X,759138:Var2,[]) link(Y,14977142:Var2,[]) } Add(If_else,11337094,413,294) { Op2=Integer(0) link(onTrue,7079025:doStrCatDlm,[]) } Add(StrCatDelim,7079025,476,294) { Delimiter=";" link(onStrCatDlm,7123208:onEvent1,[(526,300)(526,27)]) link(Str1,759138:Var3,[(482,277)]) link(Str2,14977142:Var3,[(489,266)]) } Add(GetDataEx,759138,350,272) { Angle=3 link(Data,11821509:Position,[(286,277)(286,338)(216,338)]) } Add(GetDataEx,14977142,357,261) { Angle=3 link(Data,5737337:Position,[(139,266)]) } END_SDK Add(InfoTip,5768843,91,112) { Info=#8:Картинка| Width=78 Height=102 }
Логика такая: 1. Координаты всех чёрных точек заносятся в основной массив ( массив у меня StrList ). 2. Берём по 1 значению из основного массива ( это значение из массива сразу удаляется ) и ищем координаты его 8-х соседей((x-1;y-1),(x;y-1),(x+1;y-1),(x-1;y),(x+1;y),(x-1;y+1),(x;y+1),(x+1;y+1)) 3. Полученные координаты ищем в основном массиве, если их там нет ,то п. 2. 4. За каждого найденного +1 к результату ( и его значение удаляется из основного массива, но добавляется в другой массив "Соседи" ) 5. А дальше уже массив "Соседи" перебирается подобно пунктам 2,3,4.
|