void LabelImage::colorLabeledImage(const ImageUInt& rImageLabeled, const std::list<LabelRect>& rListRectsLabel, ImageRGB8& rImageColored)
{
	// ラベル付けされた画像を色づけして出力(デバッグ用)
	rImageColored.setSize(rImageLabeled.getWidth(), rImageLabeled.getHeight());
	rImageColored.fillPixel(PixelRGB8(0, 0, 0));

	const unsigned int numLabelColors = 6;
	PixelRGB8 tablePixelLabels[numLabelColors] = { PixelRGB8(0, 0, 128), PixelRGB8(128, 0, 0), PixelRGB8(128, 0, 128),
									PixelRGB8(0, 128, 0), PixelRGB8(0, 128, 128), PixelRGB8(128, 128, 0) };
	Rect2i rectLabeled = rImageLabeled.getRect();
	ImageUInt::const_iterator itLabeled = rImageLabeled.range_begin(rectLabeled);
	ImageRGB8::iterator itLabeledColor = rImageColored.range_begin(rectLabeled);
	for (; itLabeled != rImageLabeled.range_end(rectLabeled); ++ itLabeled, ++ itLabeledColor) {
		unsigned int valueLabel = (*itLabeled).getA();
		if (valueLabel == 0) continue;
		*itLabeledColor = tablePixelLabels[(valueLabel - 1) % numLabelColors];
	}
	std::list<LabelRect>::const_iterator itRectLabel = rListRectsLabel.begin();
	for (; itRectLabel != rListRectsLabel.end(); ++ itRectLabel) {
		const Vector2f& rPointCOG = (*itRectLabel).getCOG();
		rImageColored.setPixel(roundInt(rPointCOG.getX()), roundInt(rPointCOG.getY()), PixelRGB8(255, 255, 255));
		const Rect2i& rRect = (*itRectLabel).getBoundingBox();
		for (unsigned int x = rRect.getLowerX(); x <= rRect.getUpperX(); x ++) {
			rImageColored.setPixel(x, rRect.getLowerY(), PixelRGB8(255, 0, 0));
			rImageColored.setPixel(x, rRect.getUpperY(), PixelRGB8(255, 0, 0));
		}
		for (unsigned int y = rRect.getLowerY(); y < rRect.getUpperY(); y ++) {
			rImageColored.setPixel(rRect.getLowerX(), y, PixelRGB8(255, 0, 0));
			rImageColored.setPixel(rRect.getUpperX(), y, PixelRGB8(255, 0, 0));
		}
	}
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
	{
		return FALSE;
	}

	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	GUI::refreshBoardDisplayData();

	cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
			   | WS_MINIMIZEBOX | WS_SYSMENU;

	cs.dwExStyle &= ~WS_EX_CLIENTEDGE;

	CRect windowrect(0, 0, roundInt(GUI::boundsOfBoard.x[0]), roundInt(GUI::boundsOfBoard.x[1]));
	::AdjustWindowRect(&windowrect, WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
					   | WS_MINIMIZEBOX | WS_SYSMENU, TRUE);
	cs.cx = windowrect.right - windowrect.left;
	cs.cy = windowrect.bottom - windowrect.top + 15;		//状态栏

	cs.lpszClass = AfxRegisterWndClass(0);

	return TRUE;
}
Example #3
0
void plotDotPNG(int i, int j, double d)
{
  int x1, y1, x2, y2;
  double adjust;

  if (i < g_top || j < g_left || i >= g_top + g_size || j >= g_left + g_size)
    return;
  if (d <= 0)
    return;

  i -= (g_top - 1);
  j -= (g_left - 1);
  adjust = (1 - sqrt(d)) * (g_dotSize - 2) / 2;

  x1 = roundInt((j - 0.5) * g_dotSpacing) - g_dotSize / 2 + 92;
  y1 = roundInt((i - 0.5) * g_dotSpacing) - g_dotSize / 2 + 92;
  x2 = roundInt((j - 0.5) * g_dotSpacing) + g_dotSize / 2 + 92;
  y2 = roundInt((i - 0.5) * g_dotSpacing) + g_dotSize / 2 + 92;

  x1 += adjust;
  y1 += adjust;
  x2 -= adjust;
  y2 -= adjust;

  if (i == g_selectedI && j == g_selectedJ)
    gdImageFilledRectangle(g_image, x1, y1, x2, y2, g_gray);
  else
    gdImageFilledRectangle(g_image, x1, y1, x2, y2, g_colors[getColor(d)]);
}
Example #4
0
int getColorLogLog(double score)
{
  if (score <= g_epsilon)
    return 25;
  else if (score >= 1 - g_epsilon)
    return 0;
  else if (score < 0.5)
    return 1 + roundInt(23.0 * ((-log10(2 * g_epsilon) - log10(2 * score)) / (-2 * log10(2 * g_epsilon))));
  else
    return 1 + roundInt(23.0 * ((-log10(2 * g_epsilon) + log10(2 - 2 * score)) / (-2 * log10(2 * g_epsilon))));
}
Example #5
0
int getColorLog(double score)
{
  if (score <= g_epsilon)
    return 25;
  else
    return roundInt(25.0 * log10(score) / log10(g_epsilon));
}
Example #6
0
bool ofxGuiFiles::mouseDragged(int x, int y, int button)
{
    if(mMouseIsDown && mNumberOfFiles > 0)
    {
        mSelected       = roundInt(fractionToValue(mouseToFraction(mouseToLocal(x, y)).x));
        mValue          = mFilelist.at(mSelected);
    }

    return mMouseIsDown;
}
Example #7
0
void ofxGuiImage::drawString( int x, int y, string str, bool center, ofRGBA color ) 
{
	glColor4f( color.r, color.g, color.b, color.a );
	if (center) 
		x -= roundInt( mGlobals->mParamFont.stringWidth( str ) / 2.0f );
	else 
		x += mGlobals->mParamFontXOffset;
	y += mGlobals->mParamFontYOffset;
	mGlobals->mParamFont.drawString( str, x, y );
}
Example #8
0
void horzCenterPNG(char* str, int j)
{
  int x, y;

  j -= (g_left - 1);

  y = 92 - 13;
  x = 92 + roundInt((j - 0.5) * g_dotSpacing) - 7 * strlen(str) / 2;

  gdImageString(g_image, gdFontMediumBold, x, y, (unsigned char*) str, g_black);
}
Example #9
0
void vertCenterPNG(char* str, int i)
{
  int x, y;

  i -= (g_top - 1);

  x = 92 - 7 * strlen(str);
  y = 92 + roundInt((i - 0.5) * g_dotSpacing - 6.5);

  gdImageString(g_image, gdFontMediumBold, x, y, (unsigned char*) str, g_black);
}
Example #10
0
void ofxGuiKnob::setValue(float value)
{
	if(mSteps > 1)
	{
		float	fraction	= valueToFraction(value);
		float	steps		= (float)mSteps - 1;
		float	slice		= roundInt(fraction * steps) / steps;
		
		value = mMinVal + mValDlt * slice;
	}
	
	mValue = value;	
}
Example #11
0
void gridPNG()
{
  int i, j;
  char buffer[8];

  if (g_grid > 0)
    {
      i = g_grid;
      while (i < g_top)
	i += g_grid;
      for (; i < g_top + g_size; i += g_grid)
	gdImageLine(g_image, 92,  roundInt((i - g_top + 0.5) * g_dotSpacing) + 92, 484 + 92,  roundInt((i - g_top + 0.5) * g_dotSpacing) + 92, g_black);

      i = g_labels;
      while (i < g_top)
	i += g_labels;
      for (; i < g_top + g_size; i += g_labels)
	{
	  sprintf(buffer, "%d", i);
	  vertCenterPNG(buffer, i);
	}

      j = g_grid;
      while (j < g_left)
	j += g_grid;
      for (; j < g_left + g_size; j += g_grid)
	gdImageLine(g_image, roundInt((j - g_left + 0.5) * g_dotSpacing) + 92, 92, roundInt((j - g_left + 0.5) * g_dotSpacing) + 92, 484 + 92, g_black);

      j = g_labels;
      while (j < g_left)
	j += g_labels;
      for (; j < g_left + g_size; j += g_labels)
	{
	  sprintf(buffer, "%d", j);
	  horzCenterPNG(buffer, j);
	}
    }
}
Example #12
0
void ofxGuiKnob::drawValueString(float x, float y, string text)
{
	glColor4f(mGlobals->mTextColor.r, mGlobals->mTextColor.g, mGlobals->mTextColor.b, mGlobals->mTextColor.a);
	
	x -= roundInt(mGlobals->mParamFont.stringWidth(text) / 2.0f);
	mGlobals->mParamFont.drawString(text, x, y);
	
	//	debug rect to position font
	/*
	 ofRectangle rect = mGlobals->mParamFont.getStringBoundingBox(text, x, y);
	 ofNoFill();
	 glColor4f(1.0, 0.0, 0.0, 1.0);
	 ofRect(x, y, rect.width, mGlobals->mParamFontHeight);
	 */
}
Example #13
0
void ofxGuiPanel::init(int id, string name, int x, int y, int border, int spacing)
{
	int	textHeight	= (name == "") ? 2 * border :  2 * border +mGlobals->mHeadFontHeight;

	mParamId		= id;
	mParamName		= name;

	mObjX			= x; 
	mObjY			= y;

	mBorder			= border;
	mSpacing		= spacing;
	
	adjustToNewContent(roundInt(mGlobals->mHeadFont.stringWidth(name)), textHeight);
}
Example #14
0
void ofxGuiObject::drawHighlightParamString( float x, float y, string text, bool center ) {
	if ( center ) {
		x -= roundInt( mGlobals->mParamFont.stringWidth(text) / 2.0f );
	} else {
		x += mGlobals->mParamFontXOffset;
	}

	y += mGlobals->mParamFontYOffset;
	
	//! draw the shadow
	glColor4f( mGlobals->mHighlightShadowColor.r, mGlobals->mHighlightShadowColor.g, mGlobals->mHighlightShadowColor.b, mGlobals->mHighlightShadowColor.a );
	mGlobals->mParamFont.drawString( text, x + 1, y + 1 );

	//! draw the foreground
	glColor4f( mGlobals->mHighlightTextColor.r, mGlobals->mHighlightTextColor.g, mGlobals->mHighlightTextColor.b, mGlobals->mHighlightTextColor.a );
	mGlobals->mParamFont.drawString( text, x, y );
}
Example #15
0
void ofxGuiButton::init(int id, string name, int x, int y, int width, int height, bool value, int display)
{
	int	textWidth	= (name == "") ? 0 : mGlobals->mButtonXText + roundInt(mGlobals->mHeadFont.stringWidth(name));

	mParamId		= id;
	mParamName		= name;
	
	mObjX			= x; 
	mObjY			= y;
	
	mObjWidth		= textWidth + width;
	mObjHeight		= height;

	mDisplay		= display;
	
	setValue(value);
	setControlRegion(0, 0, width, height);
}
Example #16
0
void ofxGuiRadar::setValue(float value)
{
	if(mSteps > 1)
	{
		float	fraction	= valueToFraction(value);
		float	steps		= (float)mSteps - 1;
		float	slice		= roundInt(fraction * steps) / steps;
		
		value = mMinVal + mValDlt * slice;
		
		if (mDisplay == kofxGui_Display_String && value != mValue)
		{
			int id = (int)value;
			//mGlobals->mListener->handleGui(mParamId, kofxGui_Get_String, &id, sizeof(int));
		}
	}
	
	mValue = value;	
}
Example #17
0
void ofxGuiObject::drawParamString(float x, float y, string text, bool center)
{
	glColor4f(mGlobals->mTextColor.r, mGlobals->mTextColor.g, mGlobals->mTextColor.b, mGlobals->mTextColor.a);

	if(center)
		x -= roundInt(mGlobals->mParamFont.stringWidth(text) / 2.0f);
	else
		x += mGlobals->mParamFontXOffset;
		
	y += mGlobals->mParamFontYOffset;
	mGlobals->mParamFont.drawString(text, x, y);
	
	//	debug rect to position font
	/*
	ofRectangle rect = mGlobals->mParamFont.getStringBoundingBox(text, x, y);
	ofNoFill();
	glColor4f(1.0, 0.0, 0.0, 1.0);
	ofRect(x, y, rect.width, mGlobals->mParamFontHeight);
	*/
}
Example #18
0
int ofxGuiFiles::getFileList()
{
    mFilelist.clear();

    mGlobals->mDir.reset();
    mGlobals->mDir.allowExt(mSuffix);

    mNumberOfFiles      = mGlobals->mDir.listDir(mPath);
    int maxWidth        = 0;

    for(int i = 0; i < mNumberOfFiles; i++)
    {
        string file = mGlobals->mDir.getName(i);
        mFilelist.push_back(file);

        int width = roundInt(mGlobals->mParamFont.stringWidth(file));

        if(width > maxWidth)
            maxWidth = width;
    }

    return maxWidth;
}
Example #19
0
int main(int argc, char** argv)
{
  int i, j, count;
  FILE* f;

  char *prefix, *titleString, *temperature;

  int format; /* 0: PS  1: PNG  2: GIF  3: JPEG */
  int machine;

  char* buffer; /* for system() and fopen() */
  char* plotFile;

  /* functions to call - either PS or PNG */
  void (*init)();
  void (*title)(char*);
  void (*border)();
  void (*grid)();
  void (*plotDot)(int, int, double);
  void (*vertCenter)(char*, int);
  void (*horzCenter)(char*, int);
  void (*selection)(char*, int);

  g_filter = 0;
  g_grid = -1;
  g_dotSize = -1;
  g_top = g_left = g_size = -1;
  g_selectedI = g_selectedJ = -1;
  format = 0;
  machine = 0;
  titleString = NULL;
  g_cutoffValue = 0;
  getColor = getColorLogLog;
  g_epsilon = 0.01;
  temperature = "37";

  while ((count = getopt_long(argc, argv, "Vht:c:e:g:d:u:l:s:f:i:j:p:r:mo:", OPTIONS, NULL)) != -1)
    {
      if (count == 'V')
	version("hybrid-plot-ng");
      else if (count == 'h' || count == '?')
	{
	  puts("Usage: hybrid-plot-ng [options] <file prefix>");
	  puts("");
	  puts("Options:");
	  puts("-V, --version");
	  puts("-h, --help");
	  puts("-t, --temperature=<temperature>");
	  puts("-c, --colors=(linear | log | double) (defaults to double)");
	  puts("-e, --epsilon=<color epsilon> (defaults to .01)");
	  puts("-g, --grid=<grid spacing>");
	  puts("-d, --dot=<dot size>");
	  puts("-u, --top=<initial i>");
	  puts("-l, --left=<initial j>");
	  puts("-s, --size=<size of square>");
	  printf("-f, --format=(ps");
#if HAVE_GD_PNG
	  printf(" | png");
#endif
#if HAVE_GD_GIF
	  printf(" | gif");
#endif
#if HAVE_GD_JPEG
	  printf(" | jpeg");
#endif
	  puts(") (defaults to ps)");
	  puts("-i, --i=<selected i>");
	  puts("-j, --j=<selected j>");
	  puts("-p, --title=<plot title>");
	  puts("-r, --filter=(on | off) (defaults to off)");
	  puts("-o, --cutoff=<store cutoff>");
	  puts("");
	  puts("Report bugs to " PACKAGE_BUGREPORT);
	  return EXIT_SUCCESS;
	}
      else if (count == 't')
	temperature = optarg;
      else if (count == 'c')
	{
	  if (!strcmp(optarg, "linear"))
	    getColor = getColorLinear;
	  else if (!strcmp(optarg, "log"))
	    getColor = getColorLog;
	  else if (!strcmp(optarg, "double"))
	    getColor = getColorLogLog;
	}
      else if (count == 'e')
	g_epsilon = atof(optarg);
      else if (count == 'g')
	g_grid = atoi(optarg);
      else if (count == 'd')
	g_dotSize = atoi(optarg);
      else if (count == 'u')
	g_top = atoi(optarg);
      else if (count == 'l')
	g_left = atoi(optarg);
      else if (count == 's')
	g_size = atoi(optarg);
      else if (count == 'f')
	{
	  if (!strcmp(optarg, "ps"))
	    format = 0;
	  else if (!strcmp(optarg, "png"))
	    format = 1;
	  else if (!strcmp(optarg, "gif"))
	    format = 2;
	  else if (!strcmp(optarg, "jpeg"))
	    format = 3;
	}
      else if (count == 'i')
	g_selectedI = atoi(optarg);
      else if (count == 'j')
	g_selectedJ = atoi(optarg);
      else if (count == 'p')
	  {
	    titleString = xmalloc(strlen(optarg) + 1);
	    strcpy(titleString, optarg);
	  }
      else if (count == 'r')
	{
	  if (!strcmp(optarg, "on"))
	    g_filter = 1;
	  else if (!strcmp(optarg, "off"))
	    g_filter = 0;
	}
      else if (count == 'm')
	machine = 1;
      else if (count == 'o')
	g_cutoffValue = atof(optarg);
   }

  if (optind >= argc)
    {
      fputs("Error: no prefix specified\nRun 'hybrid-plot-ng -h' for help\n", stderr);
      return EXIT_FAILURE;
    }

  plotFile = xmalloc(strlen(argv[optind]) + 107);
  strcpy(plotFile, argv[optind]);

  for (i = 0; i <= strlen(argv[optind]); ++i)
    {
      if (argv[optind][i] == '-')
	{
	  g_ss = 0;
	  argv[optind][i] = 0;
	  break;
	}
      else if (argv[optind][i] == 0)
	{
	  g_ss = 1;
	  break;
	}
    }

  g_file1 = argv[optind];
  if (g_ss) /* from hybrid-ss */
    g_file2 = g_file1;
  else      /* from hybrid */
    g_file2 = argv[optind] + i + 1;

  if (g_ss)
    prefix = g_file1;
  else
    {
      prefix = xmalloc(strlen(g_file1) + 1 + strlen(g_file2) + 1);
      strcpy(prefix, g_file1);
      strcat(prefix, "-");
      strcat(prefix, g_file2);
    }

  if (!(f = fopen(g_file1, "rt")))
    {
      buffer = xmalloc(strlen(g_file1) + 5);
      strcpy(buffer, g_file1);
      strcat(buffer, ".seq");
      if (!(f = fopen(buffer, "rt")))
	{
	  perror(buffer);
	  return EXIT_FAILURE;
	}
      free(buffer);
    }
  input(f, &g_name1, &g_string1);
  fclose(f);
  if (!g_name1)
    g_name1 = g_file1;
  g_len1 = strlen(g_string1);

  if (g_ss)
    {
      g_name2 = g_name1;
      g_string2 = g_string1;
      g_len2 = g_len1;
    }
  else
    {
      if (!(f = fopen(g_file2, "rt")))
	{
	  buffer = xmalloc(strlen(g_file2) + 5);
	  strcpy(buffer, g_file2);
	  strcat(buffer, ".seq");
	  if (!(f = fopen(buffer, "rt")))
	    {
	      perror(buffer);
	      return EXIT_FAILURE;
	    }
	  free(buffer);
	}
      input(f, &g_name2, &g_string2);
      fclose(f);
      if (!g_name2)
	g_name2 = g_file2;;
      g_len2 = strlen(g_string2);
    }

  strcat(plotFile, ".");
  strcat(plotFile, temperature);
  strcat(plotFile, ".plot");

  if (!(f = fopen(plotFile, "rt")))
    {
      perror(plotFile);
      return EXIT_FAILURE;
    }
  g_scores = inputRecords(f);
  fclose(f);
  free(plotFile);

  if (!titleString)
    {
      titleString = xmalloc(1 + strlen(g_name1) + 7 + strlen(g_name2) + 5 + strlen(temperature) + 9);
      if (g_ss)
	sprintf(titleString, "'%s' at %s degrees", g_name1, temperature);
      else
	sprintf(titleString, "'%s' vs. '%s' at %s degrees", g_name1, g_name2, temperature);
    }

  if (g_top == -1 || g_left == -1 || g_size == -1)
    {
      g_top = g_left = 1;
      g_size = g_len1 > g_len2 ? g_len1 : g_len2;
      fixSize();
    }

  g_dotSpacing = (double) 484 / g_size;
  if (g_dotSize == -1)
    g_dotSize = roundInt(g_dotSpacing);
  if (g_dotSize < 1)
    g_dotSize = 1;
  if (g_grid < 0)
    {
      g_grid = g_size / 8;
      fixGrid();
    }
  if (g_grid)
    {
      g_labels = g_grid;
      fixLabels();
    }

  init = initPS;
  title = titlePS;
  border = borderPS;
  grid = gridPS;
  plotDot = plotDotPS;
  vertCenter = vertCenterPS;
  horzCenter = horzCenterPS;
  selection = selectionPS;
#if HAVE_GD
  if (format)
    {
      init = initPNG;
      title = titlePNG;
      border = borderPNG;
      grid = gridPNG;
      plotDot = plotDotPNG;
      vertCenter = vertCenterPNG;
      horzCenter = horzCenterPNG;
      selection = selectionPNG;
    }
#endif

  buffer = xmalloc(strlen(prefix) + 1 + strlen(temperature) + 5);
  strcpy(buffer, prefix);
  strcat(buffer, ".");
  strcat(buffer, temperature);
  if (format == 0)
    {
      strcat(buffer, ".ps");
      g_file = fopen(buffer, "wt");
    }
  else
    {
      if (format == 1)
	strcat(buffer, ".png");
      else if (format == 2)
	strcat(buffer, ".gif");
      else
	strcat(buffer, ".jpg");
      g_file = fopen(buffer, "wb");
#if HAVE_GD
      g_image = gdImageCreate(612, 612);
#endif
    }
  if (!g_file)
    {
      perror(buffer);
      return EXIT_FAILURE;
    }
  free(buffer);

  init();

  title(titleString);

  border();

  grid();

  for (i = 1; i <= g_len1; ++i)
    for (j = 1; j <= g_len2; ++j)
      if (g_scores[(i - 1) * g_len2 + j - 1] >= g_cutoffValue)
	if (g_filter == 0 || filter(i, j))
	  plotDot(i, j, g_scores[(i - 1) * g_len2 + j - 1]);

  if (g_selectedI > 0 && g_selectedJ > 0)
    {
      buffer = xmalloc(24);
      sprintf(buffer, "Selected: (%d-%c, %d-%c), %g",
	      g_selectedI, g_string1[g_selectedI - 1],
	      g_selectedJ, g_string2[g_selectedJ - 1],
	      g_scores[(g_selectedI - 1) * g_len2 + g_selectedJ - 1]);
      selection(buffer, g_gray);
    }

  if (format == 1)
#if HAVE_GD_PNG
    gdImagePng(g_image, g_file)
#endif
      ;
  else if (format == 2)
#if HAVE_GD_GIF
    gdImageGif(g_image, g_file)
#endif
      ;
  else if (format == 3)
#if HAVE_GD_JPEG
    gdImageJpeg(g_image, g_file, -1)
#endif
      ;

  fclose(g_file);

  if (machine)
    {
      /* save configuration */
      buffer = xmalloc(strlen(prefix) + 5);
      strcpy(buffer, prefix);
      strcat(buffer, ".cfg");
      if (!(f = fopen(buffer, "wt")))
	{
	  perror(buffer);
	  return EXIT_FAILURE;
	}
      free(buffer);
      fprintf(f, "%f\n", g_dotSpacing);
      fprintf(f, "%d\n", g_size);
      fclose(f);
    }

  return 0;
}
Example #20
0
inline QList<Coord> getPointList( const Coord& origin, const Coord& target )
{
	// Create a list of coordinates we are going to "touch" when looking
	// from point a to point b
	QList<Coord> pointList;

	int xDiff = target.x - origin.x;
	int yDiff = target.y - origin.y;
	int zDiff = target.z - origin.z;

	// Calculate the length of the X,Y diagonal
	double xyDiagonal = sqrt( ( double ) ( xDiff* xDiff + yDiff* yDiff ) );

	// Calculate the length of the second diagonal
	double lineLength;
	if ( zDiff != 0 )
	{
		lineLength = sqrt( xyDiagonal * xyDiagonal + ( double ) ( zDiff * zDiff ) );
	}
	else
	{
		lineLength = xyDiagonal;
	}

	// Calculate the stepsize for each coordinate
	double xStep = xDiff / lineLength;
	double yStep = yDiff / lineLength;
	double zStep = zDiff / lineLength;

	// Initialize loop variables
	double currentY = origin.y;
	double currentZ = origin.z;
	double currentX = origin.x;

	Coord pos = origin;

	while ( isBetween( currentX, target.x, origin.x ) && isBetween( currentY, target.y, origin.y ) && isBetween( currentZ, target.z, origin.z ) )
	{
		pos.x = roundInt( currentX );
		pos.y = roundInt( currentY );
		pos.z = roundInt( currentZ );

		if ( pointList.count() == 0 || pointList.last() != pos )
		{
			pointList.append( pos );
		}

		// Jump to the next set of coordinates.
		currentX += xStep;
		currentY += yStep;
		currentZ += zStep;
	}

	// Add the target to the end of the pointlist if it's not already
	// there
	if ( pointList.count() != 0 && pointList.last() != target )
	{
		pointList.append( target );
	}

	return pointList;
}
Example #21
0
int getColorLinear(double score)
{
  /* choose the right color for score */
  return roundInt(25 - 25 * score);
}
Example #22
0
void ofxGuiGrid::createImages() {
	//! Allocate the space
	gridImages = new ofxGuiImage*[mXGrid*mYGrid];

	int index = 0;

	//! Setup each image
	for ( int j = 0; j < mYGrid; ++j ) {
		for ( int i = 0; i < mXGrid; ++i ) {
			index = i + j * mXGrid;
			gridImages[index] = new ofxGuiImage();

			gridImages[index]->init( CAMERAS_ID_OFFSET + index, "Cam " + ofToString(index), getGridX(i) + 1, getGridY(j) + 1, roundInt(mGridWidth - 2), roundInt(mGridHeight - 2)  );

		}
	}
}
Example #23
0
void main() {
  double a = -0.6;
  assert(roundInt(a) == -1);
}