CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Is there anyway I can gradient a LINE???

    Like from black to blue.....or you can change colors(as RGB)

    THANK YOU


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Is there anyway I can gradient a LINE???

    Use PSet and display each point!. Probably its performance would be bad, if you are looking for graphics effects

    i = 0: x = 0
    do
    y = m1*x + c1 ' standard stline formula.
    ' Modify m1 & c1 to get the effect
    ' m1 = (y2-y1)/(x2-x1), for a line passing thru
    ' 2 pts (x1,y1) to (x2,y2)
    '
    ' or use the 2pt formula:
    ' (y-y1)(x2-x1) = (y2-y1)(x-x1) and rearrange
    ' and tune for performance.

    ' if you want a parametric representation of st line
    ' x = (x2-x1)*t + x1
    ' y = (y2-y1)*t + y1 ' will draw the line from
    ' (x1,y1) to (x2,y2), where t is the param goes from 0 to 1
    ' so set t = i * 1/255 and it will increment
    ' exactly as the color index. provided you have 255 color support for each color

    pset (x,y), RGB(i,0,0) ' Red line
    pset (x,y), RGB(0,0,i) ' Blue line
    i = i + 1
    x = x + 1
    loop while i <= 255




    RK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured