This wiki is out of date, use the continuation of this wiki instead

Write in map

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:49, 24 July 2007 (edit)
Rincewind (Talk | contribs)
(New article)
← Previous diff
Current revision (22:18, 26 July 2008) (edit) (undo)
90.198.130.112 (Talk)
(Notes)
 
(9 intermediate revisions not shown.)
Line 5: Line 5:
'''INT''' write_in_map ( <'''INT''' fontID> , <'''STRING''' text> , <'''INT''' alignment> ) '''INT''' write_in_map ( <'''INT''' fontID> , <'''STRING''' text> , <'''INT''' alignment> )
-Creates a new map in memory with the given text on it (with the map borders as tight around the text as possible). +Creates a new [[graphic]] in memory with the given text on it (without borders around the text) and puts it in the [[system file]].
== Parameters == == Parameters ==
Line 17: Line 17:
== Returns == == Returns ==
-'''INT''' : [[graph]] number of the newly created map (in [[file]] 0, memory).+'''INT''' : [[GraphID]]
- +{|
 +| 0 || - Error. The text could not be obtained or was empty.
 +|-
 +| !0 || - The [[GraphID]] of the [[graphic]] of the generated [[graphic]] in the [[system file]].
 +|}
== Notes == == Notes ==
-[[Map_put]]() or [[map_xput]]() can be used to put the newly created text map on another map (this is also why the alignment parameter is handy: it enables you to chose alignment when putting the text map on another map).+This function creates a [[graphic]] containing the specified [[font]], with a [[width]] and [[height]] determined by the physical size of the text; the graphic's size will fit the text exactly to the pixel. The graphic will be stored in memory with [[FileID]] 0 (using the [[system file]]), and can be obtained at any time by calling its [[GraphID]]. The graphic can also be unloaded from memory by using [[unload_map]]().
 + 
 +The centre of the graph ([[control point]] 0) is given according to the given [[alignment]]. This gives added functionality of being able to place the graph like texts, yet also using [[flags]], [[alpha]], rotation, [[collision]](), etc.
 + 
 +Processes can adopt the graphic containing the text, or it can be displayed with some [[Functioncategory:Maps|maps functions]], creating a very handy function.
== Errors == == Errors ==
-''<If someone knows, please edit!> ''+{|
 +| Invalid font || - The specified font does not exist or is invalid.
 +|}
== Example == == Example ==
<pre> <pre>
-Program test;+Program example;
Begin Begin
- x=320/2;+ Set_text_color(rgb(222,195,140));
- y=200/2;+ graph=write_in_map(0,"Game programming is awesome!",4);
- Set_text_color(154);+ repeat
- Graph=write_in_map(0,"Game programming is awesome!",4);+ x=mouse.x;
- Loop+ y=mouse.y;
- Frame;+ frame;
- End+ until(key(_esc))
End End
</pre> </pre>
-Used in example: [[set_text_color]]()+Used in example: [[set_text_color]](), [[rgb]](), [[key]](), [[x]], [[y]], [[mouse]]
This will result in something like:<br/> This will result in something like:<br/>
[[Image:Write_in_map.png]] [[Image:Write_in_map.png]]

Current revision


Contents

[edit] Definition

INT write_in_map ( <INT fontID> , <STRING text> , <INT alignment> )

Creates a new graphic in memory with the given text on it (without borders around the text) and puts it in the system file.

[edit] Parameters

INT fontID - The FontID of the font to be used for the text.
STRING text - The text to be used.
INT alignment - The type of alignment.

[edit] Returns

INT : GraphID

0 - Error. The text could not be obtained or was empty.
 !0 - The GraphID of the graphic of the generated graphic in the system file.

[edit] Notes

This function creates a graphic containing the specified font, with a width and height determined by the physical size of the text; the graphic's size will fit the text exactly to the pixel. The graphic will be stored in memory with FileID 0 (using the system file), and can be obtained at any time by calling its GraphID. The graphic can also be unloaded from memory by using unload_map().

The centre of the graph (control point 0) is given according to the given alignment. This gives added functionality of being able to place the graph like texts, yet also using flags, alpha, rotation, collision(), etc.

Processes can adopt the graphic containing the text, or it can be displayed with some maps functions, creating a very handy function.

[edit] Errors

Invalid font - The specified font does not exist or is invalid.

[edit] Example

Program example;
Begin
    Set_text_color(rgb(222,195,140));
    graph=write_in_map(0,"Game programming is awesome!",4);
    repeat
        x=mouse.x;
        y=mouse.y;
    frame;
    until(key(_esc))
End

Used in example: set_text_color(), rgb(), key(), x, y, mouse

This will result in something like:
Image:Write_in_map.png

Personal tools