void drawpixel(double _x, double _y, int color) { double dt = (m_h + m_w) * m_zoom / 4; int x = (int)((_x - 1.0) * dt + m_w / 2), y = (int)(_y * dt + m_h / 2); if(x >= 0 && x < m_w && y >= 0 && y < m_h) { putpixel_f(x, y, color, pmira); } }
///////////////////////////////////////////////// // 绘制 Julia Set ///////////////////////////////////////////////// int JDraw(COMPLEX c, double fromx, double fromy, double tox, double toy, double sr, double cr) { int ret = 0; int update = 0; state* st = g_st - 1; clock_t tt = clock(); g_updatepoint = 0; for(int y=0; y<g_h; y++) { for(int x=0; x<g_w; x++) { ++st; if (st->ed) { continue; } COMPLEX& z = st->z; if (st->iter == 0) { double re = fromx + (tox - fromx) * (x / (double)g_w); double im = fromy + (toy - fromy) * (y / (double)g_h); z.re = cr * re + sr * im; z.im = sr * re - cr * im; } else { //z = st->z; } st->iter++; { z = z * z + c; if ( z.re*z.re + z.im*z.im > bilout ) { st->ed = 1; } } ++ret; if ( st->ed ) { color_t c = 0; c = colorMap(z, st->iter); putpixel(x, y, c); g_updatepoint += 1; } else if (st->iter == 1) { color_t c = 0; //c = colorMap(z, st->iter); putpixel_f(x, y, c); } } if (clock() - tt > 10) { tt = clock(); if (kbmouhit()) { return -1; } } } return ret; }