Ejemplo n.º 1
0
// Draw the splash screen and menu.
void MainMenu::Draw()
{
	if (splashState)
	{
		RENDER(getTexture(splashTexture), 0, TEXTURE_HEIGHT(getTexture(splashTexture)), TEXTURE_WIDTH(getTexture(splashTexture)), TEXTURE_HEIGHT(getTexture(splashTexture)), 0, false);

		DRAW_TEXT(getTexture(fontMap), SPLASH_TEXT, 100, 100, 16, 16, 0, 0, WHITE);
	}
	else if (exiting)
	{
		RENDER(getTexture(splashTexture), 0, TEXTURE_HEIGHT(getTexture(splashTexture)), TEXTURE_WIDTH(getTexture(splashTexture)), TEXTURE_HEIGHT(getTexture(splashTexture)), 0, false);

		DRAW_TEXT(getTexture(fontMap), EXIT_TEXT, 50, 300, 16, 16, 0, 0, WHITE);
	}
	else
	{
		RENDER(getTexture(splashTexture), 0, TEXTURE_HEIGHT(getTexture(splashTexture)), TEXTURE_WIDTH(getTexture(splashTexture)), TEXTURE_HEIGHT(getTexture(splashTexture)), 0, false);

		DRAW_TEXT(getTexture(fontMap), MAINMENU_OPTION_ONE, 40, 100, 16, 16, 0, 0, WHITE);

		DRAW_TEXT(getTexture(fontMap), MAINMENU_OPTION_TWO, 60, 80, 16, 16, 0, 0, WHITE);

		DRAW_TEXT(getTexture(fontMap), hScoreStream.str().c_str(), 30, 30, 16, 16, 0, 0, WHITE);

		switch (getCurrentSelection())
		{
		case 0:
			RENDER(getTexture(selectedTexture), 20, 100, 20, 20, 0, 0);
			break;
		case 1:
			RENDER(getTexture(selectedTexture), 40, 80, 20, 20, 0, 0);
			break;
		}
	}
}
Ejemplo n.º 2
0
int
main(int argc, char** argv)
{
	CvSeq*	comp = 0;
	CvRect	window, eye;
	int		key, nc, found; 
	int		text_delay, stage = STAGE_INIT;

	init();

	while (key != 'q')
	{
		frame = cvQueryFrame(capture);
		if (!frame)
			exit_nicely("cannot query frame!");
		frame->origin = 0;

		if (stage == STAGE_INIT)
			window = cvRect(0, 0, frame->width, frame->height);

		cvCvtColor(frame, gray, CV_BGR2GRAY);

		nc = get_connected_components(gray, prev, window, &comp);

		if (stage == STAGE_INIT && is_eye_pair(comp, nc, &eye))
		{
			delay_frames(5);

			cvSetImageROI(gray, eye);
			cvCopy(gray, tpl, NULL);
			cvResetImageROI(gray);

			stage = STAGE_TRACKING;
			text_delay = 10;
		}

		if (stage == STAGE_TRACKING)
		{
			found = locate_eye(gray, tpl, &window, &eye);

			if (!found || key == 'r')
				stage = STAGE_INIT;

			if (is_blink(comp, nc, window, eye)){
				text_delay = 10;
				system("/bin/bash ./blinked.sh");
			}
			DRAW_RECTS(frame, diff, window, eye);
			DRAW_TEXT(frame, "blink!", text_delay, 1);
		}

		cvShowImage(wnd_name, frame);
		cvShowImage(wnd_debug, diff);
		prev = (IplImage*)cvClone(gray);
		key  = cvWaitKey(15);
	}

	exit_nicely(NULL);
}
void RelativePositionDetection::showDebugInformations(const Object &object, Vector *pos, double tilt) {
	double pan = pos->getAngle();
	double distance = pos->getLength();
	Debugger::INFO("RelativePositionDetection", "%s-Vector %.1f; %.1f : %.1f",
			object.toString().c_str(), pan*RADIAN_TO_DEGREE, tilt*RADIAN_TO_DEGREE, distance);

#ifdef _DEBUG
	if( mDebugDrawings >= 2) {
		int x = getBall().lastImageTopLeftX;
		int y = getBall().lastImageTopLeftY;
		DRAW_TEXT(object.toString(), x + 2, y + 10, DebugDrawer::YELLOW,
			"%.0f mm (%d px; %.2f deg)", distance, getBall().lastImageWidth, tilt*RADIAN_TO_DEGREE);
		DRAW_TEXT(object.toString(), x + 2, y + 24, DebugDrawer::YELLOW,
			"Pan: %.2f deg", pan*RADIAN_TO_DEGREE);
	}
#endif
}
Ejemplo n.º 4
0
/*
 * similar to any ya_exec function in this file, this function is used to obtain text buffer and
 * draw it. However, this function is called upon X events.
 */
inline static void ya_exec_intern_ewmh_blk(ya_block_t *blk) {
	switch(blk->internal->index) {
		case YA_INT_TITLE: {
			ya_get_cur_window_title(blk);
//#ifdef YA_MUTEX
//			pthread_mutex_lock(&blk->mutex);
//#endif
#ifdef YA_VAR_WIDTH
			DRAW_TEXT(blk);
#else
			ya_draw_pango_text(blk);
#endif //YA_VAR_WIDTH
//#ifdef YA_MUTEX
//			pthread_mutex_unlock(&blk->mutex);
//#endif
			break;
		}
		case YA_INT_WORKSPACE: {
			//uint32_t current_desktop;
			//xcb_get_property_cookie_t ck = xcb_ewmh_get_current_desktop(ya.ewmh, 0);
			//xcb_ewmh_get_current_desktop_reply(ya.ewmh, ck, &current_desktop, NULL);
			if(blk->internal->option[0]==NULL)
				sprintf(blk->buf, "%u", ya.curws+1);
			else {
				ya_copy_buf_from_index(blk, ya.curws);
			}

//#ifdef YA_MUTEX
//			pthread_mutex_lock(&blk->mutex);
//#endif
#ifdef YA_VAR_WIDTH
			DRAW_TEXT(blk);
#else
			ya_draw_pango_text(blk);
#endif //YA_VAR_WIDTH
//#ifdef YA_MUTEX
//			pthread_mutex_unlock(&blk->mutex);
//#endif
			break;
		}
	}

}
Ejemplo n.º 5
0
/**
 * Initialize images, memory, and windows
 */
void
init()
{
	char* msg[] = { "Blink Detection 1.0", 
					"Copyright (c) 2009", 
					"http://nashruddin.com", 
					"Press 'q' to quit...",
					"Press 'r' to restart...",
					"Have fun!" };
	int delay, i;

	capture = cvCaptureFromCAM(0);
	if (!capture)
		exit_nicely("Cannot initialize camera!");

	cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,  FRAME_WIDTH);
	cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT);

	frame = cvQueryFrame(capture);
	if (!frame)
		exit_nicely("cannot query frame!");

	cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.4, 0.4, 0, 1, 8);
	cvNamedWindow(wnd_name, 1);

	for (delay = 20, i = 0; i < 6; i++, delay = 20)
		while (delay)
		{
			frame = cvQueryFrame(capture);
			if (!frame)
				exit_nicely("cannot query frame!");
			DRAW_TEXT(frame, msg[i], delay, 0);
			cvShowImage(wnd_name, frame);
			cvWaitKey(30);
		}

	storage = cvCreateMemStorage(0);
	if (!storage)
		exit_nicely("cannot allocate memory storage!");

	kernel = cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_CROSS, NULL);
	gray   = cvCreateImage(cvGetSize(frame), 8, 1);
	prev   = cvCreateImage(cvGetSize(frame), 8, 1);
	diff   = cvCreateImage(cvGetSize(frame), 8, 1);
	tpl	   = cvCreateImage(cvSize(TPL_WIDTH, TPL_HEIGHT), 8, 1);

	if (!kernel || !gray || !prev || !diff || !tpl)
		exit_nicely("system error.");

	gray->origin  = frame->origin;
	prev->origin  = frame->origin;
	diff->origin  = frame->origin;

	cvNamedWindow(wnd_debug, 1);
}
Ejemplo n.º 6
0
static void ya_exec_redir_persist(ya_block_t *blk) {
	int opipe[2];
	if(pipe(opipe)==-1) {
		fprintf(stderr, "Error opening pipe for block %s.%s. Terminating block's thread...\n", blk->bar->name, blk->name);
		pthread_detach(blk->thread);
		pthread_exit(NULL);
	}
	pid_t pid = fork();
	if (pid == 0) {
		dup2(opipe[1], STDOUT_FILENO);
		close(opipe[1]);
		setvbuf(stdout,NULL,_IONBF,0);

		execl(yashell, yashell, "-c", blk->cmd, (char *) NULL);
		_exit(EXIT_SUCCESS);
	}
	blk->pid = pid;
	close(opipe[1]);

	ssize_t read_ret;
	while (1) {
		read_ret = read(opipe[0], blk->buf, blk->bufsize);
		if(read_ret == 0) {
			break;
		} else if (read_ret < 0) {
			fprintf(stderr, "Error with block %s: %s\n", blk->name, strerror(errno));
			continue;
		} else {
			blk->buf[read_ret] = '\0';
#ifdef YA_DYN_COL
			ya_buf_color_parse(blk);
#endif

//#ifdef YA_MUTEX
//			pthread_mutex_lock(&blk->mutex);
//#endif
#ifdef YA_VAR_WIDTH
			DRAW_TEXT(blk);
#else
			ya_draw_pango_text(blk);
#endif //YA_VAR_WIDTH
//#ifdef YA_MUTEX
//			pthread_mutex_unlock(&blk->mutex);
//#endif
		}
	}
}
int
dllmain(int* EyeX,int* EyeY)
{
	//while (key != 'q')
	//{
		frame = cvQueryFrame(capture);
		if (!frame)
			exit_nicely("cannot query frame!");
		frame->origin = 0;
		if (stage == STAGE_INIT)
			window = cvRect(0, 0, frame->width, frame->height);
		cvCvtColor(frame, gray, CV_BGR2GRAY);
		nc = get_connected_components(gray, prev, window, &comp);
		if (stage == STAGE_INIT && is_eye_pair(comp, nc, &eye))
		{
			delay_frames(5);
			cvSetImageROI(gray, eye);
			cvCopy(gray, tpl, NULL);
			cvResetImageROI(gray);
			stage = STAGE_TRACKING;
			text_delay = 10;
		}
		if (stage == STAGE_TRACKING)
		{
			found = locate_eye(gray, tpl, &window, &eye);
			if (!found || key == 'r')
				stage = STAGE_INIT;
			if (is_blink(comp, nc, window, eye))
				text_delay = 10;
			DRAW_RECTS(frame, diff, window, eye);
			DRAW_TEXT(frame, "blink!", text_delay, 1);
		}
		cvShowImage(wnd_name, frame);
		cvShowImage(wnd_debug, diff);
		prev = cvCloneImage(gray);
		key = cvWaitKey(15);
		*EyeX = eye.x;
		*EyeY = eye.y;
		//printf("X = %d\nY = %d\nWidth = %d\nHeight = %d\n\n", eye.x, eye.y, eye.width, eye.height);
	//}
	//exit_nicely(NULL);
		return 0;
}
Ejemplo n.º 8
0
/* Render a character. */
static int
x_render_char(gx_xfont * xf, gx_xglyph xg, gx_device * dev,
	      int xo, int yo, gx_color_index color, int required)
{
    x_xfont *xxf = (x_xfont *) xf;
    char chr = (char)xg;
    gs_point wxy;
    gs_int_rect bbox;
    int x, y, w, h;
    int code;

    if (dev->dname == gs_x11_device.dname && !((gx_device_X *)dev)->is_buffered) {
	gx_device_X *xdev = (gx_device_X *)dev;

	code = (*xf->common.procs->char_metrics) (xf, xg, 0, &wxy, &bbox);
	if (code < 0)
	    return code;
	/* Buffer text for more efficient X interaction. */
	if (xdev->text.item_count == MAX_TEXT_ITEMS ||
	    xdev->text.char_count == MAX_TEXT_CHARS ||
	    (IN_TEXT(xdev) &&
	     (yo != xdev->text.origin.y || color != xdev->fore_color ||
	      xxf->font->fid != xdev->fid))
	    ) {
	    DRAW_TEXT(xdev);
	    xdev->text.item_count = xdev->text.char_count = 0;
	}
	if (xdev->text.item_count == 0) {
	    X_SET_FILL_STYLE(xdev, FillSolid);
	    X_SET_FORE_COLOR(xdev, color);
	    X_SET_FUNCTION(xdev, GXcopy);
	    xdev->text.origin.x = xdev->text.x = xo;
	    xdev->text.origin.y = yo;
	    xdev->text.items[0].font = xdev->fid = xxf->font->fid;
	}
	/*
	 * The following is wrong for rotated text, but it doesn't matter,
	 * because the next call of x_render_char will have a different Y.
	 */
	{
	    int index = xdev->text.item_count;
	    XTextItem *item = &xdev->text.items[index];
	    char *pchar = &xdev->text.chars[xdev->text.char_count++];
	    int delta = xo - xdev->text.x;

	    *pchar = chr;
	    if (index > 0 && delta == 0) {
		/* Continue the same item. */
		item[-1].nchars++;
	    } else {
		/* Start a new item. */
		item->chars = pchar;
		item->nchars = 1;
		item->delta = delta;
		if (index > 0)
		    item->font = None;
		xdev->text.item_count++;
	    }
	    xdev->text.x = xo + wxy.x;
	}
	if (xdev->bpixmap != (Pixmap) 0) {
	    x = xo + bbox.p.x;
	    y = yo + bbox.p.y;
	    w = bbox.q.x - bbox.p.x;
	    h = bbox.q.y - bbox.p.y;
	    fit_fill(dev, x, y, w, h);
	    x_update_add(xdev, x, y, w, h);
	}
	return 0;
    } else if (!required)
	return -1;		/* too hard */
    else {
	/* Display on an intermediate bitmap, then copy the bits. */
	gx_device_X *xdev = xxf->xdev;
	int wbm, raster;
	int i;
	XImage *xim;
	Pixmap xpm;
	GC fgc;
	byte *bits;

	dev_proc_copy_mono((*copy_mono)) = dev_proc(dev, copy_mono);

	code = (*xf->common.procs->char_metrics) (xf, xg, 0, &wxy, &bbox);
	if (code < 0)
	    return code;
	w = bbox.q.x - bbox.p.x;
	h = bbox.q.y - bbox.p.y;
	wbm = ROUND_UP(w, align_bitmap_mod * 8);
	raster = wbm >> 3;
	bits = (byte *) gs_malloc(xdev->memory, h, raster, "x_render_char");
	if (bits == 0)
	    return gs_error_limitcheck;
	xpm = XCreatePixmap(xdev->dpy, xdev->win, w, h, 1);
	fgc = XCreateGC(xdev->dpy, xpm, None, NULL);
	XSetForeground(xdev->dpy, fgc, 0);
	XFillRectangle(xdev->dpy, xpm, fgc, 0, 0, w, h);
	XSetForeground(xdev->dpy, fgc, 1);
	XSetFont(xdev->dpy, fgc, xxf->font->fid);
	XDrawString(xdev->dpy, xpm, fgc, -bbox.p.x, -bbox.p.y, &chr, 1);
	xim = XGetImage(xdev->dpy, xpm, 0, 0, w, h, 1, ZPixmap);
	i = 0;
	for (y = 0; y < h; y++) {
	    char b = 0;

	    for (x = 0; x < wbm; x++) {
		b = b << 1;
		if (x < w)
		    b += XGetPixel(xim, x, y);
		if ((x & 7) == 7)
		    bits[i++] = b;
	    }
	}
	code = (*copy_mono) (dev, bits, 0, raster, gx_no_bitmap_id,
			     xo + bbox.p.x, yo + bbox.p.y, w, h,
			     gx_no_color_index, color);
	gs_free(xdev->memory, (char *)bits, h, raster, "x_render_char");
	XFreePixmap(xdev->dpy, xpm);
	XFreeGC(xdev->dpy, fgc);
	XDestroyImage(xim);
	return (code < 0 ? code : 0);
    }
}
bool BallDetection::execute()
{
	mBallClouds.clear();
	mBallCloudDataList.clear();
	getRemovedBallCandidates().clearList();

	mColor = DebugDrawer::RED;

	const list<Point>* cloud = getBallPoints().getCloud();
	list<Point>::const_iterator it = cloud->begin();
	for( ; it != cloud->end(); ++it) {
		addBallPointToNearestCloud( (*it));
	}

	//mergeOverlappingClouds();

	BoundingBox bestCompareBox(Point(0,0),0,0);
	double bestCompareResult = 0.0;
	vector<PointCloud>::const_iterator pointCloudIt;
	for( pointCloudIt = mBallClouds.begin(); pointCloudIt != mBallClouds.end(); ++pointCloudIt) {

		BoundingBox box = pointCloudIt->calculateBoundingBox();
		Point point = pointCloudIt->getCenterPoint();
		mBallCenterX = point.getX();
		mBallCenterY = point.getY();
		mBallRadius = (box.width + box.height) / 4; //3 // 4
		//Debugger::INFO("BallDetection", "Cloud-Radius: %d", ballRadius);

		//Debugger::DEBUG("BallDetection", "maxValue: %i", maxValue);

		if (filterFieldLines(Point(mBallCenterX, mBallCenterY))
			&& filterHorizon(Point(mBallCenterX, mBallCenterY))) {

			// todo: filter out all possible balls with too small pixel to size ratio
			// filter out all balls with wrong expected size (tilt angle)

			getBallEdges().clearCloud();

			//Debugger::DEBUG("BallDetection", "-----------------------------");
			//Debugger::DEBUG("BallDetection", "BallRadius 1: %d", mBallRadius);

			mIsAtBorder = false;
			BallCompareData ballCompareData;
			if( !findAllBallEdges(ballCompareData)) {
				if (mDebugDrawings >= 2) {
					DRAW_CIRCLE("Ball", box.topLeft.getX(), box.topLeft.getY(), 2*mBallRadius,
							DebugDrawer::GREEN);
				}
				//break;
			}

			ballCompareData.centerX = mBallCenterX;
			ballCompareData.centerY = mBallCenterY;
			ballCompareData.numCloudPixels = pointCloudIt->getSize();

			if (mDebugDrawings >= 6) {
				DRAW_POINT("Ball", mBallCenterX, mBallCenterY, DebugDrawer::YELLOW);
			}

			int countEdges = (int)getBallEdges().getSize();
			int sumX = 0;
			int sumY = 0;
			list<Point>::const_iterator it2;
			for (it2 = getBallEdges().getCloud()->begin();
					it2 != getBallEdges().getCloud()->end(); ++it2) {
				Point p = (*it2);
				sumX += p.getX();
				sumY += p.getY();
			}
			if( countEdges > 1) {
				mBallCenterX = sumX / countEdges;
				mBallCenterY = sumY / countEdges;
				if (mDebugDrawings >= 6) {
					DRAW_POINT("Ball", mBallCenterX, mBallCenterY, DebugDrawer::BLUE);
				}
			}

			double sumDistances = 0.0;
			vector<double> radiusList;
			int i = 0;

			list<Point>::const_iterator pointIt;
			for (pointIt = getBallEdges().getCloud()->begin();
					pointIt != getBallEdges().getCloud()->end(); ++pointIt) {
				Point p = (*pointIt);
				double dx = (double)mBallCenterX - p.getX();
				double dy = (double)mBallCenterY - p.getY();
				double rad = sqrt((dx * dx) + (dy * dy));
				radiusList.push_back(rad);
				sumDistances += rad;
				/*if( mDebugInfoEnabled) {
					Debugger::DEBUG("BallDetection", "%d) Radius point: %.2f (%d; %d)", i, rad, p.getX(), p.getY());
				}*/
				++i;
			}
			if( countEdges >= 4) {
				mBallRadius = (int)(sumDistances / (double)countEdges);
				//Debugger::INFO("Ball", "Mean-Radius: %d", ballRadius);
			}

			//Debugger::DEBUG("BallDetection", "BallRadius 2: %d", mBallRadius);

			if (filterFieldLines(Point(mBallCenterX, mBallCenterY))
				&& filterHorizon(Point(mBallCenterX, mBallCenterY))) {

				//Debugger::DEBUG("BallDetection", "ballCenter: %d, %d", ballCenterX, ballCenterY);
				//Debugger::DEBUG("BallDetection", "radius: %d", ballRadius);

				ballCompareData.meanRadius = mBallRadius;
				ballCompareData.circleAnomaly = 0.0;

				int numCorrectEdges = 0;
				double maxAnomaly = (mMaxAnomalyRadiusFactor * mBallRadius) * (mMaxAnomalyRadiusFactor * mBallRadius);
				//double maxAnomaly = 25; // 5 pixel
				//Debugger::DEBUG("BallDetection", "maxAnomaly: %.2f", maxAnomaly);
				i = 0;
				vector<double>::const_iterator doubleIt;
				for (doubleIt = radiusList.begin(); doubleIt != radiusList.end(); ++doubleIt) {
					double anomaly = (double)mBallRadius - (*doubleIt);
					anomaly *= anomaly;
					if( mDebugInfoEnabled) {
						Debugger::DEBUG("BallDetection", "%d) Anomaly point: %.2f", i, anomaly);
					}
					if( anomaly > maxAnomaly) {
						ballCompareData.circleAnomaly += anomaly;
						//Debugger::DEBUG("BallDetection", "CircleAnomaly: %.2f",ballCompareData.circleAnomaly);
					} else {
						numCorrectEdges++;
					}
					++i;
				}

				if( numCorrectEdges > 0) {
					//Debugger::DEBUG("BallDetection", "CircleAnomaly1: %.2f (%d)",ballCompareData.circleAnomaly, numCorrectEdges);
					ballCompareData.circleAnomaly /= (double)numCorrectEdges;
				}
				//Debugger::DEBUG("BallDetection", "CircleAnomaly2: %.2f",ballCompareData.circleAnomaly);
				if( countEdges > 0) {
					ballCompareData.correctEdgesRatio = (double)numCorrectEdges / (double)countEdges;
				}

				box.topLeft = Point(mBallCenterX - mBallRadius, mBallCenterY - mBallRadius);
				box.width = 2 * mBallRadius;
				box.height = 2 * mBallRadius;

				double compareResult = calculateCompareResult(ballCompareData);
				if( mDebugInfoEnabled) {
					Debugger::INFO("BallDetection", "CompareResult: %f", compareResult);
				}
				if( compareResult > bestCompareResult) {
					bestCompareResult = compareResult;
					bestCompareBox = box;
				}

				if (mDebugDrawings >= 3) {
					DRAW_CIRCLE("Ball", box.topLeft.getX() +1, box.topLeft.getY() +1, box.width,
							DebugDrawer::BROWN);
				}
			} else {
				if (mDebugDrawings >= 4) {
					DRAW_CIRCLE("Ball", box.topLeft.getX(), box.topLeft.getY(), box.width,
							DebugDrawer::ORANGE);
				}
			}
		} else {
			Object obj(box.topLeft.getX(), box.topLeft.getY(), box.width, box.height);
			obj.type = Object::BALL;
			getRemovedBallCandidates().addObject(obj);
			if (mDebugDrawings >= 5) {
				DRAW_CIRCLE("Ball", box.topLeft.getX(), box.topLeft.getY(), box.width,
						DebugDrawer::LIGHT_GRAY);
			}
		}
	}

	if( bestCompareResult > 0.0) {
		int x = bestCompareBox.topLeft.getX();
		int y = bestCompareBox.topLeft.getY();
		getBall().updateObject( x, y, bestCompareBox.width, bestCompareBox.height);
		//x = getBall().lastImageX;
		//y = getBall().lastImageY;
		// todo add angle from position in image

		double panAngle = DEGREE_TO_RADIANS * getBodyStatus().getPan();
		double tiltAngle = DEGREE_TO_RADIANS * getBodyStatus().getTilt();
		double length = getRobotConfiguration().cameraHeight * tan(tiltAngle);
		length += getRobotConfiguration().cameraOffsetX;
		getBall().lastVector.updateVector(panAngle, length);

		Debugger::INFO("BallDetection", "BallVector %.1f; %.1f : %.1f", panAngle*RADIANS_TO_DEGREE, tiltAngle*RADIANS_TO_DEGREE, length);
		if( mDebugDrawings >= 1) {
			x = bestCompareBox.topLeft.getX();
			y = bestCompareBox.topLeft.getY();
			DRAW_CIRCLE("Ball", x, y, bestCompareBox.width, DebugDrawer::RED);
			if( mDebugDrawings >= 2) {
				DRAW_TEXT("Ball", x + 2, y + 10, DebugDrawer::YELLOW,
					"%.0f mm (%d px; %.2f deg)", length, bestCompareBox.width, tiltAngle*RADIANS_TO_DEGREE);
				DRAW_TEXT("Ball", x + 2, y + 24, DebugDrawer::YELLOW,
					"Pan: %.2f deg", panAngle*RADIANS_TO_DEGREE);
			}
		}
	} else {
		getBall().notSeen();
	}

	return true;
}
Ejemplo n.º 10
0
void OptionsScreen::draw(sf::RenderTarget & target, sf::RenderStates states) const
{
    target.draw(*_return_screen);

    sf::RectangleShape rect(sf::Vector2f(WINDOW_WIDTH, WINDOW_HEIGHT));
    sf::Color col(MENU_SHADOW);
    col.a = 128;
    rect.setFillColor(col);
    target.draw(rect);

    sf::Text text;
    text.setCharacterSize(36);
    text.setFont(_font.get());

#define DRAW_TEXT(item, x, y) \
    text.setColor(_selection == CHOICE_##item ? MENU_SELECTION : MENU_ITEM); \
    text.setOrigin(text.getLocalBounds().width/2, text.getLocalBounds().height/2); \
    text.setPosition(WINDOW_WIDTH/2 + x, WINDOW_HEIGHT/2 + y); \
    drawShadow(target, text); \
    target.draw(text);


    // Accept & Cancel
    text.setString(MENU_ACCEPT);
    DRAW_TEXT(ACCEPT, -280, 170);

    text.setString(MENU_CANCEL);
    DRAW_TEXT(CANCEL, -280, 220);


    // Resolution
    text.setString(MENU_RESOLUTION);
    DRAW_TEXT(RESOLUTION, -220, -180);

    sf::VideoMode mode = _modes.at(_current_mode);
    {
        std::ostringstream txt;
        txt << "< " << mode.width << "x" << mode.height << " >";
        text.setString(txt.str());
    }
    DRAW_TEXT(RESOLUTION, 220, -180);


    // Video mode
    text.setString(MENU_MODE);
    DRAW_TEXT(MODE, -220, -120);

    switch (_screen_mode)
    {
    case SMODE_WINDOWED:
        text.setString(MENU_WINDOWED);
        break;
    case SMODE_BORDERLESS:
        text.setString(MENU_BORDERLESS);
        break;
    case SMODE_FULLSCREEN:
        text.setString(MENU_FULLSCREEN);
        break;
    default:
        assert(false && "Invalid screen mode selected");
        break;
    }
    DRAW_TEXT(MODE, 220, -120);

#undef DRAW_TEXT
}
Ejemplo n.º 11
0
void PRINT_MAIN_LOGO(char *string, float x, float y)
{
	SET_UP_DRAW(2, 0.48, 0.78, 255, 255, 255, 240);
	DRAW_TEXT("STRING",  x, y, string);
}
Ejemplo n.º 12
0
void PRINT_DESC(float x, float y, char *string)
{
	SET_UP_DRAW(2, 0.28, 0.28, 255, 255, 255, 240);
	DRAW_TEXT("STRING",  x, y, string);
}