趣味で作ってるロボット用ソフトウェア
 All Classes Files Functions Enumerations Enumerator Friends Pages
text_surface_example.cpp

Text_surface.cpp の動作サンプル

#include <iostream>
#include <SDL.h>
#include "Main_window.h"
#include "View.h"
#include "Scene.h"
#include "Layer.h"
#include "Label.h"
#include "delay.h"
#include "Font.h"
#include "Color.h"
#include "Text_surface.h"
using namespace hrk;
using namespace std;
int main(int argc, char *argv[])
{
const char* font_file = (argc >= 2) ? argv[1] : "";
Main_window main_window;
main_window.show(SizeF(640, 480));
View view(main_window);
Scene* scene = view.front();
Layer* layer = scene->front();
Font font(font_file);
if (!font.is_valid()) {
cout << "Font::open(): " << font.what() << endl;
return 1;
}
font.set_pixel_size(20);
Text_surface hello_text(font, "Hellow, world.");
font.set_foreground_color(Color(0.5, 0.5, 1.0));
Text_surface jp_text(font, "こんにちは.");
Label hello_label(&hello_text);
Label jp_label(&jp_text);
layer->push_front(&hello_label);
layer->push_front(&jp_label);
jp_label.set_position(PointF(0, hello_label.size().height()));
view.redraw();
view.redraw();
delay_sec(1.5);
return 0;
}