C# Equivalent of this?

I've got some actnioscript that I need to emulate in C#.
Unfortunately I
can't quite work out what type the variables are (as you
don't seem to have
to declare them in actionscript).
This is the actionscript, which is to choose an rgb colour
based on a input
'a'. Can anyone help?
getNewColor = function(a) {
var r = (45+a*90) & 0xFF;
var g = (180+a*135) & 0xFF;
var b = (230+a*71) & 0xFF;
var min = 60;
if (r<min && g<min)
r += min;
g += min;
else if (r<min && b<min)
r += min;
b += min;
else if (g<min && b<min)
g += min;
b += min;
return ((r << 16) | (g << 8) | b);

Thanks - that really helpful.
Its seems obvious now, but it had me in a spin.
JJ
"Raymond Basque"
<[email protected]> wrote in
message news:f2hf04$lsc$[email protected]..
> The actionscript type in that scripe is Number. You can
use int in C#. The
> function (method) would be something like this:
>
> public int getNewColor(int a)
> {
> int r = (45 + a * 90) & 0xff;
> int g = (180 + a * 135) & 0xff;
> int b = (230 + a * 71) & 0xff;
> int min = 60;
> if (r < min && g < min)
> {
> r += min;
> g += min;
> }
> else if (r < min && b < min)
> {
> r += min;
> b += min;
> }
> else if (g < min && b < min)
> {
> g += min;
> b += min;
> }
> return ((r<<16) | (g<< 8) | b);
> }
>
>

Similar Messages

  • What is the non-recursive stack based equivalent of this function?

    what is the non-recursive stack based equivalent of this function?
         static void _try (int n)
              int i; if (n==4) print(); else for (i=0; i<4; i++) if (is_free(i,n)) {
                   x[n] = i;
                   _try(n+1);
         }

    It goes infinite no output. Thanks though.
    public class CopyOfDamen { // x[i] = x coordinate of queen in row i.
         static int N = 4; static Stack stack = new Stack(); static int [] x = new int[8]; public static void main(String [] par) { _try(); }
         // prints field
         static void print ()
              int i,j;
              System.out.print ("+----------------+\n");
              for (i=0; i<8; i++) {
                   System.out.print ("|");
                   for (j=0; j<8; j++)
                        if (j==x) System.out.print ("<>"); else System.out.print (" ");
                   System.out.print ("|\n");
              System.out.print ("+----------------+\n\n");
         // tests, whether (ix, iy) is beaten by queens 0...(iy-1)
         static boolean is_free (int ix, int iy)
              int i;
              for (i=0; i<iy; i++)
                   if ((x[i]==ix) || (Math.abs(x[i]-ix)==Math.abs(i-iy))) return false;
              return true;
         // tries to place queen n on row n
         static void _try () {
              int i = 0, n = 0;
    call:
              for(;;) { // forever
                   if (n == N) {
                        print();
                   } else {
                        for (;i < N; i++) {
                             if (is_free(i,n)) {
                                  x[n] = i;
                                  System.out.print(x[n] + " ");
                                  n++;
                                  stack.push(i);
                                  i = 0;
                                  continue call; // call _try (but first save state and initiate new state)
                        } System.out.println();
                   // _try returns (check termination criterion and restore state)
                   n--;
                   if (n < 0) break; // terminate
                   i = stack.pop();
    } class Stack {
         int StackSize = 32, top = 0; int [] stack = new int[StackSize]; public Stack() {} void push(int x) { if (top < StackSize) stack[top++] = x; } int pop() { if (top >= 1) return stack[--top]; return -1; }

  • Equivalent for this code

    Hi, Could you please let me know what is the EQUIVALENT for this code. This code replace 2 number of  0s or 1s to Just one 0 or 1. The code is very very slow when the input string is very big. Is there any way to replace it with something faster.
    Thanks 
    Attachments:
    Untitled 1.vi ‏7 KB

    This code takes 1ms to run on a string of 60,000 characters (one continuous string of 0's and 1's).  Whereas using your code, it takes about 900ms for the same string.

  • Equivalent of this db2 syntax in oracle?

    Can somebody please tell me what is the equivalent of the following in oracle:
    SELECT X.*
    FROM XMLTABLE (xmlnamespaces (DEFAULT "http://posample.org"),
    'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo'
    COLUMNS "CUSTNAME" CHAR(30) PATH 'name',
    "PHONENUM" XML PATH 'phone')
    as X
    I took this from http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/doc/c0023903.htm.
    Thx!

    SELECT X.*
    FROM XMLTABLE
    xmlnamespaces (DEFAULT "http://posample.org"),
    '/customerinfo' passsing "CUSTOMER.INFO"
    COLUMNS
    "CUSTNAME" VARCHAR2(30) PATH 'name',
    "PHONENUM" XMLTYPE PATH 'phone'
    ) x

  • "for XML path "  Oracle equivalent of this SQL expression

    SELECT TheID,
    REPLACE(
    RTRIM(
    SELECT StudentID + ' '
    FROM StudentinSchoolLocation TL
    WHERE (LocationID = Results.LocationID)
    FOR XML PATH ('')
    ) AS StudentIDs,
    What is the equivalent of 'For XML path' used above
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common location
    Works perfectly in SQL.
    Thank you

    Hi,
    user6287828 wrote:
    The goal is to get a concatenated list of the group by columns. Like where ever the location is same , get the studentIds and make a comma seperated list of all ids for common locationThat's called "String Aggregation"
    [AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
    I recommend the first one, the user-defined function STRAGG, which you can copy from that page.
    On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
    WM_CONCAT is not documented, so you may not want to use it in your Production applications.
    STRAGG is not so convenient if the order of items in the concatenated string is important.
    In that case, use XMLAGG or SYS_CONNECT_BY_PATH, as shown later in the asktom page.
    MODEL can also do ordered string aggregation.

  • In IE, hitting the 'F4' button would cause a 'dropdown' menu of recent web sites in the address bar; what is the Firefox equivalent of this?

    Hitting 'F4' in IE would display recently visited web sites under the address bar. This made it easy to use the keyboard (rather than the mouse); once the list web sites appeared, you could use the cursor buttons to move to the site you wanted, and hit enter. I can't find a similar feature in Firefox; instead, I have to mouse up to the Awesome Bar, click the little down arrow, and choose.

    See:
    * http://kb.mozillazine.org/Location_Bar_search
    * https://support.mozilla.com/kb/Location+bar+search

  • R12 equivalent on this 11i query

    All,
    I am working on an R12 upgrade project and by looking at the documentations, there are lot of tables in AP which are co-existing and changed but not getting a clear idea of what got changed and why multiple tables exist. Is there anyone here who can provide me the R12 query for this 11i query below?
    SELECT distinct
         ac.vendor_name,
         nvl(ac.address_line1,ac. address_line2) address_line1,
         decode(ac.city,null,'',ac. city||',')||ac.state||' '||ac.zip city_state_zip,
         pv.segment1 vendor_no,
         abb.bank_name payee_bank,
         ac.currency_code cur_code,
         ac.check_date pmt_date,
         ac.check_number pmt_number,
         ac.amount pmt_amount,
         ac.check_id
    FROM      ap_checks_all ac,
         ap_bank_accounts_all aba,
         ap_bank_branches abb,
         po_vendors pv
    WHERE
    ac.PAYMENT_METHOD_LOOKUP_ CODE in ('EFT','WIRE')
    and ac.status_lookup_code in ('NEGOTIABLE','CLEARED BUT UNACCOUNTED','RECONCILED UNACCOUNTED')
    and ac.vendor_id=pv.vendor_id
    and ac.external_bank_account_id = aba.bank_account_id
    and aba.bank_branch_id = abb.bank_branch_id
    order by ac.check_date;
    Thanks for your help.

    Hi,
    In R12 Banks and Bank branches are treated as parties and stores in HZ_PARTIES table. Also the bank accounts model has been changed in R12. All internal bank accounts store in CE_BANK_ACCOUNTS table and external bank accounts store in IBY_EXT_BANK_ACCOUNTS table. Please try below query for R12.
    SELECT distinct
    ac.vendor_name,
    nvl(ac.address_line1,ac. address_line2) address_line1,
    decode(ac.city,null,'',ac. city||',')||ac.state||' '||ac.zip city_state_zip,
    aps.segment1 vendor_no,
    hzp.party_name payee_bank,
    ac.currency_code cur_code,
    ac.check_date pmt_date,
    ac.check_number pmt_number,
    ac.amount pmt_amount,
    ac.check_id
    FROM apps.ap_checks_all ac,
    apps.IBY_EXT_BANK_ACCOUNTS IBYEB,
    apps.hz_parties hzp,
    apps.ap_suppliers aps
    WHERE
    ac.PAYMENT_METHOD_CODE in ('EFT','WIRE')
    and ac.status_lookup_code in ('NEGOTIABLE','CLEARED BUT UNACCOUNTED','RECONCILED UNACCOUNTED')
    and ac.vendor_id=aps.vendor_id
    and ac.external_bank_account_id = IBYEB.ext_bank_account_id
    and IBYEB.bank_id = hzp.party_id
    order by ac.check_date desc;
    If this answers your question please mark it as answered.
    Thanks,
    Ram
    FYI: This is just for your infromational needs.

  • SQL Server Equivalent of this for Oracle.

    I was just wondering if anyone know of any links similar to this(http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/poster/OUTPUT_poster/poster.html#).
    The fifth tab has an extremely informative picture of the architecture. Anything similar to that for SQL would be really handy.
    Thanks in advance.

    In addition to other posts, you can also check the following blogs about SQL Server architecture.
    SQL SERVER – Beginning of SQL Server Architecture – Terminology – Guest Post
    http://blog.sqlauthority.com/2012/08/30/sql-server-beginning-of-sql-server-architecture-terminology-guest-post/
    SQL Server architecture: Behind the scenes
    http://1hw.in/sql-server-architecture-behind-the-scenes/
    Thanks,
    Lydia Zhang

  • DW equivalent to this GoLive action?

    I have a site with some elements using Nate Baldwin's SetImageAndLink.action.
    I'm trying to find the same behavior or extension for DW CS3/5 so that I don't have to re-install GL just to edit a few pages.
    If it doesn't exist, I'll buy a beer for someone who would make it for us!
    Much obliged!
    -jon

    Hmm... I'll have to fix the 2010 image, but the others years are available... .
    Rolling over 1997 brings up the cover images for May 1997 & December 1997 -- a basic image swap; however, it also assigns a link to the particular backissues for that year, so that you can click through to them.
    The same is true for the following years.
    This was created with one of Nate Baldwin's actions for GoLive, & as I add new links here, I'd like to be able to re-code it in DW. If that behavior is available, I may just not know what it's called, or perhaps there is an extension out there that can be installed.
    Thanks.
    -jon

  • Equivalent of this.getCodeBase () for JFrame?

    In a JApplet, I can use this.getCodeBase () to retreive the current directory. How do I do this in a JFrame?

    Current directory isn't usually of much use. In general the files (like images etc.) which you generally pick up with codebase are better accessed through Class.getResource() which works pretty much the same whether you are in an applet or a stand-alone.

  • Printer HP ENVY 7640; which problems are equivalent to this Printer model?

    17th December 2014
    From Florianstor-4
    I'm a beginner. I d'ont now yet questions. I will send message later.
    Thanks.
    Ursula

    Hello Florianstor-4,
    Welcome to the HP Forums.
    Please feel free to write me back at any time with any questions or concerns you may have.  I am always happy to help.
    Cheers,  
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • I have a Vin, iMac 20 inch early 2008 . Can anyone tell me the now equivalent of this model? We had a housefire and I need to replace it new for old. I have a serial no. but cant find out which one would be the same model to replace it now.

    I am trying to find out how to find the specs because the machine is my daughters and it is no longer useable but if I know where I can find its details from the serial no I can get it replaced new for old on the house insurance. Where can I find these details?

    I lost equipment due to lightening strike several years ago, which also had old equipment and was not available. I gave insurance images and provided original receipts (my purchases were made on Apple.com), and Apple provided electronic copies of the receipts. You may want to contact Apple and check, if they can provide a copy. Insurance may depreciate the original value. I was offered residual value which i used to buy newer replacements, and provided the receipts for replacements back to insurance.

  • Can you do the Java equivalent of this with Generics?

    hi,
    http://www.informit.com/content/index.asp?product_id=%7B4BCD9193-97E4-4004-AF84-D7346E261C69%7D
    thanks,
    asjf

    Think of specialization as "compile-time" polymorphism. It allows you to create different implementations of methods/classes for different types, selected at compile-time. For example, I use template specialization extensively in Jace to unify entire sets of type-disparate JNI functions.
    Specialization is a very powerful technique and is also used extensively in template meta-programming (which brings us back to the OP). Even were the current form of Java generics to somehow magically support some form of specialization, you still wouldn't be able to perform meta-programming as Java generics don't work with constants.
    Any surface similarities between Java generics and C++ templates expire at trivial inspection, which means that it's a fairly futile exercise to try to compare the two.
    God bless,
    -Toby Reyelts
    Check out the free, open-source, JNI toolkit - Jace, http://jace.reyelts.com/jace

  • Equivalent of this Thu Mar 10 00:00:00 EST 2005

    Thu Mar 10 00:00:00 EST 2005
    in
    format like (mm dd yyyy)

    Stop reposting every damn question.
    Read the responses in your other thread.
    http://forum.java.sun.com/thread.jspa?threadID=605368
    If you don't understand them, then post followup
    questions there.ITG, are you "afraid" to post to the original, like posting a new one somehow gives you a fresh start like you've moved to a different city or something? You're just bugging us by crossposting, as you've been told many, many times before.

  • Problem with encoding..pls have a look at this.

    i'm getting data posted to a servlet in this format.
    Content-Type: application/octet-streamContent-Transfer-Encoding: binary&#934;&#9829; &#9787; &#9787;
    &#9829; d e &#9562; &#9556; ,&#9786; -&#9786; ?&#9786; �&#9786; &#8992;&#9786; &#8993;&#9786; X&#9787; Y&#9787; &#9565;&#9787; &#9564;&#9787; * &#9786; &#9794; * S P E C C Y
    ~&#9787;&#9786; &#9829; &#9792; &#9644; &#9786; � S P E C C Y ~&#9787;&#9787; &#9786; &#9787; &#9794; � &#9660; &#9787; B S P E C C Y ~&#9787;&#9786; &#9829; &#9830; &#9835; &#8593; " &#9786;
    how can i get the string equivalent of this.?
    i tried the following codes to receive the data.
    InputStream in = request.getInputStream();
    BufferedReader br = new BufferedReader(     new InputStreamReader(in));
         String strdata=null;
            String receivedData="";
             do
                  strdata=br.readLine();
                  if(strdata!=null)
                       receivedData+=strdata;
                  System.out.println(strdata);
             while(strdata!=null);
             byte[] receivedDataBytes=receivedData.getBytes();Also i tried this
    BufferedInputStream bis=new BufferedInputStream(in);
             bis.read(data, 0, 330);still its not working...pls help!!!

    yes i'm the server.
    client is a hardware device and it posts data to the url which is a servlet.
    the client sets some custom headers and the body
    i was able to read the headers set by the client.
    but the body part comes like this.
    Content-Disposition: form-data; name="data"
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: binarythese were also there in the body part but i was able to read them as meaningful strings..
    i need to submit the status by today.
    i can't say them that i could read the data...
    i need to tell soem valuable reasons..
    pls help!!

Maybe you are looking for

  • Printing in mirror image -- not sure why

    Hi there I had a problem suddenly develop -- I don't know if it's because I hit an unknown key combination or something, but everything I send to my printer from InDesign suddenly starting printing in mirror image.  It's not an issue in printing spec

  • How 'bout if SAP mentors "vet" SAP's choices for new ABAP keywords?

    What's prompting this post is the keyword "enhancement spot". Really bothers me, unless one thinks of a "spot" as a "gathering-place", as in the English usage "night-spot" for a club or "hot-spot" for a place where a dog's skin allergies flare-up. I

  • Can I use AIR4.0 in FlashBuilder 4.6?

    I've been developing on FlashBuilder4.6 (AIRSDK3.5) now. Should be changed to 3.5 to 4.0 the AIRSDK me. However, I have failed in the way until now. (Copy AIRSDK in FLEXSDK) (Compile I get an error when you create a class of skin) The procedure, how

  • Sending .arb files to function generator

    Hi  i am  very  fresh to labview  programming.  I have  created some  waveforms  using  HP BenchLink software(and saved in .arb file  format).  Can i send  these  wave forms  to  a  function generater  through Labview  program . if  possible   how  c

  • Best Network Settings for mostly wireless, sometimes wired?

    Folks: My household --4 desktops Macs, 2 MacBooks, all running 10.4.x or 10.5.x-- lives by using DSL via a Netopia router controlling a LAN, with Cat 5 strung to six desks. No problem there, everything works. Note: for historical reasons --because, m