Search Results

Search found 141 results on 6 pages for 'invert'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • How do I invert a colour?

    - by ThePower
    I know that this won't directly invert a colour, it will just 'oppose' it. I was wondering if anyone knew a simple way (a few lines of code) to invert a colour from any given colour? At the moment I have this (which isn't exactly the definition of an invert): const int RGBMAX = 255; Color InvertMeAColour(Color ColourToInvert) { return Color.FromArgb(RGBMAX - ColourToInvert.R, RGBMAX - ColourToInvert.G, RGBMAX - ColourToInvert.B); }

    Read the article

  • Invert linear linked list

    - by ArtWorkAD
    Hi, a linear linked list is a set of nodes. This is how a node is defined (to keep it easy we do not distinguish between node an list): class Node{ Object data; Node link; public Node(Object pData, Node pLink){ this.data = pData; this.link = pLink; } public String toString(){ if(this.link != null){ return this.data.toString() + this.link.toString(); }else{ return this.data.toString() ; } } public void inc(){ this.data = new Integer((Integer)this.data + 1); } public void lappend(Node list){ Node child = this.link; while(child != null){ child = child.link; } child.link = list; } public Node copy(){ if(this.link != null){ return new Node(new Integer((Integer)this.data), this.link.copy()); }else{ return new Node(new Integer((Integer)this.data), null); } } public Node invert(){ Node child = this.link; while(child != null){ child = child.link; } child.link = this;.... } } I am able to make a deep copy of the list. Now I want to invert the list so that the first node is the last and the last the first. The inverted list has to be a deep copy. I started developing the invert function but I am not sure. Any Ideas? Update: Maybe there is a recursive way since the linear linked list is a recursive data structure. I would take the first element, iterate through the list until I get to a node that has no child and append the first element, I would repeat this for the second, third....

    Read the article

  • opengl invert framebuffer pixels

    - by ToxIk
    I was wondering was the best way to invert the color pixels in the frame buffer is. I know it's possible to do with glReadPixels() and glDrawPixels() but the performance hit of those calls is pretty big. Basically, what I'm trying to do is have an inverted color cross-hair which is always visible no matter what's behind it. For instance, I'd have an arbitrary alpha mask bitmap or texture, have it render without depth test after the scene is drawn, and all the frame buffer pixels under the masked (full alpha) pixels of the texture would be inverted. I've been trying to do this with a texture, but I'm getting some strange results, also all the blending options I still find confusing.

    Read the article

  • Unity - Invert Movement Direction

    - by m41n
    I am currently developing a 2,5D Sidescroller in Unity (just starting to get to know it). Right now I added a turn-script to have my character face the appropriate direction of movement, though something with the movement itself is behaving oddly now. When I press the right arrow key, the character moves and faces towards the right. If I press the left arrow key, the character faces towards the left, but "moon-walks" to the right. I allready had enough trouble getting the turning to work, so what I am trying is to find a simple solution, if possible without too much reworking of the rest of my project. I was thinking of just inverting the movement direction for a specific input-key/facing-direction. So if anyone knows how to do something like that, I'd be thankful for the help. If it helps, the following is the current part of my "AnimationChooser" script to handle the turning: Quaternion targetf = Quaternion.Euler(0, 270, 0); // Vector3 Direction when facing frontway Quaternion targetb = Quaternion.Euler(0, 90, 0); // Vector3 Direction when facing opposite way if (Input.GetAxisRaw ("Vertical") < 0.0f) // if input is lower than 0 turn to targetf { transform.rotation = Quaternion.Lerp(transform.rotation, targetf, Time.deltaTime * smooth); } if (Input.GetAxisRaw ("Vertical") > 0.0f) // if input is higher than 0 turn to targetb { transform.rotation = Quaternion.Lerp(transform.rotation, targetb, Time.deltaTime * smooth); } The Values (270 and 90) and Axis are because I had to turn my model itself in the very first place to face towards any of the movement directions.

    Read the article

  • The purpose of using invert and transpose

    - by user699215
    In openGl ES and the World of 3D - why use the invers matrix? The thing is that I dont have any intuition to, why it is used, therefore please correct me: As fare as I understand, it is used in shaders - and can help you to figure out the opposite direction of the normals? Invers in ordinary numbers is like; The product of a number and its multiplicative inverse is 1. Observe that 3/5 * 5/3 = 1. In a matrix this will give you the Identity Matrix, which is the base coordinate system or the orion of the World space - right. But the invers is - some other coordinate system? You can use the transpose(Row-major order to Column-major order) of a square matrix to find the inverted matrix, as calculating the invers is process heavy - and the transpose is giving you the inverted matrix as a bi product? Again, I am looking for getting some intuition of this - and therefore be able to use it as intended. Thank you for any reply that will guide me in the right direction. Regards

    Read the article

  • How to invert alternate bits of a number

    - by Cupidvogel
    The problem is how to invert alternate bits of a number, starting from the LSB. Currently what I am doing is first doing a count = -1 while n: n >>= 1 count += 1 to first find the position of the leftmost set bit, then running a loop to invert every alternate bit: i = 0 while i <= count: num ^= 1<<i i += 2 Is there a quick hack solution instead of this rather boring loop solution? Of course, the solution can't make any asumption about the size of the integer.

    Read the article

  • Invert a string: Recursion vs iteration in javascript

    - by steweb
    Hi all, one month ago I've been interviewed by some google PTO members. One of the questions was: Invert a string recursively in js and explain the running time by big O notation this was my solution: function invert(s){ return (s.length > 1) ? s.charAt(s.length-1)+invert(s.substring(0,s.length-1)) : s; } Pretty simple, I think. And, about the big-o notation, I quickly answered O(n) as the running time depends linearly on the input. - Silence - and then, he asked me, what are the differences in terms of running time if you implement it by iteration? I replied that sometimes the compiler "translate" the recursion into iteration (some programming language course memories) so there are no differences about iteration and recursion in this case. Btw since I had no feedback about this particular question, and the interviewer didn't answer "ok" or "nope", I'd like to know if you maybe agree with me or if you can explain me whether there could be differences about the 2 kind of implementations. Thanks a lot and Regards!

    Read the article

  • Invert 1 bit in C#

    - by Matt Jacobsen
    I have 1 bit in a byte (always in the lowest order position) that I'd like to invert. ie given 00000001 I'd like to get 00000000 and with 00000000 I'd like 00000001. I solved it like this: bit > 0 ? 0 : 1; I'm curious to see how else it could be done.

    Read the article

  • Invert a stack, without using extra data structures?

    - by vks
    How would you invert a stack, without using extra data structures, like a second, or temporary, stack. Thus no stack1-stack2 or stack-queue-stack implementation in the answer. You just have access to push/pop feature of a standard stack. I think there is way to do it by keeping a global counter and using pointer manipulation. If I solve it myself, I will post it. If someone else figures it out, please post your solution.

    Read the article

  • Invert bitmap colors

    - by Alex Orlov
    I have the following problem. I have a charting program, and it's design is black, but the charts (that I get from the server as images) are light (it actually uses only 5 colors: red, green, white, black and gray). To fit with the design inversion does a good job, the only problem is that red and green are inverted also (green - pink, red - green). Is there a way to invert everything except those 2 colors, or a way to repaint those colors after inversion? And how costly are those operations (since I get the chart updates pretty often)? Thanks in advance :) UPDATE I tried replacing colors with setPixel method in a loop for(int x = 0 ;x < chart.getWidth();x++) { for(int y = 0;y < chart.getHeight();y++) { final int replacement = getColorReplacement(chart.getPixel(x, y)); if(replacement != 0) { chart.setPixel(x, y, replacement); } } } Unfortunetely, the method takes too long (~650ms), is there a faster way to do it, and will setPixels() method work faster?

    Read the article

  • Invert order of HTML elements

    - by meo
    I have the following configuration: <div><div id='box1'>&nbsp;</div><div id='box2'>&nbsp;</div><div id='box3'>&nbsp;</div><div id='box4'>&nbsp;</div></div> what i need to do is to invert the order of the divs <div><div id='box4'>&nbsp;</div><div id='box3'>&nbsp;</div><div id='box2'>&nbsp;</div><div id='box1'>&nbsp;</div></div> is there a fast way to do this with jQuery without cloning, removing and replacing the items?

    Read the article

  • Invert regexp in vim

    - by Chris J
    There's a few "how do I invert a regexp" questions here on stackoverflow, but I can't find one for vim (if it does exist, by goggle-fu is lacking today). In essence I want to match all non-printable characters and delete them. I could write a short script, or drop to a shell and use tr or something similar to delete, but a vim solution would be dandy :-) Vim has the atom \p to match printable characters, however trying to do this :s/[^\p]//g to match the inverse failed and just left me with every 'p' in the file. I've seen the (?!xxx) sequence in other questions, and vim seems to not recognise this sequence. I've not found seen an atom for non-printable chars. In the interim, I'm going to drop to external tools, but if anyone's got any trick up their sleeve to do this, it'd be welcome :-) Ta!

    Read the article

  • JQuery invert table selection

    - by Lars Tackmann
    I have page part like this <div id="inbox"> <h1>Headline</h1> <p>First paragraph</p> <table> <tbody> <tr> <td>table stuff</td> </tr> </tbody> </table> <p>Second paragraph</p> </div> I want to assign a handler to everything within the #inbox div that is not a part (a child) of the table. I tried to do something like $('#inbox:not(:has(table))').click(function(){ alert('hello inbox'); }); But that does not work, so how do I invert the selection of the table inside the #inbox ?

    Read the article

  • How to invert rows and columns using a T-SQL Pivot Table

    - by Jeff Stock
    I have a query that returns one row. However, I want to invert the rows and columns, meaning show the rows as columns and columns as rows. I think the best way to do this is to use a pivot table, which I am no expert in. Here is my simple query: SELECT Period1, Period2, Period3 FROM GL.Actuals WHERE Year = 2009 AND Account = '001-4000-50031' Results (with headers): Period1, Period2, Period3 612.58, 681.36, 676.42 I would like for the results to look like this: Desired Results: Period, Amount Period1, 612.58 Period2, 681.36 Period3, 676.42 This is a simple example, but what I'm really after is a bit more comlex than this. I realize I could produce theses results by using several SELECT commands instead. I'm just hoping someone can shine some light on how to accomplish this with a Pivot Table or if there is yet a better way.

    Read the article

  • WPF: Invert OpacityMask

    - by Meleak
    Consider the following piece of Xaml <Grid Background="Blue"> <Border Width="100" Height="60" BorderBrush="Black" BorderThickness="2"> <Border Background="Red"> <Border.OpacityMask> <VisualBrush> <VisualBrush.Visual> <TextBlock Text="Text" Foreground="#FF000000" Background="#00000000"/> </VisualBrush.Visual> </VisualBrush> </Border.OpacityMask> </Border> </Border> </Grid> It will look like this because of the OpacityMask whos only non-transparent part is the Foreground of the TextBlock. Now if I switch the Colors for Foreground and Background in the TextBlock like this <TextBlock Text="Text" Foreground="#00000000" Background="#FF000000"/> I get this because the even though the Foreground is transparent the Background behind it is not, resulting in a useless OpacityMask :) Is there anyway I can get this? Basically an inverted OpacityMask The reason I'm asking this is because of the answer I made in this question, using the approach from this link. Even though it works, it feels very "hacky". Am I missing some other way to do this here? Update To clarify, even though my example is about a TextBlock, it could be anything. Ellipse/Image/Path etc. The feature I'm after is "Invert OpacityMask"

    Read the article

  • Invert the 1bbp color under a rectangle.

    - by Scott Chamberlain
    I am working with GDI+, the image I am working with is a 1bbp image. What i would like to do is draw a rectangle on the image and everything under that rectangle will be inverted (white pixels will become black and black pixels become white). All of the sample code I have seen is for 8 bit RGB color scale images, and I don't think the techniques they use will work for me. Here is the code I have so far. This is the parent control, one of the Epl2.IDrawableCommand's will be the command that does the inverting. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Label != null) { using (Bitmap drawnLabel = new Bitmap((int)((float)Label.LabelHeight * _ImageScaleFactor), (int)((float)Label.LableLength *(int) _ImageScaleFactor), System.Drawing.Imaging.PixelFormat.Format1bppIndexed)) { using (Graphics drawBuffer = Graphics.FromImage(drawnLabel)) { drawBuffer.ScaleTransform(_ImageScaleFactor, _ImageScaleFactor); foreach (Epl2.IDrawableCommand cmd in Label.Collection) { cmd.Paint(drawBuffer); } drawBuffer.ResetTransform(); } drawnLabel.RotateFlip(Rotation); pbLabelDrawArea.Size = drawnLabel.Size; using (Graphics drawArea = pbLabelDrawArea.CreateGraphics()) { drawArea.Clear(Color.White); drawArea.DrawImage(drawnLabel, new Point(0, 0)); } } } } What should I put in the Paint(Graphic g) for this command?

    Read the article

  • Settings schema 'gnome.org.desktop.a11y.magnifier' does not contain a key named 'invert-lightness' Error when using GNOME

    - by user1105047
    I have just installed the gnome-shell on my ubuntu 12.04. When I login I get this error: GLib-GIO-ERROR: **: Settings schema 'gnome.org.desktop.a11y.magnifier' does not contain a key named 'invert-lightness' Does anyone know how to fix this? Because of this error the gnome-shell doesn't start at all! When I installed it I followed these instructions: http://www.filiwiese.com/installing-gnome-on-ubuntu-12-04-precise-pangolin/

    Read the article

  • Is it possable to invert the image output on a computer for a rear projection screen?

    - by Faken
    Hello everyone, Is there a way to flip/invert/mirror a video out on a computer with a on board Intel video card? I'm making a large rear projection screen and i need to invert the image to project properly. One of my projectors has a function that automatically inverts the image, but the other one may or may not (likely not) and i need two projectors to drive the system so I'm hoping to do the inversion on the computer side before projecting.

    Read the article

  • C: Recursive function for inverting an int

    - by Jorge
    I had this problem on an exam yesterday. I couldn't resolve it so you can imagine the result... Make a recursive function: int invertint( int num) that will receive an integer and return it but inverted, example: 321 would return as 123 I wrote this: int invertint( int num ) { int rest = num % 10; int div = num / 10; if( div == 0 ) { return( rest ); } return( rest * 10 + invert( div ) ) } Worked for 2 digits numbers but not for 3 digits or more. Since 321 would return 1 * 10 + 23 in the last stage. Thanks a lot! PS: Is there a way to understand these kind of recursion problems in a faster manner or it's up to imagination of one self?

    Read the article

  • Using the mpz_powm functions from the GMP/MPIR libraries with negative exponents

    - by Mihai Todor
    Please consider the following code: mpz_t x, n, out; mpz_init_set_ui(x, 2UL); mpz_init_set_ui(n, 7UL); mpz_init(out); mpz_invert(out, x, n); gmp_printf ("%Zd\n", out);//prints 4. 2 * 4 (mod 7) = 1. OK mpz_powm_ui(out, x, -1UL, n);//prints 1. 2 * 1 (mod 7) = 2. How come? gmp_printf ("%Zd\n", out); mpz_clear(x); mpz_clear(n); mpz_clear(out); I am unable to understand how the mpz_powm functions handle negative exponents, although, according to the documentation, it is supposed to support them. I would expect that raising a number to -1 modulo n is equivalent to inverting it modulo n. What am I missing here?

    Read the article

1 2 3 4 5 6  | Next Page >