Пример #1
0
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
void xsCanvasContext::drawImage(xsImage* image,float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x, y, width, height);
	xsFlushScreen(x, y, x + width, y + height);
}
Пример #3
0
void xsCanvasContext::drawImage(xsImage* image,float x, float y)
{
	xsGraphics *gc = xsGetSystemGc();
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x, y, 0, 0);
	xsRect clientRect;
	xsFlushScreen(x, y, originW, originH);
}
Пример #4
0
void xsCanvasContext::translate(float x, float y)
{
	xsGraphics *gc = xsGetSystemGc();
	xsGcTranslate(gc, x, y);
	xsRect 	clientRect;
	if(xsGetClientRect(&clientRect))
	{
		xsFlushScreen(clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
	}
}
Пример #5
0
void xsCanvasContext::fill()
{
	xsGraphics *gc = xsGetSystemGc();
	paintFill(gc);
	xsRect 	clientRect;
	if(xsGetClientRect(&clientRect))
	{
		xsFlushScreen(clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
	}
}
Пример #6
0
void xsCanvasContext::drawWithBaseline(const xsTChar* text, int count, float x, float y, float maxWidth, int drawFlag)
{
	xsGraphics *gc = xsGetSystemGc();
	float width, height;
	xsMeasureText(gc, text, count, &font, &width, &height);
	if(drawFlag == 0)//stroke
	{
		switch(textBaseline)
		{
		case XS_BASELINE_ALPHABETIC:
			break;
		case XS_BASELINE_TOP:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_HANGING:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_MIDDLE:
			xsDrawBorderText(gc, text, count, x, y + height/2, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_IDEOGRAPHIC:
			break;
		case XS_BASELINE_BOTTOM:
			xsDrawBorderText(gc, text, count, x, y - height/2, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		}
	}
	else if(drawFlag == 1)//fill
	{
		switch(textBaseline)
		{
		case XS_BASELINE_ALPHABETIC:
			break;
		case XS_BASELINE_TOP:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		case XS_BASELINE_HANGING:
			break;
		case XS_BASELINE_MIDDLE:
			xsDrawBorderText(gc, text, count, x, y + height/2, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		case XS_BASELINE_IDEOGRAPHIC:
			break;
		case XS_BASELINE_BOTTOM:
			xsDrawBorderText(gc, text, count, x, y - height/2, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		}
	}
	int screenWidth, screenHeight;
	xsGetScreenDimension(&screenWidth, &screenHeight);
	xsFlushScreen(0, 0, screenWidth - 1, screenHeight - 1);
}
Пример #7
0
void xsCanvasContext::drawImage(xsImage* image,float sx, float sy, float swidth, float sheight, float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	xsRect clipRect;
	clipRect.left = x;
	clipRect.top = y;
	clipRect.right = x + width;
	clipRect.bottom = y + height;
	xsSetClipRect(gc, &clipRect);
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x - sx, y - sy, originW * width/swidth, originH*height/sheight);
	xsResetClipRect(gc);
	xsFlushScreen(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
}
Пример #8
0
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);
}
Пример #9
0
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;
}
Пример #10
0
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;
}