class Potracer::Params

Params define how the Bitmap is traced

Public Instance Methods

alpha_max click to toggle source

Get the current alpha max

static VALUE
params_get_alphamax (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  return rb_float_new(params->alphamax);
}
alpha_max = max click to toggle source

Set the alpha max

  • max - threshold for the detection of corners. It controls the smoothness of the traced curve, as shown in Figure 9. The current default is 1.0. The useful range of this parameter is from 0.0 (polygon) to 1.3334 (no corners).

static VALUE
params_set_alphamax (VALUE klass, VALUE max)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->alphamax = NUM2DBL(max);
  return max;
}
optimize! click to toggle source

Turn on curve optimization

static VALUE
params_set_opticurve_true (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->opticurve = 1;
  return Qtrue;
}
optimized? click to toggle source

Are curves optimized

static VALUE
params_get_opticurve (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  return (params->opticurve == 1) ? Qtrue : Qfalse;
}
tolerance click to toggle source

Get current curve optimization tolerance

static VALUE
params_get_opttolerance (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  return rb_float_new(params->opttolerance);
}
tolerance = amount click to toggle source

Set current curve optimization tolerance

  • amount - defines the amount of error allowed in curve simplification. This value only applies if optimization is true. The current default is 0.2. Larger values tend to decrease the number of segments, at the expense of less accuracy. The useful range is from 0 to infinity, although in practice one would hardly choose values greater than 1 or so. For most purposes, the default value is a good tradeoff between space and accuracy.

static VALUE
params_set_opttolerance (VALUE klass, VALUE tolerance)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->opttolerance = NUM2DBL(tolerance);
  return tolerance;
}
turd_size click to toggle source

Get the current turd size

static VALUE
params_get_turdsize (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  return rb_int_new(params->turdsize);
}
turd_size = threshold click to toggle source

Set the turd size

  • threshold - used to “despeckle” the bitmap to be traced, by removing all curves whose enclosed area is below the given threshold. Default is 2.

static VALUE
params_set_turdsize (VALUE klass, VALUE size)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->turdsize = NUM2INT(size);
  return size;
}
turn_policy click to toggle source

Get the current Turnpolicy

static VALUE
params_get_turnpolicy (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  return rb_int_new(params->turnpolicy);
}
turn_policy = policy click to toggle source

Set the current Turnpolicy

static VALUE
params_set_turnpolicy (VALUE klass, VALUE policy)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->turnpolicy = NUM2INT(policy);
  return policy;
}
unoptimize! click to toggle source

Turn off curve optimization

static VALUE
params_set_opticurve_false (VALUE klass)
{
  potrace_param_t *params;
  Data_Get_Struct(klass, potrace_param_t, params);
  params->opticurve = 0;
  return Qfalse;
}