Difference between revisions of "Gb.display.drawChar"

From Gamebuino Wiki
Jump to: navigation, search
(Creation)
 
(Example: .)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
== Description ==
 
== Description ==
 
Draws a character at a specified location. The font is defined using [[gb.display.setFont]].
 
Draws a character at a specified location. The font is defined using [[gb.display.setFont]].
If you specify values that cause parts of the circle to be off screen, then they will not be rendered.
+
If you specify values that cause parts of the char to be off screen, then parts will not be rendered.
  
 
== Syntax ==
 
== Syntax ==
Line 11: Line 11:
 
* x: horizontal coordinate of the top left of the character
 
* x: horizontal coordinate of the top left of the character
 
* y: vertical coordinate of the top left of the character
 
* y: vertical coordinate of the top left of the character
* char: the character to draw
+
* char: the character to draw; char is the number of the '''Decimal''' character in the ASCII printable characters table.
 
* size: the size of the character
 
* size: the size of the character
 
** Changing the size changes what one pixel is viewed as - EG 4 would make each pixel a 4x4 group of pixels
 
** Changing the size changes what one pixel is viewed as - EG 4 would make each pixel a 4x4 group of pixels
Line 19: Line 19:
  
 
== Example ==
 
== Example ==
none
+
    #include <SPI.h>
 +
    #include <Gamebuino.h>
 +
    Gamebuino gb;
 +
    extern const byte font5x7[]; //use the font5x7 for uppercase letters
 +
    void setup(){
 +
      gb.begin();
 +
      gb.display.setFont(font5x7);
 +
    }
 +
    void loop(){
 +
      if(gb.update()){
 +
          gb.display.drawChar(10, 10,  90, 3);  // 90 =Z (DECIMAL char)
 +
      }
 +
    }
  
 
== See also ==
 
== See also ==
 
* [[gb.display.setFont]]
 
* [[gb.display.setFont]]

Latest revision as of 2017-02-16T13:34:11

Description

Draws a character at a specified location. The font is defined using gb.display.setFont. If you specify values that cause parts of the char to be off screen, then parts will not be rendered.

Syntax

gb.display.drawChar(x, y, char, size);

Parameters

  • x: horizontal coordinate of the top left of the character
  • y: vertical coordinate of the top left of the character
  • char: the character to draw; char is the number of the Decimal character in the ASCII printable characters table.
  • size: the size of the character
    • Changing the size changes what one pixel is viewed as - EG 4 would make each pixel a 4x4 group of pixels

Returns

none

Example

   #include <SPI.h>
   #include <Gamebuino.h>
   Gamebuino gb;
   extern const byte font5x7[]; //use the font5x7 for uppercase letters
   void setup(){
     gb.begin();
     gb.display.setFont(font5x7); 
   }
   void loop(){
     if(gb.update()){
         gb.display.drawChar(10, 10,  90, 3);  // 90 =Z (DECIMAL char)
      }
   }

See also