Esempio n. 1
0
void show_block(uint8_t x, uint8_t y, const block& fig, const color::rgb& rgb)
{
	for(uint8_t i = 0; i != fig.height; ++i)
	{
		for(uint8_t j = 0; j != fig.width; ++j)
		{
			if(fig.at(j, i))
				ws2812_matrix::set_pixel_color(x + j, y - i, rgb);
		}
	}
}
Esempio n. 2
0
void hide_block(uint8_t x, uint8_t y, const block& fig)
{
	for(uint8_t i = 0; i != fig.height; ++i)
	{
		for(uint8_t j = 0; j != fig.width; ++j)
		{
			if(fig.at(j, i))
				ws2812_matrix::clear_pixel(x + j, y - i);
		}
	}
}
Esempio n. 3
0
bool intersects(const block& b, uint8_t x, uint8_t y)
{
	for(uint8_t i = 0; i != b.height; ++i)
	{
		for(uint8_t j = 0; j != b.width; ++j)
		{
			if(b.at(j, i) && ws2812_matrix::is_on(x + j, y - i))
				return true;
		}
	}
	
	return false;
}
Esempio n. 4
0
block rotate_block(const block& b)
{
	block ret { b.height, b.width, 0, 0, 0, 0 };
	
	for(uint8_t i = 0; i != b.width; ++i)
	{
		for(uint8_t j = 0; j != b.height; ++j)
		{
			//ret.set(j, i, b.at(b.width - i - 1, j)); //ccw
			ret.set(b.height - 1 - j, i, b.at(i, j)); //cw
		}
	}
	
	return ret;
}