function defineTextures(g) { // *** Textures *** var gin = textures.lines() .orientation("vertical") .stroke("#F9F9F9"); var soda = textures.lines() .orientation("horizontal") .stroke("#F9F9F9"); var oj = textures.paths() .d("squares") .stroke("#F9F9F9"); var cola = textures.circles() .radius(4) .stroke("#F9F9F9") .fill("transparent") .strokeWidth(2); var water = textures.paths() .d("waves") .thicker() .stroke("#F9F9F9"); var vermouth = textures.paths() .d("nylon") .lighter() .stroke("#F9F9F9") .shapeRendering("crispEdges"); var stRaphael = textures.lines() .orientation("3/8", "7/8") .stroke("#f9f9f9"); var ryeWhiskey = textures.paths() .d("caps") .lighter() .thicker() .stroke("#F9F9F9"); var scotchWhiskey = textures.paths() .d("crosses") .lighter() .stroke("#F9F9F9") .thicker(); var brandy = textures.paths() .d("woven") .lighter() .thicker() .stroke("#F9F9F9"); var fernetBranca = textures.paths() .d("hexagons") .size(8) .strokeWidth(2) .stroke("#F9F9F9"); var cremeDeMenthe = textures.circles() .radius(4) .fill("#F9F9F9") .strokeWidth(2) .stroke("#f9f9f9") .complement(); var chartreuse = textures.circles() .size(5) .fill("#F9F9F9"); var limeJuice = textures.circles() .lighter() .fill("#F9F9F9"); var lemonJuice = textures.circles() .fill("#F9F9F9"); var cointreau = textures.lines() .orientation("vertical", "horizontal") .size(4) .strokeWidth(1) .shapeRendering("crispEdges") .stroke("#F9F9F9"); var cognac = textures.paths() .d("waves") .thicker() .stroke("#F9F9F9"); var lillet = textures.lines() .size(8) .stroke("#F9F9F9") .strokeWidth(2); // blank pattern var vodka = textures.paths() .d(function(s) { return ""; }) .size(1); // custom texture var whiteRum = textures.paths() .d(function(s) { return "M 0," + s*3/4 + " l " + s/2 + "," + -s/2 + " l " + s/2 + "," + s/2; }) .size(20) .strokeWidth(1) .thicker(2) .stroke("#F9F9F9"); // *** Textures *** var textureArray = [gin, soda, oj, cola, water, vermouth, stRaphael, ryeWhiskey, scotchWhiskey, brandy, fernetBranca, cremeDeMenthe, chartreuse, limeJuice, lemonJuice, cointreau, cognac, lillet, vodka, whiteRum]; // set up texture urls d3.map(textureArray, function(t) {g.call(t)}); var table = { "oj": { "name": "orange juice", "texture": oj }, "cola": { "name": "Coke", "texture": cola }, "vermouth": { "name": "vermouth", "texture": vermouth }, "gin": { "name": "gin", "texture": gin }, "stRaphael": { "name": "St. Raphael", "texture": stRaphael }, "ryeWhiskey": { "name": "rye whiskey", "texture": ryeWhiskey }, "brandy": { "name": "brandy", "texture": brandy }, "fernetBranca": { "name": "Fernet Branca", "texture": fernetBranca }, "cremeDeMenthe": { "name": "Crème de Menthe", "texture": cremeDeMenthe }, "chartreuse": { "name": "Chartreuse", "texture": chartreuse }, "limeJuice": { "name": "lime juice", "texture": limeJuice }, "lemonJuice": { "name": "lemmon juice", "texture": lemonJuice }, "scotchWhiskey": { "name": "scotch whiskey", "texture": scotchWhiskey }, "cointreau": { "name": "Cointreau", "texture": cointreau }, "cognac": { "name": "cognac", "texture": cognac }, "lillet": { "name": "Lillet Blanc", "texture": lillet }, "vodka": { "name": "vokda", "texture": vodka }, "whiteRum": { "name": "white rum", "texture": whiteRum } } return table; }