so0ly
YaBB Newbies
Offline
Posts: 3
Re: rectangle + rounded corners + gradient
Reply #5 - Mar 18th , 2008, 9:30am
I think the solution you gave me isn't going to work for me because i also need to make multiple gradients :) for example: color1 to color2 to color3... :) and in the gradientpaint API it says i can only specify 2. now i'm having something like this: - first drawing the gradient - then hiding the gradient with some rounded corners (but i need to drag and drop this so the backcolor can change, while the color of the rounded corners stays the same) int h = this.getHeight()+STROKEWEIGHT; int nboflines= (h/criterias.size())*2; app.strokeWeight(0); for(int i = 0; i< criterias.size()-1;i=i+1){ int rd = criterias.get(i).getParentCollection().getColor().getRed()/nboflines; int gd = criterias.get(i).getParentCollection().getColor().getGreen()/nboflines; int bd = criterias.get(i).getParentCollection().getColor().getBlue()/nboflines; int ru = criterias.get(i+1).getParentCollection().getColor().getRed()/nboflines; int gu = criterias.get(i+1).getParentCollection().getColor().getGreen()/nboflines; int bu = criterias.get(i+1).getParentCollection().getColor().getBlue()/nboflines; for(int j = 0; j<nboflines;j++){ int r = (criterias.get(i).getParentCollection().getColor().getRed()-(rd*j))+(j*ru); int g = (criterias.get(i).getParentCollection().getColor().getGreen()-(gd*j))+(j*gu); int b = (criterias.get(i).getParentCollection().getColor().getBlue()-(bd*j))+(j*bu); app.stroke(r,g,b); app.fill(r,g,b); //app.line(getX()-(STROKEWEIGHT/2), (getY()+(i*nboflines)+j)+2, getX()+getWidth()+STROKEWEIGHT/2, (getY()+(i*nboflines)+j)+2); app.rect(getX()-(STROKEWEIGHT/2), (getY()+(i*nboflines)+j)-STROKEWEIGHT/2, this.getWidth()+STROKEWEIGHT, 1); } } app.fill(0); app.stroke(0); //upper left app.beginShape(); app.vertex(getX()-STROKEWEIGHT/2, getY()); app.bezierVertex(getX()-STROKEWEIGHT/2,getY()-STROKEWEIGHT/4,getX()-STROKEWEIGHT /4,getY()-STROKEWEIGHT/2,getX(),getY()-STROKEWEIGHT/2); app.vertex(getX()-STROKEWEIGHT/2, getY()-STROKEWEIGHT/2); app.vertex(getX()-STROKEWEIGHT/2, getY()); app.endShape(); //upper right app.beginShape(); app.vertex(getX()+getWidth()+STROKEWEIGHT/2,getY()); app.bezierVertex(getX()+getWidth()+STROKEWEIGHT/2,getY()-STROKEWEIGHT/4,getX()+g etWidth()+STROKEWEIGHT/4,getY()-STROKEWEIGHT/2,getX()+getWidth(),getY()-STROKEWE IGHT/2); app.vertex(1+getX()+getWidth()+STROKEWEIGHT/2,getY()-STROKEWEIGHT/2); app.vertex(1+getX()+getWidth()+STROKEWEIGHT/2, getY()); app.endShape(); //under left app.beginShape(); app.vertex(getX()-STROKEWEIGHT/2, getY()+getHeight()); app.bezierVertex(getX()-STROKEWEIGHT/2,getY()+getHeight()+STROKEWEIGHT/4,getX()- STROKEWEIGHT/4,getY()+getHeight()+STROKEWEIGHT/2,getX(),getY()+getHeight()+STROK EWEIGHT/2); app.vertex(getX()-STROKEWEIGHT/2, 2+getY()+getHeight()+STROKEWEIGHT/2); app.vertex(getX()-STROKEWEIGHT/2, 2+getY()+getHeight()); app.endShape(); //under right app.beginShape(); app.vertex(getX()+getWidth()+STROKEWEIGHT/2,getY()+getHeight()); app.bezierVertex(getX()+getWidth()+STROKEWEIGHT/2,getY()+getHeight()+STROKEWEIGH T/4,getX()+getWidth()+STROKEWEIGHT/4,getY()+getHeight()+STROKEWEIGHT/2,getX()+ge tWidth(),getY()+getHeight()+STROKEWEIGHT/2); app.vertex(1+getX()+getWidth()+STROKEWEIGHT/2,2+getY()+getHeight()+STROKEWEIGHT/ 2); app.vertex(1+getX()+getWidth()+STROKEWEIGHT/2, 2+getY()+getHeight()); app.endShape();