From: Michael on 15 Jun 2010 02:29 How can I automatically scale Text[] to fit into a bounding rectangle of a size that I specify? For instance, I can get a pretty close result here, but it is not perfect (the text doesn't touch the bottom edge of the rectangle), and "36", {0,0}, and {-1,-1} are all numbers I had to find through trial and error: Graphics[{ FaceForm[], EdgeForm[Black], Rectangle[{0, 0}, {100, 10}], Text[Style["Hello", 36], {0, 0}, {-1, -1}] } ] Thanks, Michael
From: Alexei Boulbitch on 16 Jun 2010 05:41 Hi, Michael, try this: Manipulate[ Framed(a)Pane[Graphics[Text[Style["ABcdEG", n]]], {m1, m2}, Alignment -> Center], {n, 10, 30}, {m1, 50, 200}, {m2, 20, 200}] and play with parameters to chose those fitting your needs. Have fun, Alexei How can I automatically scale Text[] to fit into a bounding rectangle of a size that I specify? For instance, I can get a pretty close result here, but it is not perfect (the text doesn't touch the bottom edge of the rectangle), and "36", {0,0}, and {-1,-1} are all numbers I had to find through trial and error: Graphics[{ FaceForm[], EdgeForm[Black], Rectangle[{0, 0}, {100, 10}], Text[Style["Hello", 36], {0, 0}, {-1, -1}] } ] Thanks, Michael -- Alexei Boulbitch, Dr. habil. Senior Scientist Material Development IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 CONTERN Luxembourg Tel: +352 2454 2566 Fax: +352 2454 3566 Mobile: +49 (0) 151 52 40 66 44 e-mail: alexei.boulbitch(a)iee.lu www.iee.lu -- This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.
From: Helen Read on 16 Jun 2010 05:42 On 6/15/2010 2:29 AM, Michael wrote: > How can I automatically scale Text[] to fit into a bounding rectangle of > a size that I specify? > > For instance, I can get a pretty close result here, but it is not > perfect (the text doesn't touch the bottom edge of the rectangle), and > "36", {0,0}, and {-1,-1} are all numbers I had to find through trial and > error: > > Graphics[{ > FaceForm[], EdgeForm[Black], > Rectangle[{0, 0}, {100, 10}], > Text[Style["Hello", 36], {0, 0}, {-1, -1}] > } > ] Framed[Text[Style["Hello"]]] If you want the 36 point font, that's fine too. Framed[Text[Style["Hello", 36]]] You can set FrameMargins on any or all sides. Framed[Text[Style["Hello", 36]], FrameMargins -> {{10, 200}, {0, 0}}] Framed[Text[Style["Hello", 36]], FrameMargins -> 20] -- Helen Read University of Vermont
From: Michael on 17 Jun 2010 02:03 The problem with both of these solutions is that I need the bounding rectangle to be in a Graphics[] expression because I'm creating several of these text filled boxes at arbitrary offsets. I'm trying to create something similar to Graph[] (hopefully using it's embedding functions) but instead of vertexes I want to create collections of boxes containing text. However Mathematica seems to render text independently of the coordinate range of the graphic. For example, these two expressions produce identical output: Graphics[{ Text[Style["Test", 12]], Circle[{0, 0}, 1] } ] Graphics[{ Text[Style["Test", 12]], Circle[{0, 0}, 100] } ] I found something close to what I want to do, but it's ugly because the graphics don't scale nicely: Graphics[{ FaceForm[], EdgeForm[Black], Raster[Reverse[Rasterize["Hello", "Data"]], {{0, 0}, {100, 16}}], Rectangle[{0, 0}, {100, 16}] } ] But I would have to hope that surely there is some way to put Text[] in Graphics[] such that the size of the text is proportional to the visible coordinate range of the Graphics[]. Even if I could only find the size of the text in a given image I could then scale it as needed. I tried using Rasterize[string,"RasterSize"] but I couldn't figure out how to make it work. Any ideas along that line? I'm hoping that I'm just missing something obvious that I've overlooked in Mathematica's big API... Thanks, Michael > On 6/15/2010 2:29 AM, Michael wrote: >> How can I automatically scale Text[] to fit into a bounding rectangle of >> a size that I specify? >> >> For instance, I can get a pretty close result here, but it is not >> perfect (the text doesn't touch the bottom edge of the rectangle), and >> "36", {0,0}, and {-1,-1} are all numbers I had to find through trial and >> error: >> >> Graphics[{ >> FaceForm[], EdgeForm[Black], >> Rectangle[{0, 0}, {100, 10}], >> Text[Style["Hello", 36], {0, 0}, {-1, -1}] >> } >> ] On 6/16/2010 2:41 AM, Alexei Boulbitch wrote: > Hi, Michael, > > try this: > > Manipulate[ > > Framed(a)Pane[Graphics[Text[Style["ABcdEG", n]]], {m1, m2}, > Alignment -> Center], > > {n, 10, 30}, {m1, 50, 200}, {m2, 20, 200}] > > and play with parameters to chose those fitting your needs. > Have fun, Alexei On 6/16/2010 2:42 AM, Helen Read wrote: > Framed[Text[Style["Hello"]]] > > If you want the 36 point font, that's fine too. > > Framed[Text[Style["Hello", 36]]] > > You can set FrameMargins on any or all sides. > > Framed[Text[Style["Hello", 36]], FrameMargins -> {{10, 200}, {0, 0}}] > > Framed[Text[Style["Hello", 36]], FrameMargins -> 20]
From: Alexey Popkov on 17 Jun 2010 07:11 Hi, Michael, You can try to play with text outlines (vector representation of the text): Graphics[{{FaceForm[], EdgeForm[Black], Rectangle[{0, 0}, {100, 10}]}, Inset[First(a)ImportString[ExportString[Style["Hello", 36], "PDF"], "PDF"]]}] "Michael" <michael2718(a)gmail.com> news:hvcds8$5h9$1(a)smc.vnet.net... > The problem with both of these solutions is that I need the bounding > rectangle to be in a Graphics[] expression because I'm creating several > of these text filled boxes at arbitrary offsets. I'm trying to create > something similar to Graph[] (hopefully using it's embedding functions) > but instead of vertexes I want to create collections of boxes containing > text. However Mathematica seems to render text independently of the > coordinate range of the graphic. For example, these two expressions > produce identical output: > > Graphics[{ > Text[Style["Test", 12]], > Circle[{0, 0}, 1] > } > ] > > Graphics[{ > Text[Style["Test", 12]], > Circle[{0, 0}, 100] > } > ] > > I found something close to what I want to do, but it's ugly because the > graphics don't scale nicely: > > Graphics[{ > FaceForm[], EdgeForm[Black], > Raster[Reverse[Rasterize["Hello", "Data"]], {{0, 0}, {100, 16}}], > Rectangle[{0, 0}, {100, 16}] > } > ] > > But I would have to hope that surely there is some way to put Text[] in > Graphics[] such that the size of the text is proportional to the visible > coordinate range of the Graphics[]. Even if I could only find the size > of the text in a given image I could then scale it as needed. I tried > using Rasterize[string,"RasterSize"] but I couldn't figure out how to > make it work. Any ideas along that line? I'm hoping that I'm just > missing something obvious that I've overlooked in Mathematica's big API... > > Thanks, > > Michael > > >> On 6/15/2010 2:29 AM, Michael wrote: >>> How can I automatically scale Text[] to fit into a bounding rectangle of >>> a size that I specify? >>> >>> For instance, I can get a pretty close result here, but it is not >>> perfect (the text doesn't touch the bottom edge of the rectangle), and >>> "36", {0,0}, and {-1,-1} are all numbers I had to find through trial and >>> error: >>> >>> Graphics[{ >>> FaceForm[], EdgeForm[Black], >>> Rectangle[{0, 0}, {100, 10}], >>> Text[Style["Hello", 36], {0, 0}, {-1, -1}] >>> } >>> ] > On 6/16/2010 2:41 AM, Alexei Boulbitch wrote: >> Hi, Michael, >> >> try this: >> >> Manipulate[ >> >> Framed(a)Pane[Graphics[Text[Style["ABcdEG", n]]], {m1, m2}, >> Alignment -> Center], >> >> {n, 10, 30}, {m1, 50, 200}, {m2, 20, 200}] >> >> and play with parameters to chose those fitting your needs. >> Have fun, Alexei > On 6/16/2010 2:42 AM, Helen Read wrote: >> Framed[Text[Style["Hello"]]] >> >> If you want the 36 point font, that's fine too. >> >> Framed[Text[Style["Hello", 36]]] >> >> You can set FrameMargins on any or all sides. >> >> Framed[Text[Style["Hello", 36]], FrameMargins -> {{10, 200}, {0, 0}}] >> >> Framed[Text[Style["Hello", 36]], FrameMargins -> 20] > > >
|
Next
|
Last
Pages: 1 2 Prev: Reading Binary Data from SQL Request Next: Divergent integration result |