We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware Bugs › vector graphics drawing program
Page Index Toggle Pages: 1
vector graphics drawing program (Read 1099 times)
vector graphics drawing program
Feb 23rd, 2006, 6:20pm
 
i wanna implement a simple drawing program using vector graphics for live performance purposes.
the lines should have variing thickness (i'm using a wacom with jTablet...).

may plan is to create classes for a point (containing x, y and thickness), a line (containing an array of points), and a drawing (containing an array of lines and a method for drawing the whole thing).

any pointers as to how to best implement the drawing method?
would it make sense to use the postscript library at all?

any help appreciated!
Re: vector graphics drawing program
Reply #1 - Feb 26th, 2006, 1:45am
 
i've come along quite a bit with my project but there's one thing i can't figure out...

if i draw a stroke as polygon w curveVertices i get ArrayIndexOutOfBoundsException: 512...

it works with JAVA2D, but not with OPENGL, which i want to use. it also works with straight vertices instead of curveVertices.

my code:

beginShape(POLYGON);

//draw right side of stroke
for (int i = 0; i < count; i++){
 curveVertex(rx[i], ry[i]);
 }

//draw left side of stroke        
for (int i = count-1; i > 0; i--){  
 curveVertex(lx[i], ly[i]);
 }

endShape();

Re: vector graphics drawing program
Reply #2 - Feb 27th, 2006, 2:51pm
 
that may be a bug if it works in java2d but not opengl. could you post the portion of the code that will reproduce the bug so i can get the full error message?
Re: vector graphics drawing program
Reply #3 - Mar 1st, 2006, 12:09pm
 
ok this may not be pretty but it reproduces the error message. if i leave out the opengl bit in the size() statement, it works!

------------------------

import processing.opengl.*;

public final static int NUM  = 100;

int[] rx = new int[NUM];
int[] ry = new int[NUM];
int[] lx = new int[NUM];
int[] ly = new int[NUM];

void setup(){
 size(800, 600, OPENGL);
}

void draw() {
 generatePoints();
 drawSmooth();  
}

void generatePoints() {

 for (int i = 0; i < NUM; i++){
   rx[i] = 150+(i*5);
   ry[i] = 280;
   lx[i] = 150+(i*5);
   ly[i] = 320;
 }

}


void drawSmooth()  {

 // draw smooth ---------------------------

 fill(255);
 stroke(255);

 beginShape(POLYGON);

 for (int i = 0; i < NUM; i++){
   curveVertex(rx[i],ry[i]);
 }

 for (int i = NUM-1; i > 0; i--){
   curveVertex(lx[i],ly[i]);
 }
 endShape();
}


Re: vector graphics drawing program
Reply #4 - Mar 1st, 2006, 2:22pm
 
yup, that was a bug. fixed for rev 0106.
Page Index Toggle Pages: 1