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. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi John,
JF> My problem is how to display a fraction so it looks like a fraction, and JF> not like (2/5) + (7/8). I want the vinculum to be a horizontal line: JF> 2 7 61 JF> --- + --- = ---- JF> 5 8 40 JF> Can anyone point me at example code on how to get things formatted nicely? each Fraction understands numerator and denominator so you have the numbers. Just try in a Workspace 1234567 printString asMorph openInHand. Now you have your Morphs, each of which understands bounds to give you the top left and bottom right corner. Then with position: topLeftCorner you can move them around and draw your vinculum (thanks for a new word :-)) as a LineMorph with the class side method from: startPoint to: endPoint color: lineColor width: lineWidth between your numbers Then add them with addMorph: to whatever you use as a display. JF> Pointers to existing code would be ideal, so I can understand things, JF> rather than just dropping a solution on me. Well hope that helps with understanding. Cheers, Herbert _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by John Foster-3
On Monday 10 May 2010 12:01:58 am John Foster wrote:
> 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 You could use a Column morph with its border width set to zero and fill style set to transparent color. You may have to override cell positioning to bottom right to get numbers to align right (halo for Column ->menu->layout->table layout->cell positioning -> bottom right). Replace Red and Green morphs with Text containing numerator and denominator. Set Yellow morph's color to black, length to 3 and width to the max (numerator width, denominator width). Create Column morphs for first fraction, +, second fraction, =, total fraction and put them into a Row Morph. HTH .. Subbu _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by John Foster-3
On Monday 10 May 2010 12:01:58 am John Foster wrote:
> 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 You could use a Column morph with its border width set to zero and fill style set to transparent color. You may have to override cell positioning to bottom right to get numbers to align right (halo for Column ->menu->layout->table layout->cell positioning -> bottom right). Replace Red and Green morphs with Text containing numerator and denominator. Set Yellow morph's color to black, length to 3 and width to the max (numerator width, denominator width). Create Column morphs for first fraction, +, second fraction, =, total fraction and put them into a Row Morph. HTH .. Subbu _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Or -- if you are ok not to install Squeak images but OS images like virtual box -- you could also use LatexMorph.
http://www.tesujimath.org/squeak/LatexMorph Of course you would have to install Latex and Ghostscript first, and in the Squeak Image OSProcess, but then you could write all kinds of perfectly layouted formulas... Then make a virtual box image to distribute it to the students. As I said, it might very well be overkill for this problem. Cheers Markus Am 10.05.2010 um 16:43 schrieb K. K. Subramaniam: > On Monday 10 May 2010 12:01:58 am John Foster wrote: >> 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 > You could use a Column morph with its border width set to zero and fill style > set to transparent color. You may have to override cell positioning to bottom > right to get numbers to align right (halo for Column ->menu->layout->table > layout->cell positioning -> bottom right). Replace Red and Green morphs with > Text containing numerator and denominator. Set Yellow morph's color to black, > length to 3 and width to the max (numerator width, denominator width). > > Create Column morphs for first fraction, +, second fraction, =, total fraction > and put them into a Row Morph. > > HTH .. Subbu > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
This might be what I really need, as I was going to develop a whole series
of morphs for different types of drill. I'll see if this can work with a live ubuntu or knoppix CD. I was going to leave the problem of how to format integrals for another month. This way I only have to vary the logic of being sure the problems are appropriate difficulty, but the display logic can be the same whether it's simple arithmetic, calculus or algebra. Using a live CD also means I can cut out network support, which makes it easier to get it used in schools, as the only support/security issue is that the machines be able to boot from optical disk. I'll play with all these ideas, but using Tex seems like it will make the bigger goals less daunting. Thanks, John > Or -- if you are ok not to install Squeak images but OS images like > virtual box -- you could also use LatexMorph. > http://www.tesujimath.org/squeak/LatexMorph > > Of course you would have to install Latex and Ghostscript first, and in > the Squeak Image OSProcess, but then you could write all kinds of > perfectly layouted formulas... > > Then make a virtual box image to distribute it to the students. > As I said, it might very well be overkill for this problem. > > Cheers > > Markus > > > Am 10.05.2010 um 16:43 schrieb K. K. Subramaniam: > >> On Monday 10 May 2010 12:01:58 am John Foster wrote: >>> 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 >> You could use a Column morph with its border width set to zero and fill >> style >> set to transparent color. You may have to override cell positioning to >> bottom >> right to get numbers to align right (halo for Column >> ->menu->layout->table >> layout->cell positioning -> bottom right). Replace Red and Green morphs >> with >> Text containing numerator and denominator. Set Yellow morph's color to >> black, >> length to 3 and width to the max (numerator width, denominator width). >> >> Create Column morphs for first fraction, +, second fraction, =, total >> fraction >> and put them into a Row Morph. >> >> HTH .. Subbu >> _______________________________________________ >> Beginners mailing list >> [hidden email] >> http://lists.squeakfoundation.org/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Tuesday 11 May 2010 12:52:31 am John Foster wrote:
> I'll play with all these ideas, but using Tex seems like it will make the > bigger goals less daunting I adapted Simon's LatexMorph for Etoys to help 9-12 yr olds typeset Indic and Math text. See, http://www.squeaksource.com/LatexMorph It is not very robust (and unforgiving of missing texlive packages and utilities) but it served my purpose well. HTH .. Subbu _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |