1) What is the easiest way to draw a graphical object (e.g., a line)? Can you draw in the Workspace or must you draw on a special canvas? Could you provide a simple example?
2) How do you include a character such as a single quote in a Squeak string; i.e., what is the equivalent in Squeak SmallTalk of "'" (I am aware of the fact that you can always replace the single quote by a double quote as in 'John"s', but I wonder if there is another solution)?
3) What is the easiest way to generate a simple window containing a button, in Squeak?
Any answers to these questions would be much appreciated.
Philippe de Rochambeau
Philippe,
- What is the easiest way to draw a graphical object (e.g., a line)?
Can you draw in the Workspace or must you draw on a special canvas? Could you provide a simple example?
Have a look at class Canvas. The easiest way to draw a line is probably:
(FormCanvas on: Display) line: 0@0 to: 1000@1000 width: 1 color: Color black
or, using a more general representation
(Line from: 0@0 to: 1000@1000 withForm: (Form extent:1@1 depth:1) fillBlack) display
The latter allows more general lines as for instance in:
(Line from: 0@0 to: 1000@1000 withForm: Form fromUser) display
Hope that helps, Andreas
- What is the easiest way to draw a graphical object (e.g., a line)?
Phillippe -- Andreas offers some nicely general solutions to your question. I'd like to add that Smalltalk has always supported turtle graphics which is probably the EASIEST way to draw a line:
Pen new turn: 30; go: 100
This may not be beautiful by modern standards. But it's handy when you want to add some debugging plot output to a complicated program. -- Ward
squeak-dev@lists.squeakfoundation.org