Exemple #1
0
	int32_t Charset::draw(string str, const DrawArgument& args) const
	{
		size_t length = str.size();
		int32_t shift = 0;
		int32_t total = 0;

		using::Util::vector2d;
		using::Graphics::AlphaArgument;
		switch (alignment)
		{
		case CHA_CENTER:
			for (size_t i = 0; i < length; i++)
			{
				total += getw(str[i]);
			}
			shift -= total / 2;
		case CHA_LEFT:
			for (size_t i = 0; i < length; i++)
			{
				draw(str[i], AlphaArgument(args.getpos() + vector2d<int32_t>(shift, 0), args.getalpha()));
				shift += getw(str[i]);
			}
			break;
		case CHA_RIGHT:
			for (size_t i = length - 1; i >= 0 && i < length; i--)
			{
				shift += getw(str[i]);
				draw(str[i], AlphaArgument(args.getpos() - vector2d<int32_t>(shift, 0), args.getalpha()));
			}
			break;
		}
		return shift;
	}
Exemple #2
0
void ColorBox::draw(const DrawArgument& args) const
{
    Point<int16_t> absp = args.getpos();
    int16_t absw = args.getstretch().x();
    if (absw == 0)
        absw = width;
    int16_t absh = args.getstretch().y();
    if (absh == 0)
        absh = height;
    absw = static_cast<int16_t>(absw * args.get_xscale());
    absh = static_cast<int16_t>(absh * args.get_yscale());
    float absopc = opacity * args.get_color().a();
    Geometry::draw(absp.x(), absp.y(), absw, absh, color, absopc);
}