Results 1 to 12 of 12

Thread: changing the colour of a line created at runtime

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    This is something that has been puzzling me for quite a while:

    In a nut shell, I creat a line at runtime like this:

    Private Sub Command1_Click()
    ang1 = 3 * 100
    ang2 = ang1 * 3.1416 / 180
    'here is where I create the line
    Form1.Line (3430, 3000)-Step(Cos(ang1 + ang2 / 2) * 1320, Sin(ang1 + ang2 / 2) * 1320)
    End Sub

    Now, I'm wondering how I can make the above line white rather than black - which is the default.

    Can this be done? Thanks in advance!


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    ang1 = 3 * 100
    ang2 = ang1 * 3.1416 / 180
    'here is where I create the line
    Form1.ForeColor = vbRed
    Form1.Line (3430, 3000)-Step(Cos(ang1 + ang2 / 2) * 1320, Sin(ang1 + ang2 / 2) * 1320)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Form1.Line (3430, 3000)-Step(Cos(ang1 + ang2 / 2) * 1320, Sin(ang1 + ang2 / 2) * 1320),vbred

    You can as well use any RGBcolor instead of vbred
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    That simple? Thanks!

  5. #5
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    mmmm?

    This guy want WHITE and you give him red...
    or am I colorblind?

    btw Just kidding here :-)
    To VB or not to VB, that's the question...

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    I forgot how to spell "White"...
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    odd`? BTW how did we come to think about red both of us?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186

    Wink Less Typing

    "Red" consists of only three letters, and they happen to be neighbors on the keyboard. It's the perfect color to use for quick examples.

    Shrog

  9. #9
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    If I correctly understood it you basically just need to change the line property.

    add this line after you have created the line:

    form1.line1.color = &H00000000

    The color number is not actually the correct one (just figure it out in the properties box of line1)...

    Hope this helps,

    W.

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    wildcat_2000
    That won't work.

    Kedaman..I guess it's because maily we type and write on white and red is usually a color we ask for when we want something to stand out.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  11. #11
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186

    Exclamation Not an Object

    It won't work because it's not an object. If you add the Line control to the form, you have an object with a color property you can set. But we are using the Line method to draw a line on the screen. After it's been drawn, you cannot change the color. You have to do it before or while drawing it.

    Shrog

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The line object is usually a waste of resources, but sometimes when it comes to test animations, it could be useful

    Well red is both easy to write and nice color - it's the one i use in icq since it shows best on both black and white.
    also red is the LO byte so i use it often in test apps
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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