#N struct tuto float x float y float u float i; #N struct data float x float y float u; #N canvas 4 23 1276 755 12; #X scalar tuto 0 1980 0 0 \;; #X scalar data 860 1170 0 \;; #X scalar data 837 1040 0 \;; #X scalar data 796 1122 0 \;; #X scalar data 743 1040 0 \;; #X scalar data 844 1156 0 \;; #X scalar data 794 1045 0 \;; #X scalar data 771 1082 0 \;; #X scalar data 837 1185 0 \;; #X scalar data 813 1139 0 \;; #X scalar data 735 1185 0 \;; #X scalar data 721 1101 0 \;; #X scalar data 805 1100 0 \;; #X scalar data 773 1001 0 \;; #X scalar data 790 1010 0 \;; #X scalar data 878 1193 0 \;; #X scalar data 858 1015 0 \;; #X scalar data 845 1038 0 \;; #X scalar data 725 1190 0 \;; #X scalar data 739 1114 0 \;; #X scalar data 815 1030 0 \;; #X scalar data 812 1062 0 \;; #X scalar data 736 1067 0 \;; #X scalar data 711 1155 0 \;; #X scalar tuto 0 1980 0 20 \;; #X scalar tuto 0 1980 0 4 \;; #N canvas 806 162 462 428 substruct 0; #X obj 16 85 struct data float x float y float u; #X text 18 14 This struct object defines a data structure. The drawpolygon is a graphical part of this data structure.; #X obj 17 122 filledpolygon 400 400 4 0 0 0 40 40 40 40 0; #X restore 619 904 pd substruct; #X obj 62 1146 data-structure; #X text 180 1147 This doesn't exist !; #X text 525 868 This subpatch defines a data structure that displays a polygon-->; #X obj 527 1486 append data x y; #X obj 679 1470 pointer; #X obj 679 1404 loadbang; #X obj 527 1350 random 200; #X obj 527 1432 pack; #X obj 527 1313 t b b; #X obj 527 1245 bng 60 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 607 1352 random 200; #X obj 604 1386 + 1000; #X obj 527 1385 + 700; #X text 256 12 Creating animated graphic using data structure \, How \, do and don't; #X text 25 92 Creating animated graphic using data structure \, How \, do and don't Wether they were intended to do so or not \, the data structures objects implemented in pure data allow us to create cool abstract videos.; #X text 31 157 Two different set of difficulties while occur : First \, In order to obtain a fluid animation \, you need to avoid certain patching mistakes.; #X text 25 234 Second \, You'll need to imagine your own visual alphabet \, based mostly on mathematical manipulations.; #X text 17 293 Both have a strong impact on each other.; #X text 25 335 We can start with a quick explanation of how data structures work and how to organize your patch in an optimized way.; #X text 22 393 Data structures doesn't follow the usual organisation of pure data. Instead of instantiating each function in a block \, those functions sending and receiving informations and sounds thru cables \, A Data structure is an abstract object \, defined by a group of objects \, gathered in a patch or in a subpatch.; #X text 22 504 The name of this patch doesn't matter \, but it must contain: A "struct" object \, and as many graphical objects as you want. Those objects being :; #X text 39 1196 You have to create those data structure from inside your patch \, using the "append" object.; #X text 47 1250 Good news or WTF news \, once you have created your data structure object \, it is saved inside the patch like any other objects \, it has a position \, and if you haven't make it untouchable \, this can be done when you define it \, you can move it and delete it.; #X text 50 1332 You can also delete the "append" object if you don't need more data structures.; #X text 51 1381 Why is this object called "append" ? Because when you work with data structures \, a patch/subpatch is seen as an invisible list. When you create a data structure \, you append an item to the list of item in a patch or subpatch \, the first item being blank. Each item in this list is a data structure. Each of those items as an adresse called a "pointer".; #X text 165 574 Drawpolygon Filledpolygon drawsymbol drawtext drawnumber drawcurve filledvurve plot; #X obj 730 1967 s pd-TutoDatastruct.pd; #X text 785 1898 A click on this while add a new object to the definition of the same data structure; #X obj 9 2403 line; #X obj 9 2332 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 9 2194 tgl 50 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X text 74 2220 Click there start a motion; #X obj 9 2427 set tuto i; #X obj 115 1809 struct tuto float x float y float u float i; #X obj 9 2310 metro 600; #X msg 9 2379 \$1 600; #X obj 9 2351 * 30; #X text 151 1557 Know \, something very important: even if you can \, you musn't use multiple data structure \, but one and only one \, when you create graphic. By doing so animation will be fluid. Instead \, you must simply add objects in the definition of your data structure: ; #X text 110 1755 this struct tuto is our go-to struct \; the objects like filledpolygon \, draw polygon \, etc \, are bounded to it. You can add as much as you want.; #X obj 730 1759 bng 60 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 730 1864 random 400; #X obj 340 2418 tgl 50 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X text 401 2430 Click there start a motion; #X obj 340 2477 metro 600; #X obj 340 2594 set tuto u; #X obj 188 2376 pointer; #X obj 156 2309 loadbang; #X msg 188 2354 traverse pd-TutoDatastruct.pd \, bang; #X obj 86 2399 append tuto x y; #X obj 156 2332 t b b; #X obj 133 2309 bng 15 250 50 0 empty bb empty 17 7 0 10 -262144 -1 -1; #X obj 114 1835 filledpolygon 0 u i 0 0 0 0; #X msg 730 1938 obj \$1 1930 filledpolygon 0 u i \$1 0 \$1 0; #X obj 340 2539 random 1000; #X text 802 1790 add an object.; #X text 70 1859 All those dots are only one data structure object. ; #X text 603 2188 Delete them to see :; #X obj 749 2180 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 867 1664 s pd-TutoDatastruct.pd; #X text 673 1564 Delete them to see :; #X obj 834 1559 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 866 1627 editmode 1 \, mouse 700 1000 0 0 \, mouseup 910 1210 0 \, cut \, editmode 0; #X msg 86 2373 0 1980; #X obj 781 2278 s pd-TutoDatastruct.pd; #X msg 781 2240 editmode 1 \, mouse 0 1930 0 0 \, mouseup 400 2000 0 \, cut \, editmode 0; #X obj 749 2217 t b b; #X obj 834 1595 t b b; #X obj 834 1693 s bb; #X text 229 2100 This methode is not bad but you can't dynamically modifie each object independantly.; #X text 36 1016 Once you have defined this data structure \, it is still a definition. Now you have to put one or more data structure object that reflect it. And you can't do it with some data-structure object; #X text 883 1566 You can also do it by selecting them manualy \, but you have to reset the pointer of the append object.; #X text 595 1259 Each click on this creates another data structure following the "data" definition \, like described in the substruct subpatch above \, and add it to the patch \, at the end of the list. Here \, when we create the data structure object \, we define two parameters \, the x and y coordinates \, randomly generated.; #X text 745 1389 Here we send the pointer of the patch to the append object. So it will add data-structures object of type "data" to this patcher.; #X text 804 174 A tentative by Il pleut.; #X msg 679 1439 traverse pd-TutoDatastruct.pd \, bang; #X obj 749 2305 s bb; #X text 337 1657 A second thing is \, when you delete a data structure object \, it reinitialize the pointers of all the patch \, and you have to re-send them \, and if you have different types of data structures \, it gets awful.; #X text 388 2675 Another way is to use array+plot. Arrays are lists of data structure \, defined using other structs objects. They can be modified in size. Arrays of arrays let you create a great variety of visual and even scene. This is the most powerful methode and it requieres a dedicated tuto.; #X connect 31 0 30 2; #X connect 32 0 101 0; #X connect 33 0 39 0; #X connect 34 0 30 0; #X connect 35 0 33 0; #X connect 35 1 37 0; #X connect 36 0 35 0; #X connect 37 0 38 0; #X connect 38 0 34 1; #X connect 39 0 34 0; #X connect 55 0 59 0; #X connect 56 0 63 0; #X connect 57 0 61 0; #X connect 61 0 56 0; #X connect 62 0 55 0; #X connect 63 0 62 0; #X connect 66 0 67 0; #X connect 67 0 79 0; #X connect 68 0 70 0; #X connect 70 0 80 0; #X connect 72 0 75 2; #X connect 73 0 76 0; #X connect 74 0 72 0; #X connect 75 0 59 1; #X connect 75 0 71 1; #X connect 76 0 89 0; #X connect 76 1 74 0; #X connect 77 0 76 0; #X connect 79 0 53 0; #X connect 80 0 71 0; #X connect 84 0 92 0; #X connect 87 0 93 0; #X connect 88 0 85 0; #X connect 89 0 75 0; #X connect 91 0 90 0; #X connect 92 0 102 0; #X connect 92 1 91 0; #X connect 93 0 101 0; #X connect 93 0 94 0; #X connect 93 1 88 0; #X connect 101 0 31 0;