コード例 #1
0
ファイル: ColorBox.cpp プロジェクト: dezed/mantid
int ColorBox::colorIndex(const QColor& c)
{
  if (!isValidColor(c))
    return 0;

  return colorList().indexOf(c);
}
コード例 #2
0
// Main loop that executes program for robot
task main() {
    initialize();

    #ifdef DEBUG
        StartTask(displaySONAR);    // acquire and display sensor readings from a different thread
    #endif

    int dist = detectBox();
    bool firstSpinUp = true;
    int col = getColor();

    while (isValidColor(col)) {
	    int power = calcWheelPower(dist, col);
	    motor[WHEELS] = -power;

	    if (firstSpinUp) {
	        wait1Msec(5000);
	        firstSpinUp = false;
	    } else
	        wait1Msec(3000);

	    feed();
	    wait1Msec(1000); // Pause so next ball can get aligned
	    col = getColor();
    }

    #ifdef DEBUG
        nxtDisplayString(5, "TERMINATED");
    #endif
    terminate();
}
コード例 #3
0
int ColorBox::colorIndex(const QColor& c)
{
	if (!isValidColor(c))
		return 0;

	const QColor *ite = std::find(colors, colors + sizeof(colors), c);
	return (ite - colors);
}
コード例 #4
0
ファイル: hw1.cpp プロジェクト: yuanb10/csci1200
// This function receives the image, row/col index and color symbol
// it will return true if the element is to be dilated
bool isToDilate(const std::vector<std::string> & image,
                int row,
                int col,
                char color,
                bool square) {
    if (image[row][col] == color) {
        return false;
    }

    std::vector<int> dx;  // the inrement for row index
    std::vector<int> dy;  // the increment for col index

    getStructureElementsModel(square, dx, dy);
    // We iteratively check it's neighboring directions and check
    // if the element has color around it.
    for (unsigned int i = 0; i < dx.size() ; i++) {
        int nrow = row + dx[i];
        int ncol = col + dy[i];
        if (isValidColor(image, nrow, ncol, color)) {
            return true;
        }
    }
    return false;
}