Creating Random Colors

Just out of curiosity - I'm trying to make a string display random colors. My understanding is text.textcolor accepts a hex number in the format "RRGGBB". I"m doing the following, but I'm not sure that this is right. Can someone check and let me know?
Much appreciated.
LB 
Solved!
Go to Solution.
Attachments:
labviewdelthistoo.png ‏9 KB

You need to create a binary 24-bit number to give the color. Labview provides a VI (RGB to Color.vi) to create a color based on 3 8-bit numbers in the sub-palette Graphics & Sounds / Picture functions. See below
Marc Dubois
HaroTek LLC
www.harotek.com

Similar Messages

  • Reconnecting to dock station with new T530 creates random colored pixels.

    Anyone with a T530 that uses the OFFICIAL and real dockstation have issues with random green and pink pixels on their external monitors when they reattach?.
    My T530 has the Nvidia optimus 5400 and the HD4000 Intel chipset which apparnently go back and forth between eachother using the BIOS to save power. I was getting REALLY pissed of with the the Intel HD4000 constantly adjusting the brigthness on my screen so I disabled it and went to discrete Nvidia graphics instead and to hell with the power savings.
    Anyone else seen issues with video anamolies with the docktation? If I disconnect the DVI cable and reconnect, it goes away. Do I have a bad dock or laptop?

    I experience this as well with my T510 on two different docking stations.
    I've simply put up with it for for a few years. Tweaking some display settings helped slightly mitigate the issue.
    However, my new dock is a Mini Dock Plus, with dual outputs, which allows me some additional testing possibilities. I've been able to confirm that it is a specific cable/display that is causing the issue, not a specific port on the laptop. Furthermore, dropping the resolution from 1920x1080 to 1680x1050 caused the dots to dissapear completely.
    The odd part is that I can't seem to reproduce the issue with another device connected to the same cable/display.
    My remaining troubleshooting steps are:
    * swap out the cable with an alternate (my alternate DVI cable has ferrite cores on each end).
    * If this resolves the issue, I'll add my KVM back in the mix, but not use the apparently bad KVM DVI cables. If it doesn't, then I might have to ditch the KVM, and use input switching on my monitor :/
    My specs (but to be honest, my googling has turned up similar issues with older thinkpads and ATI graphics, so I don't think it is exactly dependant on the laptop):
    * T510
    * Nvidia NVS 3100M (with 'nvidia' driver).
    * Mini Dock & Mini Dock Plus w/ USB3.0
    * Fedora 19

  • I'm trying to create a random color generator

    //               create random color generator
                        String[]colors = {"RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "INDIGO", "PURPLE"};
    //               create variable to store random color
                        int mycolorint = (int)(Math.random()*7);
                        String mycolor = colors[mycolorint];
    //               label axis
                   StdDraw.setPenColor(StdDraw.(mycolor));
    what is wrong with this code?

    StdDraw.setPenColor(StdDraw.(mycolor));This line really doesn't make any sense. If you think about it you haven't seen any java code which includes something like "foo.(bar)" or "Foo.(bar)". The compiler wants to see identifiers either side of the dot - and identifiers don't start with a (.
    I am guessing that if "RED" gets chosen from the array, then you want the label axis to useStdDraw.setPenColor(StdDraw.RED);In that case you have to set the array up a little differently.
        // create random color generator
    ???[]colors = {
            StdDraw.RED, StdDraw.ORANGE, StdDraw.YELLOW,
            StdDraw.GREEN, StdDraw.BLUE, StdDraw.INDIGO, StdDraw.PURPLE
        // create variable to store random color
    int mycolorint = (int)(Math.random() * 7);
    ??? mycolor = colors[mycolorint];
        // label axis
    StdDraw.setPenColor(mycolor);You will have to read the documentation for this StdDraw class to see what type StdDraw.RED etc are.

  • Trouble creating random ovals

    Hello all, as much as I hate having to look really stupid, I am a nooby and I am stuck. I am trying to create randomly placed ovals by pressing my jbutton to seem as though the image is being erased. I have tried different scenarios and have read my text many times. My courses are via online and I am more of a hands on learner. I am not looking for anybody to do my work for me, I would just like to be pointed in the right direction please. I keep getting an error message in my action performed methd (cannot find symbol g (in g.filloval)). Can someone point me to a tutorial for this or point out my mistakes please, any help is greatly appreciated. Thank!
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class JEraseImage extends JApplet implements ActionListener
    private ImageIcon image = new ImageIcon ("pins.jpg");
    private int Width, Height;
    Container con = getContentPane();
    JLabel greeting = new JLabel ("If you don't like what you see");
    Font headlineFont = new Font ("Helvetica", Font.BOLD, 20);
    JButton eraseMe = new JButton ("Erase Me");
    Image pins;
          public void init() 
         greeting.setFont (headlineFont);
            con.add(greeting);
         con.add(eraseMe);
         con.setLayout(new FlowLayout());      
         pins = getImage(getCodeBase(),"pins.jpg");
            eraseMe.addActionListener(this);      
         public void paint (Graphics g)
         g.drawImage(pins, 0, 30, this);
         g.setColor(Color.WHITE);
         g.fillOval(70, 30, 100, 60);
         for(int count = 0; count < 20; ++count)
            int x = (int) (Math.random() * Width) + 0;
            int y = (int) (Math.random() * Height) + 30;
            g.fillOval(x, y, 10, 10);
         eraseMe.repaint();
         public void actionPerformed(ActionEvent eraseMe)
         g.filloval.repaint(); //also tried eraseMe.repaint();
    }Edited by: stillearning on Nov 20, 2007 7:03 PM

    I have the latest version, at least as a month ago anyways. The eraseMe is supposed to create the filled ovals when the jbutton is clicked so it will seem to erase the imageicon already in place. I tried changing to lower case o in filloval and it didn't compile but it did when I kept them uppercase. I managed to place one oval over the image in the paint method but that's as far as I seem to get. I'm guessing I went wrong somewhere in the for loop? I tested a string event in the action performed event and that worked just fine so I know my jbutton is active.
    Here is the adjusted code:
    public void paint (Graphics g)
         g.drawImage(pins, 0, 30, this);
         g.setColor(Color.WHITE);
         g.fillOval(70, 30, 100, 60);
         for(int count = 0; count < 20; ++count)
            int x = (int) (Math.random() * Width) + 0;
            int y = (int) (Math.random() * Height) + 30;
            g.fillOval(x, y, 10, 10);
         public void actionPerformed(ActionEvent eraseMe)
         repaint();
    }

  • Smudge Tool Problems, Creating weird colors.

    Hello!
    I have been strugling with this problem for hours now. The smudge tool creates some weird gray/random color(s) when im trying to smudge instead of fading. I have reseted all tools and i have reinstalled PS C4 and nothing helps.
    Picture of the problem.
    http://i60.photobucket.com/albums/h11/kas006/Problem.png
    No matter what strenght or size i use it ends up the same.

    that should go away after a few more strokes or you could just use Liquify as that produces way better results than the Smudge tool

  • 4 pre-defined random colors

    Hi everybody
    Im trying do design an application in flash and I want to use
    random colors. But i just want to use 4 pre-defined random colors.
    So my question is this: how do I set the 4 colors to display
    randomly?I must say that I'm a begginer in flash so please have
    some patience...
    Thank you for your help
    Best regards,

    Create an array that holds your pre-defined colors, then use
    the random math function to get an random index to use for your
    array which will give you your randomly defined color. Something
    like this:
    var myArray:Array = ["0xFF0000", "0x00FF00", "0x0000FF"];
    var randColor:String = myArray[random(3)];
    trace(randColor);
    So you'd use the variable randColor wherever you're defining
    the color in your movie.
    Hope that helps!

  • Random Colors? help :(

    What is the command to make random colors?

    Simple bug in your code, nothing big, really...
    rg.nextInt(256), rg.nextInt(256), rg.nextInt(256));
    There is no error in my code, the range is 0 to 255..
    "Color(int r, int g, int b, int a)
    Creates an sRGB color with the specified specified red, green, blue, and alpha values in the range (0 - 255)."Yes, there is an error in your code. I see you read the Color API. Did you read the API for Random.nextInt()?

  • HELP creating random rectangle

    hi im having trouble it seems like my code is down correct but that isnt the case because i get 4 errors all involving 'MyRectangle' i get 4 cannot find symbol if ne one knows please help me out thanks my code is below thank you
    import java.awt.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.Random;
    import javax.swing.*;
    public class DrawJPanel extends JPanel
       // Random object to create random numbers
       private Random randomNumber = new Random();
       // Timer object to generate events
       private Timer drawTimer;
       // ArrayList object to hold MyRectangle objects
       private ArrayList rectangleArrayList = new ArrayList();
       // array of possible MyRectangle colors
       private Color[] colors = { Color.BLUE, Color.ORANGE, Color.PINK,
          Color.CYAN, Color.MAGENTA, Color.YELLOW, Color.BLACK,
          Color.WHITE, Color.RED, Color.GREEN };
       // no-argument constructor
       public DrawJPanel()
          super();
          drawTimer = new Timer( 250,
             new ActionListener() // anonymous inner class
                // event handler called every 250 microseconds
                public void actionPerformed( ActionEvent event )
                   drawTimerActionPerformed();  
             } // end anonymous inner class
          ); // end call to new Timer
          drawTimer.start(); // start timer
       }  // end contructor
       // create new MyRectangle object and add it to rectangleArrayList
       private void drawTimerActionPerformed()
          // get random dimensions and a random color
          int x = randomNumber.nextInt( 380 );
          int y = randomNumber.nextInt( 380 );
          int width = randomNumber.nextInt( 150 );
          int height = randomNumber.nextInt( 150 );
          int color = randomNumber.nextInt( 10 );
          // create MyRectangle object and add it to rectangleArrayList
          MyRectangle rectangle = new MyRectangle(x,y,width,height,colors[color]);
          rectangleArrayList.add( rectangle );
          repaint();
       } // end method drawTimerActionPerformed
       // draw all rectangles
       public void paintComponent( Graphics g )
          super.paintComponent( g );
          // create iterator
          Iterator rectangleIterator = rectangleArrayList.iterator();
          MyRectangle currentRectangle; // create MyRectangle
          // iterate through ArrayList and draw all MyRectangles
          while ( rectangleIterator.hasNext() )
             currentRectangle =
                ( MyRectangle ) rectangleIterator.next();
             currentRectangle.draw( g ); // draw rectangle
       } // end method paintComponent
       // clear rectangleArray
       public void clear()
          rectangleArrayList.clear(); // clear ArrayList
          repaint(); // repaint JPanel
       } // end method clear
    } // end class DrawJPanel

    And...?
    MyRectangle is not part of the Java API. So that means you wrote it... or something like that. Did you write a MyRectangle class?

  • Where is "Assign Random Colors To Parts" in Acrobat 9 Pro Extended?

    In Acrobat 8 3D there was "Assign Random Colors To Parts" in the Enhance tab of the Conversion dialog box. Where did it go in Acrobat 9 Pro Extended?

    Hello Greg!
    Thank you for your post.
    You should know that these forums are specific to the
    Acrobat.com website and its set of hosted services, and do
    not cover the Acrobat family of desktop products.
    Please visit the following Acrobat forums for any questions
    related to the Acrobat family of desktop products:
    http://www.adobeforums.com/cgi-bin/webx/.3bbeda8b/
    Thanks!!
    Pete

  • CS3 : Create hidden color

    Hello,
    Is there any way to create a color with a script that does not goes to the swatch palette? In Indesign it is possible to create directly a color and put it to a item, i would like to create a color that is hidden for the user without myDoc.colors.add().
    Thanks,
    Asci

    On 4/2/09 8:07 AM, "Kermy" <[email protected]> wrote:<br /><br />> tell application "Adobe InDesign CS3"<br />>     delete swatch "White" replacing with swatch "Paper"<br />> end tell <br /><br />This is targetted at the application -- if you want to do it in a document,<br />you need to insert "tell document 1".<br />> <br />> Also, it might be "WHITE", "White" or "white" is there as way to do that in<br />> one step? <br /><br />You'll need to do something like get the name of every swatch, then loop<br />through doing a comparison inside an "ignoring case" construct. Something<br />like this:<br /><br />tell application "Adobe InDesign CS3"<br />    tell document 1<br />        set colorNames to name of swatches whose name is not ""<br />        ignoring case<br />            repeat with i from 1 to count of colorNames<br />                if item i of colorNames = "White" then<br />                    delete swatch (item i of colorNames) replacing with<br />swatch "Paper"<br />                end if<br />            end repeat<br />        end ignoring<br />    end tell<br />end tell<br /><br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • Program to create random numbers in plsql

    How do we Write a program to create random numbers.
    Thanks

    No need to - we have DBMS_RANDOM :)

  • Creating spot color in Illustrator CS4 js

    Hi,
    I need to create spot color in Illustrator CS4 with js, with assigned name and color values. Here what I have:
    myColor = myDoc.spots.add({name:"FOIL", colorValue:[10, 0, 100, 0]});
    But it comes out as process instead of spot and the color is not assigned.
    Thank you for your help.
    Yulia

    the add function has no parameters, you have to add them after
    addSpot ('FOIL', 10, 0, 100, 0);
    function addSpot(name, c, m, y, k) {
        try {
            swatch = app.activeDocument.swatches[name]; // if swatch exists....
            addSpot (name+='1', c, m, y, k); // ...add 1 to swatch name
        catch (e) {
            var newSpot = app.activeDocument.spots.add();
            newSpot.name = name;
            var newColor = new CMYKColor();
            newColor.cyan = c;
            newColor.magenta = m;
            newColor.yellow = y;
            newColor.black = k;
            newSpot.colorType = ColorModel.SPOT;
            newSpot.color = newColor;
            var newSpotColor = new SpotColor();
            newSpotColor.spot = newSpot;

  • How can I create random teams of 2 using numbers on an iPad?

    I am trying to create random teams of two for a card tournament. Can this be done using numbers on my iPad?

    Here's a solution using Numbers '09. If the functions used are supported in Numbers for iOS, it should work there, too. If not, try reposting in the iWork For iOS community.
    Column A of Players contains the names of the players entered in the tournament, in whatever order is convenient.
    Column B, which may be hidden, contains the same formula in all cells (except the header cell):
    =RAND()
    The formula generates a random number between zero and one.
    Column A of Teams contains team identifiers. These are text values. they play no part in determining the team selections.
    Columns B and C contain similar formulas:
    B2: =LOOKUP(SMALL(Players :: $B,2*(ROW()-1)-1),Players :: $B,Players :: $A)
    C2: =LOOKUP(SMALL(Players :: $B,2*(ROW()-1)   ),Players :: $B,Players :: $A)
    These formulas select the players in order of the random numbers in column B of Players. The players corresponding to the smallest, third smallest, fifth smallest...numbers are listed in column B, those corresponding to the second smallest, fourth smallest, sixth smallest... are listed in column C.
    The checkbox in Players::A1 is used as a trigger to spur recalculation of the tables and reordering of the teams. Clicking the checkbox toggles the value of that cell between TRUE and FALSE. Any change in a value in a Numbers table causes the table to be recalculated, which reselects the teams.
    Regards,
    Barry

  • To create custom colors for exception

    Hi experts......
    I need to create custom colors for my report in order to set exceptions. Shades of red,yellow and green is just not enough for my client, they want to see blue as well when certain exception rises. Can someone please give me a hint as to how to implement that ...is it got to do st with the mime repository?
    Thnaks in advance!
    Tina

    Hi Tina,
    You can do this by formatting in the workbook. Run the query and in the workbook, on the BEx toolbar, there is a button for formatting. Select the exception cell whose color you want to change > in the Format button choos epatterns and select the color you would like. Once you have made the changes, save the workbook. The changes will remain in place the next time the user runs this workbook.
    Take a look at this link for more info:
    http://help.sap.com/saphelp_nw04/helpdata/en/f1/0a559ee09411d2acb90000e829fbfe/content.htm
    Hope this helps...

  • Need help forming randomly colored lines, that are equidistant(ex included)

    My assignment: The
    top-right cell requires horizontal lines that are equidistant in the cell. Each line is 10 pixels apart. Additionally, the lines need to be colored randomly in any possible red, green and blue range.
    example: http://i68.photobucket.com/albums/i35/stxda/example.jpg
    (example of what I need to do)
    what I have now: http://i68.photobucket.com/albums/i35/stxda/current.jpg
    I have all the lines coded for the top right cell, but I do not know how to get the colors random. I only know how to set all the lines to one single color.
    Below is my coding:
    (please try this out and help me code it)
    my AIM screen name is sTxDa if there are any questions/comments
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    public class Lab06G90 extends Applet
    public void paint(Graphics g)
    // BELOW is for the top left cell and box (which is int a and the box's frame)
    int width = 800;
    int height = 600;
    g.drawRect(10,10,width,height);
    g.drawLine(410,10,410,610);
    g.drawLine(10,310,810,310);
    for (int a = 20; a <= 400; a += 10)
    g.drawLine(a,20,a,290);
    // BELOW is for the top right cell, which is int b. so far
    // i've only done the lines, and not yet the random colors
    for (int b = 10; b <= 290; b += 10)
    g.drawLine(420,b,800,b);
    }

    but I do not know how to get the colors randomUse the Random class.

Maybe you are looking for

  • PROBLEM WITH DIGITAL EDITIONS

    Hi, I've always encountered this problem with digital editions: Adobe Digital Editions 2.0 has encountered a problem and needs to close.  We are sorry for the inconvenience. I'm using Windows XP pro 2002, service pack2  on an old computer AMD Duron 9

  • Need help in my assignment, Java programing?

    Need help in my assignment, Java programing? It is said that there is only one natural number n such that n-1 is a square and n + 1 is a cube, that is, n - 1 = x2 and n + 1 = y3 for some natural numbers x and y. Please implement a program in Java. pl

  • One calendar all of a sudden doesn't display

    One of my calendars won't show any of it's appointments. It clicks between a checkmark and a horizontal line and in neither case does it show appointments. It doesn't click to blank in the box. The same calendar on mobile me retained it data but I'm

  • Redirecting java compilation errors to a file

    Hi, How do I redirect java compilation errors to a file while using a dos environment ? Help needed asap. Gayathri

  • Wrong text height if an image in ?

    Hi, An issue with a text containing a img tag in the htmlText property <mx:GridRow width="100%"> <mx:GridItem id="bottomText" colSpan="2" width="100%"> <mx:Text id="contentText" selectable="true" width="100%"> html conetnt here... </mx:GridItem> </mx