示例#1
0
void iterate_board2(board b) {
  int i,j;
  for(i=0; i<b->height; i++) {
    for(j=0; j<b->width; j++) {
      b->cells[i][j] = iterate_cell(b->cells[i][j]);
    }
  }
}
示例#2
0
board iterate_board(board b) {
  // because the whole board needs to tick
  // at the same time as a result of eachother,
  // we can't modify the cells in place
  // NOTE: actually we could as long as we
  // only modify the alive state and not the
  // neighbors state
  board newboard = clone_board(b);
  int i,j;
  for(i=0; i<b->height; i++) {
    for(j=0; j<b->width; j++) {
      newboard->cells[i][j] = iterate_cell(b->cells[i][j]);
    }
  }
  return newboard;
}
    bool fractal_base::process_line(const line &l) {
        const vec_ull start = l.start_point;
        const vec_ull end = l.end_point;
        // handle lines containing only a single pixel
        const vec_ull diff = ((start - end) != vec_ull{0, 0}) ? (end - start).unitV() : vec_ull{0, 0};
        const size_t length = (end - start).norm();
        bool out = true;

        for (size_t i = 0; i <= length; i++) {
            vec_ull pos = start + diff * i;
            if (iterations(pos) == NOT_DEFINED) {
                // imaginary axis is different because it points opposite our +y axis
                complex complex_pos = index_to_complex(pos);
                iterations(pos) = iterate_cell(complex_pos);
            }
            if (iterations(pos) != iterations(start)) {
                out = false;
            }
        }
        return out;
    }