Skip to content

Commit df5ddb3

Browse files
committed
fix diamond hatch fill
1 parent dc8ed52 commit df5ddb3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/vector/HatchFill.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ acgraph.vector.HatchFill.creationMap_ = (function() {
225225
}
226226
};
227227
map[acgraph.vector.HatchFill.HatchFillType.SOLID_DIAMOND] = function() {
228-
this.segmentedDrawHelper_([[this.size / 2, 0, 0, this.size / 2, this.size / 2, this.size, this.size, this.size / 2, this.size / 2, 0]], true);
228+
this.segmentedDrawHelper_([[this.size / 2, 0, 0, this.size / 2, this.size / 2, this.size, this.size, this.size / 2, this.size / 2, 0]], true, true);
229229
};
230230
map[acgraph.vector.HatchFill.HatchFillType.DASHED_FORWARD_DIAGONAL] = function() {
231231
this.rLinesHelper_([0, 0, this.size / 2, this.size / 2, this.thickness]);
@@ -305,11 +305,12 @@ acgraph.vector.HatchFill.normalizeHatchFillType = function(value, opt_default) {
305305
/**
306306
* @param {Array.<Array.<number>>} segments
307307
* @param {boolean=} opt_close
308+
* @param {boolean=} opt_filled
308309
* @this {acgraph.vector.HatchFill}
309310
* @private
310311
*/
311-
acgraph.vector.HatchFill.prototype.segmentedDrawHelper_ = function(segments, opt_close) {
312-
var path = this.strokePathHelper_();
312+
acgraph.vector.HatchFill.prototype.segmentedDrawHelper_ = function(segments, opt_close, opt_filled) {
313+
var path = this.pathHelper_(opt_filled);
313314
for (var i = 0; i < segments.length; i++) {
314315
var segment = segments[i];
315316
path.moveTo(segment[0], segment[1]);
@@ -328,7 +329,7 @@ acgraph.vector.HatchFill.prototype.segmentedDrawHelper_ = function(segments, opt
328329
* @private
329330
*/
330331
acgraph.vector.HatchFill.prototype.rLinesHelper_ = function(args, opt_rotation) {
331-
var path = this.strokePathHelper_();
332+
var path = this.pathHelper_();
332333
for (var i = 0; i < args.length; i += 5) {
333334
this.rLine_(path, args[i], args[i + 1], args[i + 2], args[i + 3], args[i + 4]);
334335
}
@@ -363,11 +364,14 @@ acgraph.vector.HatchFill.prototype.rectHelper_ = function(w, h, opt_l, opt_t) {
363364

364365

365366
/**
367+
* @param {boolean=} opt_filled .
366368
* @return {acgraph.vector.Path}
367369
* @private
368370
*/
369-
acgraph.vector.HatchFill.prototype.strokePathHelper_ = function() {
370-
return /** @type {acgraph.vector.Path} */(this.path().fill('none').stroke(this.color, this.thickness));
371+
acgraph.vector.HatchFill.prototype.pathHelper_ = function(opt_filled) {
372+
return /** @type {acgraph.vector.Path} */(opt_filled ?
373+
this.path().fill(this.color).stroke('none') :
374+
this.path().fill('none').stroke(this.color, this.thickness));
371375
};
372376

373377

0 commit comments

Comments
 (0)