aniplot/graph_renderer.py
def _render_grid_horlines(self, w, h, x2, y2, w2, h2, min_div_hpix=50.):
        """
        min_div_hpix : minimum division height (grid line distance) in pixels
        """
        assert  h > 1.
        ch = self.channels[0]
        if abs(h2) < 0.000001:
            return

        v1 = y2
        v2 = y2 + h2
        # swap begin/end if necessary to make following calculations much more convenient
        if v2 < v1:
            v1, v2 = v2, v1

        volts_per_min_div = (v2 - v1) / (h - 1.) * min_div_hpix
        pixels_per_volt = (h - 1.) / (v2 - v1)
        v_step = math.pow(2, math.ceil(math.log(volts_per_min_div, 2)))

        # volt begin
        v_begin = math.floor(v1 / v_step) * v_step + v_step
        px_begin = self._sample_to_pixel(v_begin, y2, h2, h)
        px_end   = self._sample_to_pixel(v2, y2, h2, h) # overshooting is intentional
        sign = 1 if px_end > px_begin else -1
        px_step  = pixels_per_volt * v_step * sign

        gl.glBegin(gl.GL_LINES)

        px = px_begin
        while px * sign < px_end:
            gl.glVertex3f( 0., px, 0. )
            gl.glVertex3f(  w, px, 0. )
            px += px_step

        gl.glEnd()

        min_div_hpix : minimum division height (grid line distance) in pixels
        
min_div_hpix : minimum division height (grid line distance) in pixels
min_div_hpix : minimum division height ( grid line distance ) in pixels
def _render_grid_horlines(self, w, h, x2, y2, w2, h2, min_div_hpix=50.):
        assert  h > 1.
        ch = self.channels[0]
        if abs(h2) < 0.000001:
            return
        v1 = y2
        v2 = y2 + h2
        if v2 < v1:
            v1, v2 = v2, v1
        volts_per_min_div = (v2 - v1) / (h - 1.) * min_div_hpix
        pixels_per_volt = (h - 1.) / (v2 - v1)
        v_step = math.pow(2, math.ceil(math.log(volts_per_min_div, 2)))
        v_begin = math.floor(v1 / v_step) * v_step + v_step
        px_begin = self._sample_to_pixel(v_begin, y2, h2, h)
        px_end   = self._sample_to_pixel(v2, y2, h2, h) 
        sign = 1 if px_end > px_begin else -1
        px_step  = pixels_per_volt * v_step * sign
        gl.glBegin(gl.GL_LINES)
        px = px_begin
        while px * sign < px_end:
            gl.glVertex3f( 0., px, 0. )
            gl.glVertex3f(  w, px, 0. )
            px += px_step
        gl.glEnd()
def _render_grid_horlines ( self , w , h , x2 , y2 , w2 , h2 , min_div_hpix = 50. ) : assert h > 1. ch = self . channels [ 0 ] if abs ( h2 ) < 0.000001 : return v1 = y2 v2 = y2 + h2 if v2 < v1 : v1 , v2 = v2 , v1 volts_per_min_div = ( v2 - v1 ) / ( h - 1. ) * min_div_hpix pixels_per_volt = ( h - 1. ) / ( v2 - v1 ) v_step = math . pow ( 2 , math . ceil ( math . log ( volts_per_min_div , 2 ) ) ) v_begin = math . floor ( v1 / v_step ) * v_step + v_step px_begin = self . _sample_to_pixel ( v_begin , y2 , h2 , h ) px_end = self . _sample_to_pixel ( v2 , y2 , h2 , h ) sign = 1 if px_end > px_begin else - 1 px_step = pixels_per_volt * v_step * sign gl . glBegin ( gl . GL_LINES ) px = px_begin while px * sign < px_end : gl . glVertex3f ( 0. , px , 0. ) gl . glVertex3f ( w , px , 0. ) px += px_step gl . glEnd ( )
min_div_hpix : minimum division height (grid line distance) in pixels
min_div_hpix : minimum division height ( grid line distance ) in pixels
"""
        min_div_hpix : minimum division height (grid line distance) in pixels
        """ # swap begin/end if necessary to make following calculations much more convenient # volt begin # overshooting is intentional
self
w
h
x2
y2
w2
h2
min_div_hpix