<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with add_library() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=add_library%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:52:43 +0000</pubDate>
         <description>Tagged with add_library() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedadd_library%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Box2d for python mode</title>
      <link>https://forum.processing.org/two/discussion/25473/box2d-for-python-mode</link>
      <pubDate>Sat, 09 Dec 2017 15:00:29 +0000</pubDate>
      <dc:creator>2DK</dc:creator>
      <guid isPermaLink="false">25473@/two/discussions</guid>
      <description><![CDATA[<p>I'm using python mode and try to use box2d_processing library, but Vec2 is not working. Is there someone who knows how to use that?</p>
]]></description>
   </item>
   <item>
      <title>Error on add_library('proscene')</title>
      <link>https://forum.processing.org/two/discussion/24852/error-on-add-library-proscene</link>
      <pubDate>Fri, 03 Nov 2017 04:12:21 +0000</pubDate>
      <dc:creator>cegard</dc:creator>
      <guid isPermaLink="false">24852@/two/discussions</guid>
      <description><![CDATA[<p>Hello people, I'm starting to move a proscene example written in java to python, but when I write this line:</p>

<p><code>add_library('proscene')</code></p>

<p>I've got the next error message:</p>

<p>java.lang.NoClassDefFoundError: android/view/MotionEvent
    at java.lang.Class.getDeclaredMethods0(Native Method)</p>

<p>I've already installed the proscene library.</p>
]]></description>
   </item>
   <item>
      <title>How to get sound files in processing.py</title>
      <link>https://forum.processing.org/two/discussion/23738/how-to-get-sound-files-in-processing-py</link>
      <pubDate>Mon, 07 Aug 2017 20:47:36 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">23738@/two/discussions</guid>
      <description><![CDATA[<p>I was looking at the forum as saw SoundFile() but this doesnt seem to work in python.  Any ideas</p>
]]></description>
   </item>
   <item>
      <title>Serial library with Processing.py</title>
      <link>https://forum.processing.org/two/discussion/9598/serial-library-with-processing-py</link>
      <pubDate>Fri, 27 Feb 2015 00:27:53 +0000</pubDate>
      <dc:creator>ericksonla</dc:creator>
      <guid isPermaLink="false">9598@/two/discussions</guid>
      <description><![CDATA[<p>Generally, is there library documentation for the libraries with Processing.py?</p>

<p>Specifically, I'm trying to use the Serial library. Guessing the syntax from the Java documentation, I have:</p>

<pre lang="python">
add_library('serial')

def setup():
    #setup the serial port
    print Serial.list()
    portIndex = 4
    LF = 10
    print "Connecting to ", Serial.list()[portIndex]
    myPort = Serial(Serial.list()[portIndex], 9600)   # this seems to need a first argument referring to the sketch object (analagous to "this" argument in Java)
    myPort.bufferUntil(LF)
    
def draw():
    pass
    
def serialEvent(evt):
    inString = evt.readString()
    print inString
</pre>

<p>Anyone have any advice on making this work?</p>

<p>As a side note, it would be nice to add a processing.py as a subcategory in the forums under "Questions and Modes".</p>
]]></description>
   </item>
   <item>
      <title>How to access SQL in Python Mode?</title>
      <link>https://forum.processing.org/two/discussion/23573/how-to-access-sql-in-python-mode</link>
      <pubDate>Mon, 24 Jul 2017 22:34:59 +0000</pubDate>
      <dc:creator>jjunkergamedev</dc:creator>
      <guid isPermaLink="false">23573@/two/discussions</guid>
      <description><![CDATA[<p>How can I access a SQL database in python mode? I have PyMySql set up on my local python installation, but if I try to import pymysql in Processing it gives "ImportError: No module named pymysql". Java mode can use BezierSQLib, but I don't know how I would access this in python mode.</p>
]]></description>
   </item>
   <item>
      <title>Using G4P on processing.py</title>
      <link>https://forum.processing.org/two/discussion/21913/using-g4p-on-processing-py</link>
      <pubDate>Mon, 10 Apr 2017 10:34:30 +0000</pubDate>
      <dc:creator>Raz</dc:creator>
      <guid isPermaLink="false">21913@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I want to add to my sketch (processing python sketch) handling of text area from library G4P, but it doesn't work.
Here's my code:</p>

<pre lang="python">
add_library('G4P')

text_area = None

def setup():
    size(600, 600)
    global text_area
    text_area = GTextArea(this, 80, 20, 290, 300, G4P.SCROLLBARS_BOTH | G4P.SCROLLBARS_AUTOHIDE)
    text_area.setPromptText("Please enter some text");

def draw():
    background(100)
    text_area.draw()
</pre>
]]></description>
   </item>
   <item>
      <title>Unable to get this to run in Processing Python mode, works fine in Python, any suggestions</title>
      <link>https://forum.processing.org/two/discussion/20324/unable-to-get-this-to-run-in-processing-python-mode-works-fine-in-python-any-suggestions</link>
      <pubDate>Tue, 17 Jan 2017 18:17:34 +0000</pubDate>
      <dc:creator>roystepp</dc:creator>
      <guid isPermaLink="false">20324@/two/discussions</guid>
      <description><![CDATA[<pre><code># This is a test example for the Adafruit Trellis w/HT16K33
#
#   Designed specifically to work with the Adafruit Trellis 
#   ----&gt; <a href="https://www.adafruit.com/products/1616" target="_blank" rel="nofollow">https://www.adafruit.com/products/1616</a>
#   ----&gt; <a href="https://www.adafruit.com/products/1611" target="_blank" rel="nofollow">https://www.adafruit.com/products/1611</a>
#
#   These displays use I2C to communicate, 2 pins are required to  
#   interface
#   Adafruit invests time and resources providing this open source code, 
#   please support Adafruit and open-source hardware by purchasing 
#   products from Adafruit!
#
#   Written by Limor Fried/Ladyada for Adafruit Industries.  
#   MIT license, all text above must be included in any redistribution
#
#   Python port created by Tony DiCola (tony@tonydicola.com).

import time
import Adafruit_Trellis

# This example shows reading buttons and setting/clearing buttons in a loop
#   "momentary" mode has the LED light up only when a button is pressed
#   "latching" mode lets you turn the LED on/off when pressed
#
#   Up to 8 matrices per I2C bus can be used but this example will show 4 or 1

MOMENTARY = 0
LATCHING = 1
# Set the mode here:
MODE = LATCHING

matrix0 = Adafruit_Trellis.Adafruit_Trellis()

# uncomment the below to add 3 more matrices
#
# matrix1 = Adafruit_Trellis()
# matrix2 = Adafruit_Trellis()
# matrix3 = Adafruit_Trellis()
# you can add more matrices (up to 8 per I2C bus)

# Just one
trellis = Adafruit_Trellis.Adafruit_TrellisSet(matrix0)
# or use the below to select 4, up to 8 per I2C bus can be passed in
# trellis = Adafruit_Trellis.Adafruit_TrellisSet(matrix0, matrix1, matrix2, matrix3)

# set to however many you're working with here, up to 8 per I2C bus
NUMTRELLIS = 1

numKeys = NUMTRELLIS * 16


# Connect Trellis Vin to 5V and Ground to ground.
# Connect Trellis INT wire to a digital input (optional)
# Connect Trellis I2C SDA pin to your board's SDA line
# Connect Trellis I2C SCL pin to your board's SCL line
# All Trellises on an I2C bus share the SDA, SCL and INT pin! 
# Even 8 tiles use only 3 wires max

# Set this to the number of the I2C bus that the Trellises are attached to:
I2C_BUS = 1

# Setup
print 'Trellis Demo'

# TODO: Setup the INT input

# begin() with the I2C addresses and bus numbers of each panel in order
# I find it easiest if the addresses are in order
trellis.begin((0x70, I2C_BUS))   # only one
# trellis.begin((0x70,  I2C_BUS), (0x71, I2C_BUS), (0x72, I2C_BUS), (0x73, I2C_BUS))  # or four!

# light up all the LEDs in order
for i in range(numKeys):
    trellis.setLED(i)
    trellis.writeDisplay()
    time.sleep(0.05)
# then turn them off
for i in range(numKeys):
    trellis.clrLED(i)
    trellis.writeDisplay()
    time.sleep(0.05)

# Loop
print 'Press Ctrl-C to quit.'
while True:
    time.sleep(0.03)

    if MODE == MOMENTARY:
        # If a button was just pressed or released...
        if trellis.readSwitches():
            # go through every button
            for i in range(numKeys):
                # if it was pressed, turn it on
                if trellis.justPressed(i):
                    print 'v{0}'.format(i)
                    trellis.setLED(i)
                # if it was released, turn it off
                if trellis.justReleased(i):
                    print '^{0}'.format(i)
                    trellis.clrLED(i)
            # tell the trellis to set the LEDs we requested
            trellis.writeDisplay()

    if MODE == LATCHING:
        # If a button was just pressed or released...
        if trellis.readSwitches():
            # go through every button
            for i in range(numKeys):
                # if it was pressed...
                if trellis.justPressed(i):
                    print 'v{0}'.format(i)
                    # Alternate the LED
                    if trellis.isLED(i):
                        trellis.clrLED(i)
                    else:
                        trellis.setLED(i)
            # tell the trellis to set the LEDs we requested
            trellis.writeDisplay()
</code></pre>
]]></description>
   </item>
   <item>
      <title>The MIDIBus in python mode</title>
      <link>https://forum.processing.org/two/discussion/17303/the-midibus-in-python-mode</link>
      <pubDate>Sat, 25 Jun 2016 14:05:43 +0000</pubDate>
      <dc:creator>atcon</dc:creator>
      <guid isPermaLink="false">17303@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to receive midi beat clock information from a DAW into processing via the IAC driver. I have got MIDI note information going out from processing into the DAW fine, but I want to sync up with the tempo of the project.</p>

<p>From examples in the Java info for The MIDIBus library I am getting something that looks like it is the midi clock info with this:</p>

<pre><code>  import themidibus.*; //Import the library
  MidiBus myBus; // The MidiBus

  void setup() {
    size(400, 400);
    background(0);

    myBus = new MidiBus(this, 0, 0); // Create a new MidiBus object
  }

  // Notice all bytes below are converted to integeres using the following system:
  // int i = (int)(byte &amp; 0xFF) 
  // This properly convertes an unsigned byte (MIDI uses unsigned bytes) to a signed int
  // Because java only supports signed bytes, you will get incorrect values if you don't do so

  void rawMidi(byte[] data) { // You can also use rawMidi(byte[] data, String bus_name)
    // Receive some raw data
    // data[0] will be the status byte
    // data[1] and data[2] will contain the parameter of the message (e.g. pitch and volume for noteOn noteOff)
    println();
    println("Raw Midi Data:");
    println("--------");
    println("Status Byte/MIDI Command:"+(int)(data[0] &amp; 0xFF));
    // N.B. In some cases (noteOn, noteOff, controllerChange, etc) the first half of the status byte is the command and the second half if the channel
    // In these cases (data[0] &amp; 0xF0) gives you the command and (data[0] &amp; 0x0F) gives you the channel
    for (int i = 1;i &lt; data.length;i++) {
      println("Param "+(i+1)+": "+(int)(data[i] &amp; 0xFF));
    }
  }
</code></pre>

<p>but when I try translating this into python it doesn't like taking byte[] as a variable in rawMidi. This is how I tried to do it in python (excluding the superfluous stuff):</p>

<pre><code>add_library('themidibus')

def setup():
    global myBus
    myBus = MidiBus(this, 0, 0)

def rawMidi(byte[] data):
    println()
    println("Raw Midi Data:")
    println("--------")
    println("Status Byte/MIDI Command:"+ int(data[0] &amp; 0xFF))
</code></pre>

<p>I apologise if my question is a bit jumbled - not an experienced programmer at all.</p>
]]></description>
   </item>
   <item>
      <title>Is there a way to check what system a processing sketch is running on?</title>
      <link>https://forum.processing.org/two/discussion/16801/is-there-a-way-to-check-what-system-a-processing-sketch-is-running-on</link>
      <pubDate>Tue, 24 May 2016 16:00:41 +0000</pubDate>
      <dc:creator>jshaw3</dc:creator>
      <guid isPermaLink="false">16801@/two/discussions</guid>
      <description><![CDATA[<p>I'm developing some visuals for a project that will eventually be brought into a larger ecosystem and also be running on a Raspberry Pi. I am currently doing the development on my Mac.</p>

<p>So, is there a way to get what hardware the Processing sketch is running on so I can wrap certain Pi specific libraries such as "import processing.io.*;" conditionals so they only run when the sketch is running on the PI and not my Mac?</p>

<p>The reason is that I'd prefer not to have to comment out blocks of code before I can work on my machine and then uncomment these blocks before I commit to the project repo. Seems like a bit of a risk having to do this.</p>

<p>If there are other ways of accomplishing this workflow dev. on mac and production on pi with io requirements I'd love to know about them!</p>

<p>Cheers,</p>
]]></description>
   </item>
   <item>
      <title>Play a sound? (python mode)</title>
      <link>https://forum.processing.org/two/discussion/16089/play-a-sound-python-mode</link>
      <pubDate>Mon, 18 Apr 2016 21:07:02 +0000</pubDate>
      <dc:creator>schuelaw</dc:creator>
      <guid isPermaLink="false">16089@/two/discussions</guid>
      <description><![CDATA[<p>Wrapping up the semester in intro programming, students are happily using processing's python mode.  Trying to figure out how to let them play sounds in python mode.  I've tried a few things to no avail, but I'm hoping someone here can just make it easy for me and post a snippet of python mode that plays a sound from a sound file.  Thanks,  Albert</p>
]]></description>
   </item>
   <item>
      <title>converting Problem</title>
      <link>https://forum.processing.org/two/discussion/15359/converting-problem</link>
      <pubDate>Tue, 08 Mar 2016 13:07:52 +0000</pubDate>
      <dc:creator>yougop</dc:creator>
      <guid isPermaLink="false">15359@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am quite new to Processing, doing some Python for a while now. I am wondering how to convert a Processing sketch to Python mode. I am doing some DMX stuff with the dmxp512 library. Works on the Processing side very well. Converting the sketch is straight forward, only importing libraries and two lines give me some Problems.</p>

<p>Here is the code:</p>

<pre><code>    import dmxP512.*;
    import processing.serial.*;

    DmxP512 dmxOutput;       // How to read and convert this line
    int universeSize = 512;

    String DMXPRO_PORT = "/dev/tty.usbserial-ENY46I7I";
    int DMXPRO_BAUDRATE = 115000;

    void setup() {  
      size(245, 245, JAVA2D);    
      dmxOutput = new DmxP512(this,universeSize,false);       // How to read and convert this line
      dmxOutput.setupDmxPro(DMXPRO_PORT,DMXPRO_BAUDRATE);    
    }

    void draw() {     
      background(0);
      dmxOutput.set(1,mouseX);
      dmxOutput.set(5,mouseY);
    }
</code></pre>

<p>Would be very thankful for some help with this. Cheers, Volker</p>
]]></description>
   </item>
   <item>
      <title>Importing javax libraries</title>
      <link>https://forum.processing.org/two/discussion/13505/importing-javax-libraries</link>
      <pubDate>Fri, 13 Nov 2015 10:36:29 +0000</pubDate>
      <dc:creator>6160</dc:creator>
      <guid isPermaLink="false">13505@/two/discussions</guid>
      <description><![CDATA[<p>Hi!
i'm trying to use some java libraries in python mode,  <code>javax.sound.midi.MidiMessage</code> and <code>javax.sound.midi.ShortMessage</code>.
i've tried importing the libraries using</p>

<p><code>add_library('javax.sound.midi.MidiMessage')</code></p>

<p>but the sketch compiling fails because it cannot find those libraries.
the error is:</p>

<p><code>"Exception: This sketch requires the "javax.sound.midi.MidiMessage" library"</code></p>

<p>if i try importing the libraries from a Java sketch everything works fine.</p>

<p>do you know what i'm doing wrong? or do you know how i can "install" those libraries for the python interpreter?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Python - Accessing and displaying webcam capture - black frame issue</title>
      <link>https://forum.processing.org/two/discussion/10639/python-accessing-and-displaying-webcam-capture-black-frame-issue</link>
      <pubDate>Mon, 04 May 2015 19:30:06 +0000</pubDate>
      <dc:creator>CGD</dc:creator>
      <guid isPermaLink="false">10639@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>This code is running ok, except the video (webcam capture) is only returning a black frame - I can see the webcam light is on whilst running this code. I couldn't find a working example in the Python examples or the openCV python examples either. Any help is much appreciated!</p>

<pre><code>add_library('video')

from random import randint


def setup():

    global video

    size(1280, 720, P3D)

    video = Capture(this, 640, 480)
    video.start()


def draw():
    print randint(0,9)
    image(video, 0, 0)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Why is this Python code not working?</title>
      <link>https://forum.processing.org/two/discussion/10604/why-is-this-python-code-not-working</link>
      <pubDate>Fri, 01 May 2015 01:26:52 +0000</pubDate>
      <dc:creator>JamesWlf</dc:creator>
      <guid isPermaLink="false">10604@/two/discussions</guid>
      <description><![CDATA[<p>This is from the excellent book "Algorithms for Visual Design Using Processing". It's a simple code to draw a cube on the screen and then paint it red when clicking on it. There is no error, but the cube doesn't change color. What am I doing wrong?</p>

<pre><code>add_library('peasycam')

class MyObject(object):
    dim = 40
    x =0
    y=0
    z = 0
    picked = False
    c_face = color(255)


    def pick (self, xp, yp):
        if (dist(xp,yp,screenX(x,y,z), screenY(x,y,z))&lt;dim):
            MyObject.picked = True
        else:
            MyObject.picked = False

    def draw3(self):
        if (MyObject.picked == True):
            fill(255,0,0)
        else:
            fill(MyObject.c_face)
        box(MyObject.dim)

b =  MyObject()

def setup():

    size(200,200,P3D)
    #PeasyCam(this,100)
    camera(-100,100,-100,0,0,0,0,0,1)

def draw():

    b.draw3()

    def mousePressed():
        b.pick(mouseX,mouseY)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Can't make toxiclibs Vec3D work in Python mode</title>
      <link>https://forum.processing.org/two/discussion/6731/can-t-make-toxiclibs-vec3d-work-in-python-mode</link>
      <pubDate>Tue, 12 Aug 2014 01:42:22 +0000</pubDate>
      <dc:creator>JamesWlf</dc:creator>
      <guid isPermaLink="false">6731@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to make something in Python mode, but I need toxiclibs. I try using Vec3D, but when I try to read the Vec3D coordinate values it tells me they aren't of the float type and that " argument can't be coerced to float".</p>

<p>I use Python type function to check the datatypes of the Vec3D object and its 'x' attribute and I get:</p>

<pre><code>&lt;type 'toxi.geom.Vec3D'&gt;
&lt;type 'instancemethod'&gt;
</code></pre>

<p>And here is the code I mention:</p>

<pre><code>add_library('toxiclibscore')

vector = 1

def setup():
    size(200,600)
    vector = Vec3D(width/2,height/2,0)
def draw():
    print(type(vector.x))
    ellipse(vector.x ,vector.y, 3, 3)
</code></pre>
]]></description>
   </item>
   <item>
      <title>CP5_addDrawable_python mode</title>
      <link>https://forum.processing.org/two/discussion/5938/cp5-adddrawable-python-mode</link>
      <pubDate>Sat, 21 Jun 2014 15:41:13 +0000</pubDate>
      <dc:creator>ma_pa</dc:creator>
      <guid isPermaLink="false">5938@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody,
I have a question about controlP5 in Python mode.
I need to add a .jpg image to a group, and from this discussion (<a href="http://forum.processing.org/two/discussion/1841/controlp5-canvas-and-group/p1" target="_blank" rel="nofollow">http://forum.processing.org/two/discussion/1841/controlp5-canvas-and-group/p1</a>) I know I need the addDrawable() method. 
I can't figure out how to translate this short piece of Java code into Python:</p>

<pre><code>import controlP5.*;
ControlP5 cp5;
PImage pic;
void setup() {
  size(400, 400);
  cp5 = new ControlP5(this);
  pic = loadImage("bucky.jpg");
  Group t = cp5.addGroup("group-test").setPosition(100, 100).setWidth(200);
  cp5.addSlider("slider").setPosition(0, 10).moveTo(t);
  t.addDrawable(new CDrawable() {
    public void draw(PApplet p) {
      p.pushMatrix();
      p.image(pic,0,5,200,150);
      p.popMatrix();
    }
  }
  );
}

void draw() {
  background(0);
}
</code></pre>

<p>I tried this, but I get a NullPointerException.</p>

<pre><code>add_library('controlP5')
pic = loadImage("bucky.jpg")

def setup():
    size(500,500)
    cp5 = ControlP5(this) 
    g = cp5.addGroup('blah') \
           .setPosition(50,50) \
           .setWidth(250) 
    g.addDrawable(image(pic,0,0,250,150))

def draw():
    background(0)  
</code></pre>

<p>Does anybody have a clue?
Thank you all.</p>

<p>Marco</p>
]]></description>
   </item>
   </channel>
</rss>