Пример #1
0
///////////////////////////////////////////////////////////////////////////////
// Get the dot plot bounds.
///////////////////////////////////////////////////////////////////////////////
string DotPlotBackend::getBounds() {

	// Get the handler's data as a string.
	string data = handler->toString();

	// Determine the x bounds and shave off the borders, then add a 5 pixel
	// border on each side.
	size_t xBound = data.find_first_of( "(" ) + 1;
	size_t xLength = data.find_first_of( "," ) - xBound;
	int x = 0;
	stringstream xStream( data.substr( xBound, xLength ) );
	xStream >> x;
	x -= ( BORDER * 2 );
	x += 10;

	// Determine the y bounds and shave off the borders, then add a 5 pixel
	// border on each side.
	size_t yBound = data.find_first_of( "," ) + 1;
	size_t yLength = data.find_first_of( ")" ) - yBound;
	int y = 0;
	stringstream yStream( data.substr( yBound, yLength ) );
	yStream >> y;
	y -= ( BORDER * 2 );
	y += 10;

	// Build and return the bounds string.
	stringstream boundsStream( stringstream::in | stringstream::out );
	boundsStream << x << " " << y;
	return boundsStream.str();
}
Пример #2
0
ofxColor& ofxColor::operator=(const string& asHex) {
	int offset = 0;
	if(asHex[0] == '#' || asHex[0] == 'x')
		offset = 1;
	if(asHex[1] == 'x')
		offset = 2;
	istringstream xStream(asHex.substr(offset + 0, 2));
	istringstream yStream(asHex.substr(offset + 2, 2));
	istringstream zStream(asHex.substr(offset + 4, 2));
	unsigned int x, y, z;
	xStream >> hex >> x;
	yStream >> hex >> y;
	zStream >> hex >> z;
	set(x, y, z);
	return *this;
}