#include "image.h"

void image::draw(std::string const& str, vec2i pos, font const* font, color color) {
	auto origx = pos.x;
	for(auto ch = str.begin(); ch != str.end(); ++ch) {
		if(*ch == '\n') {
			pos.x = origx;
			pos.y += font->lineheight();
			continue;
		}
		draw(font->get(*ch), pos, color);
		pos.x += font->get(*ch)->size().x;
	}
}

const std::vector<vec2i> shadow_offsets{
	vec2i(-1,  0),
	vec2i( 1,  0),
	vec2i( 0, -1),
	vec2i( 0,  1),

	vec2i(-1, -1),
	vec2i(-1,  1),
	vec2i( 1, -1),
	vec2i( 1,  1),

	vec2i( 0,  2),
	vec2i(-1,  2),
	vec2i( 1,  2)
};

void image::draw(std::string const& str, vec2i pos, font const* font, color color1, color color2) {
	for(auto so = shadow_offsets.begin(); so != shadow_offsets.end(); ++so)
		draw(str, pos + *so, font, color2);
	draw(str, pos, font, color1);
}

