OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
anonymous_namespace{NSVGUtils.cpp}::DashesParam Struct Reference
Collaboration diagram for anonymous_namespace{NSVGUtils.cpp}::DashesParam:

Public Member Functions

 DashesParam (const NSVGshape &shape, double scale)

Public Attributes

float dash_length = 1.f
bool is_line = true
unsigned char dash_index = 0
std::array< float, max_dash_array_size > dash_array
unsigned char dash_count = 0

Static Public Attributes

static constexpr size_t max_dash_array_size = 8

Detailed Description

Constructor & Destructor Documentation

◆ DashesParam()

anonymous_namespace{NSVGUtils.cpp}::DashesParam::DashesParam ( const NSVGshape & shape,
double scale )
inlineexplicit
420 :
421 dash_count(shape.strokeDashCount)
422 {
423 assert(dash_count > 0);
424 assert(dash_count <= max_dash_array_size); // limitation of nanosvg strokeDashArray
425 for (size_t i = 0; i < dash_count; ++i)
426 dash_array[i] = static_cast<float>(shape.strokeDashArray[i] * scale);
427
428 // Figure out dash offset.
429 float all_dash_length = 0;
430 for (unsigned char j = 0; j < dash_count; ++j)
431 all_dash_length += dash_array[j];
432
433 if (dash_count%2 == 1) // (shape.strokeDashCount & 1)
434 all_dash_length *= 2.0f;
435
436 // Find location inside pattern
437 float dash_offset = fmodf(static_cast<float>(shape.strokeDashOffset * scale), all_dash_length);
438 if (dash_offset < 0.0f)
439 dash_offset += all_dash_length;
440
441 while (dash_offset > dash_array[dash_index]) {
442 dash_offset -= dash_array[dash_index];
443 dash_index = (dash_index + 1) % shape.strokeDashCount;
444 is_line = !is_line;
445 }
446
447 dash_length = dash_array[dash_index] - dash_offset;
448 }
int scale(const int val)
Definition WipeTowerDialog.cpp:58
unsigned char dash_index
Definition NSVGUtils.cpp:415
std::array< float, max_dash_array_size > dash_array
Definition NSVGUtils.cpp:417
unsigned char dash_count
Definition NSVGUtils.cpp:418
static constexpr size_t max_dash_array_size
Definition NSVGUtils.cpp:416
float dash_length
Definition NSVGUtils.cpp:408
bool is_line
Definition NSVGUtils.cpp:412

References dash_array, dash_count, dash_index, dash_length, is_line, max_dash_array_size, and scale().

Here is the call graph for this function:

Member Data Documentation

◆ dash_array

std::array<float, max_dash_array_size> anonymous_namespace{NSVGUtils.cpp}::DashesParam::dash_array

◆ dash_count

unsigned char anonymous_namespace{NSVGUtils.cpp}::DashesParam::dash_count = 0

◆ dash_index

unsigned char anonymous_namespace{NSVGUtils.cpp}::DashesParam::dash_index = 0

◆ dash_length

float anonymous_namespace{NSVGUtils.cpp}::DashesParam::dash_length = 1.f

◆ is_line

bool anonymous_namespace{NSVGUtils.cpp}::DashesParam::is_line = true

◆ max_dash_array_size

size_t anonymous_namespace{NSVGUtils.cpp}::DashesParam::max_dash_array_size = 8
staticconstexpr

Referenced by DashesParam().


The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/NSVGUtils.cpp