Handy or similar pencil sketch library in Processing.py

Is there a way to make your sketches look more like they have been sketched by a pencil (ie rough sketch type lines)?

I’ve seen people using the Handy library in other processing modes but can’t see any info on it within Processing.py?

Thanks!

You can use most Processing (Java) libraries with Python Mode. For example, to use Handy, install it like any other library in the IDE using –

Sketch > Import Library > Add Library

Once that’s installed, you can create a Handy sketch using Python Mode like so:

add_library('handy')
 
def setup():
  size(300, 200)
  global h
  h = HandyRenderer(this)
 
def draw():
  background(235, 215, 182)
  h.rect(75, 50, 150, 100)

This is an animated sketch, but static sketches should work fine, too.

2 Likes

When I try this I get a ClassCastExeption:

java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)
at jycessing.LibraryImporter.addJarToClassLoader(LibraryImporter.java:315)
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(LibraryImporter.java:164)
at jycessing.LibraryImporter.addLibrary(LibraryImporter.java:140)
at jycessing.LibraryImporter$1.call(LibraryImporter.java:82)
at org.python.core.PyObject.call(PyObject.java:480)
at org.python.core.PyObject.call(PyObject.java:484)
at org.python.pycode._pyx61.f$0(sketch_221203c.pyde:1)
at org.python.pycode._pyx61.call_function(sketch_221203c.pyde)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.pycode._pyx60.f$0(/var/folders/pz/_61lfmhn4gj6g5mh6v66b7cm0000gn/T/sketch_221203c3047145917091245605/sketch_221203c.pyde:96)
at org.python.pycode._pyx60.call_function(/var/folders/pz/_61lfmhn4gj6g5mh6v66b7cm0000gn/T/sketch_221203c3047145917091245605/sketch_221203c.pyde)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at jycessing.PAppletJythonDriver.processSketch(PAppletJythonDriver.java:233)
at jycessing.PAppletJythonDriver.findSketchMethods(PAppletJythonDriver.java:613)
at jycessing.Runner.runSketchBlocking(Runner.java:399)
at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:112)
at java.base/java.lang.Thread.run(Thread.java:833)

Are you using Processing 3.5.4? What is your OS, system, etc. setup?

macOS Catalina, Processing 4.0.1

For Python Mode, use Processing 3.5.4