Beispiel #1
0
static int graphicsRectangle(lua_State *L) { // love.graphics.rectangle()

	if (sf2d_get_current_screen() == currentScreen) {

		char *mode = luaL_checkstring(L, 1);

		int x = luaL_checkinteger(L, 2);
		int y = luaL_checkinteger(L, 3);

		translateCoords(&x, &y);

		int w = luaL_checkinteger(L, 4);
		int h = luaL_checkinteger(L, 5);

		if (strcmp(mode, "fill") == 0) {
			sf2d_draw_rectangle(x, y, w, h, getCurrentColor());
		} else if (strcmp(mode, "line") == 0) {
			sf2d_draw_line(x, y, x, y + h, currentLineWidth, getCurrentColor());
			sf2d_draw_line(x, y, x + w, y, currentLineWidth, getCurrentColor());

			sf2d_draw_line(x + w, y, x + w, y + h, currentLineWidth, getCurrentColor());
			sf2d_draw_line(x, y + h, x + w, y + h, currentLineWidth, getCurrentColor());
		}

	}

	return 0;

}
Beispiel #2
0
/***
Draw a rectangle outline on the current screen.
@function linedRectangle
@tparam integer x rectangle origin horizontal coordinate, in pixels
@tparam integer y rectangle origin vertical coordinate, in pixels
@tparam integer width rectangle width, in pixels
@tparam integer height rectangle height, in pixels
@tparam[opt=1] integer lineWidth line's thickness, in pixels
@tparam[opt=0] number angle rectangle rotation, in radians
@tparam[opt=default color] integer color drawing color
*/
static int gfx_linedRectangle(lua_State *L) {
	int x = luaL_checkinteger(L, 1);
	int y = luaL_checkinteger(L, 2);
	int width = luaL_checkinteger(L, 3);
	int height = luaL_checkinteger(L, 4);
	float lineWidth = luaL_optnumber(L, 5, 1.0f);

	float angle = luaL_optnumber(L, 6, 0);
	u32 color = luaL_optinteger(L, 7, color_default);

	// Corner coordinates
	int x2 = x + width, y2 = y;
	int x3 = x2, y3 = y + height;
	int x4 = x, y4 = y3;

	// Rotate corners
	if (angle != 0) {
		int cx = x + width/2, cy = y + height/2;
		rotatePoint(x,  y,  cx, cy, angle, &x,  &y );
		rotatePoint(x2, y2, cx, cy, angle, &x2, &y2);
		rotatePoint(x3, y3, cx, cy, angle, &x3, &y3);
		rotatePoint(x4, y4, cx, cy, angle, &x4, &y4);
	}

	// Draw lines
	sf2d_draw_line(x,  y,  x2, y2, lineWidth, color);
	sf2d_draw_line(x2, y2, x3, y3, lineWidth, color);
	sf2d_draw_line(x3, y3, x4, y4, lineWidth, color);
	sf2d_draw_line(x4, y4, x,  y,  lineWidth, color);

	return 0;
}
Beispiel #3
0
static int graphicsLine(lua_State *L) { // love.graphics.line() -- Semi-Broken

	if (sf2d_get_current_screen() == currentScreen) {

		int argc = lua_gettop(L);
		int i = 0;

		if ((argc/2)*2 == argc) {
			for( i; i < argc / 2; i++) {

				int t = i * 4;

				int x1 = luaL_checkinteger(L, t + 1);
				int y1 = luaL_checkinteger(L, t + 2);
				int x2 = luaL_checkinteger(L, t + 3);
				int y2 = luaL_checkinteger(L, t + 4);

				translateCoords(&x1, &y1);
				translateCoords(&x2, &y2);

				sf2d_draw_line(x1, y1, x2, y2, currentLineWidth, getCurrentColor());

			}
		}

	}

	return 0;

}
Beispiel #4
0
/***
Draw a triangle outline on the current screen.
@function linedTriangle
@tparam integer x1 horizontal coordinate of a vertex of the triangle, in pixels
@tparam integer y1 vertical coordinate of a vertex of the triangle, in pixels
@tparam integer x2 horizontal coordinate of a vertex of the triangle, in pixels
@tparam integer y2 vertical coordinate of a vertex of the triangle, in pixels
@tparam integer x3 horizontal coordinate of a vertex of the triangle, in pixels
@tparam integer y3 vertical coordinate of a vertex of the triangle, in pixels
@tparam[opt=1] number lineWidth line's thickness, in pixels
@tparam[opt=default color] integer color drawing color
*/
static int gfx_linedTriangle(lua_State *L) {
	int x1 = luaL_checkinteger(L, 1);
	int y1 = luaL_checkinteger(L, 2);
	int x2 = luaL_checkinteger(L, 3);
	int y2 = luaL_checkinteger(L, 4);
	int x3 = luaL_checkinteger(L, 5);
	int y3 = luaL_checkinteger(L, 6);
	float lineWidth = luaL_optnumber(L, 7, 1.0f);

	u32 color = luaL_optinteger(L, 8, color_default);

	sf2d_draw_line(x1, y1, x2, y2, lineWidth, color);
	sf2d_draw_line(x2, y2, x3, y3, lineWidth, color);
	sf2d_draw_line(x3, y3, x1, y1, lineWidth, color);

	return 0;
}
Beispiel #5
0
/***
Draw a line on the current screen.
@function line
@tparam integer x1 line's starting point horizontal coordinate, in pixels
@tparam integer y1 line's starting point vertical coordinate, in pixels
@tparam integer x2 line's endpoint horizontal coordinate, in pixels
@tparam integer y2 line's endpoint vertical coordinate, in pixels
@tparam[opt=1] number width line's thickness, in pixels
@tparam[opt=default color] integer color drawing color
*/
static int gfx_line(lua_State *L) {
	int x1 = luaL_checkinteger(L, 1);
	int y1 = luaL_checkinteger(L, 2);
	int x2 = luaL_checkinteger(L, 3);
	int y2 = luaL_checkinteger(L, 4);
	float width = luaL_optnumber(L, 5, 1.0f);
	
	u32 color = luaL_optinteger(L, 6, color_default);
	
	sf2d_draw_line(x1, y1, x2, y2, width, color);

	return 0;
}
Beispiel #6
0
static int graphicsCircle(lua_State *L) { // love.graphics.circle()

	if (sf2d_get_current_screen() == currentScreen) {

		int step = 15;

		char *mode = luaL_checkstring(L, 1);
		int x = luaL_checkinteger(L, 2);
		int y = luaL_checkinteger(L, 3);
		int r = luaL_checkinteger(L, 4);

		translateCoords(&x, &y);

		sf2d_draw_line(x, y, x, y, 1, getCurrentColor()); // Fixes weird circle bug.
		sf2d_draw_fill_circle(x, y, r, getCurrentColor());

	}

	return 0;

}
void Lux_NATIVE_DrawLine( LuxRect points, ObjectEffect effects )
{
	Lux_NATIVE_SetFrame(points, true);
	sf2d_draw_line(points.x, points.y, points.w, points.h, RGBA8(effects.primary_colour.r, effects.primary_colour.g, effects.primary_colour.b, effects.primary_colour.a) );
}