How to use External Libraries in your own sketch with your own data.
in
Contributed Library Questions
•
1 year ago
Hey Everyone;
I'm really stumped on how to incorporate the functions of external libraries into my own sketchs. Im think this is super easy, but Im just totally totally stumped. Here is my problem;
I do not understand what pieces of the external library I need to include in my sketch to gain its functionality (besides
import.theLibrary*; ). And then, how to use them with my own data (or parameters).
Every tutorial site says, "look at the examples provided and that will show you" but like, I dont get it. There are so many lines of code in the example files, which lines of code do i need to include in my sketch to gain functionality, and then, how do I incorporate my own variables into the library on my shit? I have read and watch everything I thought that might have the answer, but Im still missing it...
I watched awesome Joes' awesome PeasyCam tutorial
http://vimeo.com/18325690 (he is the man btw (thank you Jose)).
But I dont understand how to find out the name of the thing you need to Declare (bascially what you need to include in your sketch for the library to start working for you). In the case of the PeasyCam provided example, its right there at the top. But so is all this other stuff. How do you discern what elements you need to include to get it to work in your sketch. He only includes
PeasyCam cam; then
cam = new PeasyCam(this,100); but there is all this other stuff in the PeasyCam example file.
So, what if I wanted to use a different library, there are so many and not all of them are nearly as clear how to initialize in your sketch... For example, Im looking at Toxiclibs provided example PolarUnravel in Geometry.
If I wanted to make a bar chart thing of mine do the same thing as the awesome Toxiclibs PolarUnravel example. Which lines of that code/library to I need to include to get the lines in my sketch to do that same cool unravel thing? And, which from the example file do I not include in my sketch file. Then, how do I tell it to work? Like, to start the unraveling not by clicking the mouse (which is how it works in the example file), but rather start the unravleing by hitting the "u" key. How would I do that?
This is the way Jose did it in his tutorial for PeasyCam. How would I do this for Toxiclibs PolarUnravel.
- import peasy.*;
- PeasyCam jCam; //1 DECLARE INSTANCE OF the PEASY CAM CLASS
- void setup() {
- size(600, 600, P3D);
- jCam = new PeasyCam(this, 100); //2 INITLIZE PEASY CAM
- }
- void draw() {
- background(100);
- box(600);
- }
So if I wanted to make my bar chart (example below) do the exact same thing that happens in the PolarUnravel; what would i need to include in my sketch?
- void setup() {
- size(680, 380, P3D);
- smooth();
- }
- void draw() {
- int x = 50;
- stroke(111);
- for (int i = 0; i < 50; i++) {
- line(x, 250, x, i*2);
- x+=10;
- }
- }
Any advice would be much appreciated. Thank you all so much for your time, and enjoy the weekend.
Peace, weezyF
1