[Newbies] (no subject)

John Foster johnps11 at bigpond.com
Sun May 9 18:31:58 UTC 2010


Hi everyone,

I've been using Squeak to write little tools to help my students drill
various maths skills.  Since modern students have major issues working
with fractions (due, I believe, to too much calculator too soon) I want to
produce a morph that displays a simple arithmetic problem.  The student
attempts to solve the problem, and then clicks on the morph, which then
displays the solution.  If the student clicks on the morph again it shows
a new (randomly selected) problem.  I've used the idea with a few other
types of problem quite successfully.

My problem is how to display a fraction so it looks like a fraction, and
not like (2/5) + (7/8).  I want the vinculum to be a horizontal line:

 2     7      61
--- + --- =  ----
 5     8      40

Can anyone point me at example code on how to get things formatted nicely?
 It looks as if I have to somehow calculate how many pixels wide and high
each character is, and place each character nicely individually, which
seems like an insane amount of work to do something that seems like it
should be straightforward.  Should I have 5 text morphs imbedded in a
rectangle morph, using automatic sizing and keeping track of the bounds of
each so I can draw lines to put the vinculums in place, or is there a
cleaner way that requires less management code?  Things seem awfully messy
catering for the different things that could come up (like 2/15, 15/2,
2/123 etc).

Pointers to existing code would be ideal, so I can understand things,
rather than just dropping a solution on me.

Thanks in advance,

John Foster.




More information about the Beginners mailing list