I want to build some simulation in supercollider.
I need to find the releatvie postion of index,
now I am working on a 10 agent(just small dot on the screen) and I want to find the left and right agent with some algorithm, before that
I want to print, each agent number on a window
but I didn’t much look on it, I didn’t find any kinds of tutorials to print just number of agent on it
is it possibe to just print number on a window? (number/index of agent)
now I only drawing dots with pen tool, add the number for better understanding
If you are already using the Pen class, you can use the methods string
or stringAtPoint
to draw text. You can get and set the font with Pen.font
, too. They aren’t documented, but there are examples which use them in the Pen help file.
1 Like
Another option is to use a Button to represent the agent and a StaticText to show the number above. Depending on your needs in terms of graphics, this approach might be simpler than using Pen.
(
v = View().fixedSize_(500@500).front.alwaysOnTop_(true).background_(Color.white);
~views = 10.collect{|i| View().layout_(
VLayout(
StaticText().font_(\Arial, 9).string_((i + 1).asSymbol).align_(\center),
[ Button().fixedSize_(9@9), align: \center]
).spacing_(2)).fixedSize_(50@50)
};
v.layout = VLayout(*~views);
10.do{|i| ~views[i].moveTo(450.rand, 450.rand) }
)
1 Like
thanks for the quick reply 
It is much easier than I expect haha
But for this just check the current object’s index
but thanks! It seems be helpful for next step 