Changeset 1065


Ignore:
Timestamp:
Nov 12, 2011, 6:08:43 PM (11 years ago)
Author:
sam
Message:

tutorial: clamp zoom values in the Mandelbrot viewer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/tutorial/tut03.cpp

    r1064 r1065  
    5858        Ticker::Ref(m_mousetext);
    5959
     60        m_zoomtext = new Text(NULL, "gfx/font/ascii.png");
     61        m_zoomtext->SetPos(ivec3(5, m_size.y - 43, 1));
     62        Ticker::Ref(m_zoomtext);
     63
    6064        position = ivec3(0, 0, 0);
    6165        bbox[0] = position;
     
    6973        Ticker::Unref(m_centertext);
    7074        Ticker::Unref(m_mousetext);
     75        Ticker::Unref(m_zoomtext);
    7176        delete m_pixels;
    7277    }
     
    9196        {
    9297            double zoom = pow(2.0, (buttons[0] ? -deltams : deltams) * 0.0015);
    93             if (m_radius * zoom > 1.5)
    94                 zoom = 1.0;
     98            if (m_radius * zoom > 8.0)
     99                zoom = 8.0 / m_radius;
     100            else if (m_radius * zoom < 1e-14)
     101                zoom = 1e-14 / m_radius;
    95102            m_radius *= zoom;
    96103            m_center = (m_center - worldmouse) * zoom + worldmouse;
     
    104111        sprintf(buf, " mouse: %+13.11f%+13.11fi", worldmouse.x, worldmouse.y);
    105112        m_mousetext->SetText(buf);
     113        sprintf(buf, "  zoom: %g", 1.0 / m_radius);
     114        m_zoomtext->SetText(buf);
    106115
    107116        u8vec4 *m_pixelstart = m_pixels + m_size.x * m_size.y / 4 * m_frame;
     
    327336
    328337    /* Debug information */
    329     Text *m_centertext, *m_mousetext;
     338    Text *m_centertext, *m_mousetext, *m_zoomtext;
    330339};
    331340
Note: See TracChangeset for help on using the changeset viewer.