Function Repository Resource:

DrawSketch

Source Notebook

Draw a sketch

Contributed by: Wolfram Neural Networks Team

ResourceFunction["DrawSketch"][object]

draws a sketch of the specified object.

ResourceFunction["DrawSketch"][object,temp]

uses temperature temp to regulate sampling.

ResourceFunction["DrawSketch"][object,temp,len]

restricts the drawing to a length of len.

Details and Options

Only a limited set of object values are supported. The complete list is available with ResourceFunction["DrawSketch"][]. Typical values include "Alarm Clock", "Cat", "Spider", "Trombone" and "Windmill".
The temperature temp controls the randomness of the sketch. Lower values will produce more similar results. Higher tempertures produce more variability. The default temp is 0.01.
The maximum length len sets an upper limit on the number of strokes to include. The default value is 300.
Each new object sketched requires downloading a Sketch-RNN neural network from the Wolfram Neural Net Repository.

Examples

Basic Examples (1) 

Draw a sketch of a toothbrush:

In[1]:=
ResourceFunction["DrawSketch"]["Toothbrush"]
Out[1]=

Scope (3) 

Draw three bicycles:

In[2]:=
Table[ResourceFunction["DrawSketch"]["Bicycle"], 3]
Out[2]=

Increase the temperature to add variability, often at the cost of decreased quality:

In[3]:=
Table[ResourceFunction["DrawSketch"]["Bicycle", .5], 3]
Out[3]=

Limit the number of strokes to different values:

In[4]:=
Table[ResourceFunction["DrawSketch"]["Octopus", 0, len], {len, {100, 200, 300}}]
Out[4]=

Properties and Relations (2) 

See all available objects:

In[5]:=
ResourceFunction["DrawSketch"][]
Out[5]=

Using zero temperature produces the same sketch each time:

In[6]:=
Table[ResourceFunction["DrawSketch"]["Windmill", 0], 3]
Out[6]=

Neat Examples (1) 

Create a function which displays an animation showing the object being drawn from the sequence of pen strokes chosen by the network:

In[7]:=
animateSketch[obj_] := DynamicModule[{lines, plotRange}, lines = DeleteCases[drawSketch[obj], {}];
  plotRange = Map[MinMax, 1.05*{lines[[All, All, 1]], lines[[All, All, 2]]}];
  Animate[
   Graphics[Line@lines[[1 ;; i]], PlotRange -> plotRange], {i, 1, Length[lines], 1}, AnimationRepetitions -> 1]]
In[8]:=
animateSketch["Bird"]
Out[8]=

Version History

  • 1.0.0 – 23 October 2020

Related Resources

License Information