Find the center of an element
434390
function(element) {
    var c={};
    try {
      var rect = element.getBoundingClientRect();
      c.x = Math.floor((rect.left + rect.right) / 2);
      c.y = Math.floor((rect.top + rect.bottom) / 2);
    } catch(e) {
      c.x = 1;
      c.y = 1;
    }
    return c;
  }
443702
function findLargestAbsElement (M) {
  const te = M.elements;
  const n = M.dimension;
  let max = _Math.abs(te[0]);
  let rowCol = {
    row: 0,
    column: 0,
    value: te[0]
  };
  for (let i = 0; i < n; ++i) {
    for (let j = 0; j < n; ++j) {
      const val = te[i * n + j];
      const ti = _Math.abs(val);
      if (ti > max) {
        max = ti;
        rowCol.row = j;
        rowCol.column = i;
        rowCol.value = val;
      }
    }
  }
  return rowCol;
}
131686
def find(self, start, end):
        """"""
        if self.intervals and not end < self.intervals[0].start:
            overlapping = [i for i in self.intervals if i.end >= start
                                                    and i.start <= end]
        else:
            overlapping = []

        if self.left and start <= self.center:
            overlapping += self.left.find(start, end)

        if self.right and end >= self.center:
            overlapping += self.right.find(start, end)

        return overlapping
286132
function getCenterWithHeading(position, rotation, resolution) {
  const size = map.getSize();
  const height = size[1];

  return [
    position[0] - Math.sin(rotation) * height * resolution * 1 / 4,
    position[1] + Math.cos(rotation) * height * resolution * 1 / 4
  ];
}
1034789
function findElementInEvent(e, selector) {
            var el = $(e.target);
            if (!el.is(selector)) {
                if (typeof selector === 'string') {
                    el = el.parents(selector);
                }
                else if (selector.nodeType) {
                    var found;
                    el.parents().each(function (index, _el) {
                        if (_el === selector) found = selector;
                    });
                    if (!found) return undefined;
                    else return selector;
                }
            }
            if (el.length === 0) {
                return undefined;
            }
            return el[0];
        }
423811
function getCenter(touches) {
      var valuesX = [], valuesY = [];

      for(var t= 0,len=touches.length; t<len; t++) {
        valuesX.push(touches[t].pageX);
        valuesY.push(touches[t].pageY);
      }

      return {
        pageX: ((Math.min.apply(Math, valuesX) + Math.max.apply(Math, valuesX)) / 2),
          pageY: ((Math.min.apply(Math, valuesY) + Math.max.apply(Math, valuesY)) / 2)
      };
    }
161026
def center(visible_only = true)
      if atoms.empty?
        return Atom.new(0,0,0)
      else
        bounds = bounding_box(visible_only)
        x = (bounds[0].x + bounds[1].x)/2.0
        y = (bounds[0].y + bounds[1].y)/2.0
        z = (bounds[0].z + bounds[1].z)/2.0
        return Atom.new(x,y,z)
      end
    end
92122
function closest(element, selector) {
    var closest;

    while (!closest) {
        if (matches(element, selector)) {
            closest = element;
        }

        element = parent(element);

        if (!element || element === document) {
            break;
        }
    }

    return closest;
}
622276
def get_center(self):
        
        return Point((self.p1.x+self.p2.x)/2.0, (self.p1.y+self.p2.y)/2.0)
1173771
function findClosestParent(startElement, fn) {
            var parent = startElement.parentElement;
            if (!parent) {
                return undefined;
            }
            return fn(parent) ? parent : findClosestParent(parent, fn);
        }
848673
function( elem ) {

		// No argument, return index in parent
		if ( !elem ) {
			return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
		}

		// index in selector
		if ( typeof elem === "string" ) {
			return indexOf.call( jQuery( elem ), this[ 0 ] );
		}

		// Locate the position of the desired element
		return indexOf.call( this,

			// If it receives a jQuery object, the first element is used
			elem.jquery ? elem[ 0 ] : elem
		);
	}
516500
function findCenter( elem ) {
	var offset,
		document = $( elem.ownerDocument );
	elem = $( elem );
	offset = elem.offset();

	return {
		x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
		y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
	};
}
648248
function getOffset(selector) {
      var rect, doc, docElem;
      var elem = document.querySelector(selector);

      if(!elem) { return false; }
      if(!elem.getClientRects().length) {
        return { top: 0, left: 0, width: 0, height: 0};
      }

      rect = elem.getBoundingClientRect();

      if(rect.width || rect.height) {
        doc = elem.ownerDocument;
        docElem = doc.documentElement;
      }

      return {
        top: rect.top + window.pageYOffset - docElem.clientTop,
        left: rect.left + window.pageXOffset - docElem.clientLeft,
        width: elem.offsetWidth,
        height: elem.offsetHeight
      }
    }
723371
function getCenter(pointers) {
    var pointersLength = pointers.length;

    // no need to loop when only one touch
    if (pointersLength === 1) {
        return {
            x: round(pointers[0].clientX),
            y: round(pointers[0].clientY)
        };
    }

    var x = 0, y = 0, i = 0;
    while (i < pointersLength) {
        x += pointers[i].clientX;
        y += pointers[i].clientY;
        i++;
    }

    return {
        x: round(x / pointersLength),
        y: round(y / pointersLength)
    };
}
712769
def center_atoms(self):
        
        nodes = set()
        for n, atom in self.atoms():
            if atom._reactant != atom._product:
                nodes.add(n)

        for n, m, bond in self.bonds():
            if bond._reactant != bond._product:
                nodes.add(n)
                nodes.add(m)

        return list(nodes)
1352254
def a(self):
        '''
        

        '''
        a = Point(self.center)

        if self.xAxisIsMajor:
            a.x += self.majorRadius
        else:
            a.y += self.majorRadius
        return a
866080
function getElementSize(element) {
    const rect = element.getBoundingClientRect();
    return {
        width: Math.round(rect.width),
        height: Math.round(rect.height),
    };
}