void AnimateDamage(int x, int y, int damage)
{
	std::ostringstream ss;
	ss << damage;
	std::string s = ss.str();

	int n_steps = duration * fps;
	float angle_delta = 2.0f * pi / n_steps;

	terminal_layer(animation_layer);
	for (int i=0; i<n_steps; i++)
	{
		if (terminal_has_input()) break;
		terminal_clear_area(0, 0, terminal_state(TK_WIDTH), terminal_state(TK_HEIGHT));
		float dx = std::sin(i*angle_delta) * radius * terminal_state(TK_CELL_WIDTH) + i*2;
		float dy = -2.0f * radius * terminal_state(TK_CELL_WIDTH) / n_steps * i - terminal_state(TK_CELL_HEIGHT)/2;
		terminal_color(color_from_argb(255/n_steps*(n_steps-i), 255, 64, 0));
		terminal_printf(x, y, "[offset=%dx%d]%s", (int)dx, (int)dy, s.c_str());
		terminal_refresh();
		terminal_delay(1000/fps);
	}
	terminal_color("white");
}
void BasicOutput()
{
	terminal_options("title=BearLibTerminal demo: output facilities");
	terminal_options("font.name=default; font.supplement=Media/Omni/supplement-runic.png");

	terminal_blending(BLENDING_ADDITIVE);
	terminal_color(COLOR_WHITE);

	terminal_clear();

	// Simple output with postformatting
	terminal_printf(1, 1, "[color=gray]1. Most basic:[/color] ABC abc");

	// Wide color range
	int n = terminal_printf(1, 3, "[color=gray]2. Colors: ");
	const char long_word[] = "Antidisestablishmentarianism";
	const size_t long_word_length = sizeof(long_word)-1;
	for ( size_t i = 0; i < long_word_length; i++ )
	{
		float factor = float(i)/long_word_length;
		int red = (1.0f - factor) * 255;
		int green = factor * 255;
		terminal_color(color_from_argb(255, red, green, 0));
		terminal_put(n+1+i, 3, long_word[i]);
	}
	terminal_color(color_from_name("white"));

	// Tile backgrounds
	terminal_printf(1, 5, "[color=gray]3. Backgrounds: [color=black][bkcolor=gray] grey [/bkcolor] [bkcolor=red] red ");

	// Simple unicode output
	terminal_printf(1, 7, "[color=gray]4. Unicode:[/color] Latin Русский Ελληνικά");

	// Composite (overlay) tiles
	n = terminal_printf(1, 9, "[color=gray]5. Tile overlay: ");
	terminal_printf(n+1, 9, "a+  = a, a+  = a, a vs. [color=red]ä");
	terminal_printf(n+1, 9, "[color=red]  /   /    ▔   ▔        [/color]a");

	// Unicode Box Drawing characters
	terminal_printf(1, 11, "[color=gray]6. Box drawing:");
	const char* box_lines[] =
	{
		"       ┌──┬───┐      ╔═════╗ ",
		" ┌───┬─┘  │   ├──┐   ╟──┐  ║ ",
		" └─┐ └─┐  ├───┘  │   ║  └──╢ ",
		"   └───┴──┴──────┘   ╚═════╝ "
	};
	for ( size_t i = 0; i < sizeof(box_lines)/sizeof(box_lines[i]); i++ )
	{
		terminal_printf(1, 12+i, "%s", box_lines[i]);
	}

	// Box drawing + overlay application
	terminal_printf(1, 17, "[color=gray]7. Box drawing + overlay:");
	terminal_color(0xFF006000);
	for ( int y = 0; y < 6; y++ )
	{
		for ( int x = 0; x < 19; x++ )
		{
			terminal_put(1+x, 18+y, 'A'+(x+y)%26);
		}
	}
	DrawOverlayRectangle(3, 19, 15, 4, 0xFFFFFFFF, 0xA0909090);
	terminal_printf(4, 20, "[color=white]Itym:\nHeavy draggon");

	terminal_printf(40, 17, "[color=gray]8. Font supplement:");
	terminal_printf(40, 19, "fire ([color=red][uE001][/color]) - water ([color=lighter blue][uE004][/color]) - earth ([color=dark green][uE00F][/color])");
	terminal_printf(40, 20, "\uE001\uE002\uE003, \uE004\uE005\uE006\uE007\uE008! \uE009\uE00A\uE00B \uE00C \uE00D\uE00E\uE00F\uE010.");

	terminal_refresh();

	int key = 0;
	do
	{
		key = terminal_get();
	}
	while ( key != VK_CLOSE && key != VK_ESCAPE );
}