It is currently Sun May 26, 2013 4:18 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: I need code ... line and curves like paint.net .
PostPosted: Mon Feb 27, 2012 10:02 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
I have to draw lines as in "paint.net"

When I draw the line i have 4 points that I can move to draw the curves


in my software:
I draw the line with the left mouse button and with Right mouse (left mouse button is used in paint)
I move the 4 points to draw the curve

someone help me with the code?


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Mon Feb 27, 2012 10:26 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2865
Location: Wales, UK
This should help: http://www.purebasic.fr/english/viewtopic.php?f=13&t=48758&start=32

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Mon Feb 27, 2012 10:35 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
Thank .


But is not what I need..

... "I have to draw lines as in "paint.net" ...


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 1:56 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 2401
Location: Utah, USA
VisualJump3D wrote:
in my software:
I draw the line with the left mouse button and with Right mouse (left mouse button is used in paint)
I move the 4 points to draw the curve

someone help me with the code?


Where is your code showing what you have got so far?

_________________
Image


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 3:24 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Feb 12, 2006 10:06 pm
Posts: 516
I'm guessing it is something similar to

Code:
RunProgram("Paint.exe")

_________________
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 12:45 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
sorry ...

when i write : << "in my software: I draw the line with the left mouse button and with Right mouse (left mouse button is used in paint) I move the 4 points to draw the curve ">>

is not my code , is what I would ...

Thank !


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 5:38 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2865
Location: Wales, UK
...the point is though, a lot depends on what you already have done, what, overall, your app is to accomplish and how - are you using GDI Plus? Are you using the Canvas Gadget? Are you using a Screen/Windowed Screen? There are all sorts of possibilities but we can't read your mind..... :shock:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 7:23 pm 
Offline
Always Here
Always Here
User avatar

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7304
Location: Norway
It's called a bezier curve. I have a code to draw one, but the handles aren't draggable. You will have to do that yourself.
Code:
EnableExplicit


Structure SPointF
  X.d
  Y.d
EndStructure

Macro PointF(Var, pX, pY)
  Var.SPointF\x = pX
  Var\y = pY
EndMacro

Global PointF(A, 40, 100)
Global PointF(B, 80, 20)
Global PointF(C, 150, 180)
Global PointF(D, 260, 100)

Procedure lerp(*dest.SPointF, *a.SPointF, *b.SPointF, T.d)
  *dest\x = *a\x + (*b\x-*a\x)*T
  *dest\y = *a\y + (*b\y-*a\y)*T
EndProcedure

Procedure Bezier(*dest.SPointF, T.f)
  Protected AB.SPointF
  Protected BC.SPointF
  Protected CD.SPointF
  Protected ABBC.SPointF
  Protected BCCD.SPointF
 
  lerp (ab, a,b,t);           // point between a and b (green)
  ;Plot(ab\x, ab\y, $007F00)
  lerp (bc, b,c,t);           // point between b and c (green)
  ;Plot(bc\x, bc\y, $007F00)
  lerp (cd, c,d,t);           // point between c and d (green)
  ;Plot(cd\x, cd\y, $007F00)
  lerp (abbc, ab,bc,t);       // point between ab and bc (blue)
  ;Plot(abbc\x, abbc\y, $FF0000)
  lerp (bccd, bc,cd,t);       // point between bc and cd (red)
  ;Plot(bccd\x, bccd\y, $0000FF)
  lerp (*dest, abbc,bccd,t);   // point on the bezier-curve (black)
EndProcedure


; Line plotting code
Global pX, pY
Procedure LinePlotStart(X, Y)
  pX = X
  pY = Y
EndProcedure

Procedure LinePlot(X, Y, Col)
  LineXY(pX, pY, X, Y, Col)
  pX = X
  pY = Y
EndProcedure
; End line plotting code

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

CreateImage(0, 512, 384)
StartDrawing(ImageOutput(0))
  Box(0, 0, 512, 384, $FFFFFF)
  Global p.SPointF
  Global I.l
  Global T.f
  #Step = 100
  Bezier(p, 0)
  LinePlotStart(p\x, p\y)
  For I=0 To #Step
    t.f = i/(#Step+0.)
    bezier (p, t)
    LinePlot(p\x, p\y, 0)
  Next
  DrawingMode(#PB_2DDrawing_Transparent)
  Circle(A\x, A\y, 2, $00FF00) : DrawText(A\x, A\y, "A") :
  Circle(B\x, B\y, 2, $00FF00) : DrawText(B\x, B\y, "B") :
  Circle(C\x, C\y, 2, $00FF00) : DrawText(C\x, C\y, "C") :
  Circle(D\x, D\y, 2, $00FF00) : DrawText(D\x, D\y, "D") :
StopDrawing()

ImageGadget(0, 0, 0, 0, 0, ImageID(0))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

_________________
Woa, I set up a web server.


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 9:03 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
Thank !

But in Paint.net the 4 points are all in the line , not outside ...

Help me !!


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 9:15 pm 
Offline
User
User

Joined: Mon Jul 09, 2007 4:47 pm
Posts: 67
Location: Right Here
VisualJump3D wrote:
Help me !!

The forum helps those who (try to) help themselves. :)


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 9:20 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
Please , " juror" read all my posts about my software "visualjump3d" ...
so you can tell I'm just asking a little help for part of my code ...



look and read this url : http://mathworld.wolfram.com/B-Spline.html

thank.


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 10:38 pm 
Offline
User
User

Joined: Mon Jul 09, 2007 4:47 pm
Posts: 67
Location: Right Here
So show us what you've got. Based on your posts it's hard to determine what you've written.

What about trond's post was bad?


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 10:41 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
Sorry for my english


In the code of Trod the 4 point for draw the line are outside the line ...

Please open Paint.net and draw a line , after you can understand me !


Last edited by VisualJump3D on Tue Feb 28, 2012 10:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 10:42 pm 
Offline
User
User

Joined: Mon Jul 09, 2007 4:47 pm
Posts: 67
Location: Right Here
Do you have any CODE?


Top
 Profile  
 
 Post subject: Re: I need code ... line and curves like paint.net .
PostPosted: Tue Feb 28, 2012 10:45 pm 
Offline
User
User

Joined: Thu Jun 23, 2011 8:32 pm
Posts: 26
what "code"? , Code for BSpline ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye