コード例 #1
0
ファイル: canvascontext.cpp プロジェクト: jameslin2014/xskit
void xsCanvasContext::clearRect(float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	xsSetColor(gc, XS_COLOR_WHITE);
	xsFillRectangle(gc, x, y, width, height);
	xsFlushScreen(x, y, x + width, y + height);
}
コード例 #2
0
ファイル: canvascontext.cpp プロジェクト: jameslin2014/xskit
void xsCanvasContext::strokeRect(float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	int i;
	lineWidth = lineWidth > 1.0 ? lineWidth : 1.0;
//another way to draw rectangle with specified linwWidth.
//	xsFillRectangle(gc, x - lineWidth + 1, y - lineWidth + 1, width + 2 * (lineWidth - 1), height + 2 * (lineWidth - 1), strokeColor);
//	xsFillRectangle(gc, x, y, width, height, XS_COLOR_WHITE);
	xsSetColor(gc, strokeColor);

	for(i = 0; i < lineWidth; i++)
	{
		xsDrawRectangle(gc, x - i, y - i, width + 2*i, height + 2*i);
	}
	xsFlushScreen(x - lineWidth, y - lineWidth, x + width + 2*lineWidth, y + height + 2*lineWidth);
}
コード例 #3
0
ファイル: demoapp.cpp プロジェクト: mixtile/xskit
int DemoApp::start()
{
	xsColor color = {255,255,255,255};
	xsSetColor(xsGetSystemGc(), color);
	xsGetScreenDimension(&width, &height);
	xsFillRectangle(xsGetSystemGc(), 0, 0, width, height);//, xsArgbToColor(0xFFFFFFFF));
	xsFlushScreen(0, 0, width - 1, height - 1);

	const char * js = getManifest()->getStartup();
	invokeJavascript(js, LOAD_JS_STRING);

	x = (width - BOX_SIZE) / 2;
	y = (height - BOX_SIZE) / 2;
	//img = this->getResource()->loadImage(xsT("logo-48x48.jpg"));
	//timer = xsStartTimer(20, _onTimeout, this);

	return XS_EC_OK;
}
コード例 #4
0
ファイル: demoapp.cpp プロジェクト: mixtile/xskit
int DemoApp::onTimeout()
{
	xsGraphics *gc = xsGetSystemGc();

	// clear
	xsColor color = {255, 255, 255, 255};
	xsSetColor(gc, color);
	xsFillRectangle(gc, x, y, BOX_SIZE, BOX_SIZE);//, xsArgbToColor(0xFFFFFFFF));

	// draw new box
	x += rateX;
	y += rateY;

	if (x < 0 || x + BOX_SIZE > width)
		rateX = -rateX;
	if (y < 0 || y + BOX_SIZE > height)
		rateY = -rateY;

	xsDrawImage(gc, img, x, y, 0, 0);
	
	xsFlushScreen(0, 0, width - 1, height - 1);

	return 0;
}
コード例 #5
0
ファイル: canvascontext.cpp プロジェクト: jameslin2014/xskit
void xsCanvasContext::paintFill(xsGraphics *gc)
{
	xsIterator iter = NULL;
	xsArrayList lines = NULL;
	xsLine *line = NULL;
	xsRectangle *rect = NULL;
	xsArc *arc = NULL;
	xsBezierCurve* curve = NULL;

	for (;;)
	{
		arc = static_cast<xsArc *>(xsArrayListIterate(arcs, &iter));
		if (iter == NULL || arc == NULL)
			break;

		arc->fill(gc);
	}

	iter = NULL;
	for (;;)
	{
		rect = static_cast<xsRectangle *>(xsArrayListIterate(rects, &iter));
		if (iter == NULL || rect == NULL)
			break;

		rect->fill(gc);
	}

	iter = NULL;
	for (;;)
	{
		curve = static_cast<xsBezierCurve *>(xsArrayListIterate(curves, &iter));
		if (iter == NULL || curve == NULL)
			break;

		curve->fill(gc);
	}

	xsGraphicsGroup* groupTmp = graphicsGroups;
	while(groupTmp != NULL)
	{
		lines = groupTmp ->lines;
		int n = xsArrayListSize(lines);

		if(n < 2)
			return;
		line = static_cast<xsLine *>(xsArrayListGet(lines, 0));
		xsPoint *polygen = (xsPoint*)xsCalloc(sizeof(xsPoint)*(n + 1));
		polygen[0].x = line ->x1;
		polygen[0].y = line ->y1;
		int i = 1;
		iter = NULL;
		for (;;)
		{
			line = static_cast<xsLine *>(xsArrayListIterate(lines, &iter));
			if (iter == NULL || line == NULL)
				break;

			polygen[i].x = line ->x2;
			polygen[i].y = line ->y2;
			i++;
		}

		xsSetColor(gc, fillColor);
		xsFillPolygon(gc, polygen, n + 1);
		if(polygen != NULL)
		{
			xsFree(polygen);
			polygen = NULL;
		}
		groupTmp = groupTmp ->next;
	}

}