//--------------------------------------------------------------------- public DistanceInterpolator3(int x1, int y1, int x2, int y2, int sx, int sy, int ex, int ey, int x, int y) { unchecked { m_dx = (x2 - x1); m_dy = (y2 - y1); m_dx_start = (LineAA.Mr(sx) - LineAA.Mr(x1)); m_dy_start = (LineAA.Mr(sy) - LineAA.Mr(y1)); m_dx_end = (LineAA.Mr(ex) - LineAA.Mr(x2)); m_dy_end = (LineAA.Mr(ey) - LineAA.Mr(y2)); m_dist = (AggBasics.iround((double)(x + LineAA.SUBPIXEL_SCALE / 2 - x2) * (double)(m_dy) - (double)(y + LineAA.SUBPIXEL_SCALE / 2 - y2) * (double)(m_dx))); m_dist_start = ((LineAA.Mr(x + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(sx)) * m_dy_start - (LineAA.Mr(y + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(sy)) * m_dx_start); m_dist_end = ((LineAA.Mr(x + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(ex)) * m_dy_end - (LineAA.Mr(y + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(ey)) * m_dx_end); m_dx <<= LineAA.SUBPIXEL_SHIFT; m_dy <<= LineAA.SUBPIXEL_SHIFT; m_dx_start <<= LineAA.MR_SUBPIXEL_SHIFT; m_dy_start <<= LineAA.MR_SUBPIXEL_SHIFT; m_dx_end <<= LineAA.MR_SUBPIXEL_SHIFT; m_dy_end <<= LineAA.MR_SUBPIXEL_SHIFT; } }
public override void Line0(LineParameters lp) { if (doClipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; int flags = ClipLiangBarsky.ClipLineSegment(ref x1, ref y1, ref x2, ref y2, clippingRectangle); if ((flags & 4) == 0) { if (flags != 0) { LineParameters lp2 = new LineParameters(x1, y1, x2, y2, AggBasics.uround(AggMath.calc_distance(x1, y1, x2, y2))); Line0NoClip(lp2); } else { Line0NoClip(lp); } } } else { Line0NoClip(lp); } }
//--------------------------------------------------------------------- public void Setup(double r, double fx, double fy) { m_r = AggBasics.iround(r * SpanGenGradient.GR_SUBPIX_SCALE); m_fx = AggBasics.iround(fx * SpanGenGradient.GR_SUBPIX_SCALE); m_fy = AggBasics.iround(fy * SpanGenGradient.GR_SUBPIX_SCALE); UpdateValues(); }
//---------------------------------------------------------------- public void Begin(double x, double y, int len) { // Calculate transformed coordinates at x1,y1 double xt = x; double yt = y; m_trans_dir.Transform(ref xt, ref yt); int x1 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y1 = AggBasics.iround(yt * SUBPIXEL_SCALE); double dx; double dy; double delta = 1 / (double)SUBPIXEL_SCALE; // Calculate scale by X at x1,y1 dx = xt + delta; dy = yt; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sx1 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate scale by Y at x1,y1 dx = xt; dy = yt + delta; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sy1 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate transformed coordinates at x2,y2 x += len; xt = x; yt = y; m_trans_dir.Transform(ref xt, ref yt); int x2 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.iround(yt * SUBPIXEL_SCALE); // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sx2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sy2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (int)len); }
public override void ToPix(ref Color c) { c.red = (byte)AggBasics.uround(r); c.green = (byte)AggBasics.uround(g); c.blue = (byte)AggBasics.uround(b); c.alpha = (byte)AggBasics.uround(a); }
public void Init(double x1, double y1, double cx, double cy, double x2, double y2) { m_start_x = x1; m_start_y = y1; m_end_x = x2; m_end_y = y2; double dx1 = cx - x1; double dy1 = cy - y1; double dx2 = x2 - cx; double dy2 = y2 - cy; double len = Math.Sqrt(dx1 * dx1 + dy1 * dy1) + Math.Sqrt(dx2 * dx2 + dy2 * dy2); m_num_steps = (int)AggBasics.uround(len * 0.25 * m_scale); if (m_num_steps < 4) { m_num_steps = 4; } double subdivide_step = 1.0 / m_num_steps; double subdivide_step2 = subdivide_step * subdivide_step; double tmpx = (x1 - cx * 2.0 + x2) * subdivide_step2; double tmpy = (y1 - cy * 2.0 + y2) * subdivide_step2; m_saved_fx = m_fx = x1; m_saved_fy = m_fy = y1; m_saved_dfx = m_dfx = tmpx + (cx - x1) * (2.0 * subdivide_step); m_saved_dfy = m_dfy = tmpy + (cy - y1) * (2.0 * subdivide_step); m_ddfx = tmpx * 2.0; m_ddfy = tmpy * 2.0; m_step = m_num_steps; }
public static void Bisectrix(LineParameters l1, LineParameters l2, out int x, out int y) { double k = (double)(l2.len) / (double)(l1.len); double tx = l2.x2 - (l2.x1 - l1.x1) * k; double ty = l2.y2 - (l2.y1 - l1.y1) * k; //All bisectrices must be on the right of the line //If the next point is on the left (l1 => l2.2) //then the bisectix should be rotated by 180 degrees. if ((double)(l2.x2 - l2.x1) * (double)(l2.y1 - l1.y1) < (double)(l2.y2 - l2.y1) * (double)(l2.x1 - l1.x1) + 100.0) { tx -= (tx - l2.x1) * 2.0; ty -= (ty - l2.y1) * 2.0; } // Check if the bisectrix is too short double dx = tx - l2.x1; double dy = ty - l2.y1; if ((int)Math.Sqrt(dx * dx + dy * dy) < SUBPIXEL_SCALE) { x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1; y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1; return; } x = AggBasics.iround(tx); y = AggBasics.iround(ty); }
public void Init(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2) { m_start_x = x1; m_start_y = y1; m_end_x = x2; m_end_y = y2; double dx1 = cx1 - x1; double dy1 = cy1 - y1; double dx2 = cx2 - cx1; double dy2 = cy2 - cy1; double dx3 = x2 - cx2; double dy3 = y2 - cy2; double len = (Math.Sqrt(dx1 * dx1 + dy1 * dy1) + Math.Sqrt(dx2 * dx2 + dy2 * dy2) + Math.Sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale; m_num_steps = (int)AggBasics.uround(len); if (m_num_steps < 4) { m_num_steps = 4; } double subdivide_step = 1.0 / m_num_steps; double subdivide_step2 = subdivide_step * subdivide_step; double subdivide_step3 = subdivide_step * subdivide_step * subdivide_step; double pre1 = 3.0 * subdivide_step; double pre2 = 3.0 * subdivide_step2; double pre4 = 6.0 * subdivide_step2; double pre5 = 6.0 * subdivide_step3; double tmp1x = x1 - cx1 * 2.0 + cx2; double tmp1y = y1 - cy1 * 2.0 + cy2; double tmp2x = (cx1 - cx2) * 3.0 - x1 + x2; double tmp2y = (cy1 - cy2) * 3.0 - y1 + y2; m_saved_fx = m_fx = x1; m_saved_fy = m_fy = y1; m_saved_dfx = m_dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdivide_step3; m_saved_dfy = m_dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdivide_step3; m_saved_ddfx = m_ddfx = tmp1x * pre4 + tmp2x * pre5; m_saved_ddfy = m_ddfy = tmp1y * pre4 + tmp2y * pre5; m_dddfx = tmp2x * pre5; m_dddfy = tmp2y * pre5; m_step = m_num_steps; }
public DistanceInterpolator1(int x1, int y1, int x2, int y2, int x, int y) { m_dx = (x2 - x1); m_dy = (y2 - y1); m_dist = (AggBasics.iround((double)(x + LineAA.SUBPIXEL_SCALE / 2 - x2) * (double)(m_dy) - (double)(y + LineAA.SUBPIXEL_SCALE / 2 - y2) * (double)(m_dx))); m_dx <<= LineAA.SUBPIXEL_SHIFT; m_dy <<= LineAA.SUBPIXEL_SHIFT; }
void SetGamma(IGammaFunction gamma_function) { int i; for (i = 0; i < AA_SCALE; i++) { m_gamma[i] = (byte)(AggBasics.uround(gamma_function.GetGamma((float)(i) / AA_MASK) * AA_MASK)); } }
static LineProfileAnitAlias() { //GammaNone => just return i*** s_gamma_none = new byte[AA_SCALE]; for (int i = AA_SCALE - 1; i >= 0; --i) { s_gamma_none[i] = (byte)(AggBasics.uround(((float)(i) / AA_MASK) * AA_MASK)); } }
//--------------------------------------------------------------------- public int Calculate(int x, int y, int d) { double dx = x - m_fx; double dy = y - m_fy; double d2 = dx * m_fy - dy * m_fx; double d3 = m_r2 * (dx * dx + dy * dy) - d2 * d2; return(AggBasics.iround((dx * m_fx + dy * m_fy + System.Math.Sqrt(System.Math.Abs(d3))) * m_mul)); }
public override void Line3(LineParameters lp, int sx, int sy, int ex, int ey) { if (doClipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; int flags = ClipLiangBarsky.ClipLineSegment(ref x1, ref y1, ref x2, ref y2, clippingRectangle); if ((flags & 4) == 0) { if (flags != 0) { LineParameters lp2 = new LineParameters(x1, y1, x2, y2, AggBasics.uround(AggMath.calc_distance(x1, y1, x2, y2))); if ((flags & 1) != 0) { sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else { while (Math.Abs(sx - lp.x1) + Math.Abs(sy - lp.y1) > lp2.len) { sx = (lp.x1 + sx) >> 1; sy = (lp.y1 + sy) >> 1; } } if ((flags & 2) != 0) { ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else { while (Math.Abs(ex - lp.x2) + Math.Abs(ey - lp.y2) > lp2.len) { ex = (lp.x2 + ex) >> 1; ey = (lp.y2 + ey) >> 1; } } Line3NoClip(lp2, sx, sy, ex, ey); } else { Line3NoClip(lp, sx, sy, ex, ey); } } } else { Line3NoClip(lp, sx, sy, ex, ey); } }
//-------------------------------------------------------------------- // This function normalizes integer values and corrects the rounding // errors. It doesn't do anything with the source floating point values // (m_weight_array_dbl), it corrects only integers according to the rule // of 1.0 which means that any sum of pixel weights must be equal to 1.0. // So, the filter function must produce a graph of the proper shape. //-------------------------------------------------------------------- public void Normalize() { int i; int flip = 1; for (i = 0; i < (int)ImgSubPixConst.SCALE; i++) { for (;;) { int sum = 0; int j; for (j = 0; j < m_diameter; j++) { sum += m_weight_array[j * (int)ImgSubPixConst.SCALE + i]; } if (sum == (int)ImgFilterConst.SCALE) { break; } double k = (double)((int)ImgFilterConst.SCALE) / (double)(sum); sum = 0; for (j = 0; j < m_diameter; j++) { sum += m_weight_array[j * (int)ImgSubPixConst.SCALE + i] = (int)AggBasics.iround(m_weight_array[j * (int)ImgSubPixConst.SCALE + i] * k); } sum -= (int)ImgFilterConst.SCALE; int inc = (sum > 0) ? -1 : 1; for (j = 0; j < m_diameter && sum != 0; j++) { flip ^= 1; int idx = flip != 0 ? m_diameter / 2 + j / 2 : m_diameter / 2 - j / 2; int v = m_weight_array[idx * (int)ImgSubPixConst.SCALE + i]; if (v < (int)ImgFilterConst.SCALE) { m_weight_array[idx * (int)ImgSubPixConst.SCALE + i] += (int)inc; sum += inc; } } } } int pivot = m_diameter << (ImgSubPixConst.SHIFT - 1); for (i = 0; i < pivot; i++) { m_weight_array[pivot + i] = m_weight_array[pivot - i]; } int end = (Diameter << ImgSubPixConst.SHIFT) - 1; m_weight_array[0] = m_weight_array[end]; }
public bool IsDiff(LineAAVertex val) { int dx = val.x - x; int dy = val.y - y; if ((dx + dy) == 0) { return(false); } return((len = AggBasics.uround(Math.Sqrt(dx * dx + dy * dy))) > SIGDIFF); }
/// <summary> /// fix_degeneration_bisectrix_start /// </summary> /// <param name="lp"></param> /// <param name="x"></param> /// <param name="y"></param> public static void FixDegenBisectrixStart(LineParameters lp, ref int x, ref int y) { int d = AggBasics.iround(((double)(x - lp.x2) * (double)(lp.y2 - lp.y1) - (double)(y - lp.y2) * (double)(lp.x2 - lp.x1)) / lp.len); if (d < SUBPIXEL_SCALE / 2) { x = lp.x1 + (lp.y2 - lp.y1); y = lp.y1 - (lp.x2 - lp.x1); } }
void ReallocLut(double radius) { m_radius = radius; m_diameter = AggBasics.uceil(radius) * 2; m_start = -(m_diameter / 2 - 1); int size = m_diameter << ImgSubPixConst.SHIFT; if (size > m_weight_array.Length) { m_weight_array = new int[size]; } }
bool is_identity() { return(AggBasics.is_equal_eps(sx, 1.0, EPSILON) && AggBasics.is_equal_eps(shy, 0.0, EPSILON) && AggBasics.is_equal_eps(w0, 0.0, EPSILON) && AggBasics.is_equal_eps(shx, 0.0, EPSILON) && AggBasics.is_equal_eps(sy, 1.0, EPSILON) && AggBasics.is_equal_eps(w1, 0.0, EPSILON) && AggBasics.is_equal_eps(tx, 0.0, EPSILON) && AggBasics.is_equal_eps(ty, 0.0, EPSILON) && AggBasics.is_equal_eps(w2, 1.0, EPSILON)); }
public spiral(double x, double y, double r1, double r2, double step, double start_angle = 0) { m_x = x; m_y = y; m_r1 = r1; m_r2 = r2; m_step = step; m_start_angle = start_angle; m_angle = start_angle; m_da = AggBasics.deg2rad(4.0); m_dr = m_step / 90.0; }
public bool IsDiff(LineAAVertex val) { //*** NEED 64 bits long long dx = val.x - x; long dy = val.y - y; if ((dx + dy) == 0) { return(false); } return((len = AggBasics.uround(Math.Sqrt(dx * dx + dy * dy))) > SIGDIFF); }
byte[] GetProfileBuffer(double w) { m_subpixel_width = (int)AggBasics.uround(w * SUBPIX_SCALE); int size = m_subpixel_width + SUBPIX_SCALE * 6; if (size > m_profile.Length) { //clear ? m_profile = new byte[size]; //m_profile.Resize(size); } return(m_profile); }
public DistanceInterpolator2(int x1, int y1, int x2, int y2, int ex, int ey, int x, int y, int none) { m_dx = (x2 - x1); m_dy = (y2 - y1); m_dx_start = (LineAA.Mr(ex) - LineAA.Mr(x2)); m_dy_start = (LineAA.Mr(ey) - LineAA.Mr(y2)); m_dist = (AggBasics.iround((double)(x + LineAA.SUBPIXEL_SCALE / 2 - x2) * (double)(m_dy) - (double)(y + LineAA.SUBPIXEL_SCALE / 2 - y2) * (double)(m_dx))); m_dist_start = ((LineAA.Mr(x + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(ex)) * m_dy_start - (LineAA.Mr(y + LineAA.SUBPIXEL_SCALE / 2) - LineAA.Mr(ey)) * m_dx_start); m_dx <<= LineAA.SUBPIXEL_SHIFT; m_dy <<= LineAA.SUBPIXEL_SHIFT; m_dx_start <<= LineAA.MR_SUBPIXEL_SHIFT; m_dy_start <<= LineAA.MR_SUBPIXEL_SHIFT; }
void SetGamma(IGammaFunction gamma_function) { //TODO:review gamma again*** if (gamma_function == null) { m_gamma = s_gamma_none; } else { m_gamma = new byte[AA_SCALE]; for (int i = AA_SCALE - 1; i >= 0; --i) { //pass i to gamma func *** m_gamma[i] = (byte)(AggBasics.uround(gamma_function.GetGamma((float)(i) / AA_MASK) * AA_MASK)); } } }
//---------------------------------------------------------------- public void ReSync(double xe, double ye, int len) { // Assume x1,y1 are equal to the ones at the previous end point int x1 = m_coord_x.Y; int y1 = m_coord_y.Y; int sx1 = m_scale_x.Y; int sy1 = m_scale_y.Y; // Calculate transformed coordinates at x2,y2 double xt = xe; double yt = ye; m_trans_dir.Transform(ref xt, ref yt); int x2 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.iround(yt * SUBPIXEL_SCALE); double delta = 1 / (double)SUBPIXEL_SCALE; double dx; double dy; // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.Transform(ref dx, ref dy); dx -= xe; dy -= ye; int sx2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.Transform(ref dx, ref dy); dx -= xe; dy -= ye; int sy2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (int)len); }
//---------------------------------------------------------------- public void Begin(double x, double y, int len) { double tx; double ty; tx = x; ty = y; m_trans.Transform(ref tx, ref ty); int x1 = AggBasics.iround(tx * (double)SUB_PIXEL_SCALE); int y1 = AggBasics.iround(ty * (double)SUB_PIXEL_SCALE); tx = x + len; ty = y; m_trans.Transform(ref tx, ref ty); int x2 = AggBasics.iround(tx * (double)SUB_PIXEL_SCALE); int y2 = AggBasics.iround(ty * (double)SUB_PIXEL_SCALE); m_li_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_li_y = new LineInterpolatorDDA2(y1, y2, (int)len); }
void Calculate(Imaging.IImageFilter filter, bool normalization) { double r = filter.GetRadius(); ReallocLut(r); int i; int pivot = Diameter << (ImgSubPixConst.SHIFT - 1); for (i = 0; i < pivot; i++) { double x = (double)i / (double)ImgSubPixConst.SCALE; double y = filter.CalculateWeight(x); m_weight_array[pivot + i] = m_weight_array[pivot - i] = AggBasics.iround(y * ImgFilterConst.SCALE); } int end = (Diameter << ImgSubPixConst.SHIFT) - 1; m_weight_array[0] = m_weight_array[end]; if (normalization) { Normalize(); } }
public static int Convert(double x) { return(AggBasics.iround( x * LineAA.SUBPIXEL_SCALE, LineAA.SUBPIXEL_COORD)); }
// Create //-------------------------------------------------------------------- public void Create(IImageReaderWriter src) { // we are going to create a dialated image for filtering // we add m_dilation pixels to every side of the image and then copy the image in the x // dirrection into each end so that we can sample into this image to get filtering on x repeating // if the original image look like this // // 123456 // // the new image would look like this // // 0000000000 // 0000000000 // 5612345612 // 0000000000 // 0000000000 m_height = (int)AggBasics.uceil(src.Height); m_width = (int)AggBasics.uceil(src.Width); m_width_hr = (int)AggBasics.uround(src.Width * LineAA.SUBPIXEL_SCALE); m_half_height_hr = (int)AggBasics.uround(src.Height * LineAA.SUBPIXEL_SCALE / 2); m_offset_y_hr = m_dilation_hr + m_half_height_hr - LineAA.SUBPIXEL_SCALE / 2; m_half_height_hr += LineAA.SUBPIXEL_SCALE / 2; int bufferWidth = m_width + m_dilation * 2; int bufferHeight = m_height + m_dilation * 2; int bytesPerPixel = src.BitDepth / 8; int newSizeInBytes = bufferWidth * bufferHeight * bytesPerPixel; if (m_DataSizeInBytes < newSizeInBytes) { m_DataSizeInBytes = newSizeInBytes; m_data = new byte[m_DataSizeInBytes]; } m_buf = new ChildImage(m_data, 0, bufferWidth, bufferHeight, bufferWidth * bytesPerPixel, src.BitDepth, bytesPerPixel); byte[] destBuffer = m_buf.GetBuffer(); byte[] srcBuffer = src.GetBuffer(); // copy the image into the middle of the dest for (int y = 0; y < m_height; y++) { for (int x = 0; x < m_width; x++) { int sourceOffset = src.GetBufferOffsetXY(x, y); int destOffset = m_buf.GetBufferOffsetXY(m_dilation, y + m_dilation); for (int channel = 0; channel < bytesPerPixel; channel++) { destBuffer[destOffset++] = srcBuffer[sourceOffset++]; } } } // copy the first two pixels form the end into the begining and from the begining into the end for (int y = 0; y < m_height; y++) { int s1Offset = src.GetBufferOffsetXY(0, y); int d1Offset = m_buf.GetBufferOffsetXY(m_dilation + m_width, y); int s2Offset = src.GetBufferOffsetXY(m_width - m_dilation, y); int d2Offset = m_buf.GetBufferOffsetXY(0, y); for (int x = 0; x < m_dilation; x++) { for (int channel = 0; channel < bytesPerPixel; channel++) { destBuffer[d1Offset++] = srcBuffer[s1Offset++]; destBuffer[d2Offset++] = srcBuffer[s2Offset++]; } } } }
public override void ToPix(ref Color c) { c.red = (byte)AggBasics.uround(r); }
public int Calculate(int x, int y, int d) { return((int)AggBasics.uround(System.Math.Abs(System.Math.Atan2((double)(y), (double)(x))) * (double)(d) / System.Math.PI)); }