by ttty · 11y ago · 0 comments
texture({lines: true, heavier: true, stroke: 'red'})
Is easier to configure if you need reusable textures.I feel it’s a matter of taste, but one practical reason I prefer chaining to configuration objects is that you get a runtime error when you misspell a property, rather than it being silently ignored.
var t = texture().lines().stroke('red')
if(this.button.on) t= texture.heavier()
Compare the previous with this one. var t = texture({lines: true, heavier: this.button.on, stroke: 'red'})
I also hate the non standard constructor: this should be like this var texture = new Texture({lines: true, heavier: this.button.on, stroke: 'red'});Also, use of the "new" keyword is contentious. You can hardly pretend that it is best practice.
var t = texture().lines().stroke('red')
if(this.button.on) t.heavier() textures.circles()
.radius(4)
.fill("transparent")
.strokeWidth(2);
could initially be var circles = textures.circles({
radius: 4,
fill: "transparent",
strokeWidth: 2
});
and later updated to be circles.strokeWidth( 1 );
Which works rather nicely especially when the config object is generated dynamically.