+ use c++ headers
+ apply mapnik c++ style formatting
This commit is contained in:
parent
5826c1c6ec
commit
c0b4eda911
57 changed files with 10825 additions and 10825 deletions
2
deps/agg/include/agg_alpha_mask_u8.h
vendored
2
deps/agg/include/agg_alpha_mask_u8.h
vendored
|
@ -19,7 +19,7 @@
|
|||
#ifndef AGG_ALPHA_MASK_U8_INCLUDED
|
||||
#define AGG_ALPHA_MASK_U8_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
|
|
2
deps/agg/include/agg_arc.h
vendored
2
deps/agg/include/agg_arc.h
vendored
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGG_ARC_INCLUDED
|
||||
#define AGG_ARC_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
4
deps/agg/include/agg_array.h
vendored
4
deps/agg/include/agg_array.h
vendored
|
@ -15,8 +15,8 @@
|
|||
#ifndef AGG_ARRAY_INCLUDED
|
||||
#define AGG_ARRAY_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_basics.h
vendored
2
deps/agg/include/agg_basics.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_BASICS_INCLUDED
|
||||
#define AGG_BASICS_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_config.h"
|
||||
|
||||
//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR
|
||||
|
|
2
deps/agg/include/agg_color_rgba.h
vendored
2
deps/agg/include/agg_color_rgba.h
vendored
|
@ -24,7 +24,7 @@
|
|||
#ifndef AGG_COLOR_RGBA_INCLUDED
|
||||
#define AGG_COLOR_RGBA_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_conv_gpc.h
vendored
2
deps/agg/include/agg_conv_gpc.h
vendored
|
@ -24,7 +24,7 @@
|
|||
#ifndef AGG_CONV_GPC_INCLUDED
|
||||
#define AGG_CONV_GPC_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_array.h"
|
||||
|
||||
|
|
2
deps/agg/include/agg_dda_line.h
vendored
2
deps/agg/include/agg_dda_line.h
vendored
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGG_DDA_LINE_INCLUDED
|
||||
#define AGG_DDA_LINE_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_ellipse.h
vendored
2
deps/agg/include/agg_ellipse.h
vendored
|
@ -21,7 +21,7 @@
|
|||
#define AGG_ELLIPSE_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
|
2
deps/agg/include/agg_font_cache_manager.h
vendored
2
deps/agg/include/agg_font_cache_manager.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_FONT_CACHE_MANAGER_INCLUDED
|
||||
#define AGG_FONT_CACHE_MANAGER_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_gamma_functions.h
vendored
2
deps/agg/include/agg_gamma_functions.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_GAMMA_FUNCTIONS_INCLUDED
|
||||
#define AGG_GAMMA_FUNCTIONS_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_gamma_lut.h
vendored
2
deps/agg/include/agg_gamma_lut.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_GAMMA_LUT_INCLUDED
|
||||
#define AGG_GAMMA_LUT_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_glyph_raster_bin.h
vendored
2
deps/agg/include/agg_glyph_raster_bin.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_GLYPH_RASTER_BIN_INCLUDED
|
||||
#define AGG_GLYPH_RASTER_BIN_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_line_aa_basics.h
vendored
2
deps/agg/include/agg_line_aa_basics.h
vendored
|
@ -15,7 +15,7 @@
|
|||
#ifndef AGG_LINE_AA_BASICS_INCLUDED
|
||||
#define AGG_LINE_AA_BASICS_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_math.h
vendored
2
deps/agg/include/agg_math.h
vendored
|
@ -19,7 +19,7 @@
|
|||
#ifndef AGG_MATH_INCLUDED
|
||||
#define AGG_MATH_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
4
deps/agg/include/agg_path_storage.h
vendored
4
deps/agg/include/agg_path_storage.h
vendored
|
@ -16,8 +16,8 @@
|
|||
#ifndef AGG_PATH_STORAGE_INCLUDED
|
||||
#define AGG_PATH_STORAGE_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include "agg_math.h"
|
||||
#include "agg_array.h"
|
||||
#include "agg_bezier_arc.h"
|
||||
|
|
2
deps/agg/include/agg_path_storage_integer.h
vendored
2
deps/agg/include/agg_path_storage_integer.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED
|
||||
#define AGG_PATH_STORAGE_INTEGER_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_pixfmt_amask_adaptor.h
vendored
2
deps/agg/include/agg_pixfmt_amask_adaptor.h
vendored
|
@ -17,7 +17,7 @@
|
|||
#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
|
|
2
deps/agg/include/agg_pixfmt_gray.h
vendored
2
deps/agg/include/agg_pixfmt_gray.h
vendored
|
@ -24,7 +24,7 @@
|
|||
#ifndef AGG_PIXFMT_GRAY_INCLUDED
|
||||
#define AGG_PIXFMT_GRAY_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_gray.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
2
deps/agg/include/agg_pixfmt_rgb.h
vendored
2
deps/agg/include/agg_pixfmt_rgb.h
vendored
|
@ -24,7 +24,7 @@
|
|||
#ifndef AGG_PIXFMT_RGB_INCLUDED
|
||||
#define AGG_PIXFMT_RGB_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
2
deps/agg/include/agg_pixfmt_rgb_packed.h
vendored
2
deps/agg/include/agg_pixfmt_rgb_packed.h
vendored
|
@ -24,7 +24,7 @@
|
|||
#ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED
|
||||
#define AGG_PIXFMT_RGB_PACKED_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
4
deps/agg/include/agg_pixfmt_rgba.h
vendored
4
deps/agg/include/agg_pixfmt_rgba.h
vendored
|
@ -25,8 +25,8 @@
|
|||
#ifndef AGG_PIXFMT_RGBA_INCLUDED
|
||||
#define AGG_PIXFMT_RGBA_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
2
deps/agg/include/agg_rasterizer_cells_aa.h
vendored
2
deps/agg/include/agg_rasterizer_cells_aa.h
vendored
|
@ -29,7 +29,7 @@
|
|||
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
|
||||
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include "agg_math.h"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#ifndef AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED
|
||||
#define AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
|
||||
|
|
6
deps/agg/include/agg_scanline_storage_aa.h
vendored
6
deps/agg/include/agg_scanline_storage_aa.h
vendored
|
@ -24,9 +24,9 @@
|
|||
#ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED
|
||||
#define AGG_SCANLINE_STORAGE_AA_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "agg_array.h"
|
||||
|
||||
|
||||
|
|
6
deps/agg/include/agg_scanline_storage_bin.h
vendored
6
deps/agg/include/agg_scanline_storage_bin.h
vendored
|
@ -25,9 +25,9 @@
|
|||
#ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED
|
||||
#define AGG_SCANLINE_STORAGE_BIN_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "agg_array.h"
|
||||
|
||||
|
||||
|
|
2
deps/agg/include/agg_simul_eq.h
vendored
2
deps/agg/include/agg_simul_eq.h
vendored
|
@ -19,7 +19,7 @@
|
|||
#ifndef AGG_SIMUL_EQ_INCLUDED
|
||||
#define AGG_SIMUL_EQ_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
6
deps/agg/include/agg_span_gradient.h
vendored
6
deps/agg/include/agg_span_gradient.h
vendored
|
@ -16,9 +16,9 @@
|
|||
#ifndef AGG_SPAN_GRADIENT_INCLUDED
|
||||
#define AGG_SPAN_GRADIENT_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_math.h"
|
||||
#include "agg_array.h"
|
||||
|
|
2
deps/agg/include/agg_trans_affine.h
vendored
2
deps/agg/include/agg_trans_affine.h
vendored
|
@ -19,7 +19,7 @@
|
|||
#ifndef AGG_TRANS_AFFINE_INCLUDED
|
||||
#define AGG_TRANS_AFFINE_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
2
deps/agg/include/agg_trans_lens.h
vendored
2
deps/agg/include/agg_trans_lens.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_WARP_MAGNIFIER_INCLUDED
|
||||
#define AGG_WARP_MAGNIFIER_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
|
||||
|
|
2
deps/agg/include/agg_trans_viewport.h
vendored
2
deps/agg/include/agg_trans_viewport.h
vendored
|
@ -21,7 +21,7 @@
|
|||
#ifndef AGG_TRANS_VIEWPORT_INCLUDED
|
||||
#define AGG_TRANS_VIEWPORT_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
|
||||
|
|
2
deps/agg/include/agg_vpgen_segmentator.h
vendored
2
deps/agg/include/agg_vpgen_segmentator.h
vendored
|
@ -16,7 +16,7 @@
|
|||
#ifndef AGG_VPGEN_SEGMENTATOR_INCLUDED
|
||||
#define AGG_VPGEN_SEGMENTATOR_INCLUDED
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg
|
||||
|
|
148
deps/agg/src/agg_arc.cpp
vendored
148
deps/agg/src/agg_arc.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -23,84 +23,84 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------------------
|
||||
arc::arc(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw) :
|
||||
m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0)
|
||||
//------------------------------------------------------------------------
|
||||
arc::arc(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw) :
|
||||
m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0)
|
||||
{
|
||||
normalize(a1, a2, ccw);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::init(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw)
|
||||
{
|
||||
m_x = x; m_y = y;
|
||||
m_rx = rx; m_ry = ry;
|
||||
normalize(a1, a2, ccw);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::approximation_scale(double s)
|
||||
{
|
||||
m_scale = s;
|
||||
if(m_initialized)
|
||||
{
|
||||
normalize(a1, a2, ccw);
|
||||
normalize(m_start, m_end, m_ccw);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::rewind(unsigned)
|
||||
{
|
||||
m_path_cmd = path_cmd_move_to;
|
||||
m_angle = m_start;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned arc::vertex(double* x, double* y)
|
||||
{
|
||||
if(is_stop(m_path_cmd)) return path_cmd_stop;
|
||||
if((m_angle < m_end - m_da/4) != m_ccw)
|
||||
{
|
||||
*x = m_x + cos(m_end) * m_rx;
|
||||
*y = m_y + sin(m_end) * m_ry;
|
||||
m_path_cmd = path_cmd_stop;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::init(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw)
|
||||
*x = m_x + cos(m_angle) * m_rx;
|
||||
*y = m_y + sin(m_angle) * m_ry;
|
||||
|
||||
m_angle += m_da;
|
||||
|
||||
unsigned pf = m_path_cmd;
|
||||
m_path_cmd = path_cmd_line_to;
|
||||
return pf;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::normalize(double a1, double a2, bool ccw)
|
||||
{
|
||||
double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
|
||||
m_da = acos(ra / (ra + 0.125 / m_scale)) * 2;
|
||||
if(ccw)
|
||||
{
|
||||
m_x = x; m_y = y;
|
||||
m_rx = rx; m_ry = ry;
|
||||
normalize(a1, a2, ccw);
|
||||
while(a2 < a1) a2 += pi * 2.0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::approximation_scale(double s)
|
||||
else
|
||||
{
|
||||
m_scale = s;
|
||||
if(m_initialized)
|
||||
{
|
||||
normalize(m_start, m_end, m_ccw);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::rewind(unsigned)
|
||||
{
|
||||
m_path_cmd = path_cmd_move_to;
|
||||
m_angle = m_start;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned arc::vertex(double* x, double* y)
|
||||
{
|
||||
if(is_stop(m_path_cmd)) return path_cmd_stop;
|
||||
if((m_angle < m_end - m_da/4) != m_ccw)
|
||||
{
|
||||
*x = m_x + cos(m_end) * m_rx;
|
||||
*y = m_y + sin(m_end) * m_ry;
|
||||
m_path_cmd = path_cmd_stop;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
|
||||
*x = m_x + cos(m_angle) * m_rx;
|
||||
*y = m_y + sin(m_angle) * m_ry;
|
||||
|
||||
m_angle += m_da;
|
||||
|
||||
unsigned pf = m_path_cmd;
|
||||
m_path_cmd = path_cmd_line_to;
|
||||
return pf;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arc::normalize(double a1, double a2, bool ccw)
|
||||
{
|
||||
double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
|
||||
m_da = acos(ra / (ra + 0.125 / m_scale)) * 2;
|
||||
if(ccw)
|
||||
{
|
||||
while(a2 < a1) a2 += pi * 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(a1 < a2) a1 += pi * 2.0;
|
||||
m_da = -m_da;
|
||||
}
|
||||
m_ccw = ccw;
|
||||
m_start = a1;
|
||||
m_end = a2;
|
||||
m_initialized = true;
|
||||
while(a1 < a2) a1 += pi * 2.0;
|
||||
m_da = -m_da;
|
||||
}
|
||||
m_ccw = ccw;
|
||||
m_start = a1;
|
||||
m_end = a2;
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
148
deps/agg/src/agg_arrowhead.cpp
vendored
148
deps/agg/src/agg_arrowhead.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -13,7 +13,7 @@
|
|||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Simple arrowhead/arrowtail generator
|
||||
// Simple arrowhead/arrowtail generator
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
@ -22,89 +22,89 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
arrowhead::arrowhead() :
|
||||
m_head_d1(1.0),
|
||||
m_head_d2(1.0),
|
||||
m_head_d3(1.0),
|
||||
m_head_d4(0.0),
|
||||
m_tail_d1(1.0),
|
||||
m_tail_d2(1.0),
|
||||
m_tail_d3(1.0),
|
||||
m_tail_d4(0.0),
|
||||
m_head_flag(false),
|
||||
m_tail_flag(false),
|
||||
m_curr_id(0),
|
||||
m_curr_coord(0)
|
||||
//------------------------------------------------------------------------
|
||||
arrowhead::arrowhead() :
|
||||
m_head_d1(1.0),
|
||||
m_head_d2(1.0),
|
||||
m_head_d3(1.0),
|
||||
m_head_d4(0.0),
|
||||
m_tail_d1(1.0),
|
||||
m_tail_d2(1.0),
|
||||
m_tail_d3(1.0),
|
||||
m_tail_d4(0.0),
|
||||
m_head_flag(false),
|
||||
m_tail_flag(false),
|
||||
m_curr_id(0),
|
||||
m_curr_coord(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arrowhead::rewind(unsigned path_id)
|
||||
{
|
||||
m_curr_id = path_id;
|
||||
m_curr_coord = 0;
|
||||
if(path_id == 0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void arrowhead::rewind(unsigned path_id)
|
||||
{
|
||||
m_curr_id = path_id;
|
||||
m_curr_coord = 0;
|
||||
if(path_id == 0)
|
||||
if(!m_tail_flag)
|
||||
{
|
||||
if(!m_tail_flag)
|
||||
{
|
||||
m_cmd[0] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
m_coord[0] = m_tail_d1; m_coord[1] = 0.0;
|
||||
m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3;
|
||||
m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3;
|
||||
m_coord[6] = -m_tail_d2; m_coord[7] = 0.0;
|
||||
m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3;
|
||||
m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3;
|
||||
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_cmd[1] = path_cmd_line_to;
|
||||
m_cmd[2] = path_cmd_line_to;
|
||||
m_cmd[3] = path_cmd_line_to;
|
||||
m_cmd[4] = path_cmd_line_to;
|
||||
m_cmd[5] = path_cmd_line_to;
|
||||
m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_cmd[6] = path_cmd_stop;
|
||||
m_cmd[0] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
m_coord[0] = m_tail_d1; m_coord[1] = 0.0;
|
||||
m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3;
|
||||
m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3;
|
||||
m_coord[6] = -m_tail_d2; m_coord[7] = 0.0;
|
||||
m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3;
|
||||
m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3;
|
||||
|
||||
if(path_id == 1)
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_cmd[1] = path_cmd_line_to;
|
||||
m_cmd[2] = path_cmd_line_to;
|
||||
m_cmd[3] = path_cmd_line_to;
|
||||
m_cmd[4] = path_cmd_line_to;
|
||||
m_cmd[5] = path_cmd_line_to;
|
||||
m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_cmd[6] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
|
||||
if(path_id == 1)
|
||||
{
|
||||
if(!m_head_flag)
|
||||
{
|
||||
if(!m_head_flag)
|
||||
{
|
||||
m_cmd[0] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
m_coord[0] = -m_head_d1; m_coord[1] = 0.0;
|
||||
m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3;
|
||||
m_coord[4] = m_head_d2; m_coord[5] = 0.0;
|
||||
m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3;
|
||||
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_cmd[1] = path_cmd_line_to;
|
||||
m_cmd[2] = path_cmd_line_to;
|
||||
m_cmd[3] = path_cmd_line_to;
|
||||
m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_cmd[5] = path_cmd_stop;
|
||||
m_cmd[0] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
m_coord[0] = -m_head_d1; m_coord[1] = 0.0;
|
||||
m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3;
|
||||
m_coord[4] = m_head_d2; m_coord[5] = 0.0;
|
||||
m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3;
|
||||
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_cmd[1] = path_cmd_line_to;
|
||||
m_cmd[2] = path_cmd_line_to;
|
||||
m_cmd[3] = path_cmd_line_to;
|
||||
m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_cmd[5] = path_cmd_stop;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned arrowhead::vertex(double* x, double* y)
|
||||
//------------------------------------------------------------------------
|
||||
unsigned arrowhead::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_curr_id < 2)
|
||||
{
|
||||
if(m_curr_id < 2)
|
||||
{
|
||||
unsigned curr_idx = m_curr_coord * 2;
|
||||
*x = m_coord[curr_idx];
|
||||
*y = m_coord[curr_idx + 1];
|
||||
return m_cmd[m_curr_coord++];
|
||||
}
|
||||
return path_cmd_stop;
|
||||
unsigned curr_idx = m_curr_coord * 2;
|
||||
*x = m_coord[curr_idx];
|
||||
*y = m_coord[curr_idx + 1];
|
||||
return m_cmd[m_curr_coord++];
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
412
deps/agg/src/agg_bezier_arc.cpp
vendored
412
deps/agg/src/agg_bezier_arc.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -13,7 +13,7 @@
|
|||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e.,
|
||||
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e.,
|
||||
// 4, 7, 10, or 13 vertices.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -26,233 +26,233 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
// This epsilon is used to prevent us from adding degenerate curves
|
||||
// (converging to a single point).
|
||||
// The value isn't very critical. Function arc_to_bezier() has a limit
|
||||
// of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
|
||||
// becomes inaccurate. But slight exceeding is quite appropriate.
|
||||
//-------------------------------------------------bezier_arc_angle_epsilon
|
||||
const double bezier_arc_angle_epsilon = 0.01;
|
||||
// This epsilon is used to prevent us from adding degenerate curves
|
||||
// (converging to a single point).
|
||||
// The value isn't very critical. Function arc_to_bezier() has a limit
|
||||
// of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
|
||||
// becomes inaccurate. But slight exceeding is quite appropriate.
|
||||
//-------------------------------------------------bezier_arc_angle_epsilon
|
||||
const double bezier_arc_angle_epsilon = 0.01;
|
||||
|
||||
//------------------------------------------------------------arc_to_bezier
|
||||
void arc_to_bezier(double cx, double cy, double rx, double ry,
|
||||
double start_angle, double sweep_angle,
|
||||
double* curve)
|
||||
//------------------------------------------------------------arc_to_bezier
|
||||
void arc_to_bezier(double cx, double cy, double rx, double ry,
|
||||
double start_angle, double sweep_angle,
|
||||
double* curve)
|
||||
{
|
||||
double x0 = cos(sweep_angle / 2.0);
|
||||
double y0 = sin(sweep_angle / 2.0);
|
||||
double tx = (1.0 - x0) * 4.0 / 3.0;
|
||||
double ty = y0 - tx * x0 / y0;
|
||||
double px[4];
|
||||
double py[4];
|
||||
px[0] = x0;
|
||||
py[0] = -y0;
|
||||
px[1] = x0 + tx;
|
||||
py[1] = -ty;
|
||||
px[2] = x0 + tx;
|
||||
py[2] = ty;
|
||||
px[3] = x0;
|
||||
py[3] = y0;
|
||||
|
||||
double sn = sin(start_angle + sweep_angle / 2.0);
|
||||
double cs = cos(start_angle + sweep_angle / 2.0);
|
||||
|
||||
unsigned i;
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
double x0 = cos(sweep_angle / 2.0);
|
||||
double y0 = sin(sweep_angle / 2.0);
|
||||
double tx = (1.0 - x0) * 4.0 / 3.0;
|
||||
double ty = y0 - tx * x0 / y0;
|
||||
double px[4];
|
||||
double py[4];
|
||||
px[0] = x0;
|
||||
py[0] = -y0;
|
||||
px[1] = x0 + tx;
|
||||
py[1] = -ty;
|
||||
px[2] = x0 + tx;
|
||||
py[2] = ty;
|
||||
px[3] = x0;
|
||||
py[3] = y0;
|
||||
curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn);
|
||||
curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs);
|
||||
}
|
||||
}
|
||||
|
||||
double sn = sin(start_angle + sweep_angle / 2.0);
|
||||
double cs = cos(start_angle + sweep_angle / 2.0);
|
||||
|
||||
unsigned i;
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn);
|
||||
curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bezier_arc::init(double x, double y,
|
||||
double rx, double ry,
|
||||
double start_angle,
|
||||
double sweep_angle)
|
||||
{
|
||||
start_angle = fmod(start_angle, 2.0 * pi);
|
||||
if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi;
|
||||
if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi;
|
||||
|
||||
if(fabs(sweep_angle) < 1e-10)
|
||||
{
|
||||
m_num_vertices = 4;
|
||||
m_cmd = path_cmd_line_to;
|
||||
m_vertices[0] = x + rx * cos(start_angle);
|
||||
m_vertices[1] = y + ry * sin(start_angle);
|
||||
m_vertices[2] = x + rx * cos(start_angle + sweep_angle);
|
||||
m_vertices[3] = y + ry * sin(start_angle + sweep_angle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bezier_arc::init(double x, double y,
|
||||
double rx, double ry,
|
||||
double start_angle,
|
||||
double sweep_angle)
|
||||
double total_sweep = 0.0;
|
||||
double local_sweep = 0.0;
|
||||
double prev_sweep;
|
||||
m_num_vertices = 2;
|
||||
m_cmd = path_cmd_curve4;
|
||||
bool done = false;
|
||||
do
|
||||
{
|
||||
start_angle = fmod(start_angle, 2.0 * pi);
|
||||
if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi;
|
||||
if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi;
|
||||
|
||||
if(fabs(sweep_angle) < 1e-10)
|
||||
if(sweep_angle < 0.0)
|
||||
{
|
||||
m_num_vertices = 4;
|
||||
m_cmd = path_cmd_line_to;
|
||||
m_vertices[0] = x + rx * cos(start_angle);
|
||||
m_vertices[1] = y + ry * sin(start_angle);
|
||||
m_vertices[2] = x + rx * cos(start_angle + sweep_angle);
|
||||
m_vertices[3] = y + ry * sin(start_angle + sweep_angle);
|
||||
return;
|
||||
prev_sweep = total_sweep;
|
||||
local_sweep = -pi * 0.5;
|
||||
total_sweep -= pi * 0.5;
|
||||
if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
|
||||
{
|
||||
local_sweep = sweep_angle - prev_sweep;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_sweep = total_sweep;
|
||||
local_sweep = pi * 0.5;
|
||||
total_sweep += pi * 0.5;
|
||||
if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
|
||||
{
|
||||
local_sweep = sweep_angle - prev_sweep;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
double total_sweep = 0.0;
|
||||
double local_sweep = 0.0;
|
||||
double prev_sweep;
|
||||
m_num_vertices = 2;
|
||||
m_cmd = path_cmd_curve4;
|
||||
bool done = false;
|
||||
do
|
||||
{
|
||||
if(sweep_angle < 0.0)
|
||||
{
|
||||
prev_sweep = total_sweep;
|
||||
local_sweep = -pi * 0.5;
|
||||
total_sweep -= pi * 0.5;
|
||||
if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
|
||||
{
|
||||
local_sweep = sweep_angle - prev_sweep;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_sweep = total_sweep;
|
||||
local_sweep = pi * 0.5;
|
||||
total_sweep += pi * 0.5;
|
||||
if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
|
||||
{
|
||||
local_sweep = sweep_angle - prev_sweep;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
arc_to_bezier(x, y, rx, ry,
|
||||
start_angle,
|
||||
local_sweep,
|
||||
m_vertices + m_num_vertices - 2);
|
||||
|
||||
arc_to_bezier(x, y, rx, ry,
|
||||
start_angle,
|
||||
local_sweep,
|
||||
m_vertices + m_num_vertices - 2);
|
||||
m_num_vertices += 6;
|
||||
start_angle += local_sweep;
|
||||
}
|
||||
while(!done && m_num_vertices < 26);
|
||||
}
|
||||
|
||||
m_num_vertices += 6;
|
||||
start_angle += local_sweep;
|
||||
}
|
||||
while(!done && m_num_vertices < 26);
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void bezier_arc_svg::init(double x0, double y0,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x2, double y2)
|
||||
{
|
||||
m_radii_ok = true;
|
||||
|
||||
if(rx < 0.0) rx = -rx;
|
||||
if(ry < 0.0) ry = -rx;
|
||||
|
||||
// Calculate the middle point between
|
||||
// the current and the final points
|
||||
//------------------------
|
||||
double dx2 = (x0 - x2) / 2.0;
|
||||
double dy2 = (y0 - y2) / 2.0;
|
||||
|
||||
double cos_a = cos(angle);
|
||||
double sin_a = sin(angle);
|
||||
|
||||
// Calculate (x1, y1)
|
||||
//------------------------
|
||||
double x1 = cos_a * dx2 + sin_a * dy2;
|
||||
double y1 = -sin_a * dx2 + cos_a * dy2;
|
||||
|
||||
// Ensure radii are large enough
|
||||
//------------------------
|
||||
double prx = rx * rx;
|
||||
double pry = ry * ry;
|
||||
double px1 = x1 * x1;
|
||||
double py1 = y1 * y1;
|
||||
|
||||
// Check that radii are large enough
|
||||
//------------------------
|
||||
double radii_check = px1/prx + py1/pry;
|
||||
if(radii_check > 1.0)
|
||||
{
|
||||
rx = sqrt(radii_check) * rx;
|
||||
ry = sqrt(radii_check) * ry;
|
||||
prx = rx * rx;
|
||||
pry = ry * ry;
|
||||
if(radii_check > 10.0) m_radii_ok = false;
|
||||
}
|
||||
|
||||
// Calculate (cx1, cy1)
|
||||
//------------------------
|
||||
double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0;
|
||||
double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1);
|
||||
double coef = sign * sqrt((sq < 0) ? 0 : sq);
|
||||
double cx1 = coef * ((rx * y1) / ry);
|
||||
double cy1 = coef * -((ry * x1) / rx);
|
||||
|
||||
//
|
||||
// Calculate (cx, cy) from (cx1, cy1)
|
||||
//------------------------
|
||||
double sx2 = (x0 + x2) / 2.0;
|
||||
double sy2 = (y0 + y2) / 2.0;
|
||||
double cx = sx2 + (cos_a * cx1 - sin_a * cy1);
|
||||
double cy = sy2 + (sin_a * cx1 + cos_a * cy1);
|
||||
|
||||
// Calculate the start_angle (angle1) and the sweep_angle (dangle)
|
||||
//------------------------
|
||||
double ux = (x1 - cx1) / rx;
|
||||
double uy = (y1 - cy1) / ry;
|
||||
double vx = (-x1 - cx1) / rx;
|
||||
double vy = (-y1 - cy1) / ry;
|
||||
double p, n;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void bezier_arc_svg::init(double x0, double y0,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x2, double y2)
|
||||
// Calculate the angle start
|
||||
//------------------------
|
||||
n = sqrt(ux*ux + uy*uy);
|
||||
p = ux; // (1 * ux) + (0 * uy)
|
||||
sign = (uy < 0) ? -1.0 : 1.0;
|
||||
double v = p / n;
|
||||
if(v < -1.0) v = -1.0;
|
||||
if(v > 1.0) v = 1.0;
|
||||
double start_angle = sign * acos(v);
|
||||
|
||||
// Calculate the sweep angle
|
||||
//------------------------
|
||||
n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
|
||||
p = ux * vx + uy * vy;
|
||||
sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
|
||||
v = p / n;
|
||||
if(v < -1.0) v = -1.0;
|
||||
if(v > 1.0) v = 1.0;
|
||||
double sweep_angle = sign * acos(v);
|
||||
if(!sweep_flag && sweep_angle > 0)
|
||||
{
|
||||
m_radii_ok = true;
|
||||
|
||||
if(rx < 0.0) rx = -rx;
|
||||
if(ry < 0.0) ry = -rx;
|
||||
|
||||
// Calculate the middle point between
|
||||
// the current and the final points
|
||||
//------------------------
|
||||
double dx2 = (x0 - x2) / 2.0;
|
||||
double dy2 = (y0 - y2) / 2.0;
|
||||
|
||||
double cos_a = cos(angle);
|
||||
double sin_a = sin(angle);
|
||||
|
||||
// Calculate (x1, y1)
|
||||
//------------------------
|
||||
double x1 = cos_a * dx2 + sin_a * dy2;
|
||||
double y1 = -sin_a * dx2 + cos_a * dy2;
|
||||
|
||||
// Ensure radii are large enough
|
||||
//------------------------
|
||||
double prx = rx * rx;
|
||||
double pry = ry * ry;
|
||||
double px1 = x1 * x1;
|
||||
double py1 = y1 * y1;
|
||||
|
||||
// Check that radii are large enough
|
||||
//------------------------
|
||||
double radii_check = px1/prx + py1/pry;
|
||||
if(radii_check > 1.0)
|
||||
{
|
||||
rx = sqrt(radii_check) * rx;
|
||||
ry = sqrt(radii_check) * ry;
|
||||
prx = rx * rx;
|
||||
pry = ry * ry;
|
||||
if(radii_check > 10.0) m_radii_ok = false;
|
||||
}
|
||||
|
||||
// Calculate (cx1, cy1)
|
||||
//------------------------
|
||||
double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0;
|
||||
double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1);
|
||||
double coef = sign * sqrt((sq < 0) ? 0 : sq);
|
||||
double cx1 = coef * ((rx * y1) / ry);
|
||||
double cy1 = coef * -((ry * x1) / rx);
|
||||
|
||||
//
|
||||
// Calculate (cx, cy) from (cx1, cy1)
|
||||
//------------------------
|
||||
double sx2 = (x0 + x2) / 2.0;
|
||||
double sy2 = (y0 + y2) / 2.0;
|
||||
double cx = sx2 + (cos_a * cx1 - sin_a * cy1);
|
||||
double cy = sy2 + (sin_a * cx1 + cos_a * cy1);
|
||||
|
||||
// Calculate the start_angle (angle1) and the sweep_angle (dangle)
|
||||
//------------------------
|
||||
double ux = (x1 - cx1) / rx;
|
||||
double uy = (y1 - cy1) / ry;
|
||||
double vx = (-x1 - cx1) / rx;
|
||||
double vy = (-y1 - cy1) / ry;
|
||||
double p, n;
|
||||
|
||||
// Calculate the angle start
|
||||
//------------------------
|
||||
n = sqrt(ux*ux + uy*uy);
|
||||
p = ux; // (1 * ux) + (0 * uy)
|
||||
sign = (uy < 0) ? -1.0 : 1.0;
|
||||
double v = p / n;
|
||||
if(v < -1.0) v = -1.0;
|
||||
if(v > 1.0) v = 1.0;
|
||||
double start_angle = sign * acos(v);
|
||||
|
||||
// Calculate the sweep angle
|
||||
//------------------------
|
||||
n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
|
||||
p = ux * vx + uy * vy;
|
||||
sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
|
||||
v = p / n;
|
||||
if(v < -1.0) v = -1.0;
|
||||
if(v > 1.0) v = 1.0;
|
||||
double sweep_angle = sign * acos(v);
|
||||
if(!sweep_flag && sweep_angle > 0)
|
||||
{
|
||||
sweep_angle -= pi * 2.0;
|
||||
}
|
||||
else
|
||||
if (sweep_flag && sweep_angle < 0)
|
||||
sweep_angle -= pi * 2.0;
|
||||
}
|
||||
else
|
||||
if (sweep_flag && sweep_angle < 0)
|
||||
{
|
||||
sweep_angle += pi * 2.0;
|
||||
}
|
||||
|
||||
// We can now build and transform the resulting arc
|
||||
//------------------------
|
||||
m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
|
||||
trans_affine mtx = trans_affine_rotation(angle);
|
||||
mtx *= trans_affine_translation(cx, cy);
|
||||
|
||||
for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
|
||||
{
|
||||
mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);
|
||||
}
|
||||
// We can now build and transform the resulting arc
|
||||
//------------------------
|
||||
m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
|
||||
trans_affine mtx = trans_affine_rotation(angle);
|
||||
mtx *= trans_affine_translation(cx, cy);
|
||||
|
||||
// We must make sure that the starting and ending points
|
||||
// exactly coincide with the initial (x0,y0) and (x2,y2)
|
||||
m_arc.vertices()[0] = x0;
|
||||
m_arc.vertices()[1] = y0;
|
||||
if(m_arc.num_vertices() > 2)
|
||||
{
|
||||
m_arc.vertices()[m_arc.num_vertices() - 2] = x2;
|
||||
m_arc.vertices()[m_arc.num_vertices() - 1] = y2;
|
||||
}
|
||||
for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
|
||||
{
|
||||
mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);
|
||||
}
|
||||
|
||||
// We must make sure that the starting and ending points
|
||||
// exactly coincide with the initial (x0,y0) and (x2,y2)
|
||||
m_arc.vertices()[0] = x0;
|
||||
m_arc.vertices()[1] = y0;
|
||||
if(m_arc.num_vertices() > 2)
|
||||
{
|
||||
m_arc.vertices()[m_arc.num_vertices() - 2] = x2;
|
||||
m_arc.vertices()[m_arc.num_vertices() - 1] = y2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
470
deps/agg/src/agg_bspline.cpp
vendored
470
deps/agg/src/agg_bspline.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -21,242 +21,242 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline() :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline() :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline(int num) :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline(int num) :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
{
|
||||
init(num);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline(int num, const double* x, const double* y) :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
{
|
||||
init(num, x, y);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::init(int max)
|
||||
{
|
||||
if(max > 2 && max > m_max)
|
||||
{
|
||||
m_am.resize(max * 3);
|
||||
m_max = max;
|
||||
m_x = &m_am[m_max];
|
||||
m_y = &m_am[m_max * 2];
|
||||
}
|
||||
m_num = 0;
|
||||
m_last_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::add_point(double x, double y)
|
||||
{
|
||||
if(m_num < m_max)
|
||||
{
|
||||
m_x[m_num] = x;
|
||||
m_y[m_num] = y;
|
||||
++m_num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::prepare()
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
int i, k, n1;
|
||||
double* temp;
|
||||
double* r;
|
||||
double* s;
|
||||
double h, p, d, f, e;
|
||||
|
||||
for(k = 0; k < m_num; k++)
|
||||
{
|
||||
m_am[k] = 0.0;
|
||||
}
|
||||
|
||||
n1 = 3 * m_num;
|
||||
|
||||
pod_array<double> al(n1);
|
||||
temp = &al[0];
|
||||
|
||||
for(k = 0; k < n1; k++)
|
||||
{
|
||||
temp[k] = 0.0;
|
||||
}
|
||||
|
||||
r = temp + m_num;
|
||||
s = temp + m_num * 2;
|
||||
|
||||
n1 = m_num - 1;
|
||||
d = m_x[1] - m_x[0];
|
||||
e = (m_y[1] - m_y[0]) / d;
|
||||
|
||||
for(k = 1; k < n1; k++)
|
||||
{
|
||||
h = d;
|
||||
d = m_x[k + 1] - m_x[k];
|
||||
f = e;
|
||||
e = (m_y[k + 1] - m_y[k]) / d;
|
||||
al[k] = d / (d + h);
|
||||
r[k] = 1.0 - al[k];
|
||||
s[k] = 6.0 * (e - f) / (h + d);
|
||||
}
|
||||
|
||||
for(k = 1; k < n1; k++)
|
||||
{
|
||||
p = 1.0 / (r[k] * al[k - 1] + 2.0);
|
||||
al[k] *= -p;
|
||||
s[k] = (s[k] - r[k] * s[k - 1]) * p;
|
||||
}
|
||||
|
||||
m_am[n1] = 0.0;
|
||||
al[n1 - 1] = s[n1 - 1];
|
||||
m_am[n1 - 1] = al[n1 - 1];
|
||||
|
||||
for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
|
||||
{
|
||||
al[k] = al[k] * al[k + 1] + s[k];
|
||||
m_am[k] = al[k];
|
||||
}
|
||||
}
|
||||
m_last_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::init(int num, const double* x, const double* y)
|
||||
{
|
||||
if(num > 2)
|
||||
{
|
||||
init(num);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bspline::bspline(int num, const double* x, const double* y) :
|
||||
m_max(0),
|
||||
m_num(0),
|
||||
m_x(0),
|
||||
m_y(0),
|
||||
m_last_idx(-1)
|
||||
{
|
||||
init(num, x, y);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::init(int max)
|
||||
{
|
||||
if(max > 2 && max > m_max)
|
||||
int i;
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
m_am.resize(max * 3);
|
||||
m_max = max;
|
||||
m_x = &m_am[m_max];
|
||||
m_y = &m_am[m_max * 2];
|
||||
add_point(*x++, *y++);
|
||||
}
|
||||
m_num = 0;
|
||||
m_last_idx = -1;
|
||||
prepare();
|
||||
}
|
||||
m_last_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::add_point(double x, double y)
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::bsearch(int n, const double *x, double x0, int *i)
|
||||
{
|
||||
int j = n - 1;
|
||||
int k;
|
||||
|
||||
for(*i = 0; (j - *i) > 1; )
|
||||
{
|
||||
if(m_num < m_max)
|
||||
if(x0 < x[k = (*i + j) >> 1]) j = k;
|
||||
else *i = k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::interpolation(double x, int i) const
|
||||
{
|
||||
int j = i + 1;
|
||||
double d = m_x[i] - m_x[j];
|
||||
double h = x - m_x[j];
|
||||
double r = m_x[i] - x;
|
||||
double p = d * d / 6.0;
|
||||
return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
|
||||
((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::extrapolation_left(double x) const
|
||||
{
|
||||
double d = m_x[1] - m_x[0];
|
||||
return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
|
||||
(x - m_x[0]) +
|
||||
m_y[0];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::extrapolation_right(double x) const
|
||||
{
|
||||
double d = m_x[m_num - 1] - m_x[m_num - 2];
|
||||
return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
|
||||
(x - m_x[m_num - 1]) +
|
||||
m_y[m_num - 1];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::get(double x) const
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Extrapolation on the left
|
||||
if(x < m_x[0]) return extrapolation_left(x);
|
||||
|
||||
// Extrapolation on the right
|
||||
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
|
||||
|
||||
// Interpolation
|
||||
bsearch(m_num, m_x, x, &i);
|
||||
return interpolation(x, i);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::get_stateful(double x) const
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
// Extrapolation on the left
|
||||
if(x < m_x[0]) return extrapolation_left(x);
|
||||
|
||||
// Extrapolation on the right
|
||||
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
|
||||
|
||||
if(m_last_idx >= 0)
|
||||
{
|
||||
m_x[m_num] = x;
|
||||
m_y[m_num] = y;
|
||||
++m_num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::prepare()
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
int i, k, n1;
|
||||
double* temp;
|
||||
double* r;
|
||||
double* s;
|
||||
double h, p, d, f, e;
|
||||
|
||||
for(k = 0; k < m_num; k++)
|
||||
// Check if x is not in current range
|
||||
if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
|
||||
{
|
||||
m_am[k] = 0.0;
|
||||
}
|
||||
|
||||
n1 = 3 * m_num;
|
||||
|
||||
pod_array<double> al(n1);
|
||||
temp = &al[0];
|
||||
|
||||
for(k = 0; k < n1; k++)
|
||||
{
|
||||
temp[k] = 0.0;
|
||||
}
|
||||
|
||||
r = temp + m_num;
|
||||
s = temp + m_num * 2;
|
||||
|
||||
n1 = m_num - 1;
|
||||
d = m_x[1] - m_x[0];
|
||||
e = (m_y[1] - m_y[0]) / d;
|
||||
|
||||
for(k = 1; k < n1; k++)
|
||||
{
|
||||
h = d;
|
||||
d = m_x[k + 1] - m_x[k];
|
||||
f = e;
|
||||
e = (m_y[k + 1] - m_y[k]) / d;
|
||||
al[k] = d / (d + h);
|
||||
r[k] = 1.0 - al[k];
|
||||
s[k] = 6.0 * (e - f) / (h + d);
|
||||
}
|
||||
|
||||
for(k = 1; k < n1; k++)
|
||||
{
|
||||
p = 1.0 / (r[k] * al[k - 1] + 2.0);
|
||||
al[k] *= -p;
|
||||
s[k] = (s[k] - r[k] * s[k - 1]) * p;
|
||||
}
|
||||
|
||||
m_am[n1] = 0.0;
|
||||
al[n1 - 1] = s[n1 - 1];
|
||||
m_am[n1 - 1] = al[n1 - 1];
|
||||
|
||||
for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
|
||||
{
|
||||
al[k] = al[k] * al[k + 1] + s[k];
|
||||
m_am[k] = al[k];
|
||||
}
|
||||
}
|
||||
m_last_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::init(int num, const double* x, const double* y)
|
||||
{
|
||||
if(num > 2)
|
||||
{
|
||||
init(num);
|
||||
int i;
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
add_point(*x++, *y++);
|
||||
}
|
||||
prepare();
|
||||
}
|
||||
m_last_idx = -1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void bspline::bsearch(int n, const double *x, double x0, int *i)
|
||||
{
|
||||
int j = n - 1;
|
||||
int k;
|
||||
|
||||
for(*i = 0; (j - *i) > 1; )
|
||||
{
|
||||
if(x0 < x[k = (*i + j) >> 1]) j = k;
|
||||
else *i = k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::interpolation(double x, int i) const
|
||||
{
|
||||
int j = i + 1;
|
||||
double d = m_x[i] - m_x[j];
|
||||
double h = x - m_x[j];
|
||||
double r = m_x[i] - x;
|
||||
double p = d * d / 6.0;
|
||||
return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
|
||||
((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::extrapolation_left(double x) const
|
||||
{
|
||||
double d = m_x[1] - m_x[0];
|
||||
return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
|
||||
(x - m_x[0]) +
|
||||
m_y[0];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::extrapolation_right(double x) const
|
||||
{
|
||||
double d = m_x[m_num - 1] - m_x[m_num - 2];
|
||||
return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
|
||||
(x - m_x[m_num - 1]) +
|
||||
m_y[m_num - 1];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::get(double x) const
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Extrapolation on the left
|
||||
if(x < m_x[0]) return extrapolation_left(x);
|
||||
|
||||
// Extrapolation on the right
|
||||
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
|
||||
|
||||
// Interpolation
|
||||
bsearch(m_num, m_x, x, &i);
|
||||
return interpolation(x, i);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double bspline::get_stateful(double x) const
|
||||
{
|
||||
if(m_num > 2)
|
||||
{
|
||||
// Extrapolation on the left
|
||||
if(x < m_x[0]) return extrapolation_left(x);
|
||||
|
||||
// Extrapolation on the right
|
||||
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
|
||||
|
||||
if(m_last_idx >= 0)
|
||||
{
|
||||
// Check if x is not in current range
|
||||
if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
|
||||
// Check if x between next points (most probably)
|
||||
if(m_last_idx < m_num - 2 &&
|
||||
x >= m_x[m_last_idx + 1] &&
|
||||
x <= m_x[m_last_idx + 2])
|
||||
{
|
||||
// Check if x between next points (most probably)
|
||||
if(m_last_idx < m_num - 2 &&
|
||||
x >= m_x[m_last_idx + 1] &&
|
||||
x <= m_x[m_last_idx + 2])
|
||||
{
|
||||
++m_last_idx;
|
||||
}
|
||||
else
|
||||
if(m_last_idx > 0 &&
|
||||
x >= m_x[m_last_idx - 1] &&
|
||||
++m_last_idx;
|
||||
}
|
||||
else
|
||||
if(m_last_idx > 0 &&
|
||||
x >= m_x[m_last_idx - 1] &&
|
||||
x <= m_x[m_last_idx])
|
||||
{
|
||||
// x is between pevious points
|
||||
|
@ -267,18 +267,18 @@ namespace agg
|
|||
// Else perform full search
|
||||
bsearch(m_num, m_x, x, &m_last_idx);
|
||||
}
|
||||
}
|
||||
return interpolation(x, m_last_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Interpolation
|
||||
bsearch(m_num, m_x, x, &m_last_idx);
|
||||
return interpolation(x, m_last_idx);
|
||||
}
|
||||
return interpolation(x, m_last_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Interpolation
|
||||
bsearch(m_num, m_x, x, &m_last_idx);
|
||||
return interpolation(x, m_last_idx);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
1064
deps/agg/src/agg_curves.cpp
vendored
1064
deps/agg/src/agg_curves.cpp
vendored
File diff suppressed because it is too large
Load diff
14148
deps/agg/src/agg_embedded_raster_fonts.cpp
vendored
14148
deps/agg/src/agg_embedded_raster_fonts.cpp
vendored
File diff suppressed because it is too large
Load diff
1242
deps/agg/src/agg_gsv_text.cpp
vendored
1242
deps/agg/src/agg_gsv_text.cpp
vendored
File diff suppressed because it is too large
Load diff
126
deps/agg/src/agg_image_filters.cpp
vendored
126
deps/agg/src/agg_image_filters.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -23,81 +23,81 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//--------------------------------------------------------------------
|
||||
void image_filter_lut::realloc_lut(double radius)
|
||||
//--------------------------------------------------------------------
|
||||
void image_filter_lut::realloc_lut(double radius)
|
||||
{
|
||||
m_radius = radius;
|
||||
m_diameter = uceil(radius) * 2;
|
||||
m_start = -int(m_diameter / 2 - 1);
|
||||
unsigned size = m_diameter << image_subpixel_shift;
|
||||
if(size > m_weight_array.size())
|
||||
{
|
||||
m_radius = radius;
|
||||
m_diameter = uceil(radius) * 2;
|
||||
m_start = -int(m_diameter / 2 - 1);
|
||||
unsigned size = m_diameter << image_subpixel_shift;
|
||||
if(size > m_weight_array.size())
|
||||
{
|
||||
m_weight_array.resize(size);
|
||||
}
|
||||
m_weight_array.resize(size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 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.
|
||||
//--------------------------------------------------------------------
|
||||
void image_filter_lut::normalize()
|
||||
//--------------------------------------------------------------------
|
||||
// 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.
|
||||
//--------------------------------------------------------------------
|
||||
void image_filter_lut::normalize()
|
||||
{
|
||||
unsigned i;
|
||||
int flip = 1;
|
||||
|
||||
for(i = 0; i < image_subpixel_scale; i++)
|
||||
{
|
||||
unsigned i;
|
||||
int flip = 1;
|
||||
|
||||
for(i = 0; i < image_subpixel_scale; i++)
|
||||
for(;;)
|
||||
{
|
||||
for(;;)
|
||||
int sum = 0;
|
||||
unsigned j;
|
||||
for(j = 0; j < m_diameter; j++)
|
||||
{
|
||||
int sum = 0;
|
||||
unsigned j;
|
||||
for(j = 0; j < m_diameter; j++)
|
||||
sum += m_weight_array[j * image_subpixel_scale + i];
|
||||
}
|
||||
|
||||
if(sum == image_filter_scale) break;
|
||||
|
||||
double k = double(image_filter_scale) / double(sum);
|
||||
sum = 0;
|
||||
for(j = 0; j < m_diameter; j++)
|
||||
{
|
||||
sum += m_weight_array[j * image_subpixel_scale + i] =
|
||||
iround(m_weight_array[j * image_subpixel_scale + i] * k);
|
||||
}
|
||||
|
||||
sum -= image_filter_scale;
|
||||
int inc = (sum > 0) ? -1 : 1;
|
||||
|
||||
for(j = 0; j < m_diameter && sum; j++)
|
||||
{
|
||||
flip ^= 1;
|
||||
unsigned idx = flip ? m_diameter/2 + j/2 : m_diameter/2 - j/2;
|
||||
int v = m_weight_array[idx * image_subpixel_scale + i];
|
||||
if(v < image_filter_scale)
|
||||
{
|
||||
sum += m_weight_array[j * image_subpixel_scale + i];
|
||||
}
|
||||
|
||||
if(sum == image_filter_scale) break;
|
||||
|
||||
double k = double(image_filter_scale) / double(sum);
|
||||
sum = 0;
|
||||
for(j = 0; j < m_diameter; j++)
|
||||
{
|
||||
sum += m_weight_array[j * image_subpixel_scale + i] =
|
||||
iround(m_weight_array[j * image_subpixel_scale + i] * k);
|
||||
}
|
||||
|
||||
sum -= image_filter_scale;
|
||||
int inc = (sum > 0) ? -1 : 1;
|
||||
|
||||
for(j = 0; j < m_diameter && sum; j++)
|
||||
{
|
||||
flip ^= 1;
|
||||
unsigned idx = flip ? m_diameter/2 + j/2 : m_diameter/2 - j/2;
|
||||
int v = m_weight_array[idx * image_subpixel_scale + i];
|
||||
if(v < image_filter_scale)
|
||||
{
|
||||
m_weight_array[idx * image_subpixel_scale + i] += inc;
|
||||
sum += inc;
|
||||
}
|
||||
m_weight_array[idx * image_subpixel_scale + i] += inc;
|
||||
sum += inc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned pivot = m_diameter << (image_subpixel_shift - 1);
|
||||
|
||||
for(i = 0; i < pivot; i++)
|
||||
{
|
||||
m_weight_array[pivot + i] = m_weight_array[pivot - i];
|
||||
}
|
||||
unsigned end = (diameter() << image_subpixel_shift) - 1;
|
||||
m_weight_array[0] = m_weight_array[end];
|
||||
}
|
||||
|
||||
unsigned pivot = m_diameter << (image_subpixel_shift - 1);
|
||||
|
||||
for(i = 0; i < pivot; i++)
|
||||
{
|
||||
m_weight_array[pivot + i] = m_weight_array[pivot - i];
|
||||
}
|
||||
unsigned end = (diameter() << image_subpixel_shift) - 1;
|
||||
m_weight_array[0] = m_weight_array[end];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
114
deps/agg/src/agg_line_aa_basics.cpp
vendored
114
deps/agg/src/agg_line_aa_basics.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -18,65 +18,65 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//-------------------------------------------------------------------------
|
||||
// The number of the octant is determined as a 3-bit value as follows:
|
||||
// bit 0 = vertical flag
|
||||
// bit 1 = sx < 0
|
||||
// bit 2 = sy < 0
|
||||
//
|
||||
// [N] shows the number of the orthogonal quadrant
|
||||
// <M> shows the number of the diagonal quadrant
|
||||
// <1>
|
||||
// [1] | [0]
|
||||
// . (3)011 | 001(1) .
|
||||
// . | .
|
||||
// . | .
|
||||
// . | .
|
||||
// (2)010 .|. 000(0)
|
||||
// <2> ----------.+.----------- <0>
|
||||
// (6)110 . | . 100(4)
|
||||
// . | .
|
||||
// . | .
|
||||
// . | .
|
||||
// (7)111 | 101(5)
|
||||
// [2] | [3]
|
||||
// <3>
|
||||
// 0,1,2,3,4,5,6,7
|
||||
const int8u line_parameters::s_orthogonal_quadrant[8] = { 0,0,1,1,3,3,2,2 };
|
||||
const int8u line_parameters::s_diagonal_quadrant[8] = { 0,1,2,1,0,3,2,3 };
|
||||
//-------------------------------------------------------------------------
|
||||
// The number of the octant is determined as a 3-bit value as follows:
|
||||
// bit 0 = vertical flag
|
||||
// bit 1 = sx < 0
|
||||
// bit 2 = sy < 0
|
||||
//
|
||||
// [N] shows the number of the orthogonal quadrant
|
||||
// <M> shows the number of the diagonal quadrant
|
||||
// <1>
|
||||
// [1] | [0]
|
||||
// . (3)011 | 001(1) .
|
||||
// . | .
|
||||
// . | .
|
||||
// . | .
|
||||
// (2)010 .|. 000(0)
|
||||
// <2> ----------.+.----------- <0>
|
||||
// (6)110 . | . 100(4)
|
||||
// . | .
|
||||
// . | .
|
||||
// . | .
|
||||
// (7)111 | 101(5)
|
||||
// [2] | [3]
|
||||
// <3>
|
||||
// 0,1,2,3,4,5,6,7
|
||||
const int8u line_parameters::s_orthogonal_quadrant[8] = { 0,0,1,1,3,3,2,2 };
|
||||
const int8u line_parameters::s_diagonal_quadrant[8] = { 0,1,2,1,0,3,2,3 };
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void bisectrix(const line_parameters& l1,
|
||||
const line_parameters& l2,
|
||||
int* x, int* y)
|
||||
//-------------------------------------------------------------------------
|
||||
void bisectrix(const line_parameters& l1,
|
||||
const line_parameters& l2,
|
||||
int* x, 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)
|
||||
{
|
||||
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)sqrt(dx * dx + dy * dy) < line_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 = iround(tx);
|
||||
*y = iround(ty);
|
||||
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)sqrt(dx * dx + dy * dy) < line_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 = iround(tx);
|
||||
*y = iround(ty);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
164
deps/agg/src/agg_line_profile_aa.cpp
vendored
164
deps/agg/src/agg_line_profile_aa.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -18,99 +18,99 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void line_profile_aa::width(double w)
|
||||
//---------------------------------------------------------------------
|
||||
void line_profile_aa::width(double w)
|
||||
{
|
||||
if(w < 0.0) w = 0.0;
|
||||
|
||||
if(w < m_smoother_width) w += w;
|
||||
else w += m_smoother_width;
|
||||
|
||||
w *= 0.5;
|
||||
|
||||
w -= m_smoother_width;
|
||||
double s = m_smoother_width;
|
||||
if(w < 0.0)
|
||||
{
|
||||
if(w < 0.0) w = 0.0;
|
||||
s += w;
|
||||
w = 0.0;
|
||||
}
|
||||
set(w, s);
|
||||
}
|
||||
|
||||
if(w < m_smoother_width) w += w;
|
||||
else w += m_smoother_width;
|
||||
|
||||
w *= 0.5;
|
||||
//---------------------------------------------------------------------
|
||||
line_profile_aa::value_type* line_profile_aa::profile(double w)
|
||||
{
|
||||
m_subpixel_width = uround(w * subpixel_scale);
|
||||
unsigned size = m_subpixel_width + subpixel_scale * 6;
|
||||
if(size > m_profile.size())
|
||||
{
|
||||
m_profile.resize(size);
|
||||
}
|
||||
return &m_profile[0];
|
||||
}
|
||||
|
||||
w -= m_smoother_width;
|
||||
double s = m_smoother_width;
|
||||
if(w < 0.0)
|
||||
{
|
||||
s += w;
|
||||
w = 0.0;
|
||||
}
|
||||
set(w, s);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void line_profile_aa::set(double center_width, double smoother_width)
|
||||
{
|
||||
double base_val = 1.0;
|
||||
if(center_width == 0.0) center_width = 1.0 / subpixel_scale;
|
||||
if(smoother_width == 0.0) smoother_width = 1.0 / subpixel_scale;
|
||||
|
||||
double width = center_width + smoother_width;
|
||||
if(width < m_min_width)
|
||||
{
|
||||
double k = width / m_min_width;
|
||||
base_val *= k;
|
||||
center_width /= k;
|
||||
smoother_width /= k;
|
||||
}
|
||||
|
||||
value_type* ch = profile(center_width + smoother_width);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
line_profile_aa::value_type* line_profile_aa::profile(double w)
|
||||
unsigned subpixel_center_width = unsigned(center_width * subpixel_scale);
|
||||
unsigned subpixel_smoother_width = unsigned(smoother_width * subpixel_scale);
|
||||
|
||||
value_type* ch_center = ch + subpixel_scale*2;
|
||||
value_type* ch_smoother = ch_center + subpixel_center_width;
|
||||
|
||||
unsigned i;
|
||||
|
||||
unsigned val = m_gamma[unsigned(base_val * aa_mask)];
|
||||
ch = ch_center;
|
||||
for(i = 0; i < subpixel_center_width; i++)
|
||||
{
|
||||
m_subpixel_width = uround(w * subpixel_scale);
|
||||
unsigned size = m_subpixel_width + subpixel_scale * 6;
|
||||
if(size > m_profile.size())
|
||||
{
|
||||
m_profile.resize(size);
|
||||
}
|
||||
return &m_profile[0];
|
||||
*ch++ = (value_type)val;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void line_profile_aa::set(double center_width, double smoother_width)
|
||||
for(i = 0; i < subpixel_smoother_width; i++)
|
||||
{
|
||||
double base_val = 1.0;
|
||||
if(center_width == 0.0) center_width = 1.0 / subpixel_scale;
|
||||
if(smoother_width == 0.0) smoother_width = 1.0 / subpixel_scale;
|
||||
|
||||
double width = center_width + smoother_width;
|
||||
if(width < m_min_width)
|
||||
{
|
||||
double k = width / m_min_width;
|
||||
base_val *= k;
|
||||
center_width /= k;
|
||||
smoother_width /= k;
|
||||
}
|
||||
|
||||
value_type* ch = profile(center_width + smoother_width);
|
||||
|
||||
unsigned subpixel_center_width = unsigned(center_width * subpixel_scale);
|
||||
unsigned subpixel_smoother_width = unsigned(smoother_width * subpixel_scale);
|
||||
|
||||
value_type* ch_center = ch + subpixel_scale*2;
|
||||
value_type* ch_smoother = ch_center + subpixel_center_width;
|
||||
|
||||
unsigned i;
|
||||
|
||||
unsigned val = m_gamma[unsigned(base_val * aa_mask)];
|
||||
ch = ch_center;
|
||||
for(i = 0; i < subpixel_center_width; i++)
|
||||
{
|
||||
*ch++ = (value_type)val;
|
||||
}
|
||||
|
||||
for(i = 0; i < subpixel_smoother_width; i++)
|
||||
{
|
||||
*ch_smoother++ =
|
||||
m_gamma[unsigned((base_val -
|
||||
base_val *
|
||||
(double(i) / subpixel_smoother_width)) * aa_mask)];
|
||||
}
|
||||
|
||||
unsigned n_smoother = profile_size() -
|
||||
subpixel_smoother_width -
|
||||
subpixel_center_width -
|
||||
subpixel_scale*2;
|
||||
|
||||
val = m_gamma[0];
|
||||
for(i = 0; i < n_smoother; i++)
|
||||
{
|
||||
*ch_smoother++ = (value_type)val;
|
||||
}
|
||||
|
||||
ch = ch_center;
|
||||
for(i = 0; i < subpixel_scale*2; i++)
|
||||
{
|
||||
*--ch = *ch_center++;
|
||||
}
|
||||
*ch_smoother++ =
|
||||
m_gamma[unsigned((base_val -
|
||||
base_val *
|
||||
(double(i) / subpixel_smoother_width)) * aa_mask)];
|
||||
}
|
||||
|
||||
unsigned n_smoother = profile_size() -
|
||||
subpixel_smoother_width -
|
||||
subpixel_center_width -
|
||||
subpixel_scale*2;
|
||||
|
||||
val = m_gamma[0];
|
||||
for(i = 0; i < n_smoother; i++)
|
||||
{
|
||||
*ch_smoother++ = (value_type)val;
|
||||
}
|
||||
|
||||
ch = ch_center;
|
||||
for(i = 0; i < subpixel_scale*2; i++)
|
||||
{
|
||||
*--ch = *ch_center++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
18
deps/agg/src/agg_pixfmt_rgba.cpp
vendored
18
deps/agg/src/agg_pixfmt_rgba.cpp
vendored
|
@ -9,8 +9,8 @@ namespace agg
|
|||
|
||||
template<class ColorT, class Order>
|
||||
void comp_op_rgba_hue<ColorT,Order>::blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
if (cover < 255)
|
||||
{
|
||||
|
@ -41,8 +41,8 @@ void comp_op_rgba_hue<ColorT,Order>::blend_pix(value_type* p,
|
|||
|
||||
template<class ColorT, class Order>
|
||||
void comp_op_rgba_saturation<ColorT,Order>::blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
if (cover < 255)
|
||||
{
|
||||
|
@ -73,8 +73,8 @@ void comp_op_rgba_saturation<ColorT,Order>::blend_pix(value_type* p,
|
|||
|
||||
template<class ColorT, class Order>
|
||||
void comp_op_rgba_color<ColorT,Order>::blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
if (cover < 255)
|
||||
{
|
||||
|
@ -106,8 +106,8 @@ void comp_op_rgba_color<ColorT,Order>::blend_pix(value_type* p,
|
|||
|
||||
template<class ColorT, class Order>
|
||||
void comp_op_rgba_value<ColorT,Order>::blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
if (cover < 255)
|
||||
{
|
||||
|
@ -144,4 +144,4 @@ template struct comp_op_rgba_value<agg::rgba8, agg::order_rgba>;
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
264
deps/agg/src/agg_rounded_rect.cpp
vendored
264
deps/agg/src/agg_rounded_rect.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -23,141 +23,141 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------------------
|
||||
rounded_rect::rounded_rect(double x1, double y1, double x2, double y2, double r) :
|
||||
m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
|
||||
m_rx1(r), m_ry1(r), m_rx2(r), m_ry2(r),
|
||||
m_rx3(r), m_ry3(r), m_rx4(r), m_ry4(r)
|
||||
//------------------------------------------------------------------------
|
||||
rounded_rect::rounded_rect(double x1, double y1, double x2, double y2, double r) :
|
||||
m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2),
|
||||
m_rx1(r), m_ry1(r), m_rx2(r), m_ry2(r),
|
||||
m_rx3(r), m_ry3(r), m_rx4(r), m_ry4(r)
|
||||
{
|
||||
if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
|
||||
if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::rect(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
m_x1 = x1;
|
||||
m_y1 = y1;
|
||||
m_x2 = x2;
|
||||
m_y2 = y2;
|
||||
if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
|
||||
if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double r)
|
||||
{
|
||||
m_rx1 = m_ry1 = m_rx2 = m_ry2 = m_rx3 = m_ry3 = m_rx4 = m_ry4 = r;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx, double ry)
|
||||
{
|
||||
m_rx1 = m_rx2 = m_rx3 = m_rx4 = rx;
|
||||
m_ry1 = m_ry2 = m_ry3 = m_ry4 = ry;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx_bottom, double ry_bottom,
|
||||
double rx_top, double ry_top)
|
||||
{
|
||||
m_rx1 = m_rx2 = rx_bottom;
|
||||
m_rx3 = m_rx4 = rx_top;
|
||||
m_ry1 = m_ry2 = ry_bottom;
|
||||
m_ry3 = m_ry4 = ry_top;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx1, double ry1, double rx2, double ry2,
|
||||
double rx3, double ry3, double rx4, double ry4)
|
||||
{
|
||||
m_rx1 = rx1; m_ry1 = ry1; m_rx2 = rx2; m_ry2 = ry2;
|
||||
m_rx3 = rx3; m_ry3 = ry3; m_rx4 = rx4; m_ry4 = ry4;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::normalize_radius()
|
||||
{
|
||||
double dx = fabs(m_x2 - m_x1);
|
||||
double dy = fabs(m_y2 - m_y1);
|
||||
|
||||
double k = 1.0;
|
||||
double t;
|
||||
t = dx / (m_rx1 + m_rx2); if(t < k) k = t;
|
||||
t = dx / (m_rx3 + m_rx4); if(t < k) k = t;
|
||||
t = dy / (m_ry1 + m_ry2); if(t < k) k = t;
|
||||
t = dy / (m_ry3 + m_ry4); if(t < k) k = t;
|
||||
|
||||
if(k < 1.0)
|
||||
{
|
||||
if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
|
||||
if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
|
||||
m_rx1 *= k; m_ry1 *= k; m_rx2 *= k; m_ry2 *= k;
|
||||
m_rx3 *= k; m_ry3 *= k; m_rx4 *= k; m_ry4 *= k;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::rect(double x1, double y1, double x2, double y2)
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::rewind(unsigned)
|
||||
{
|
||||
m_status = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned rounded_rect::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_stop;
|
||||
switch(m_status)
|
||||
{
|
||||
m_x1 = x1;
|
||||
m_y1 = y1;
|
||||
m_x2 = x2;
|
||||
m_y2 = y2;
|
||||
if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
|
||||
if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double r)
|
||||
{
|
||||
m_rx1 = m_ry1 = m_rx2 = m_ry2 = m_rx3 = m_ry3 = m_rx4 = m_ry4 = r;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx, double ry)
|
||||
{
|
||||
m_rx1 = m_rx2 = m_rx3 = m_rx4 = rx;
|
||||
m_ry1 = m_ry2 = m_ry3 = m_ry4 = ry;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx_bottom, double ry_bottom,
|
||||
double rx_top, double ry_top)
|
||||
{
|
||||
m_rx1 = m_rx2 = rx_bottom;
|
||||
m_rx3 = m_rx4 = rx_top;
|
||||
m_ry1 = m_ry2 = ry_bottom;
|
||||
m_ry3 = m_ry4 = ry_top;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::radius(double rx1, double ry1, double rx2, double ry2,
|
||||
double rx3, double ry3, double rx4, double ry4)
|
||||
{
|
||||
m_rx1 = rx1; m_ry1 = ry1; m_rx2 = rx2; m_ry2 = ry2;
|
||||
m_rx3 = rx3; m_ry3 = ry3; m_rx4 = rx4; m_ry4 = ry4;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::normalize_radius()
|
||||
{
|
||||
double dx = fabs(m_x2 - m_x1);
|
||||
double dy = fabs(m_y2 - m_y1);
|
||||
|
||||
double k = 1.0;
|
||||
double t;
|
||||
t = dx / (m_rx1 + m_rx2); if(t < k) k = t;
|
||||
t = dx / (m_rx3 + m_rx4); if(t < k) k = t;
|
||||
t = dy / (m_ry1 + m_ry2); if(t < k) k = t;
|
||||
t = dy / (m_ry3 + m_ry4); if(t < k) k = t;
|
||||
|
||||
if(k < 1.0)
|
||||
{
|
||||
m_rx1 *= k; m_ry1 *= k; m_rx2 *= k; m_ry2 *= k;
|
||||
m_rx3 *= k; m_ry3 *= k; m_rx4 *= k; m_ry4 *= k;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rounded_rect::rewind(unsigned)
|
||||
{
|
||||
m_status = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned rounded_rect::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_stop;
|
||||
switch(m_status)
|
||||
{
|
||||
case 0:
|
||||
m_arc.init(m_x1 + m_rx1, m_y1 + m_ry1, m_rx1, m_ry1,
|
||||
pi, pi+pi*0.5);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 1:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return cmd;
|
||||
|
||||
case 2:
|
||||
m_arc.init(m_x2 - m_rx2, m_y1 + m_ry2, m_rx2, m_ry2,
|
||||
pi+pi*0.5, 0.0);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 3:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 4:
|
||||
m_arc.init(m_x2 - m_rx3, m_y2 - m_ry3, m_rx3, m_ry3,
|
||||
0.0, pi*0.5);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 5:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 6:
|
||||
m_arc.init(m_x1 + m_rx4, m_y2 - m_ry4, m_rx4, m_ry4,
|
||||
pi*0.5, pi);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 7:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 8:
|
||||
cmd = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_status++;
|
||||
break;
|
||||
}
|
||||
return cmd;
|
||||
case 0:
|
||||
m_arc.init(m_x1 + m_rx1, m_y1 + m_ry1, m_rx1, m_ry1,
|
||||
pi, pi+pi*0.5);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 1:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return cmd;
|
||||
|
||||
case 2:
|
||||
m_arc.init(m_x2 - m_rx2, m_y1 + m_ry2, m_rx2, m_ry2,
|
||||
pi+pi*0.5, 0.0);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 3:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 4:
|
||||
m_arc.init(m_x2 - m_rx3, m_y2 - m_ry3, m_rx3, m_ry3,
|
||||
0.0, pi*0.5);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 5:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 6:
|
||||
m_arc.init(m_x1 + m_rx4, m_y2 - m_ry4, m_rx4, m_ry4,
|
||||
pi*0.5, pi);
|
||||
m_arc.rewind(0);
|
||||
m_status++;
|
||||
|
||||
case 7:
|
||||
cmd = m_arc.vertex(x, y);
|
||||
if(is_stop(cmd)) m_status++;
|
||||
else return path_cmd_line_to;
|
||||
|
||||
case 8:
|
||||
cmd = path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
m_status++;
|
||||
break;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
182
deps/agg/src/agg_sqrt_tables.cpp
vendored
182
deps/agg/src/agg_sqrt_tables.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -21,95 +21,95 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
int16u g_sqrt_table[1024] = //----------g_sqrt_table
|
||||
{
|
||||
0,
|
||||
2048,2896,3547,4096,4579,5017,5418,5793,6144,6476,6792,7094,7384,7663,7932,8192,8444,
|
||||
8689,8927,9159,9385,9606,9822,10033,10240,10443,10642,10837,11029,11217,11403,11585,
|
||||
11765,11942,12116,12288,12457,12625,12790,12953,13114,13273,13430,13585,13738,13890,
|
||||
14040,14189,14336,14482,14626,14768,14910,15050,15188,15326,15462,15597,15731,15864,
|
||||
15995,16126,16255,16384,16512,16638,16764,16888,17012,17135,17257,17378,17498,17618,
|
||||
17736,17854,17971,18087,18203,18318,18432,18545,18658,18770,18882,18992,19102,19212,
|
||||
19321,19429,19537,19644,19750,19856,19961,20066,20170,20274,20377,20480,20582,20684,
|
||||
20785,20886,20986,21085,21185,21283,21382,21480,21577,21674,21771,21867,21962,22058,
|
||||
22153,22247,22341,22435,22528,22621,22713,22806,22897,22989,23080,23170,23261,23351,
|
||||
23440,23530,23619,23707,23796,23884,23971,24059,24146,24232,24319,24405,24491,24576,
|
||||
24661,24746,24831,24915,24999,25083,25166,25249,25332,25415,25497,25580,25661,25743,
|
||||
25824,25905,25986,26067,26147,26227,26307,26387,26466,26545,26624,26703,26781,26859,
|
||||
26937,27015,27092,27170,27247,27324,27400,27477,27553,27629,27705,27780,27856,27931,
|
||||
28006,28081,28155,28230,28304,28378,28452,28525,28599,28672,28745,28818,28891,28963,
|
||||
29035,29108,29180,29251,29323,29394,29466,29537,29608,29678,29749,29819,29890,29960,
|
||||
30030,30099,30169,30238,30308,30377,30446,30515,30583,30652,30720,30788,30856,30924,
|
||||
30992,31059,31127,31194,31261,31328,31395,31462,31529,31595,31661,31727,31794,31859,
|
||||
31925,31991,32056,32122,32187,32252,32317,32382,32446,32511,32575,32640,32704,32768,
|
||||
32832,32896,32959,33023,33086,33150,33213,33276,33339,33402,33465,33527,33590,33652,
|
||||
33714,33776,33839,33900,33962,34024,34086,34147,34208,34270,34331,34392,34453,34514,
|
||||
34574,34635,34695,34756,34816,34876,34936,34996,35056,35116,35176,35235,35295,35354,
|
||||
35413,35472,35531,35590,35649,35708,35767,35825,35884,35942,36001,36059,36117,36175,
|
||||
36233,36291,36348,36406,36464,36521,36578,36636,36693,36750,36807,36864,36921,36978,
|
||||
37034,37091,37147,37204,37260,37316,37372,37429,37485,37540,37596,37652,37708,37763,
|
||||
37819,37874,37929,37985,38040,38095,38150,38205,38260,38315,38369,38424,38478,38533,
|
||||
38587,38642,38696,38750,38804,38858,38912,38966,39020,39073,39127,39181,39234,39287,
|
||||
39341,39394,39447,39500,39553,39606,39659,39712,39765,39818,39870,39923,39975,40028,
|
||||
40080,40132,40185,40237,40289,40341,40393,40445,40497,40548,40600,40652,40703,40755,
|
||||
40806,40857,40909,40960,41011,41062,41113,41164,41215,41266,41317,41368,41418,41469,
|
||||
41519,41570,41620,41671,41721,41771,41821,41871,41922,41972,42021,42071,42121,42171,
|
||||
42221,42270,42320,42369,42419,42468,42518,42567,42616,42665,42714,42763,42813,42861,
|
||||
42910,42959,43008,43057,43105,43154,43203,43251,43300,43348,43396,43445,43493,43541,
|
||||
43589,43637,43685,43733,43781,43829,43877,43925,43972,44020,44068,44115,44163,44210,
|
||||
44258,44305,44352,44400,44447,44494,44541,44588,44635,44682,44729,44776,44823,44869,
|
||||
44916,44963,45009,45056,45103,45149,45195,45242,45288,45334,45381,45427,45473,45519,
|
||||
45565,45611,45657,45703,45749,45795,45840,45886,45932,45977,46023,46069,46114,46160,
|
||||
46205,46250,46296,46341,46386,46431,46477,46522,46567,46612,46657,46702,46746,46791,
|
||||
46836,46881,46926,46970,47015,47059,47104,47149,47193,47237,47282,47326,47370,47415,
|
||||
47459,47503,47547,47591,47635,47679,47723,47767,47811,47855,47899,47942,47986,48030,
|
||||
48074,48117,48161,48204,48248,48291,48335,48378,48421,48465,48508,48551,48594,48637,
|
||||
48680,48723,48766,48809,48852,48895,48938,48981,49024,49067,49109,49152,49195,49237,
|
||||
49280,49322,49365,49407,49450,49492,49535,49577,49619,49661,49704,49746,49788,49830,
|
||||
49872,49914,49956,49998,50040,50082,50124,50166,50207,50249,50291,50332,50374,50416,
|
||||
50457,50499,50540,50582,50623,50665,50706,50747,50789,50830,50871,50912,50954,50995,
|
||||
51036,51077,51118,51159,51200,51241,51282,51323,51364,51404,51445,51486,51527,51567,
|
||||
51608,51649,51689,51730,51770,51811,51851,51892,51932,51972,52013,52053,52093,52134,
|
||||
52174,52214,52254,52294,52334,52374,52414,52454,52494,52534,52574,52614,52654,52694,
|
||||
52734,52773,52813,52853,52892,52932,52972,53011,53051,53090,53130,53169,53209,53248,
|
||||
53287,53327,53366,53405,53445,53484,53523,53562,53601,53640,53679,53719,53758,53797,
|
||||
53836,53874,53913,53952,53991,54030,54069,54108,54146,54185,54224,54262,54301,54340,
|
||||
54378,54417,54455,54494,54532,54571,54609,54647,54686,54724,54762,54801,54839,54877,
|
||||
54915,54954,54992,55030,55068,55106,55144,55182,55220,55258,55296,55334,55372,55410,
|
||||
55447,55485,55523,55561,55599,55636,55674,55712,55749,55787,55824,55862,55900,55937,
|
||||
55975,56012,56049,56087,56124,56162,56199,56236,56273,56311,56348,56385,56422,56459,
|
||||
56497,56534,56571,56608,56645,56682,56719,56756,56793,56830,56867,56903,56940,56977,
|
||||
57014,57051,57087,57124,57161,57198,57234,57271,57307,57344,57381,57417,57454,57490,
|
||||
57527,57563,57599,57636,57672,57709,57745,57781,57817,57854,57890,57926,57962,57999,
|
||||
58035,58071,58107,58143,58179,58215,58251,58287,58323,58359,58395,58431,58467,58503,
|
||||
58538,58574,58610,58646,58682,58717,58753,58789,58824,58860,58896,58931,58967,59002,
|
||||
59038,59073,59109,59144,59180,59215,59251,59286,59321,59357,59392,59427,59463,59498,
|
||||
59533,59568,59603,59639,59674,59709,59744,59779,59814,59849,59884,59919,59954,59989,
|
||||
60024,60059,60094,60129,60164,60199,60233,60268,60303,60338,60373,60407,60442,60477,
|
||||
60511,60546,60581,60615,60650,60684,60719,60753,60788,60822,60857,60891,60926,60960,
|
||||
60995,61029,61063,61098,61132,61166,61201,61235,61269,61303,61338,61372,61406,61440,
|
||||
61474,61508,61542,61576,61610,61644,61678,61712,61746,61780,61814,61848,61882,61916,
|
||||
61950,61984,62018,62051,62085,62119,62153,62186,62220,62254,62287,62321,62355,62388,
|
||||
62422,62456,62489,62523,62556,62590,62623,62657,62690,62724,62757,62790,62824,62857,
|
||||
62891,62924,62957,62991,63024,63057,63090,63124,63157,63190,63223,63256,63289,63323,
|
||||
63356,63389,63422,63455,63488,63521,63554,63587,63620,63653,63686,63719,63752,63785,
|
||||
63817,63850,63883,63916,63949,63982,64014,64047,64080,64113,64145,64178,64211,64243,
|
||||
64276,64309,64341,64374,64406,64439,64471,64504,64536,64569,64601,64634,64666,64699,
|
||||
64731,64763,64796,64828,64861,64893,64925,64957,64990,65022,65054,65086,65119,65151,
|
||||
65183,65215,65247,65279,65312,65344,65376,65408,65440,65472,65504
|
||||
};
|
||||
int16u g_sqrt_table[1024] = //----------g_sqrt_table
|
||||
{
|
||||
0,
|
||||
2048,2896,3547,4096,4579,5017,5418,5793,6144,6476,6792,7094,7384,7663,7932,8192,8444,
|
||||
8689,8927,9159,9385,9606,9822,10033,10240,10443,10642,10837,11029,11217,11403,11585,
|
||||
11765,11942,12116,12288,12457,12625,12790,12953,13114,13273,13430,13585,13738,13890,
|
||||
14040,14189,14336,14482,14626,14768,14910,15050,15188,15326,15462,15597,15731,15864,
|
||||
15995,16126,16255,16384,16512,16638,16764,16888,17012,17135,17257,17378,17498,17618,
|
||||
17736,17854,17971,18087,18203,18318,18432,18545,18658,18770,18882,18992,19102,19212,
|
||||
19321,19429,19537,19644,19750,19856,19961,20066,20170,20274,20377,20480,20582,20684,
|
||||
20785,20886,20986,21085,21185,21283,21382,21480,21577,21674,21771,21867,21962,22058,
|
||||
22153,22247,22341,22435,22528,22621,22713,22806,22897,22989,23080,23170,23261,23351,
|
||||
23440,23530,23619,23707,23796,23884,23971,24059,24146,24232,24319,24405,24491,24576,
|
||||
24661,24746,24831,24915,24999,25083,25166,25249,25332,25415,25497,25580,25661,25743,
|
||||
25824,25905,25986,26067,26147,26227,26307,26387,26466,26545,26624,26703,26781,26859,
|
||||
26937,27015,27092,27170,27247,27324,27400,27477,27553,27629,27705,27780,27856,27931,
|
||||
28006,28081,28155,28230,28304,28378,28452,28525,28599,28672,28745,28818,28891,28963,
|
||||
29035,29108,29180,29251,29323,29394,29466,29537,29608,29678,29749,29819,29890,29960,
|
||||
30030,30099,30169,30238,30308,30377,30446,30515,30583,30652,30720,30788,30856,30924,
|
||||
30992,31059,31127,31194,31261,31328,31395,31462,31529,31595,31661,31727,31794,31859,
|
||||
31925,31991,32056,32122,32187,32252,32317,32382,32446,32511,32575,32640,32704,32768,
|
||||
32832,32896,32959,33023,33086,33150,33213,33276,33339,33402,33465,33527,33590,33652,
|
||||
33714,33776,33839,33900,33962,34024,34086,34147,34208,34270,34331,34392,34453,34514,
|
||||
34574,34635,34695,34756,34816,34876,34936,34996,35056,35116,35176,35235,35295,35354,
|
||||
35413,35472,35531,35590,35649,35708,35767,35825,35884,35942,36001,36059,36117,36175,
|
||||
36233,36291,36348,36406,36464,36521,36578,36636,36693,36750,36807,36864,36921,36978,
|
||||
37034,37091,37147,37204,37260,37316,37372,37429,37485,37540,37596,37652,37708,37763,
|
||||
37819,37874,37929,37985,38040,38095,38150,38205,38260,38315,38369,38424,38478,38533,
|
||||
38587,38642,38696,38750,38804,38858,38912,38966,39020,39073,39127,39181,39234,39287,
|
||||
39341,39394,39447,39500,39553,39606,39659,39712,39765,39818,39870,39923,39975,40028,
|
||||
40080,40132,40185,40237,40289,40341,40393,40445,40497,40548,40600,40652,40703,40755,
|
||||
40806,40857,40909,40960,41011,41062,41113,41164,41215,41266,41317,41368,41418,41469,
|
||||
41519,41570,41620,41671,41721,41771,41821,41871,41922,41972,42021,42071,42121,42171,
|
||||
42221,42270,42320,42369,42419,42468,42518,42567,42616,42665,42714,42763,42813,42861,
|
||||
42910,42959,43008,43057,43105,43154,43203,43251,43300,43348,43396,43445,43493,43541,
|
||||
43589,43637,43685,43733,43781,43829,43877,43925,43972,44020,44068,44115,44163,44210,
|
||||
44258,44305,44352,44400,44447,44494,44541,44588,44635,44682,44729,44776,44823,44869,
|
||||
44916,44963,45009,45056,45103,45149,45195,45242,45288,45334,45381,45427,45473,45519,
|
||||
45565,45611,45657,45703,45749,45795,45840,45886,45932,45977,46023,46069,46114,46160,
|
||||
46205,46250,46296,46341,46386,46431,46477,46522,46567,46612,46657,46702,46746,46791,
|
||||
46836,46881,46926,46970,47015,47059,47104,47149,47193,47237,47282,47326,47370,47415,
|
||||
47459,47503,47547,47591,47635,47679,47723,47767,47811,47855,47899,47942,47986,48030,
|
||||
48074,48117,48161,48204,48248,48291,48335,48378,48421,48465,48508,48551,48594,48637,
|
||||
48680,48723,48766,48809,48852,48895,48938,48981,49024,49067,49109,49152,49195,49237,
|
||||
49280,49322,49365,49407,49450,49492,49535,49577,49619,49661,49704,49746,49788,49830,
|
||||
49872,49914,49956,49998,50040,50082,50124,50166,50207,50249,50291,50332,50374,50416,
|
||||
50457,50499,50540,50582,50623,50665,50706,50747,50789,50830,50871,50912,50954,50995,
|
||||
51036,51077,51118,51159,51200,51241,51282,51323,51364,51404,51445,51486,51527,51567,
|
||||
51608,51649,51689,51730,51770,51811,51851,51892,51932,51972,52013,52053,52093,52134,
|
||||
52174,52214,52254,52294,52334,52374,52414,52454,52494,52534,52574,52614,52654,52694,
|
||||
52734,52773,52813,52853,52892,52932,52972,53011,53051,53090,53130,53169,53209,53248,
|
||||
53287,53327,53366,53405,53445,53484,53523,53562,53601,53640,53679,53719,53758,53797,
|
||||
53836,53874,53913,53952,53991,54030,54069,54108,54146,54185,54224,54262,54301,54340,
|
||||
54378,54417,54455,54494,54532,54571,54609,54647,54686,54724,54762,54801,54839,54877,
|
||||
54915,54954,54992,55030,55068,55106,55144,55182,55220,55258,55296,55334,55372,55410,
|
||||
55447,55485,55523,55561,55599,55636,55674,55712,55749,55787,55824,55862,55900,55937,
|
||||
55975,56012,56049,56087,56124,56162,56199,56236,56273,56311,56348,56385,56422,56459,
|
||||
56497,56534,56571,56608,56645,56682,56719,56756,56793,56830,56867,56903,56940,56977,
|
||||
57014,57051,57087,57124,57161,57198,57234,57271,57307,57344,57381,57417,57454,57490,
|
||||
57527,57563,57599,57636,57672,57709,57745,57781,57817,57854,57890,57926,57962,57999,
|
||||
58035,58071,58107,58143,58179,58215,58251,58287,58323,58359,58395,58431,58467,58503,
|
||||
58538,58574,58610,58646,58682,58717,58753,58789,58824,58860,58896,58931,58967,59002,
|
||||
59038,59073,59109,59144,59180,59215,59251,59286,59321,59357,59392,59427,59463,59498,
|
||||
59533,59568,59603,59639,59674,59709,59744,59779,59814,59849,59884,59919,59954,59989,
|
||||
60024,60059,60094,60129,60164,60199,60233,60268,60303,60338,60373,60407,60442,60477,
|
||||
60511,60546,60581,60615,60650,60684,60719,60753,60788,60822,60857,60891,60926,60960,
|
||||
60995,61029,61063,61098,61132,61166,61201,61235,61269,61303,61338,61372,61406,61440,
|
||||
61474,61508,61542,61576,61610,61644,61678,61712,61746,61780,61814,61848,61882,61916,
|
||||
61950,61984,62018,62051,62085,62119,62153,62186,62220,62254,62287,62321,62355,62388,
|
||||
62422,62456,62489,62523,62556,62590,62623,62657,62690,62724,62757,62790,62824,62857,
|
||||
62891,62924,62957,62991,63024,63057,63090,63124,63157,63190,63223,63256,63289,63323,
|
||||
63356,63389,63422,63455,63488,63521,63554,63587,63620,63653,63686,63719,63752,63785,
|
||||
63817,63850,63883,63916,63949,63982,64014,64047,64080,64113,64145,64178,64211,64243,
|
||||
64276,64309,64341,64374,64406,64439,64471,64504,64536,64569,64601,64634,64666,64699,
|
||||
64731,64763,64796,64828,64861,64893,64925,64957,64990,65022,65054,65086,65119,65151,
|
||||
65183,65215,65247,65279,65312,65344,65376,65408,65440,65472,65504
|
||||
};
|
||||
|
||||
|
||||
int8 g_elder_bit_table[256] = //---------g_elder_bit_table
|
||||
{
|
||||
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
|
||||
};
|
||||
|
||||
int8 g_elder_bit_table[256] = //---------g_elder_bit_table
|
||||
{
|
||||
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
|
||||
};
|
||||
|
||||
}
|
||||
|
|
300
deps/agg/src/agg_trans_affine.cpp
vendored
300
deps/agg/src/agg_trans_affine.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -22,173 +22,173 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
const trans_affine trans_affine::identity;
|
||||
const trans_affine trans_affine::identity;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::parl_to_parl(const double* src,
|
||||
const double* dst)
|
||||
{
|
||||
sx = src[2] - src[0];
|
||||
shy = src[3] - src[1];
|
||||
shx = src[4] - src[0];
|
||||
sy = src[5] - src[1];
|
||||
tx = src[0];
|
||||
ty = src[1];
|
||||
invert();
|
||||
multiply(trans_affine(dst[2] - dst[0], dst[3] - dst[1],
|
||||
dst[4] - dst[0], dst[5] - dst[1],
|
||||
dst[0], dst[1]));
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::parl_to_parl(const double* src,
|
||||
const double* dst)
|
||||
{
|
||||
sx = src[2] - src[0];
|
||||
shy = src[3] - src[1];
|
||||
shx = src[4] - src[0];
|
||||
sy = src[5] - src[1];
|
||||
tx = src[0];
|
||||
ty = src[1];
|
||||
invert();
|
||||
multiply(trans_affine(dst[2] - dst[0], dst[3] - dst[1],
|
||||
dst[4] - dst[0], dst[5] - dst[1],
|
||||
dst[0], dst[1]));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::rect_to_parl(double x1, double y1,
|
||||
double x2, double y2,
|
||||
const double* parl)
|
||||
{
|
||||
double src[6];
|
||||
src[0] = x1; src[1] = y1;
|
||||
src[2] = x2; src[3] = y1;
|
||||
src[4] = x2; src[5] = y2;
|
||||
parl_to_parl(src, parl);
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::rect_to_parl(double x1, double y1,
|
||||
double x2, double y2,
|
||||
const double* parl)
|
||||
{
|
||||
double src[6];
|
||||
src[0] = x1; src[1] = y1;
|
||||
src[2] = x2; src[3] = y1;
|
||||
src[4] = x2; src[5] = y2;
|
||||
parl_to_parl(src, parl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::parl_to_rect(const double* parl,
|
||||
double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
double dst[6];
|
||||
dst[0] = x1; dst[1] = y1;
|
||||
dst[2] = x2; dst[3] = y1;
|
||||
dst[4] = x2; dst[5] = y2;
|
||||
parl_to_parl(parl, dst);
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::parl_to_rect(const double* parl,
|
||||
double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
double dst[6];
|
||||
dst[0] = x1; dst[1] = y1;
|
||||
dst[2] = x2; dst[3] = y1;
|
||||
dst[4] = x2; dst[5] = y2;
|
||||
parl_to_parl(parl, dst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::multiply(const trans_affine& m)
|
||||
{
|
||||
double t0 = sx * m.sx + shy * m.shx;
|
||||
double t2 = shx * m.sx + sy * m.shx;
|
||||
double t4 = tx * m.sx + ty * m.shx + m.tx;
|
||||
shy = sx * m.shy + shy * m.sy;
|
||||
sy = shx * m.shy + sy * m.sy;
|
||||
ty = tx * m.shy + ty * m.sy + m.ty;
|
||||
sx = t0;
|
||||
shx = t2;
|
||||
tx = t4;
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::multiply(const trans_affine& m)
|
||||
{
|
||||
double t0 = sx * m.sx + shy * m.shx;
|
||||
double t2 = shx * m.sx + sy * m.shx;
|
||||
double t4 = tx * m.sx + ty * m.shx + m.tx;
|
||||
shy = sx * m.shy + shy * m.sy;
|
||||
sy = shx * m.shy + sy * m.sy;
|
||||
ty = tx * m.shy + ty * m.sy + m.ty;
|
||||
sx = t0;
|
||||
shx = t2;
|
||||
tx = t4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::invert()
|
||||
{
|
||||
double d = determinant_reciprocal();
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::invert()
|
||||
{
|
||||
double d = determinant_reciprocal();
|
||||
|
||||
double t0 = sy * d;
|
||||
sy = sx * d;
|
||||
shy = -shy * d;
|
||||
shx = -shx * d;
|
||||
double t0 = sy * d;
|
||||
sy = sx * d;
|
||||
shy = -shy * d;
|
||||
shx = -shx * d;
|
||||
|
||||
double t4 = -tx * t0 - ty * shx;
|
||||
ty = -tx * shy - ty * sy;
|
||||
double t4 = -tx * t0 - ty * shx;
|
||||
ty = -tx * shy - ty * sy;
|
||||
|
||||
sx = t0;
|
||||
tx = t4;
|
||||
return *this;
|
||||
}
|
||||
sx = t0;
|
||||
tx = t4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::flip_x()
|
||||
{
|
||||
sx = -sx;
|
||||
shy = -shy;
|
||||
tx = -tx;
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::flip_x()
|
||||
{
|
||||
sx = -sx;
|
||||
shy = -shy;
|
||||
tx = -tx;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::flip_y()
|
||||
{
|
||||
shx = -shx;
|
||||
sy = -sy;
|
||||
ty = -ty;
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::flip_y()
|
||||
{
|
||||
shx = -shx;
|
||||
sy = -sy;
|
||||
ty = -ty;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::reset()
|
||||
{
|
||||
sx = sy = 1.0;
|
||||
shy = shx = tx = ty = 0.0;
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
const trans_affine& trans_affine::reset()
|
||||
{
|
||||
sx = sy = 1.0;
|
||||
shy = shx = tx = ty = 0.0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_identity(double epsilon) const
|
||||
{
|
||||
return is_equal_eps(sx, 1.0, epsilon) &&
|
||||
is_equal_eps(shy, 0.0, epsilon) &&
|
||||
is_equal_eps(shx, 0.0, epsilon) &&
|
||||
is_equal_eps(sy, 1.0, epsilon) &&
|
||||
is_equal_eps(tx, 0.0, epsilon) &&
|
||||
is_equal_eps(ty, 0.0, epsilon);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_identity(double epsilon) const
|
||||
{
|
||||
return is_equal_eps(sx, 1.0, epsilon) &&
|
||||
is_equal_eps(shy, 0.0, epsilon) &&
|
||||
is_equal_eps(shx, 0.0, epsilon) &&
|
||||
is_equal_eps(sy, 1.0, epsilon) &&
|
||||
is_equal_eps(tx, 0.0, epsilon) &&
|
||||
is_equal_eps(ty, 0.0, epsilon);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_valid(double epsilon) const
|
||||
{
|
||||
return fabs(sx) > epsilon && fabs(sy) > epsilon;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_valid(double epsilon) const
|
||||
{
|
||||
return fabs(sx) > epsilon && fabs(sy) > epsilon;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_equal(const trans_affine& m, double epsilon) const
|
||||
{
|
||||
return is_equal_eps(sx, m.sx, epsilon) &&
|
||||
is_equal_eps(shy, m.shy, epsilon) &&
|
||||
is_equal_eps(shx, m.shx, epsilon) &&
|
||||
is_equal_eps(sy, m.sy, epsilon) &&
|
||||
is_equal_eps(tx, m.tx, epsilon) &&
|
||||
is_equal_eps(ty, m.ty, epsilon);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
bool trans_affine::is_equal(const trans_affine& m, double epsilon) const
|
||||
{
|
||||
return is_equal_eps(sx, m.sx, epsilon) &&
|
||||
is_equal_eps(shy, m.shy, epsilon) &&
|
||||
is_equal_eps(shx, m.shx, epsilon) &&
|
||||
is_equal_eps(sy, m.sy, epsilon) &&
|
||||
is_equal_eps(tx, m.tx, epsilon) &&
|
||||
is_equal_eps(ty, m.ty, epsilon);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_affine::rotation() const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double x2 = 1.0;
|
||||
double y2 = 0.0;
|
||||
transform(&x1, &y1);
|
||||
transform(&x2, &y2);
|
||||
return atan2(y2-y1, x2-x1);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
double trans_affine::rotation() const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double x2 = 1.0;
|
||||
double y2 = 0.0;
|
||||
transform(&x1, &y1);
|
||||
transform(&x2, &y2);
|
||||
return atan2(y2-y1, x2-x1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_affine::translation(double* dx, double* dy) const
|
||||
{
|
||||
*dx = tx;
|
||||
*dy = ty;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void trans_affine::translation(double* dx, double* dy) const
|
||||
{
|
||||
*dx = tx;
|
||||
*dy = ty;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_affine::scaling(double* x, double* y) const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double x2 = 1.0;
|
||||
double y2 = 1.0;
|
||||
trans_affine t(*this);
|
||||
t *= trans_affine_rotation(-rotation());
|
||||
t.transform(&x1, &y1);
|
||||
t.transform(&x2, &y2);
|
||||
*x = x2 - x1;
|
||||
*y = y2 - y1;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void trans_affine::scaling(double* x, double* y) const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double x2 = 1.0;
|
||||
double y2 = 1.0;
|
||||
trans_affine t(*this);
|
||||
t *= trans_affine_rotation(-rotation());
|
||||
t.transform(&x1, &y1);
|
||||
t.transform(&x2, &y2);
|
||||
*x = x2 - x1;
|
||||
*y = y2 - y1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
358
deps/agg/src/agg_trans_double_path.cpp
vendored
358
deps/agg/src/agg_trans_double_path.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -19,176 +19,176 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
trans_double_path::trans_double_path() :
|
||||
m_base_length(0.0),
|
||||
m_base_height(1.0),
|
||||
m_kindex1(0.0),
|
||||
m_kindex2(0.0),
|
||||
m_status1(initial),
|
||||
m_status2(initial),
|
||||
m_preserve_x_scale(true)
|
||||
//------------------------------------------------------------------------
|
||||
trans_double_path::trans_double_path() :
|
||||
m_base_length(0.0),
|
||||
m_base_height(1.0),
|
||||
m_kindex1(0.0),
|
||||
m_kindex2(0.0),
|
||||
m_status1(initial),
|
||||
m_status2(initial),
|
||||
m_preserve_x_scale(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::reset()
|
||||
{
|
||||
m_src_vertices1.remove_all();
|
||||
m_src_vertices2.remove_all();
|
||||
m_kindex1 = 0.0;
|
||||
m_kindex1 = 0.0;
|
||||
m_status1 = initial;
|
||||
m_status2 = initial;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::move_to1(double x, double y)
|
||||
{
|
||||
if(m_status1 == initial)
|
||||
{
|
||||
m_src_vertices1.modify_last(vertex_dist(x, y));
|
||||
m_status1 = making_path;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::reset()
|
||||
else
|
||||
{
|
||||
m_src_vertices1.remove_all();
|
||||
m_src_vertices2.remove_all();
|
||||
m_kindex1 = 0.0;
|
||||
m_kindex1 = 0.0;
|
||||
m_status1 = initial;
|
||||
m_status2 = initial;
|
||||
line_to1(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::move_to1(double x, double y)
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::line_to1(double x, double y)
|
||||
{
|
||||
if(m_status1 == making_path)
|
||||
{
|
||||
if(m_status1 == initial)
|
||||
m_src_vertices1.add(vertex_dist(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::move_to2(double x, double y)
|
||||
{
|
||||
if(m_status2 == initial)
|
||||
{
|
||||
m_src_vertices2.modify_last(vertex_dist(x, y));
|
||||
m_status2 = making_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
line_to2(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::line_to2(double x, double y)
|
||||
{
|
||||
if(m_status2 == making_path)
|
||||
{
|
||||
m_src_vertices2.add(vertex_dist(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::finalize_path(vertex_storage& vertices)
|
||||
{
|
||||
unsigned i;
|
||||
double dist;
|
||||
double d;
|
||||
|
||||
vertices.close(false);
|
||||
if(vertices.size() > 2)
|
||||
{
|
||||
if(vertices[vertices.size() - 2].dist * 10.0 <
|
||||
vertices[vertices.size() - 3].dist)
|
||||
{
|
||||
m_src_vertices1.modify_last(vertex_dist(x, y));
|
||||
m_status1 = making_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
line_to1(x, y);
|
||||
d = vertices[vertices.size() - 3].dist +
|
||||
vertices[vertices.size() - 2].dist;
|
||||
|
||||
vertices[vertices.size() - 2] =
|
||||
vertices[vertices.size() - 1];
|
||||
|
||||
vertices.remove_last();
|
||||
vertices[vertices.size() - 2].dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::line_to1(double x, double y)
|
||||
dist = 0;
|
||||
for(i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
if(m_status1 == making_path)
|
||||
{
|
||||
m_src_vertices1.add(vertex_dist(x, y));
|
||||
}
|
||||
vertex_dist& v = vertices[i];
|
||||
d = v.dist;
|
||||
v.dist = dist;
|
||||
dist += d;
|
||||
}
|
||||
|
||||
return (vertices.size() - 1) / dist;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::move_to2(double x, double y)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::finalize_paths()
|
||||
{
|
||||
if(m_status1 == making_path && m_src_vertices1.size() > 1 &&
|
||||
m_status2 == making_path && m_src_vertices2.size() > 1)
|
||||
{
|
||||
if(m_status2 == initial)
|
||||
{
|
||||
m_src_vertices2.modify_last(vertex_dist(x, y));
|
||||
m_status2 = making_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
line_to2(x, y);
|
||||
}
|
||||
m_kindex1 = finalize_path(m_src_vertices1);
|
||||
m_kindex2 = finalize_path(m_src_vertices2);
|
||||
m_status1 = ready;
|
||||
m_status2 = ready;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::line_to2(double x, double y)
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::total_length1() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status1 == ready) ?
|
||||
m_src_vertices1[m_src_vertices1.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::total_length2() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status2 == ready) ?
|
||||
m_src_vertices2[m_src_vertices2.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::transform1(const vertex_storage& vertices,
|
||||
double kindex, double kx,
|
||||
double *x, double* y) const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double dx = 1.0;
|
||||
double dy = 1.0;
|
||||
double d = 0.0;
|
||||
double dd = 1.0;
|
||||
*x *= kx;
|
||||
if(*x < 0.0)
|
||||
{
|
||||
if(m_status2 == making_path)
|
||||
{
|
||||
m_src_vertices2.add(vertex_dist(x, y));
|
||||
}
|
||||
// Extrapolation on the left
|
||||
//--------------------------
|
||||
x1 = vertices[0].x;
|
||||
y1 = vertices[0].y;
|
||||
dx = vertices[1].x - x1;
|
||||
dy = vertices[1].y - y1;
|
||||
dd = vertices[1].dist - vertices[0].dist;
|
||||
d = *x;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::finalize_path(vertex_storage& vertices)
|
||||
{
|
||||
unsigned i;
|
||||
double dist;
|
||||
double d;
|
||||
|
||||
vertices.close(false);
|
||||
if(vertices.size() > 2)
|
||||
{
|
||||
if(vertices[vertices.size() - 2].dist * 10.0 <
|
||||
vertices[vertices.size() - 3].dist)
|
||||
{
|
||||
d = vertices[vertices.size() - 3].dist +
|
||||
vertices[vertices.size() - 2].dist;
|
||||
|
||||
vertices[vertices.size() - 2] =
|
||||
vertices[vertices.size() - 1];
|
||||
|
||||
vertices.remove_last();
|
||||
vertices[vertices.size() - 2].dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
dist = 0;
|
||||
for(i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
vertex_dist& v = vertices[i];
|
||||
d = v.dist;
|
||||
v.dist = dist;
|
||||
dist += d;
|
||||
}
|
||||
|
||||
return (vertices.size() - 1) / dist;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::finalize_paths()
|
||||
{
|
||||
if(m_status1 == making_path && m_src_vertices1.size() > 1 &&
|
||||
m_status2 == making_path && m_src_vertices2.size() > 1)
|
||||
{
|
||||
m_kindex1 = finalize_path(m_src_vertices1);
|
||||
m_kindex2 = finalize_path(m_src_vertices2);
|
||||
m_status1 = ready;
|
||||
m_status2 = ready;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::total_length1() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status1 == ready) ?
|
||||
m_src_vertices1[m_src_vertices1.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_double_path::total_length2() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status2 == ready) ?
|
||||
m_src_vertices2[m_src_vertices2.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::transform1(const vertex_storage& vertices,
|
||||
double kindex, double kx,
|
||||
double *x, double* y) const
|
||||
{
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double dx = 1.0;
|
||||
double dy = 1.0;
|
||||
double d = 0.0;
|
||||
double dd = 1.0;
|
||||
*x *= kx;
|
||||
if(*x < 0.0)
|
||||
{
|
||||
// Extrapolation on the left
|
||||
//--------------------------
|
||||
x1 = vertices[0].x;
|
||||
y1 = vertices[0].y;
|
||||
dx = vertices[1].x - x1;
|
||||
dy = vertices[1].y - y1;
|
||||
dd = vertices[1].dist - vertices[0].dist;
|
||||
d = *x;
|
||||
}
|
||||
else
|
||||
else
|
||||
if(*x > vertices[vertices.size() - 1].dist)
|
||||
{
|
||||
// Extrapolation on the right
|
||||
|
@ -211,13 +211,13 @@ namespace agg
|
|||
if(m_preserve_x_scale)
|
||||
{
|
||||
unsigned k;
|
||||
for(i = 0; (j - i) > 1; )
|
||||
for(i = 0; (j - i) > 1; )
|
||||
{
|
||||
if(*x < vertices[k = (i + j) >> 1].dist)
|
||||
if(*x < vertices[k = (i + j) >> 1].dist)
|
||||
{
|
||||
j = k;
|
||||
j = k;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
i = k;
|
||||
}
|
||||
|
@ -238,36 +238,36 @@ namespace agg
|
|||
dx = vertices[j].x - x1;
|
||||
dy = vertices[j].y - y1;
|
||||
}
|
||||
*x = x1 + dx * d / dd;
|
||||
*y = y1 + dy * d / dd;
|
||||
}
|
||||
*x = x1 + dx * d / dd;
|
||||
*y = y1 + dy * d / dd;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::transform(double *x, double *y) const
|
||||
//------------------------------------------------------------------------
|
||||
void trans_double_path::transform(double *x, double *y) const
|
||||
{
|
||||
if(m_status1 == ready && m_status2 == ready)
|
||||
{
|
||||
if(m_status1 == ready && m_status2 == ready)
|
||||
if(m_base_length > 1e-10)
|
||||
{
|
||||
if(m_base_length > 1e-10)
|
||||
{
|
||||
*x *= m_src_vertices1[m_src_vertices1.size() - 1].dist /
|
||||
m_base_length;
|
||||
}
|
||||
|
||||
double x1 = *x;
|
||||
double y1 = *y;
|
||||
double x2 = *x;
|
||||
double y2 = *y;
|
||||
double dd = m_src_vertices2[m_src_vertices2.size() - 1].dist /
|
||||
m_src_vertices1[m_src_vertices1.size() - 1].dist;
|
||||
|
||||
transform1(m_src_vertices1, m_kindex1, 1.0, &x1, &y1);
|
||||
transform1(m_src_vertices2, m_kindex2, dd, &x2, &y2);
|
||||
|
||||
*x = x1 + *y * (x2 - x1) / m_base_height;
|
||||
*y = y1 + *y * (y2 - y1) / m_base_height;
|
||||
*x *= m_src_vertices1[m_src_vertices1.size() - 1].dist /
|
||||
m_base_length;
|
||||
}
|
||||
|
||||
double x1 = *x;
|
||||
double y1 = *y;
|
||||
double x2 = *x;
|
||||
double y2 = *y;
|
||||
double dd = m_src_vertices2[m_src_vertices2.size() - 1].dist /
|
||||
m_src_vertices1[m_src_vertices1.size() - 1].dist;
|
||||
|
||||
transform1(m_src_vertices1, m_kindex1, 1.0, &x1, &y1);
|
||||
transform1(m_src_vertices2, m_kindex2, dd, &x2, &y2);
|
||||
|
||||
*x = x1 + *y * (x2 - x1) / m_base_height;
|
||||
*y = y1 + *y * (y2 - y1) / m_base_height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
252
deps/agg/src/agg_trans_single_path.cpp
vendored
252
deps/agg/src/agg_trans_single_path.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -20,127 +20,127 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
trans_single_path::trans_single_path() :
|
||||
m_base_length(0.0),
|
||||
m_kindex(0.0),
|
||||
m_status(initial),
|
||||
m_preserve_x_scale(true)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
trans_single_path::trans_single_path() :
|
||||
m_base_length(0.0),
|
||||
m_kindex(0.0),
|
||||
m_status(initial),
|
||||
m_preserve_x_scale(true)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::reset()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_kindex = 0.0;
|
||||
m_status = initial;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::reset()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_kindex = 0.0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::move_to(double x, double y)
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::move_to(double x, double y)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
if(m_status == initial)
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
m_status = making_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
line_to(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::line_to(double x, double y)
|
||||
{
|
||||
if(m_status == making_path)
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::finalize_path()
|
||||
{
|
||||
if(m_status == making_path && m_src_vertices.size() > 1)
|
||||
{
|
||||
unsigned i;
|
||||
double dist;
|
||||
double d;
|
||||
|
||||
m_src_vertices.close(false);
|
||||
if(m_src_vertices.size() > 2)
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
m_status = making_path;
|
||||
if(m_src_vertices[m_src_vertices.size() - 2].dist * 10.0 <
|
||||
m_src_vertices[m_src_vertices.size() - 3].dist)
|
||||
{
|
||||
d = m_src_vertices[m_src_vertices.size() - 3].dist +
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist;
|
||||
|
||||
m_src_vertices[m_src_vertices.size() - 2] =
|
||||
m_src_vertices[m_src_vertices.size() - 1];
|
||||
|
||||
m_src_vertices.remove_last();
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
dist = 0.0;
|
||||
for(i = 0; i < m_src_vertices.size(); i++)
|
||||
{
|
||||
vertex_dist& v = m_src_vertices[i];
|
||||
double d = v.dist;
|
||||
v.dist = dist;
|
||||
dist += d;
|
||||
}
|
||||
m_kindex = (m_src_vertices.size() - 1) / dist;
|
||||
m_status = ready;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_single_path::total_length() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status == ready) ?
|
||||
m_src_vertices[m_src_vertices.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::transform(double *x, double *y) const
|
||||
{
|
||||
if(m_status == ready)
|
||||
{
|
||||
if(m_base_length > 1e-10)
|
||||
{
|
||||
*x *= m_src_vertices[m_src_vertices.size() - 1].dist /
|
||||
m_base_length;
|
||||
}
|
||||
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double dx = 1.0;
|
||||
double dy = 1.0;
|
||||
double d = 0.0;
|
||||
double dd = 1.0;
|
||||
if(*x < 0.0)
|
||||
{
|
||||
// Extrapolation on the left
|
||||
//--------------------------
|
||||
x1 = m_src_vertices[0].x;
|
||||
y1 = m_src_vertices[0].y;
|
||||
dx = m_src_vertices[1].x - x1;
|
||||
dy = m_src_vertices[1].y - y1;
|
||||
dd = m_src_vertices[1].dist - m_src_vertices[0].dist;
|
||||
d = *x;
|
||||
}
|
||||
else
|
||||
{
|
||||
line_to(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::line_to(double x, double y)
|
||||
{
|
||||
if(m_status == making_path)
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::finalize_path()
|
||||
{
|
||||
if(m_status == making_path && m_src_vertices.size() > 1)
|
||||
{
|
||||
unsigned i;
|
||||
double dist;
|
||||
double d;
|
||||
|
||||
m_src_vertices.close(false);
|
||||
if(m_src_vertices.size() > 2)
|
||||
{
|
||||
if(m_src_vertices[m_src_vertices.size() - 2].dist * 10.0 <
|
||||
m_src_vertices[m_src_vertices.size() - 3].dist)
|
||||
{
|
||||
d = m_src_vertices[m_src_vertices.size() - 3].dist +
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist;
|
||||
|
||||
m_src_vertices[m_src_vertices.size() - 2] =
|
||||
m_src_vertices[m_src_vertices.size() - 1];
|
||||
|
||||
m_src_vertices.remove_last();
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
dist = 0.0;
|
||||
for(i = 0; i < m_src_vertices.size(); i++)
|
||||
{
|
||||
vertex_dist& v = m_src_vertices[i];
|
||||
double d = v.dist;
|
||||
v.dist = dist;
|
||||
dist += d;
|
||||
}
|
||||
m_kindex = (m_src_vertices.size() - 1) / dist;
|
||||
m_status = ready;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
double trans_single_path::total_length() const
|
||||
{
|
||||
if(m_base_length >= 1e-10) return m_base_length;
|
||||
return (m_status == ready) ?
|
||||
m_src_vertices[m_src_vertices.size() - 1].dist :
|
||||
0.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_single_path::transform(double *x, double *y) const
|
||||
{
|
||||
if(m_status == ready)
|
||||
{
|
||||
if(m_base_length > 1e-10)
|
||||
{
|
||||
*x *= m_src_vertices[m_src_vertices.size() - 1].dist /
|
||||
m_base_length;
|
||||
}
|
||||
|
||||
double x1 = 0.0;
|
||||
double y1 = 0.0;
|
||||
double dx = 1.0;
|
||||
double dy = 1.0;
|
||||
double d = 0.0;
|
||||
double dd = 1.0;
|
||||
if(*x < 0.0)
|
||||
{
|
||||
// Extrapolation on the left
|
||||
//--------------------------
|
||||
x1 = m_src_vertices[0].x;
|
||||
y1 = m_src_vertices[0].y;
|
||||
dx = m_src_vertices[1].x - x1;
|
||||
dy = m_src_vertices[1].y - y1;
|
||||
dd = m_src_vertices[1].dist - m_src_vertices[0].dist;
|
||||
d = *x;
|
||||
}
|
||||
else
|
||||
if(*x > m_src_vertices[m_src_vertices.size() - 1].dist)
|
||||
{
|
||||
// Extrapolation on the right
|
||||
|
@ -163,13 +163,13 @@ namespace agg
|
|||
if(m_preserve_x_scale)
|
||||
{
|
||||
unsigned k;
|
||||
for(i = 0; (j - i) > 1; )
|
||||
for(i = 0; (j - i) > 1; )
|
||||
{
|
||||
if(*x < m_src_vertices[k = (i + j) >> 1].dist)
|
||||
if(*x < m_src_vertices[k = (i + j) >> 1].dist)
|
||||
{
|
||||
j = k;
|
||||
j = k;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
i = k;
|
||||
}
|
||||
|
@ -190,12 +190,12 @@ namespace agg
|
|||
dx = m_src_vertices[j].x - x1;
|
||||
dy = m_src_vertices[j].y - y1;
|
||||
}
|
||||
double x2 = x1 + dx * d / dd;
|
||||
double y2 = y1 + dy * d / dd;
|
||||
*x = x2 - *y * dy / dd;
|
||||
*y = y2 + *y * dx / dd;
|
||||
}
|
||||
double x2 = x1 + dx * d / dd;
|
||||
double y2 = y1 + dy * d / dd;
|
||||
*x = x2 - *y * dy / dd;
|
||||
*y = y2 + *y * dx / dd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
86
deps/agg/src/agg_trans_warp_magnifier.cpp
vendored
86
deps/agg/src/agg_trans_warp_magnifier.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -19,52 +19,52 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_warp_magnifier::transform(double* x, double* y) const
|
||||
//------------------------------------------------------------------------
|
||||
void trans_warp_magnifier::transform(double* x, double* y) const
|
||||
{
|
||||
double dx = *x - m_xc;
|
||||
double dy = *y - m_yc;
|
||||
double r = sqrt(dx * dx + dy * dy);
|
||||
if(r < m_radius)
|
||||
{
|
||||
double dx = *x - m_xc;
|
||||
double dy = *y - m_yc;
|
||||
double r = sqrt(dx * dx + dy * dy);
|
||||
if(r < m_radius)
|
||||
{
|
||||
*x = m_xc + dx * m_magn;
|
||||
*y = m_yc + dy * m_magn;
|
||||
return;
|
||||
}
|
||||
|
||||
double m = (r + m_radius * (m_magn - 1.0)) / r;
|
||||
*x = m_xc + dx * m;
|
||||
*y = m_yc + dy * m;
|
||||
*x = m_xc + dx * m_magn;
|
||||
*y = m_yc + dy * m_magn;
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_warp_magnifier::inverse_transform(double* x, double* y) const
|
||||
double m = (r + m_radius * (m_magn - 1.0)) / r;
|
||||
*x = m_xc + dx * m;
|
||||
*y = m_yc + dy * m;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void trans_warp_magnifier::inverse_transform(double* x, double* y) const
|
||||
{
|
||||
// New version by Andrew Skalkin
|
||||
//-----------------
|
||||
double dx = *x - m_xc;
|
||||
double dy = *y - m_yc;
|
||||
double r = sqrt(dx * dx + dy * dy);
|
||||
|
||||
if(r < m_radius * m_magn)
|
||||
{
|
||||
// New version by Andrew Skalkin
|
||||
//-----------------
|
||||
double dx = *x - m_xc;
|
||||
double dy = *y - m_yc;
|
||||
double r = sqrt(dx * dx + dy * dy);
|
||||
|
||||
if(r < m_radius * m_magn)
|
||||
{
|
||||
*x = m_xc + dx / m_magn;
|
||||
*y = m_yc + dy / m_magn;
|
||||
}
|
||||
else
|
||||
{
|
||||
double rnew = r - m_radius * (m_magn - 1.0);
|
||||
*x = m_xc + rnew * dx / r;
|
||||
*y = m_yc + rnew * dy / r;
|
||||
}
|
||||
|
||||
// Old version
|
||||
//-----------------
|
||||
//trans_warp_magnifier t(*this);
|
||||
//t.magnification(1.0 / m_magn);
|
||||
//t.radius(m_radius * m_magn);
|
||||
//t.transform(x, y);
|
||||
*x = m_xc + dx / m_magn;
|
||||
*y = m_yc + dy / m_magn;
|
||||
}
|
||||
else
|
||||
{
|
||||
double rnew = r - m_radius * (m_magn - 1.0);
|
||||
*x = m_xc + rnew * dx / r;
|
||||
*y = m_yc + rnew * dy / r;
|
||||
}
|
||||
|
||||
// Old version
|
||||
//-----------------
|
||||
//trans_warp_magnifier t(*this);
|
||||
//t.magnification(1.0 / m_magn);
|
||||
//t.radius(m_radius * m_magn);
|
||||
//t.transform(x, y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
288
deps/agg/src/agg_vcgen_bspline.cpp
vendored
288
deps/agg/src/agg_vcgen_bspline.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -18,176 +18,176 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_bspline::vcgen_bspline() :
|
||||
m_src_vertices(),
|
||||
m_spline_x(),
|
||||
m_spline_y(),
|
||||
m_interpolation_step(1.0/50.0),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_bspline::vcgen_bspline() :
|
||||
m_src_vertices(),
|
||||
m_spline_x(),
|
||||
m_spline_y(),
|
||||
m_interpolation_step(1.0/50.0),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::remove_all()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(point_d(x, y));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::remove_all()
|
||||
else
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(point_d(x, y));
|
||||
m_src_vertices.add(point_d(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.add(point_d(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::rewind(unsigned)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_bspline::rewind(unsigned)
|
||||
{
|
||||
m_cur_abscissa = 0.0;
|
||||
m_max_abscissa = 0.0;
|
||||
m_src_vertex = 0;
|
||||
if(m_status == initial && m_src_vertices.size() > 2)
|
||||
{
|
||||
if(m_closed)
|
||||
{
|
||||
m_spline_x.init(m_src_vertices.size() + 8);
|
||||
m_spline_y.init(m_src_vertices.size() + 8);
|
||||
m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x);
|
||||
m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y);
|
||||
m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x);
|
||||
m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y);
|
||||
m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x);
|
||||
m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y);
|
||||
m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x);
|
||||
m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_spline_x.init(m_src_vertices.size());
|
||||
m_spline_y.init(m_src_vertices.size());
|
||||
}
|
||||
unsigned i;
|
||||
for(i = 0; i < m_src_vertices.size(); i++)
|
||||
{
|
||||
double x = m_closed ? i + 4 : i;
|
||||
m_spline_x.add_point(x, m_src_vertices[i].x);
|
||||
m_spline_y.add_point(x, m_src_vertices[i].y);
|
||||
}
|
||||
m_cur_abscissa = 0.0;
|
||||
m_max_abscissa = 0.0;
|
||||
m_src_vertex = 0;
|
||||
if(m_status == initial && m_src_vertices.size() > 2)
|
||||
m_max_abscissa = m_src_vertices.size() - 1;
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_closed)
|
||||
{
|
||||
m_spline_x.init(m_src_vertices.size() + 8);
|
||||
m_spline_y.init(m_src_vertices.size() + 8);
|
||||
m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x);
|
||||
m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y);
|
||||
m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x);
|
||||
m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y);
|
||||
m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x);
|
||||
m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y);
|
||||
m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x);
|
||||
m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_spline_x.init(m_src_vertices.size());
|
||||
m_spline_y.init(m_src_vertices.size());
|
||||
}
|
||||
unsigned i;
|
||||
for(i = 0; i < m_src_vertices.size(); i++)
|
||||
{
|
||||
double x = m_closed ? i + 4 : i;
|
||||
m_spline_x.add_point(x, m_src_vertices[i].x);
|
||||
m_spline_y.add_point(x, m_src_vertices[i].y);
|
||||
}
|
||||
m_cur_abscissa = 0.0;
|
||||
m_max_abscissa = m_src_vertices.size() - 1;
|
||||
if(m_closed)
|
||||
{
|
||||
m_cur_abscissa = 4.0;
|
||||
m_max_abscissa += 5.0;
|
||||
m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y);
|
||||
}
|
||||
m_spline_x.prepare();
|
||||
m_spline_y.prepare();
|
||||
m_cur_abscissa = 4.0;
|
||||
m_max_abscissa += 5.0;
|
||||
m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y);
|
||||
m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x);
|
||||
m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y);
|
||||
}
|
||||
m_status = ready;
|
||||
m_spline_x.prepare();
|
||||
m_spline_y.prepare();
|
||||
}
|
||||
m_status = ready;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_bspline::vertex(double* x, double* y)
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_bspline::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
switch(m_status)
|
||||
{
|
||||
switch(m_status)
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2)
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
if(m_src_vertices.size() == 2)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertex].x;
|
||||
*y = m_src_vertices[m_src_vertex].y;
|
||||
m_src_vertex++;
|
||||
if(m_src_vertex == 1) return path_cmd_move_to;
|
||||
if(m_src_vertex == 2) return path_cmd_line_to;
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = path_cmd_move_to;
|
||||
m_status = polygon;
|
||||
m_src_vertex = 0;
|
||||
|
||||
case polygon:
|
||||
if(m_cur_abscissa >= m_max_abscissa)
|
||||
{
|
||||
if(m_closed)
|
||||
{
|
||||
m_status = end_poly;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertices.size() - 1].x;
|
||||
*y = m_src_vertices[m_src_vertices.size() - 1].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
}
|
||||
|
||||
*x = m_spline_x.get_stateful(m_cur_abscissa);
|
||||
*y = m_spline_y.get_stateful(m_cur_abscissa);
|
||||
m_src_vertex++;
|
||||
m_cur_abscissa += m_interpolation_step;
|
||||
return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
|
||||
|
||||
case end_poly:
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | m_closed;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
if(m_src_vertices.size() == 2)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertex].x;
|
||||
*y = m_src_vertices[m_src_vertex].y;
|
||||
m_src_vertex++;
|
||||
if(m_src_vertex == 1) return path_cmd_move_to;
|
||||
if(m_src_vertex == 2) return path_cmd_line_to;
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = path_cmd_move_to;
|
||||
m_status = polygon;
|
||||
m_src_vertex = 0;
|
||||
|
||||
case polygon:
|
||||
if(m_cur_abscissa >= m_max_abscissa)
|
||||
{
|
||||
if(m_closed)
|
||||
{
|
||||
m_status = end_poly;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertices.size() - 1].x;
|
||||
*y = m_src_vertices[m_src_vertices.size() - 1].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
}
|
||||
|
||||
*x = m_spline_x.get_stateful(m_cur_abscissa);
|
||||
*y = m_spline_y.get_stateful(m_cur_abscissa);
|
||||
m_src_vertex++;
|
||||
m_cur_abscissa += m_interpolation_step;
|
||||
return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
|
||||
|
||||
case end_poly:
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | m_closed;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
252
deps/agg/src/agg_vcgen_contour.cpp
vendored
252
deps/agg/src/agg_vcgen_contour.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -23,143 +23,143 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_contour::vcgen_contour() :
|
||||
m_stroker(),
|
||||
m_width(1),
|
||||
m_src_vertices(),
|
||||
m_out_vertices(),
|
||||
m_status(initial),
|
||||
m_src_vertex(0),
|
||||
m_closed(0),
|
||||
m_orientation(0),
|
||||
m_auto_detect(false)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_contour::vcgen_contour() :
|
||||
m_stroker(),
|
||||
m_width(1),
|
||||
m_src_vertices(),
|
||||
m_out_vertices(),
|
||||
m_status(initial),
|
||||
m_src_vertex(0),
|
||||
m_closed(0),
|
||||
m_orientation(0),
|
||||
m_auto_detect(false)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::remove_all()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_orientation = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::remove_all()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_orientation = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::add_vertex(double x, double y, unsigned cmd)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
if(is_end_poly(cmd))
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
m_closed = get_close_flag(cmd);
|
||||
if(m_orientation == path_flags_none)
|
||||
{
|
||||
m_orientation = get_orientation(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::rewind(unsigned)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(true);
|
||||
if(m_auto_detect)
|
||||
{
|
||||
if(!is_oriented(m_orientation))
|
||||
{
|
||||
m_orientation = (calc_polygon_area(m_src_vertices) > 0.0) ?
|
||||
path_flags_ccw :
|
||||
path_flags_cw;
|
||||
}
|
||||
}
|
||||
if(is_oriented(m_orientation))
|
||||
{
|
||||
m_stroker.width(is_ccw(m_orientation) ? m_width : -m_width);
|
||||
}
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_contour::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
switch(m_status)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = outline;
|
||||
cmd = path_cmd_move_to;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
|
||||
case outline:
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_status = end_poly;
|
||||
break;
|
||||
}
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex).dist,
|
||||
m_src_vertices.curr(m_src_vertex).dist);
|
||||
++m_src_vertex;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
|
||||
case out_vertices:
|
||||
if(m_out_vertex >= m_out_vertices.size())
|
||||
{
|
||||
m_status = outline;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_end_poly(cmd))
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
if(m_orientation == path_flags_none)
|
||||
{
|
||||
m_orientation = get_orientation(cmd);
|
||||
}
|
||||
}
|
||||
const point_d& c = m_out_vertices[m_out_vertex++];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
return cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case end_poly:
|
||||
if(!m_closed) return path_cmd_stop;
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_contour::rewind(unsigned)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(true);
|
||||
if(m_auto_detect)
|
||||
{
|
||||
if(!is_oriented(m_orientation))
|
||||
{
|
||||
m_orientation = (calc_polygon_area(m_src_vertices) > 0.0) ?
|
||||
path_flags_ccw :
|
||||
path_flags_cw;
|
||||
}
|
||||
}
|
||||
if(is_oriented(m_orientation))
|
||||
{
|
||||
m_stroker.width(is_ccw(m_orientation) ? m_width : -m_width);
|
||||
}
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_contour::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
switch(m_status)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = outline;
|
||||
cmd = path_cmd_move_to;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
|
||||
case outline:
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_status = end_poly;
|
||||
break;
|
||||
}
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex).dist,
|
||||
m_src_vertices.curr(m_src_vertex).dist);
|
||||
++m_src_vertex;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
|
||||
case out_vertices:
|
||||
if(m_out_vertex >= m_out_vertices.size())
|
||||
{
|
||||
m_status = outline;
|
||||
}
|
||||
else
|
||||
{
|
||||
const point_d& c = m_out_vertices[m_out_vertex++];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
return cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case end_poly:
|
||||
if(!m_closed) return path_cmd_stop;
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
364
deps/agg/src/agg_vcgen_dash.cpp
vendored
364
deps/agg/src/agg_vcgen_dash.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -24,211 +24,211 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_dash::vcgen_dash() :
|
||||
m_total_dash_len(0.0),
|
||||
m_num_dashes(0),
|
||||
m_dash_start(0.0),
|
||||
m_shorten(0.0),
|
||||
m_curr_dash_start(0.0),
|
||||
m_curr_dash(0),
|
||||
m_src_vertices(),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_dash::vcgen_dash() :
|
||||
m_total_dash_len(0.0),
|
||||
m_num_dashes(0),
|
||||
m_dash_start(0.0),
|
||||
m_shorten(0.0),
|
||||
m_curr_dash_start(0.0),
|
||||
m_curr_dash(0),
|
||||
m_src_vertices(),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::remove_all_dashes()
|
||||
{
|
||||
m_total_dash_len = 0.0;
|
||||
m_num_dashes = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
m_curr_dash = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::add_dash(double dash_len, double gap_len)
|
||||
{
|
||||
if(m_num_dashes < max_dashes)
|
||||
{
|
||||
m_total_dash_len += dash_len + gap_len;
|
||||
m_dashes[m_num_dashes++] = dash_len;
|
||||
m_dashes[m_num_dashes++] = gap_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::dash_start(double ds)
|
||||
{
|
||||
m_dash_start = ds;
|
||||
calc_dash_start(fabs(ds));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::remove_all_dashes()
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::calc_dash_start(double ds)
|
||||
{
|
||||
m_curr_dash = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
while(ds > 0.0)
|
||||
{
|
||||
m_total_dash_len = 0.0;
|
||||
m_num_dashes = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
m_curr_dash = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::add_dash(double dash_len, double gap_len)
|
||||
{
|
||||
if(m_num_dashes < max_dashes)
|
||||
if(ds > m_dashes[m_curr_dash])
|
||||
{
|
||||
m_total_dash_len += dash_len + gap_len;
|
||||
m_dashes[m_num_dashes++] = dash_len;
|
||||
m_dashes[m_num_dashes++] = gap_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::dash_start(double ds)
|
||||
{
|
||||
m_dash_start = ds;
|
||||
calc_dash_start(fabs(ds));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::calc_dash_start(double ds)
|
||||
{
|
||||
m_curr_dash = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
while(ds > 0.0)
|
||||
{
|
||||
if(ds > m_dashes[m_curr_dash])
|
||||
{
|
||||
ds -= m_dashes[m_curr_dash];
|
||||
++m_curr_dash;
|
||||
m_curr_dash_start = 0.0;
|
||||
if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curr_dash_start = ds;
|
||||
ds = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::remove_all()
|
||||
{
|
||||
m_status = initial;
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
ds -= m_dashes[m_curr_dash];
|
||||
++m_curr_dash;
|
||||
m_curr_dash_start = 0.0;
|
||||
if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
m_curr_dash_start = ds;
|
||||
ds = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::rewind(unsigned)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::remove_all()
|
||||
{
|
||||
m_status = initial;
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
shorten_path(m_src_vertices, m_shorten, m_closed);
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_dash::vertex(double* x, double* y)
|
||||
else
|
||||
{
|
||||
unsigned cmd = path_cmd_move_to;
|
||||
while(!is_stop(cmd))
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
switch(m_status)
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_dash::rewind(unsigned)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
shorten_path(m_src_vertices, m_shorten, m_closed);
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_dash::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_move_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
switch(m_status)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_num_dashes < 2 || m_src_vertices.size() < 2)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_num_dashes < 2 || m_src_vertices.size() < 2)
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = polyline;
|
||||
m_src_vertex = 1;
|
||||
m_v1 = &m_src_vertices[0];
|
||||
m_v2 = &m_src_vertices[1];
|
||||
m_curr_rest = m_v1->dist;
|
||||
*x = m_v1->x;
|
||||
*y = m_v1->y;
|
||||
if(m_dash_start >= 0.0) calc_dash_start(m_dash_start);
|
||||
return path_cmd_move_to;
|
||||
|
||||
case polyline:
|
||||
{
|
||||
double dash_rest = m_dashes[m_curr_dash] - m_curr_dash_start;
|
||||
|
||||
unsigned cmd = (m_curr_dash & 1) ?
|
||||
path_cmd_move_to :
|
||||
path_cmd_line_to;
|
||||
|
||||
if(m_curr_rest > dash_rest)
|
||||
{
|
||||
m_curr_rest -= dash_rest;
|
||||
++m_curr_dash;
|
||||
if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
*x = m_v2->x - (m_v2->x - m_v1->x) * m_curr_rest / m_v1->dist;
|
||||
*y = m_v2->y - (m_v2->y - m_v1->y) * m_curr_rest / m_v1->dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curr_dash_start += m_curr_rest;
|
||||
*x = m_v2->x;
|
||||
*y = m_v2->y;
|
||||
++m_src_vertex;
|
||||
m_v1 = m_v2;
|
||||
m_curr_rest = m_v1->dist;
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex > m_src_vertices.size())
|
||||
{
|
||||
m_status = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v2 = &m_src_vertices
|
||||
[
|
||||
(m_src_vertex >= m_src_vertices.size()) ? 0 :
|
||||
m_src_vertex
|
||||
];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_status = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v2 = &m_src_vertices[m_src_vertex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case stop:
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = polyline;
|
||||
m_src_vertex = 1;
|
||||
m_v1 = &m_src_vertices[0];
|
||||
m_v2 = &m_src_vertices[1];
|
||||
m_curr_rest = m_v1->dist;
|
||||
*x = m_v1->x;
|
||||
*y = m_v1->y;
|
||||
if(m_dash_start >= 0.0) calc_dash_start(m_dash_start);
|
||||
return path_cmd_move_to;
|
||||
|
||||
case polyline:
|
||||
{
|
||||
double dash_rest = m_dashes[m_curr_dash] - m_curr_dash_start;
|
||||
|
||||
unsigned cmd = (m_curr_dash & 1) ?
|
||||
path_cmd_move_to :
|
||||
path_cmd_line_to;
|
||||
|
||||
if(m_curr_rest > dash_rest)
|
||||
{
|
||||
m_curr_rest -= dash_rest;
|
||||
++m_curr_dash;
|
||||
if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
|
||||
m_curr_dash_start = 0.0;
|
||||
*x = m_v2->x - (m_v2->x - m_v1->x) * m_curr_rest / m_v1->dist;
|
||||
*y = m_v2->y - (m_v2->y - m_v1->y) * m_curr_rest / m_v1->dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curr_dash_start += m_curr_rest;
|
||||
*x = m_v2->x;
|
||||
*y = m_v2->y;
|
||||
++m_src_vertex;
|
||||
m_v1 = m_v2;
|
||||
m_curr_rest = m_v1->dist;
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex > m_src_vertices.size())
|
||||
{
|
||||
m_status = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v2 = &m_src_vertices
|
||||
[
|
||||
(m_src_vertex >= m_src_vertices.size()) ? 0 :
|
||||
m_src_vertex
|
||||
];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_status = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v2 = &m_src_vertices[m_src_vertex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
return path_cmd_stop;
|
||||
break;
|
||||
|
||||
case stop:
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
114
deps/agg/src/agg_vcgen_markers_term.cpp
vendored
114
deps/agg/src/agg_vcgen_markers_term.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -22,82 +22,82 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::remove_all()
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::remove_all()
|
||||
{
|
||||
m_markers.remove_all();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_markers.remove_all();
|
||||
if(m_markers.size() & 1)
|
||||
{
|
||||
// Initial state, the first coordinate was added.
|
||||
// If two of more calls of start_vertex() occures
|
||||
// we just modify the last one.
|
||||
m_markers.modify_last(coord_type(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_markers.add(coord_type(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::add_vertex(double x, double y, unsigned cmd)
|
||||
else
|
||||
{
|
||||
if(is_move_to(cmd))
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
if(m_markers.size() & 1)
|
||||
{
|
||||
// Initial state, the first coordinate was added.
|
||||
// If two of more calls of start_vertex() occures
|
||||
// we just modify the last one.
|
||||
m_markers.modify_last(coord_type(x, y));
|
||||
// Add three more points, 0,1,1,0
|
||||
m_markers.add(coord_type(x, y));
|
||||
m_markers.add(m_markers[m_markers.size() - 1]);
|
||||
m_markers.add(m_markers[m_markers.size() - 3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_markers.add(coord_type(x, y));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
if(m_markers.size() & 1)
|
||||
if(m_markers.size())
|
||||
{
|
||||
// Initial state, the first coordinate was added.
|
||||
// Add three more points, 0,1,1,0
|
||||
m_markers.add(coord_type(x, y));
|
||||
m_markers.add(m_markers[m_markers.size() - 1]);
|
||||
m_markers.add(m_markers[m_markers.size() - 3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_markers.size())
|
||||
{
|
||||
// Replace two last points: 0,1,1,0 -> 0,1,2,1
|
||||
m_markers[m_markers.size() - 1] = m_markers[m_markers.size() - 2];
|
||||
m_markers[m_markers.size() - 2] = coord_type(x, y);
|
||||
}
|
||||
// Replace two last points: 0,1,1,0 -> 0,1,2,1
|
||||
m_markers[m_markers.size() - 1] = m_markers[m_markers.size() - 2];
|
||||
m_markers[m_markers.size() - 2] = coord_type(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::rewind(unsigned path_id)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_markers_term::rewind(unsigned path_id)
|
||||
{
|
||||
m_curr_id = path_id * 2;
|
||||
m_curr_idx = m_curr_id;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_markers_term::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_curr_id > 2 || m_curr_idx >= m_markers.size())
|
||||
{
|
||||
m_curr_id = path_id * 2;
|
||||
m_curr_idx = m_curr_id;
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_markers_term::vertex(double* x, double* y)
|
||||
const coord_type& c = m_markers[m_curr_idx];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
if(m_curr_idx & 1)
|
||||
{
|
||||
if(m_curr_id > 2 || m_curr_idx >= m_markers.size())
|
||||
{
|
||||
return path_cmd_stop;
|
||||
}
|
||||
const coord_type& c = m_markers[m_curr_idx];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
if(m_curr_idx & 1)
|
||||
{
|
||||
m_curr_idx += 3;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
++m_curr_idx;
|
||||
return path_cmd_move_to;
|
||||
m_curr_idx += 3;
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
++m_curr_idx;
|
||||
return path_cmd_move_to;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
342
deps/agg/src/agg_vcgen_smooth_poly1.cpp
vendored
342
deps/agg/src/agg_vcgen_smooth_poly1.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -22,204 +22,204 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_smooth_poly1::vcgen_smooth_poly1() :
|
||||
m_src_vertices(),
|
||||
m_smooth_value(0.5),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_smooth_poly1::vcgen_smooth_poly1() :
|
||||
m_src_vertices(),
|
||||
m_smooth_value(0.5),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::remove_all()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::remove_all()
|
||||
else
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::rewind(unsigned)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::rewind(unsigned)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::calculate(const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
const vertex_dist& v2,
|
||||
const vertex_dist& v3)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_smooth_poly1::calculate(const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
const vertex_dist& v2,
|
||||
const vertex_dist& v3)
|
||||
{
|
||||
|
||||
double k1 = v0.dist / (v0.dist + v1.dist);
|
||||
double k2 = v1.dist / (v1.dist + v2.dist);
|
||||
|
||||
double xm1 = v0.x + (v2.x - v0.x) * k1;
|
||||
double ym1 = v0.y + (v2.y - v0.y) * k1;
|
||||
double xm2 = v1.x + (v3.x - v1.x) * k2;
|
||||
double ym2 = v1.y + (v3.y - v1.y) * k2;
|
||||
|
||||
m_ctrl1_x = v1.x + m_smooth_value * (v2.x - xm1);
|
||||
m_ctrl1_y = v1.y + m_smooth_value * (v2.y - ym1);
|
||||
m_ctrl2_x = v2.x + m_smooth_value * (v1.x - xm2);
|
||||
m_ctrl2_y = v2.y + m_smooth_value * (v1.y - ym2);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_smooth_poly1::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
|
||||
double k1 = v0.dist / (v0.dist + v1.dist);
|
||||
double k2 = v1.dist / (v1.dist + v2.dist);
|
||||
|
||||
double xm1 = v0.x + (v2.x - v0.x) * k1;
|
||||
double ym1 = v0.y + (v2.y - v0.y) * k1;
|
||||
double xm2 = v1.x + (v3.x - v1.x) * k2;
|
||||
double ym2 = v1.y + (v3.y - v1.y) * k2;
|
||||
|
||||
m_ctrl1_x = v1.x + m_smooth_value * (v2.x - xm1);
|
||||
m_ctrl1_y = v1.y + m_smooth_value * (v2.y - ym1);
|
||||
m_ctrl2_x = v2.x + m_smooth_value * (v1.x - xm2);
|
||||
m_ctrl2_y = v2.y + m_smooth_value * (v1.y - ym2);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_smooth_poly1::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
switch(m_status)
|
||||
{
|
||||
switch(m_status)
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2)
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2)
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
if(m_src_vertices.size() == 2)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertex].x;
|
||||
*y = m_src_vertices[m_src_vertex].y;
|
||||
m_src_vertex++;
|
||||
if(m_src_vertex == 1) return path_cmd_move_to;
|
||||
if(m_src_vertex == 2) return path_cmd_line_to;
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = path_cmd_move_to;
|
||||
m_status = polygon;
|
||||
m_src_vertex = 0;
|
||||
|
||||
case polygon:
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
*x = m_src_vertices[0].x;
|
||||
*y = m_src_vertices[0].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_curve4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertices.size() - 1].x;
|
||||
*y = m_src_vertices[m_src_vertices.size() - 1].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_curve3;
|
||||
}
|
||||
}
|
||||
|
||||
calculate(m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex + 1));
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
if(m_src_vertices.size() == 2)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertex].x;
|
||||
*y = m_src_vertices[m_src_vertex].y;
|
||||
m_src_vertex++;
|
||||
if(m_src_vertex == 1) return path_cmd_move_to;
|
||||
if(m_src_vertex == 2) return path_cmd_line_to;
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
if(m_closed)
|
||||
cmd = path_cmd_move_to;
|
||||
m_status = polygon;
|
||||
m_src_vertex = 0;
|
||||
|
||||
case polygon:
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_status = ctrl1;
|
||||
return ((m_src_vertex == 1) ?
|
||||
path_cmd_move_to :
|
||||
path_cmd_curve4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex == 1)
|
||||
{
|
||||
m_status = ctrl_b;
|
||||
return path_cmd_move_to;
|
||||
}
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
m_status = ctrl_e;
|
||||
return path_cmd_curve3;
|
||||
}
|
||||
m_status = ctrl1;
|
||||
*x = m_src_vertices[0].x;
|
||||
*y = m_src_vertices[0].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_curve4;
|
||||
}
|
||||
break;
|
||||
|
||||
case ctrl_b:
|
||||
*x = m_ctrl2_x;
|
||||
*y = m_ctrl2_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve3;
|
||||
|
||||
case ctrl_e:
|
||||
*x = m_ctrl1_x;
|
||||
*y = m_ctrl1_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve3;
|
||||
|
||||
case ctrl1:
|
||||
*x = m_ctrl1_x;
|
||||
*y = m_ctrl1_y;
|
||||
m_status = ctrl2;
|
||||
return path_cmd_curve4;
|
||||
|
||||
case ctrl2:
|
||||
*x = m_ctrl2_x;
|
||||
*y = m_ctrl2_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve4;
|
||||
|
||||
case end_poly:
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | m_closed;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
*x = m_src_vertices[m_src_vertices.size() - 1].x;
|
||||
*y = m_src_vertices[m_src_vertices.size() - 1].y;
|
||||
m_status = end_poly;
|
||||
return path_cmd_curve3;
|
||||
}
|
||||
}
|
||||
|
||||
calculate(m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex + 1));
|
||||
|
||||
*x = m_src_vertices[m_src_vertex].x;
|
||||
*y = m_src_vertices[m_src_vertex].y;
|
||||
m_src_vertex++;
|
||||
|
||||
if(m_closed)
|
||||
{
|
||||
m_status = ctrl1;
|
||||
return ((m_src_vertex == 1) ?
|
||||
path_cmd_move_to :
|
||||
path_cmd_curve4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex == 1)
|
||||
{
|
||||
m_status = ctrl_b;
|
||||
return path_cmd_move_to;
|
||||
}
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
m_status = ctrl_e;
|
||||
return path_cmd_curve3;
|
||||
}
|
||||
m_status = ctrl1;
|
||||
return path_cmd_curve4;
|
||||
}
|
||||
break;
|
||||
|
||||
case ctrl_b:
|
||||
*x = m_ctrl2_x;
|
||||
*y = m_ctrl2_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve3;
|
||||
|
||||
case ctrl_e:
|
||||
*x = m_ctrl1_x;
|
||||
*y = m_ctrl1_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve3;
|
||||
|
||||
case ctrl1:
|
||||
*x = m_ctrl1_x;
|
||||
*y = m_ctrl1_y;
|
||||
m_status = ctrl2;
|
||||
return path_cmd_curve4;
|
||||
|
||||
case ctrl2:
|
||||
*x = m_ctrl2_x;
|
||||
*y = m_ctrl2_y;
|
||||
m_status = polygon;
|
||||
return path_cmd_curve4;
|
||||
|
||||
case end_poly:
|
||||
m_status = stop;
|
||||
return path_cmd_end_poly | m_closed;
|
||||
|
||||
case stop:
|
||||
return path_cmd_stop;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
332
deps/agg/src/agg_vcgen_stroke.cpp
vendored
332
deps/agg/src/agg_vcgen_stroke.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -23,191 +23,191 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_stroke::vcgen_stroke() :
|
||||
m_stroker(),
|
||||
m_src_vertices(),
|
||||
m_out_vertices(),
|
||||
m_shorten(0.0),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0),
|
||||
m_out_vertex(0)
|
||||
//------------------------------------------------------------------------
|
||||
vcgen_stroke::vcgen_stroke() :
|
||||
m_stroker(),
|
||||
m_src_vertices(),
|
||||
m_out_vertices(),
|
||||
m_shorten(0.0),
|
||||
m_closed(0),
|
||||
m_status(initial),
|
||||
m_src_vertex(0),
|
||||
m_out_vertex(0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::remove_all()
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::remove_all()
|
||||
else
|
||||
{
|
||||
m_src_vertices.remove_all();
|
||||
m_closed = 0;
|
||||
m_status = initial;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_status = initial;
|
||||
if(is_move_to(cmd))
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_dist(x, y));
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
m_src_vertices.add(vertex_dist(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
m_closed = get_close_flag(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::rewind(unsigned)
|
||||
//------------------------------------------------------------------------
|
||||
void vcgen_stroke::rewind(unsigned)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
if(m_status == initial)
|
||||
{
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
shorten_path(m_src_vertices, m_shorten, m_closed);
|
||||
if(m_src_vertices.size() < 3) m_closed = 0;
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
m_src_vertices.close(m_closed != 0);
|
||||
shorten_path(m_src_vertices, m_shorten, m_closed);
|
||||
if(m_src_vertices.size() < 3) m_closed = 0;
|
||||
}
|
||||
m_status = ready;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_stroke::vertex(double* x, double* y)
|
||||
//------------------------------------------------------------------------
|
||||
unsigned vcgen_stroke::vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
unsigned cmd = path_cmd_line_to;
|
||||
while(!is_stop(cmd))
|
||||
switch(m_status)
|
||||
{
|
||||
switch(m_status)
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
|
||||
{
|
||||
case initial:
|
||||
rewind(0);
|
||||
|
||||
case ready:
|
||||
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
|
||||
{
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = m_closed ? outline1 : cap1;
|
||||
cmd = path_cmd_move_to;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case cap1:
|
||||
m_stroker.calc_cap(m_out_vertices,
|
||||
m_src_vertices[0],
|
||||
m_src_vertices[1],
|
||||
m_src_vertices[0].dist);
|
||||
m_src_vertex = 1;
|
||||
m_prev_status = outline1;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case cap2:
|
||||
m_stroker.calc_cap(m_out_vertices,
|
||||
m_src_vertices[m_src_vertices.size() - 1],
|
||||
m_src_vertices[m_src_vertices.size() - 2],
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist);
|
||||
m_prev_status = outline2;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case outline1:
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_prev_status = close_first;
|
||||
m_status = end_poly1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
m_status = cap2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex).dist,
|
||||
m_src_vertices.curr(m_src_vertex).dist);
|
||||
++m_src_vertex;
|
||||
m_prev_status = m_status;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case close_first:
|
||||
m_status = outline2;
|
||||
cmd = path_cmd_move_to;
|
||||
|
||||
case outline2:
|
||||
if(m_src_vertex <= unsigned(m_closed == 0))
|
||||
{
|
||||
m_status = end_poly2;
|
||||
m_prev_status = stop;
|
||||
break;
|
||||
}
|
||||
|
||||
--m_src_vertex;
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex).dist,
|
||||
m_src_vertices.prev(m_src_vertex).dist);
|
||||
|
||||
m_prev_status = m_status;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case out_vertices:
|
||||
if(m_out_vertex >= m_out_vertices.size())
|
||||
{
|
||||
m_status = m_prev_status;
|
||||
}
|
||||
else
|
||||
{
|
||||
const point_d& c = m_out_vertices[m_out_vertex++];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
return cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case end_poly1:
|
||||
m_status = m_prev_status;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
|
||||
case end_poly2:
|
||||
m_status = m_prev_status;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_cw;
|
||||
|
||||
case stop:
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
m_status = m_closed ? outline1 : cap1;
|
||||
cmd = path_cmd_move_to;
|
||||
m_src_vertex = 0;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case cap1:
|
||||
m_stroker.calc_cap(m_out_vertices,
|
||||
m_src_vertices[0],
|
||||
m_src_vertices[1],
|
||||
m_src_vertices[0].dist);
|
||||
m_src_vertex = 1;
|
||||
m_prev_status = outline1;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case cap2:
|
||||
m_stroker.calc_cap(m_out_vertices,
|
||||
m_src_vertices[m_src_vertices.size() - 1],
|
||||
m_src_vertices[m_src_vertices.size() - 2],
|
||||
m_src_vertices[m_src_vertices.size() - 2].dist);
|
||||
m_prev_status = outline2;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case outline1:
|
||||
if(m_closed)
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size())
|
||||
{
|
||||
m_prev_status = close_first;
|
||||
m_status = end_poly1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_src_vertex >= m_src_vertices.size() - 1)
|
||||
{
|
||||
m_status = cap2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex).dist,
|
||||
m_src_vertices.curr(m_src_vertex).dist);
|
||||
++m_src_vertex;
|
||||
m_prev_status = m_status;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case close_first:
|
||||
m_status = outline2;
|
||||
cmd = path_cmd_move_to;
|
||||
|
||||
case outline2:
|
||||
if(m_src_vertex <= unsigned(m_closed == 0))
|
||||
{
|
||||
m_status = end_poly2;
|
||||
m_prev_status = stop;
|
||||
break;
|
||||
}
|
||||
|
||||
--m_src_vertex;
|
||||
m_stroker.calc_join(m_out_vertices,
|
||||
m_src_vertices.next(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex),
|
||||
m_src_vertices.prev(m_src_vertex),
|
||||
m_src_vertices.curr(m_src_vertex).dist,
|
||||
m_src_vertices.prev(m_src_vertex).dist);
|
||||
|
||||
m_prev_status = m_status;
|
||||
m_status = out_vertices;
|
||||
m_out_vertex = 0;
|
||||
break;
|
||||
|
||||
case out_vertices:
|
||||
if(m_out_vertex >= m_out_vertices.size())
|
||||
{
|
||||
m_status = m_prev_status;
|
||||
}
|
||||
else
|
||||
{
|
||||
const point_d& c = m_out_vertices[m_out_vertex++];
|
||||
*x = c.x;
|
||||
*y = c.y;
|
||||
return cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case end_poly1:
|
||||
m_status = m_prev_status;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
|
||||
case end_poly2:
|
||||
m_status = m_prev_status;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_cw;
|
||||
|
||||
case stop:
|
||||
cmd = path_cmd_stop;
|
||||
break;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
184
deps/agg/src/agg_vpgen_clip_polygon.cpp
vendored
184
deps/agg/src/agg_vpgen_clip_polygon.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -19,115 +19,115 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Determine the clipping code of the vertex according to the
|
||||
// Cyrus-Beck line clipping algorithm
|
||||
//
|
||||
// | |
|
||||
// 0110 | 0010 | 0011
|
||||
// | |
|
||||
// -------+--------+-------- clip_box.y2
|
||||
// | |
|
||||
// 0100 | 0000 | 0001
|
||||
// | |
|
||||
// -------+--------+-------- clip_box.y1
|
||||
// | |
|
||||
// 1100 | 1000 | 1001
|
||||
// | |
|
||||
// clip_box.x1 clip_box.x2
|
||||
//
|
||||
//
|
||||
unsigned vpgen_clip_polygon::clipping_flags(double x, double y)
|
||||
//------------------------------------------------------------------------
|
||||
// Determine the clipping code of the vertex according to the
|
||||
// Cyrus-Beck line clipping algorithm
|
||||
//
|
||||
// | |
|
||||
// 0110 | 0010 | 0011
|
||||
// | |
|
||||
// -------+--------+-------- clip_box.y2
|
||||
// | |
|
||||
// 0100 | 0000 | 0001
|
||||
// | |
|
||||
// -------+--------+-------- clip_box.y1
|
||||
// | |
|
||||
// 1100 | 1000 | 1001
|
||||
// | |
|
||||
// clip_box.x1 clip_box.x2
|
||||
//
|
||||
//
|
||||
unsigned vpgen_clip_polygon::clipping_flags(double x, double y)
|
||||
{
|
||||
if(x < m_clip_box.x1)
|
||||
{
|
||||
if(x < m_clip_box.x1)
|
||||
{
|
||||
if(y > m_clip_box.y2) return 6;
|
||||
if(y < m_clip_box.y1) return 12;
|
||||
return 4;
|
||||
}
|
||||
|
||||
if(x > m_clip_box.x2)
|
||||
{
|
||||
if(y > m_clip_box.y2) return 3;
|
||||
if(y < m_clip_box.y1) return 9;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(y > m_clip_box.y2) return 2;
|
||||
if(y < m_clip_box.y1) return 8;
|
||||
|
||||
return 0;
|
||||
if(y > m_clip_box.y2) return 6;
|
||||
if(y < m_clip_box.y1) return 12;
|
||||
return 4;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::reset()
|
||||
if(x > m_clip_box.x2)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
if(y > m_clip_box.y2) return 3;
|
||||
if(y < m_clip_box.y1) return 9;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::move_to(double x, double y)
|
||||
if(y > m_clip_box.y2) return 2;
|
||||
if(y < m_clip_box.y1) return 8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::reset()
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::move_to(double x, double y)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_clip_flags = clipping_flags(x, y);
|
||||
if(m_clip_flags == 0)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_clip_flags = clipping_flags(x, y);
|
||||
if(m_clip_flags == 0)
|
||||
m_x[0] = x;
|
||||
m_y[0] = y;
|
||||
m_num_vertices = 1;
|
||||
}
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_cmd = path_cmd_move_to;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::line_to(double x, double y)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
unsigned flags = clipping_flags(x, y);
|
||||
|
||||
if(m_clip_flags == flags)
|
||||
{
|
||||
if(flags == 0)
|
||||
{
|
||||
m_x[0] = x;
|
||||
m_y[0] = y;
|
||||
m_num_vertices = 1;
|
||||
}
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_cmd = path_cmd_move_to;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polygon::line_to(double x, double y)
|
||||
else
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
unsigned flags = clipping_flags(x, y);
|
||||
|
||||
if(m_clip_flags == flags)
|
||||
{
|
||||
if(flags == 0)
|
||||
{
|
||||
m_x[0] = x;
|
||||
m_y[0] = y;
|
||||
m_num_vertices = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_num_vertices = clip_liang_barsky(m_x1, m_y1,
|
||||
x, y,
|
||||
m_clip_box,
|
||||
m_x, m_y);
|
||||
}
|
||||
|
||||
m_clip_flags = flags;
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_num_vertices = clip_liang_barsky(m_x1, m_y1,
|
||||
x, y,
|
||||
m_clip_box,
|
||||
m_x, m_y);
|
||||
}
|
||||
|
||||
m_clip_flags = flags;
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
unsigned vpgen_clip_polygon::vertex(double* x, double* y)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
unsigned vpgen_clip_polygon::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_vertex < m_num_vertices)
|
||||
{
|
||||
if(m_vertex < m_num_vertices)
|
||||
{
|
||||
*x = m_x[m_vertex];
|
||||
*y = m_y[m_vertex];
|
||||
++m_vertex;
|
||||
unsigned cmd = m_cmd;
|
||||
m_cmd = path_cmd_line_to;
|
||||
return cmd;
|
||||
}
|
||||
return path_cmd_stop;
|
||||
*x = m_x[m_vertex];
|
||||
*y = m_y[m_vertex];
|
||||
++m_vertex;
|
||||
unsigned cmd = m_cmd;
|
||||
m_cmd = path_cmd_line_to;
|
||||
return cmd;
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
116
deps/agg/src/agg_vpgen_clip_polyline.cpp
vendored
116
deps/agg/src/agg_vpgen_clip_polyline.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -18,60 +18,60 @@
|
|||
|
||||
namespace agg
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::reset()
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_move_to = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::move_to(double x, double y)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_move_to = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::line_to(double x, double y)
|
||||
{
|
||||
double x2 = x;
|
||||
double y2 = y;
|
||||
unsigned flags = clip_line_segment(&m_x1, &m_y1, &x2, &y2, m_clip_box);
|
||||
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
if((flags & 4) == 0)
|
||||
{
|
||||
if((flags & 1) != 0 || m_move_to)
|
||||
{
|
||||
m_x[0] = m_x1;
|
||||
m_y[0] = m_y1;
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_num_vertices = 1;
|
||||
}
|
||||
m_x[m_num_vertices] = x2;
|
||||
m_y[m_num_vertices] = y2;
|
||||
m_cmd[m_num_vertices++] = path_cmd_line_to;
|
||||
m_move_to = (flags & 2) != 0;
|
||||
}
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
unsigned vpgen_clip_polyline::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_vertex < m_num_vertices)
|
||||
{
|
||||
*x = m_x[m_vertex];
|
||||
*y = m_y[m_vertex];
|
||||
return m_cmd[m_vertex++];
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::reset()
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_move_to = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::move_to(double x, double y)
|
||||
{
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_move_to = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vpgen_clip_polyline::line_to(double x, double y)
|
||||
{
|
||||
double x2 = x;
|
||||
double y2 = y;
|
||||
unsigned flags = clip_line_segment(&m_x1, &m_y1, &x2, &y2, m_clip_box);
|
||||
|
||||
m_vertex = 0;
|
||||
m_num_vertices = 0;
|
||||
if((flags & 4) == 0)
|
||||
{
|
||||
if((flags & 1) != 0 || m_move_to)
|
||||
{
|
||||
m_x[0] = m_x1;
|
||||
m_y[0] = m_y1;
|
||||
m_cmd[0] = path_cmd_move_to;
|
||||
m_num_vertices = 1;
|
||||
}
|
||||
m_x[m_num_vertices] = x2;
|
||||
m_y[m_num_vertices] = y2;
|
||||
m_cmd[m_num_vertices++] = path_cmd_line_to;
|
||||
m_move_to = (flags & 2) != 0;
|
||||
}
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
unsigned vpgen_clip_polyline::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_vertex < m_num_vertices)
|
||||
{
|
||||
*x = m_x[m_vertex];
|
||||
*y = m_y[m_vertex];
|
||||
return m_cmd[m_vertex++];
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
}
|
||||
|
|
80
deps/agg/src/agg_vpgen_segmentator.cpp
vendored
80
deps/agg/src/agg_vpgen_segmentator.cpp
vendored
|
@ -2,8 +2,8 @@
|
|||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
@ -19,49 +19,49 @@
|
|||
namespace agg
|
||||
{
|
||||
|
||||
void vpgen_segmentator::move_to(double x, double y)
|
||||
{
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_dx = 0.0;
|
||||
m_dy = 0.0;
|
||||
m_dl = 2.0;
|
||||
m_ddl = 2.0;
|
||||
m_cmd = path_cmd_move_to;
|
||||
}
|
||||
void vpgen_segmentator::move_to(double x, double y)
|
||||
{
|
||||
m_x1 = x;
|
||||
m_y1 = y;
|
||||
m_dx = 0.0;
|
||||
m_dy = 0.0;
|
||||
m_dl = 2.0;
|
||||
m_ddl = 2.0;
|
||||
m_cmd = path_cmd_move_to;
|
||||
}
|
||||
|
||||
void vpgen_segmentator::line_to(double x, double y)
|
||||
{
|
||||
m_x1 += m_dx;
|
||||
m_y1 += m_dy;
|
||||
m_dx = x - m_x1;
|
||||
m_dy = y - m_y1;
|
||||
double len = sqrt(m_dx * m_dx + m_dy * m_dy) * m_approximation_scale;
|
||||
if(len < 1e-30) len = 1e-30;
|
||||
m_ddl = 1.0 / len;
|
||||
m_dl = (m_cmd == path_cmd_move_to) ? 0.0 : m_ddl;
|
||||
if(m_cmd == path_cmd_stop) m_cmd = path_cmd_line_to;
|
||||
}
|
||||
void vpgen_segmentator::line_to(double x, double y)
|
||||
{
|
||||
m_x1 += m_dx;
|
||||
m_y1 += m_dy;
|
||||
m_dx = x - m_x1;
|
||||
m_dy = y - m_y1;
|
||||
double len = sqrt(m_dx * m_dx + m_dy * m_dy) * m_approximation_scale;
|
||||
if(len < 1e-30) len = 1e-30;
|
||||
m_ddl = 1.0 / len;
|
||||
m_dl = (m_cmd == path_cmd_move_to) ? 0.0 : m_ddl;
|
||||
if(m_cmd == path_cmd_stop) m_cmd = path_cmd_line_to;
|
||||
}
|
||||
|
||||
unsigned vpgen_segmentator::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_cmd == path_cmd_stop) return path_cmd_stop;
|
||||
unsigned vpgen_segmentator::vertex(double* x, double* y)
|
||||
{
|
||||
if(m_cmd == path_cmd_stop) return path_cmd_stop;
|
||||
|
||||
unsigned cmd = m_cmd;
|
||||
m_cmd = path_cmd_line_to;
|
||||
if(m_dl >= 1.0 - m_ddl)
|
||||
{
|
||||
m_dl = 1.0;
|
||||
m_cmd = path_cmd_stop;
|
||||
*x = m_x1 + m_dx;
|
||||
*y = m_y1 + m_dy;
|
||||
return cmd;
|
||||
}
|
||||
*x = m_x1 + m_dx * m_dl;
|
||||
*y = m_y1 + m_dy * m_dl;
|
||||
m_dl += m_ddl;
|
||||
unsigned cmd = m_cmd;
|
||||
m_cmd = path_cmd_line_to;
|
||||
if(m_dl >= 1.0 - m_ddl)
|
||||
{
|
||||
m_dl = 1.0;
|
||||
m_cmd = path_cmd_stop;
|
||||
*x = m_x1 + m_dx;
|
||||
*y = m_y1 + m_dy;
|
||||
return cmd;
|
||||
}
|
||||
*x = m_x1 + m_dx * m_dl;
|
||||
*y = m_y1 + m_dy * m_dl;
|
||||
m_dl += m_ddl;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue