Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/path_converters.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <cmath>
#include <cstdint>
#include <limits>

#include "agg_clip_liang_barsky.h"
#include "mplutils.h"
Expand Down Expand Up @@ -1019,8 +1020,18 @@ class Sketch
{
rewind(0);
const double d_M_PI = 3.14159265358979323846;
m_p_scale = (2.0 * d_M_PI) / (m_length * m_randomness);
m_log_randomness = 2.0 * log(m_randomness);
// Set derived values to zero if m_length or m_randomness are zero to
// avoid divide-by-zero errors when a sketch is created but not used.
if (m_length <= std::numeric_limits<double>::epsilon() || m_randomness <= std::numeric_limits<double>::epsilon()) {
m_p_scale = 0.0;
} else {
m_p_scale = (2.0 * d_M_PI) / (m_length * m_randomness);
}
if (m_randomness <= std::numeric_limits<double>::epsilon()) {
m_log_randomness = 0.0;
} else {
m_log_randomness = 2.0 * log(m_randomness);
}
}

unsigned vertex(double *x, double *y)
Expand Down