def resize(self, width, height): PApplet.resize(self,width,height) # TODO figure out how to handle resize in context of Swing signals etc self.w = width self.h = height if self.view is not None: self.view.resize(self.w, self.h, False)
def Q(name): """Gets a variable from the current sketch. Processing has a number of methods and variables with the same name, 'mousePressed' for example. This allows us to disambiguate. Also casts numeric values as floats to make it easier to translate code from pde to python. """ retval = PApplet.getDeclaredField(name).get(Sketch.get_instance()) if isinstance(retval, (long, int)): return float(retval) else: return retval
def __saveBytes__(where, data): if isinstance(where, basestring): return __papplet__.saveBytes(where, data) return PApplet.saveBytes(where, data)
def __saveStream__(target, source): if isinstance(source, basestring) or isinstance(target, basestring): return __papplet__.saveStream(target, source) return PApplet.saveStream(target, source)
def __loadJSONObject__(o): if isinstance(o, basestring): return __papplet__.loadJSONObject(o) return PApplet.loadJSONObject(o)
def __loadJSONArray__(o): if isinstance(o, basestring): return __papplet__.loadJSONArray(o) return PApplet.loadJSONArray(o)
def __loadBytes__(o): if isinstance(o, basestring): return __papplet__.loadBytes(o) return PApplet.loadBytes(o)
def __createWriter__(o): if isinstance(o, basestring): return __papplet__.createWriter(o) return PApplet.createWriter(o)
def mouseDragged(self,evt): if type(evt) is javaMouseEvent: PApplet.mouseDragged(self, evt) elif type(evt) is p5MouseEvent: self.view.mouseDragged() self.draw()
def __createOutput__(o): if isinstance(o, basestring): return __papplet__.createOutput(o) return PApplet.createOutput(o)