third_party/cairo/src/cairo-stroke-style.c
double
_cairo_stroke_style_dash_stroked (const cairo_stroke_style_t *style)
{
    double stroked, cap_scale;
    unsigned int i;

    switch (style->line_cap) {
    default: ASSERT_NOT_REACHED;
    case CAIRO_LINE_CAP_BUTT:   cap_scale = 0.0; break;
    case CAIRO_LINE_CAP_ROUND:  cap_scale = ROUND_MINSQ_APPROXIMATION; break;
    case CAIRO_LINE_CAP_SQUARE: cap_scale = 1.0; break;
    }

    stroked = 0.0;
    if (style->num_dashes & 1) {
        /* Each dash element is used both as on and as off. The order in which they are summed is
	 * irrelevant, so sum the coverage of one dash element, taken both on and off at each iteration */
	for (i = 0; i < style->num_dashes; i++)
	    stroked += style->dash[i] + cap_scale * MIN (style->dash[i], style->line_width);
    } else {
        /* Even (0, 2, ...) dashes are on and simply counted for the coverage, odd dashes are off, thus
	 * their coverage is approximated based on the area covered by the caps of adjacent on dases. */
	for (i = 0; i + 1 < style->num_dashes; i += 2)
	    stroked += style->dash[i] + cap_scale * MIN (style->dash[i+1], style->line_width);
    }

    return stroked;
}
/*
 * Computes the length of the "on" part of a dashed stroke style,
 * taking into account also line caps.
 * Returns 0 for non-dashed styles.
 */
Computes the length of the "on" part of a dashed stroke style,
taking into account also line caps.
Returns 0 for non-dashed styles.
Computes the length of the " on " part of a dashed stroke style taking into account also line caps . Returns 0 for non - dashed styles .
double
_cairo_stroke_style_dash_stroked (const cairo_stroke_style_t *style)
{
    double stroked, cap_scale;
    unsigned int i;
    switch (style->line_cap) {
    default: ASSERT_NOT_REACHED;
    case CAIRO_LINE_CAP_BUTT:   cap_scale = 0.0; break;
    case CAIRO_LINE_CAP_ROUND:  cap_scale = ROUND_MINSQ_APPROXIMATION; break;
    case CAIRO_LINE_CAP_SQUARE: cap_scale = 1.0; break;
    }
    stroked = 0.0;
    if (style->num_dashes & 1) {
	for (i = 0; i < style->num_dashes; i++)
	    stroked += style->dash[i] + cap_scale * MIN (style->dash[i], style->line_width);
    } else {
	for (i = 0; i + 1 < style->num_dashes; i += 2)
	    stroked += style->dash[i] + cap_scale * MIN (style->dash[i+1], style->line_width);
    }
    return stroked;
}
double _cairo_stroke_style_dash_stroked ( const cairo_stroke_style_t * style ) { double stroked , cap_scale ; unsigned int i ; switch ( style -> line_cap ) { default : ASSERT_NOT_REACHED ; case CAIRO_LINE_CAP_BUTT : cap_scale = 0.0 ; break ; case CAIRO_LINE_CAP_ROUND : cap_scale = ROUND_MINSQ_APPROXIMATION ; break ; case CAIRO_LINE_CAP_SQUARE : cap_scale = 1.0 ; break ; } stroked = 0.0 ; if ( style -> num_dashes & 1 ) { for ( i = 0 ; i < style -> num_dashes ; i ++ ) stroked += style -> dash [ i ] + cap_scale * MIN ( style -> dash [ i ] , style -> line_width ) ; } else { for ( i = 0 ; i + 1 < style -> num_dashes ; i += 2 ) stroked += style -> dash [ i ] + cap_scale * MIN ( style -> dash [ i + 1 ] , style -> line_width ) ; } return stroked ; }
Computes the length of the "on" part of a dashed stroke style,
 taking into account also line caps.
Computes the length of the " on " part of a dashed stroke style taking into account also line caps .
/* Each dash element is used both as on and as off. The order in which they are summed is
	 * irrelevant, so sum the coverage of one dash element, taken both on and off at each iteration */ /* Even (0, 2, ...) dashes are on and simply counted for the coverage, odd dashes are off, thus
	 * their coverage is approximated based on the area covered by the caps of adjacent on dases. */