drawing a filled star with jit.gl.sketch possible
hello list,
i am trying to write a little paint program using the
jit.gl.sketch object.
at the end i want control the color and blend of all
drawn objects. (between 100-300 objects)
i am drawing polygons, which works fine for triangle and quad
shapes.
but i get strange results, if i want to draw a simple
star with a fill or later a video texture.
i read in the opengl specs, that i have to triangulate
the polygon first.
has anyone a tip, how to do this in jitter ?
best,
t.
Star shapes are much easier if you use the tri_fan primitive (instead of say, polygon), with the starting vertex in the center of the star.
Hope that helps.
Andrew B.
thank you andrew for the fast response !
the star was only an example for drawing a shape.
at the end i want to draw filled polygones of
any shape by defining its outline.
(as in all common drawing programs)
best,
t.
hello all,
seems to be not possible writing a simple vector paint program in jitter :-(
but found a free alternative: openframeworks
it can be easyly done there and it is also controllable via osc.
(and much faster than jitter !!)
so i let openframeworks do the "hard work" and
controll it with max. which is more fun to program with :-)
perhaps we will get basic tiangulation functionality in future versions
of jitter. that would be great !
best,
t.
Vector painting can be achieved by using java(mxj) but is not a straight forward approach.
BTW, OFW is really nice
hi efe,
could not find an example how draw a filled polygon with java ...
perhaps you can give me a tip, where i can start searching.
best,
t.
Hello titan22:
sorry for the delay, busy days!
Herewith a small example. I took an array from one of the processing examples(a star) and used as an array of coordinates. Glitchy but can give you an idea.
compile the code either with the quickie, terminal(if OSX) or eclipse:
import com.cycling74.max.*;
import java.util.Random;
public class ProcessingStar3 extends MaxObject{
private int count=0;
private int[] x = { 50, 61, 83, 69, 71, 50, 29, 31, 17, 39 };
private int[] y = { 18, 37, 43, 60, 82, 73, 82, 60, 43, 37 };
int finalarray[]=new int [x.length-1];
public ProcessingStar3(){
declareAttribute("count");
}
public void bang(){
for(int i=0;i
}
count++;
if(count>x.length-1){
count=0;}else{
count=count;}
outlet(0,new Atom[]{Atom.newAtom(x[count]*0.01),Atom.newAtom(y[count]*0.01)});
//outlet(1,y[count]);
}
}
once compiled:
note that the arrays might be generated in a completely different fashion
hope it helps!
Emmanuel
hello emmanuel,
thank you for the example !
but perhaps i was not clear enought.
the problem is not defining points and draw an
outline. this can be done nicely with the jit.gl.sketch
object. using lineto or line_loop ..
the callange is to get this object filled.
the normal opengl workflow is:
- define the points (vertex points)
- triangulate them with the opengl Tessellation function
- draw the triangles
in openframeworks and processing you have
wrapper functions to do the tessellation.
AND you have access to the opengl build in functions.
in jitter, you have no wrapper and
in jit.gl.sketch it is not possible to use
the opengl functions.
information about tessellation can befound here:
http://www.flipcode.com/archives/Polygon_Tessellation_In_OpenGL.shtml
the star was just an example.
t.
hello all,
i have just seen, that we now can draw filled polygons with jt.gl.sketch !!
(its in the 5.1.3 update)
a very special thank to the developing team.
its a bit like christmas for me :-)
and hopefully we will see a lot of speedy opengl accelerated vector
animations made with jitter in the future.
best,
t.