Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 2962af9

Browse files
committed
[[ Graphics ]] Dashes
This patch adds two new state setters to MCGContext, one for dash-offset and one for dash-array.
1 parent 4ee648b commit 2962af9

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

libgraphics/include/graphics.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,8 @@ void MCGContextSetStrokeWidth(MCGContextRef context, MCGFloat width);
940940
void MCGContextSetStrokeMiterLimit(MCGContextRef context, MCGFloat limit);
941941
void MCGContextSetStrokeJoinStyle(MCGContextRef context, MCGJoinStyle style);
942942
void MCGContextSetStrokeCapStyle(MCGContextRef context, MCGCapStyle style);
943+
void MCGContextSetStrokeDashOffset(MCGContextRef context, MCGFloat offset);
944+
void MCGContextSetStrokeDashArray(MCGContextRef context, const MCGFloat* lengths, uindex_t length_count);
943945
void MCGContextSetStrokeDashes(MCGContextRef context, MCGFloat phase, const MCGFloat *lengths, uindex_t arity);
944946
void MCGContextSetStrokePaintStyle(MCGContextRef context, MCGPaintStyle style);
945947

libgraphics/src/context.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,19 @@ void MCGContextSetStrokeCapStyle(MCGContextRef self, MCGCapStyle p_style)
15841584
self -> state -> stroke_attr . cap_style = p_style;
15851585
}
15861586

1587+
void MCGContextSetStrokeDashOffset(MCGContextRef self, MCGFloat p_offset)
1588+
{
1589+
MCGContextSetStrokeDashes(self,
1590+
p_offset,
1591+
self->state->stroke_attr.dashes != nullptr ? self->state->stroke_attr.dashes->lengths : nullptr,
1592+
self->state->stroke_attr.dashes != nullptr ? self->state->stroke_attr.dashes->count : 0);
1593+
}
1594+
1595+
void MCGContextSetStrokeDashArray(MCGContextRef self, const MCGFloat *p_lengths, uindex_t p_arity)
1596+
{
1597+
MCGContextSetStrokeDashes(self, self->state->stroke_attr.dashes != nullptr ? self->state->stroke_attr.dashes->phase : 0, p_lengths, p_arity);
1598+
}
1599+
15871600
void MCGContextSetStrokeDashes(MCGContextRef self, MCGFloat p_phase, const MCGFloat *p_lengths, uindex_t p_arity)
15881601
{
15891602
if (!MCGContextIsValid(self))
@@ -1597,8 +1610,7 @@ void MCGContextSetStrokeDashes(MCGContextRef self, MCGFloat p_phase, const MCGFl
15971610
MCGDashesRelease(self -> state -> stroke_attr . dashes);
15981611
self -> state -> stroke_attr . dashes = NULL;
15991612

1600-
if (p_arity > 0)
1601-
t_success = MCGDashesCreate(p_phase, p_lengths, p_arity, self -> state -> stroke_attr . dashes);
1613+
t_success = MCGDashesCreate(p_phase, p_lengths, p_arity, self -> state -> stroke_attr . dashes);
16021614
}
16031615

16041616
self -> is_valid = t_success;

0 commit comments

Comments
 (0)