Skip to content

Commit

Permalink
Allow texture fills in the canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
knicos committed Apr 7, 2017
1 parent c62d421 commit dc664f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
12 changes: 6 additions & 6 deletions js/core/jseden.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions js/selectors/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,11 @@ Eden.Selectors.assign = function(selector, attributes, values) {
res[i].prefix = "action "+vals[j]+" {";
res[i].name = vals[j];
Eden.Index.update(res[i]);
} else if (res[i].type == "assignment" || res[i].type=="definition") {
Eden.Index.remove(res[i]);
res[i].lvalue.name = vals[j];
res[i].source = res[i].source.replace(/\w*/, vals[j]);
Eden.Index.update(res[i]);
} break;
default: console.error("Cannot modify property '"+attribs[j]+"'");
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/canvas/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,10 @@ EdenUI.plugins.Canvas2D = function (edenUI, success) {
}

this.setFillStyle = function (context, style) {
if (style instanceof EdenUI.plugins.Canvas2D.FillStyle) {
if (style instanceof CanvasImage) {
var pat = context.createPattern(style.image,"repeat");
context.fillStyle = pat;
} else if (style instanceof EdenUI.plugins.Canvas2D.FillStyle) {
context.fillStyle = style.getColour(context);
} else {
context.fillStyle = style;
Expand Down
8 changes: 4 additions & 4 deletions plugins/jseden-plugins.min.js

Large diffs are not rendered by default.

2 comments on commit dc664f8

@ElizabethHudnott
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very similar to https://github.com/EMGroup/js-eden/blob/master/plugins/canvas/fillpattern.js-e (which I was at one time planning on extending to incorporate options for different kinds of repeat, stretching, etc.).

@knicos
Copy link
Member Author

@knicos knicos commented on dc664f8 Apr 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A case of zero documentation = reinventing the wheel...

Please sign in to comment.