Texts and TablesTexts and TablesWith CindyScript you can produce controlled and styled text for a drawing. The essential functionality is covered by the drawtext operator. Furthermore, with drawtable a table output can be generated. Using texts and tables in scripts is very useful, since one can use the script language to control when and where text is displayed in a construction. This is a very important tool for providing explanatory texts and functional exercises that react to input.Drawing Text:
|
Modifier | Parameter | Effect |
size | <real> | sets the text size |
color | [<real>,<real>,<real>] | sets the text color |
alpha | <real> | sets the text opacity |
xoffset | <real> | set an x offset in pixels between text and base point |
yoffset | <real> | set a y offset in pixels between text and base point |
offset | [<real>,<real>] | set an xy offset in pixels between text and base point |
align | "left", "right", "mid" | determines where the text alignment should be |
bold | <bool> | flag for bold text |
italics | <bool> | flag for italics text |
family | <string> | specifying the font family |
serif
, sansserif
monospaced
are allowed, that always produce corresponding standard font types.x=1..10; forall(x,i, drawtext((i,0),"Text", size->2*i+15, bold->true, color->(1-i/10,0,i/10)) )
drawtext((0,0),size->18, "In Cinderella 'newlines' in Text are really used as line terminators. So this text will appear as a multilined text.")
fontfamilies()
families=fontfamilies(); i=0; while(length(families)>i,i=i+1; drawtext((mod(i,5)*7,round(i/5)),families_i,family->families_i); )
unicode(<string>)
unicode(<string>)
accepts a unicode description (a number) given as a string of digits. It returns a string with the corresponding unicode character. By default the base of the unicode description is 16. So hexadecimal descriptions are usually accepted as input. The base can be changed by a modifier.base
modifier.unicode("0041")
and unicode("65",base->10)
produce the character "A".candisplay(<string>)
drawtable(<vec>,<list>)
x=1..10; table=apply(x,(#,#^2,#^3,#^4)); drawtable((0,0),table);
drawtable
operator supports several modifiers to control the graphical appearance of the table. A summary of the modifiers is given in the following table:Modifier | Parameter | Effect |
width | <int> | the width of the cells in pixels |
height | <int> | the width of the cells in pixels |
flip |
| exchanges the role of rows and columns |
border | <bool> | turns on/off drawing of lines and borders |
size | <real> | sets the text size |
color | [<real>,<real>,<real>] | sets the text color |
alpha | <real> | sets the text opacity |
offset | [<real>,<real>] | sets an xy offset in pixels between text and base point |
align | "left", "right", "mid" | determines the horizontal text alignment within a cell |
back | <bool> | turns on/off the drawing of a table background |
back | [<real>,<real>,<real>] | turns on the drawing of table background and sets it to an RGB color |
backalpha | <real> | sets opacity of the table background |
drawtable
operator. modifiers are used to create a nice appearance of the tables. A second table is used to create a heading for the table.x=1..9; tab=apply(x,(#,#^2,#^3,#^4)); tab1=("x","$x^2$","$x^3$","$x^4$"); linecolor((0,0,.8)); drawtable((0,0),tab, width->50, height->22, back->(1,0,0), backalpha->0.1, align->"right", size->12 ); linecolor((0,0,0)); drawtable((0,8.1),tab1,flip->true, width->50, height->33, back->(0,0,1), backalpha->0.4, align->"mid", size->16, color->(1,1,1) );
Contributors to this page: Wurster
,
Kortenkamp
and
Akira Iritani
.
Page last modified on Thursday 10 of July, 2014 [08:12:09 UTC] by Wurster.
The content on this page is licensed under the terms of the License.