| | |
Need help in stroke and shape
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 53
Reputation:
Solved Threads: 0
Hi, I am trying to make stroke and shape make a path like two sin curves.
so a path from x,y to x2,y2 first is like ------------------------- will become
/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/
if you understand what i mean.
I am very confused am I suppose to be changing the shape or the stroke to make a line from xy to x2x2 with a sign curve shape.
so a path from x,y to x2,y2 first is like ------------------------- will become
/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/
if you understand what i mean.
I am very confused am I suppose to be changing the shape or the stroke to make a line from xy to x2x2 with a sign curve shape.
if you have to use a Shape i would go with a CubicCurve2D
the sun tutorial that covers these is here
to get one period of a sin or cos wave you need two of these
if not explain what you need to do in more detail
the sun tutorial that covers these is here
to get one period of a sin or cos wave you need two of these
if not explain what you need to do in more detail
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
•
•
Join Date: Jul 2008
Posts: 53
Reputation:
Solved Threads: 0
•
•
•
•
if you have to use a Shape i would go with a CubicCurve2D
the sun tutorial that covers these is here
to get one period of a sin or cos wave you need two of these
if not explain what you need to do in more detail
well i want to be able to draw a line that looks like a thread.
so i think it have to do with stroke.
threads are like a group of strings wrapped together kind of similer to wires.
would be cool if i pass x1,y1,x2,y2, and a color and it will have shades of the color wrapping around
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
ok:
it's not perfect, and doesn't take into account orientation, but it illustrates my idea:
the setStroke() only makes it bigger and doesn't effect the look otherwise adding orientation may be difficult this way but i'll give it a shot if asked... (PS: Ask, i almost want to see if i can)
it's not perfect, and doesn't take into account orientation, but it illustrates my idea:
java Syntax (Toggle Plain Text)
public void paint(Graphics g){ Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(4,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); for(int i=0;i<=80;i+=8){ g2.setColor(new Color(0,0,0)); g2.draw(makeSin(10+i,10,40+i,40)); g2.setColor(new Color(128,128,128)); g2.draw(makeSin(14+i,10,44+i,40)); } } public CubicCurve2D.Double makeSin(double x,double y,double x2,double y2){ return new CubicCurve2D.Double(x,y,(x+x2)/2,y,(x+x2)/2,y2,x2,y2); }
the setStroke() only makes it bigger and doesn't effect the look otherwise adding orientation may be difficult this way but i'll give it a shot if asked... (PS: Ask, i almost want to see if i can)
Last edited by sciwizeh; Jul 14th, 2008 at 11:55 pm.
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
•
•
Join Date: Jul 2008
Posts: 53
Reputation:
Solved Threads: 0
•
•
•
•
ok:Attachment 6612
it's not perfect, and doesn't take into account orientation, but it illustrates my idea:
java Syntax (Toggle Plain Text)
public void paint(Graphics g){ Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(4,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); for(int i=0;i<=80;i+=8){ g2.setColor(new Color(0,0,0)); g2.draw(makeSin(10+i,10,40+i,40)); g2.setColor(new Color(128,128,128)); g2.draw(makeSin(14+i,10,44+i,40)); } } public CubicCurve2D.Double makeSin(double x,double y,double x2,double y2){ return new CubicCurve2D.Double(x,y,(x+x2)/2,y,(x+x2)/2,y2,x2,y2); }
the setStroke() only makes it bigger and doesn't effect the look otherwise adding orientation may be difficult this way but i'll give it a shot if asked... (PS: Ask, i almost want to see if i can)
•
•
Join Date: Jul 2008
Posts: 53
Reputation:
Solved Threads: 0
•
•
•
•
like this?:Attachment 6611
if so, then plainly stroke won't do it, i don't think, i would still use CubicCurve2D, ill write a bit of sample code, but it may take a moment
I think using stroke is possible because stroke is a shape also. Just the coding is more complex and you go in steps along the line.
While without using stroke you just do a loop long the line.
I going to try to draw the same idea as a stroke still. I think it is possible and would be better to be able to ever reuse the method
•
•
•
•
I think using stroke is possible because stroke is a shape also.
got an example?
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
•
•
Join Date: Jul 2008
Posts: 53
Reputation:
Solved Threads: 0
•
•
•
•
what? no it isn't, stroke doesn't extend shape, and BasicStroke doesn't implement it either.
got an example?
I was coding it using stroke method but I stopped becuase It does not do color blending when strokes overlap each other.
Also stroke was kind of weird you need to draw lines as a polygon shape for it to fill nicely
So better way was to do what u did and not use strokes.
the line coloring wasnt looking that great. I might have to use a thread image with a color mask to make it look better.
![]() |
Similar Threads
- vector shape question (Graphics and Multimedia)
- How to call a class that draws a circle in a MouseMoved method ?? (Java)
- Web Graphic Programs....Design? (Graphics and Multimedia)
- cannot get the sendmail to actualy send an email with the form selections (PHP)
Other Threads in the Java Forum
- Previous Thread: Array Selections
- Next Thread: Troubles with printing triangles
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api append apple applet application arguments array arrays automation bi binary bluetooth businessintelligence busy_handler(null) chat class classes client code component database draw eclipse encryption equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop main map method methods mobile netbeans newbie number open-source oracle oriented panel print problem program programming project qt recursion reference replaysolutions repositories return robot scanner screen scrollbar se server set singleton size sms socket sort sql string swing test threads time tree utility windows xor





