1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "MandelUtil.h"
- using mnd::MandelViewport;
- void MandelViewport::adjustAspectRatio(double nwidth, double nheight)
- {
- double otherRatio = nwidth / nheight;
- if (width < height * otherRatio)
- width = height * otherRatio;
- else if (height < width / otherRatio)
- height = width / otherRatio;
- }
- void MandelViewport::normalize(void)
- {
- if (width < 0) {
- x += width;
- width = -width;
- }
- if (height < 0) {
- y += height;
- height = -height;
- }
- }
- void MandelViewport::zoomCenter(float scale)
- {
- x += width * (1 - scale) / 2;
- y += height * (1 - scale) / 2;
- width *= scale;
- height *= scale;
- }
- MandelViewport MandelViewport::standardView(void)
- {
- return MandelViewport{
- -2.25,
- -1.5,
- 3,
- 3
- };
- }
|