#N canvas 0 19 495 603 10;
#X text 0 1 New Drawing Commands: draw;
#X text 0 1 __________________________;
#X obj 53 47 struct drawtut-one float x float y;
#X obj 53 219 draw rect 0 0 40 40;
#X text 53 67 The first argument "drawtut-one" is a name we will associated
with our shape.;
#X text 53 98 The other arguments define data to associate with this
data structure. The fields "x" and "y" are names for data fields \,
and the word "float" that precedes each one tells Pd that each one
should hold a floating point number.;
#X text 53 195 Now let's define a shape to associate with this [struct]:
;
#X text 53 241 This object starts with the word "draw" followed by
the name of an svg shape-- "rect" here. Any arguments after that are
coordinates and other data telling Pd how to draw the shape. For convenience
\, coordinates are relative to the x/y fields.;
#X text 53 298 Any [draw] object on the same canvas as our [struct]
will be used to draw a shape to represent the data structure we've
defined here. To keep things organized Pd expects there to be only
one [struct] object per canvas. That way it's simple to know which
[draw] commands go with which data structure.;
#X text 53 369 So how do we draw something? We just type the name we
gave to the [struct] into an object box. This will create an object
\, referred to in Pd as a "scalar". It will have data for "x" and "y"
fields and will use the info in our [draw] object to draw itself on
the canvas.;
#X text 53 439 Type our [struct] name "drawtut-one" in the box below:
;
#X text 53 152 The field names "x" and "y" are special in Pd. Their
values will be associated with the base x/y coordinates of what we
draw to represent an object created from the [struct] above.;
#X text 53 23 Let's draw something! First \, we need a [struct]:;
#X text 53 509 That's it! To sum up: once you have a [struct] and some
[draw] objects \, you can create a scalar like the one above on any
canvas in the running Pd instance. For convenience we created everything
in the main patch \, but since there's only one [struct] per canvas
you typically will want to keep your [struct] and any [draw] objects
in their own subpatch.;
#X obj 56 463;
