/*
* CINELERRA
* Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
*/
#include "bcdisplayinfo.h"
void copy_from(PolarConfig &src);
int equivalent(PolarConfig &src);
- void interpolate(PolarConfig &prev,
- PolarConfig &next,
- long prev_frame,
- long next_frame,
+ void interpolate(PolarConfig &prev,
+ PolarConfig &next,
+ long prev_frame,
+ long next_frame,
long current_frame);
-
+
int polar_to_rectangular;
float depth;
float angle;
return EQUIV(this->angle, src.angle) && EQUIV(this->depth, src.depth);
}
-void PolarConfig::interpolate(PolarConfig &prev,
- PolarConfig &next,
- long prev_frame,
- long next_frame,
+void PolarConfig::interpolate(PolarConfig &prev,
+ PolarConfig &next,
+ long prev_frame,
+ long next_frame,
long current_frame)
{
double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
PolarWindow::PolarWindow(PolarEffect *plugin)
- : PluginClientWindow(plugin,
- 270,
- 100,
- 270,
- 100,
+ : PluginClientWindow(plugin,
+ 270,
+ 100,
+ 270,
+ 100,
0)
{
this->plugin = plugin;
PolarDepth::PolarDepth(PolarEffect *plugin, int x, int y)
- : BC_FSlider(x,
- y,
+ : BC_FSlider(x,
+ y,
0,
200,
- 200,
- (float)1,
+ 200,
+ (float)1,
(float)100,
plugin->config.depth)
{
PolarAngle::PolarAngle(PolarEffect *plugin, int x, int y)
- : BC_FSlider(x,
- y,
+ : BC_FSlider(x,
+ y,
0,
200,
- 200,
- (float)1,
- (float)360,
+ 200,
+ (float)1,
+ (float)360,
plugin->config.angle)
{
this->plugin = plugin;
need_reconfigure = 1;
temp_frame = 0;
engine = 0;
-
+
}
PolarEffect::~PolarEffect()
{
-
+
if(temp_frame) delete temp_frame;
if(engine) delete engine;
}
-const char* PolarEffect::plugin_title() { return _("Polar"); }
+const char* PolarEffect::plugin_title() { return N_("Polar"); }
int PolarEffect::is_realtime() { return 1; }
{
if(input->get_rows()[0] == output->get_rows()[0])
{
- if(!temp_frame) temp_frame = new VFrame(0,
- -1,
- input->get_w(),
- input->get_h(),
- input->get_color_model(),
- -1);
+ if(!temp_frame)
+ temp_frame = new VFrame(input->get_w(), input->get_h(),
+ input->get_color_model(), 0);
temp_frame->copy_from(input);
this->input = temp_frame;
}
-
-
+
+
if(!engine) engine = new PolarEngine(this, PluginClient::smp + 1);
engine->process_packages();
{
if(wy > cen_y)
{
- phi = M_PI -
- atan(((double)(wx - cen_x)) /
+ phi = M_PI -
+ atan(((double)(wx - cen_x)) /
((double)(wy - cen_y)));
- r = sqrt(SQR(wx - cen_x) +
+ r = sqrt(SQR(wx - cen_x) +
SQR(wy - cen_y));
}
- else
+ else
if(wy < cen_y)
{
- phi = atan(((double)(wx - cen_x)) /
+ phi = atan(((double)(wx - cen_x)) /
((double)(cen_y - wy)));
- r = sqrt(SQR(wx - cen_x) +
+ r = sqrt(SQR(wx - cen_x) +
SQR(cen_y - wy));
}
else
r = wx - cen_x;
}
}
- else
+ else
if(wx < cen_x)
{
if(wy < cen_y)
{
- phi = 2 * M_PI -
+ phi = 2 * M_PI -
atan(((double)(cen_x -wx)) /
((double)(cen_y - wy)));
- r = sqrt(SQR(cen_x - wx) +
+ r = sqrt(SQR(cen_x - wx) +
SQR(cen_y - wy));
}
- else
+ else
if(wy > cen_y)
{
- phi = M_PI +
- atan(((double)(cen_x - wx)) /
+ phi = M_PI +
+ atan(((double)(cen_x - wx)) /
((double)(wy - cen_y)));
- r = sqrt(SQR(cen_x - wx) +
+ r = sqrt(SQR(cen_x - wx) +
SQR(wy - cen_y));
}
else
}
if (wx != cen_x)
{
- m = fabs(((double)(wy - cen_y)) /
+ m = fabs(((double)(wy - cen_y)) /
((double)(wx - cen_x)));
}
else
{
m = 0;
}
-
- if(m <= ((double)(y2 - y1) /
+
+ if(m <= ((double)(y2 - y1) /
(double)(x2 - x1)))
{
if(wx == cen_x)
ymax = cen_y - y1;
xmax = ymax / m;
}
-
+
rmax = sqrt((double)(SQR(xmax) + SQR(ymax)));
t = ((cen_y - y1) < (cen_x - x1)) ? (cen_y - y1) : (cen_x - x1);
xi = (int)(x_calc + 0.5);
yi = (int)(y_calc + 0.5);
-
+
if(WITHIN(0, xi, w - 1) && WITHIN(0, yi, h - 1))
{
x = x_calc;
phi = (2 * M_PI) * (wx - x1) / xdiff;
phi = fmod (phi + angl, 2 * M_PI);
-
+
if(phi >= 1.5 * M_PI)
phi2 = 2 * M_PI - phi;
else
m = (double)1.0 / xx;
else
m = 0;
-
+
if(m <= ((double)(ydiff) / (double)(xdiff)))
{
if(phi2 == 0)
ymax = ym - y1;
xmax = ymax / m;
}
-
+
rmax = sqrt((double)(SQR(xmax) + SQR(ymax)));
-
+
t = ((ym - y1) < (xm - x1)) ? (ym - y1) : (xm - x1);
rmax = (rmax - t) / 100.0 * (100 - circle) + t;
r = rmax * (double)((wy - y1) / (double)(ydiff));
else
r = rmax * (double)((y2 - wy) / (double)(ydiff));
-
+
xx = r * sin (phi2);
yy = r * cos (phi2);
xi = (int)(x_calc + 0.5);
yi = (int)(y_calc + 0.5);
-
- if(WITHIN(0, xi, w - 1) &&
- WITHIN(0, yi, h - 1))
+
+ if(WITHIN(0, xi, w - 1) &&
+ WITHIN(0, yi, h - 1))
{
x = x_calc;
y = y_calc;
double cy;
double cen_x = (double)(w - 1) / 2.0;
double cen_y = (double)(h - 1) / 2.0;
-
+
switch(plugin->input->get_color_model())
{
case BC_RGB_FLOAT: