This example uses texture.js to create custom patterns.
xxxxxxxxxx
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="x.css">
<link href='https://fonts.googleapis.com/css?family=Raleway:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<h2>Draw in the Box to Create a Pattern</h2>
<div id="clickToClear"></div>
<div id="example"></div>
<script type="text/javascript" src="datgui-min.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="textures.min.js"></script>
<script src="x.js"></script>
</body>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js