Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Algorithm question

Algorithm question

Scheduled Pinned Locked Moved C#
questionalgorithmsdata-structurestutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rassul Yunussov
    wrote on last edited by
    #1

    I want to have an array of colors from blue to red - like a rainbow... How to fill in this array programmatically???

    C 1 Reply Last reply
    0
    • R Rassul Yunussov

      I want to have an array of colors from blue to red - like a rainbow... How to fill in this array programmatically???

      C Offline
      C Offline
      Corinna John
      wrote on last edited by
      #2

      Start with blue (0/0/255) into first loop. Every turn adds a little green, and when green is 255, subtracts a little blue, until you reach pure green (0/255/0). Then begin a second loop, that adds red and subtracts green, until there is clear red. Start 000/000/255 (blue) 000/010/255 000/020/255 000/030/255 ... 000/255/255 (cyan) 000/255/240 000/255/230 000/255/220 ... 000/255/000 (green) 010/255/000 020/255/000 030/255/000 ... 255/255/000 (yellow) 255/240/000 255/230/000 255/220/000 ... 255/000/000 (red) As you can see, there are four loops like that: for(int green=0; green<256; green++){ colors.Add(new Color( 0, green, 255 )); } for(int blue=255; blue>-1; blue--){ colors.Add(new Color( 0, 255, blue )); } DISCLAIMER: This response in not tested, it's simple guesswork. _________________________________ Please inform me about my English mistakes, as I'm still trying to learn your language!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups