• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=ZeekyHBomb;42709249].NET 4.5 still has [url=http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx]GetResponse[/url] and I can't find anything about HttpWebRequest being changed in .NET 4.5.1. What's the exact error message you get when attempting to use GetResponse?[/QUOTE] Seems to me like he's talking about his autocomplete.
I'm having a little fun with HLSL (.usf) shit, and I got this: [t]http://i.imgur.com/mxBQVJz.png[/t] now I need a reliable way of making bright red things look, but my first try went something like: [t]http://i.imgur.com/lbzVgES.jpg[/t] Currently I have this ([B]very [/B]simple) thing: [code] OutColor.rgb = (OutColor.r + OutColor.g + OutColor.b) / 3; OutColor.rgb = (OutColor.rgb * 2.5f) - 0.32f;[/code]
Assuming you meant "making bright things look red", you could do a "smooth lerp" (I forgot how it's called) on OutColor.r and a slower smooth lerp on the other two channels. White will still appear white, if you also want it to have a reddish tone, just multiply a (smallish) constant > 1 to OutColor.r. Also note that the color channels have a different percieved luminance: blue looks darker than red, which look darker than green.
[QUOTE=JohnnyOnFlame;42711954]I'm having a little fun with HLSL (.usf) shit, and I got this: [t]http://i.imgur.com/mxBQVJz.png[/t] now I need a reliable way of making bright red things look, but my first try went something like: [t]http://i.imgur.com/lbzVgES.jpg[/t] Currently I have this ([B]very [/B]simple) thing: [code] OutColor.rgb = (OutColor.r + OutColor.g + OutColor.b) / 3; OutColor.rgb = (OutColor.rgb * 2.5f) - 0.32f;[/code][/QUOTE] First of all, I see you're first making it BW by just averaging colors. It's sometimes "good enough", but there are special formulas that make it look much better: [url=http://entropymine.com/imageworsener/grayscale/]check out this one. It's not based on luminancy, like many people who point out averaging recommend.[/url] Secondly, I don't get your algorithm: you're just BWing it, thus making your colors be all the same, then you're multiplying them all and substracting something else from them all. Either I'm not getting HLSL, or this line should leave everything BW: [code]OutColor.rgb = (OutColor.rgb * 2.5f) - 0.32f;[/code]
[QUOTE=vombatus;42712382]First of all, I see you're first making it BW by just averaging colors. It's sometimes "good enough", but there are special formulas that make it look much better: [url=http://entropymine.com/imageworsener/grayscale/]check out this one. It's not based on luminancy, like many people who point out averaging recommend.[/url] Secondly, I don't get your algorithm: you're just BWing it, thus making your colors be all the same, then you're multiplying them all and substracting something else from them all. Either I'm not getting HLSL, or this line should leave everything BW: [code]OutColor.rgb = (OutColor.rgb * 2.5f) - 0.32f;[/code][/QUOTE] Not at all- that will "cast" the colour, which is { R,G,B,A } to something like { R,G,B }, so it will not affect alpha values. It just delimits the affected values. (thats what I got from when I tried with GLSL- testing also agrees with what I affirmed) And thanks for the link. [editline]31st October 2013[/editline] [QUOTE=ZeekyHBomb;42712337]Assuming you meant "making bright things look red", you could do a "smooth lerp" (I forgot how it's called) on OutColor.r and a slower smooth lerp on the other two channels. White will still appear white, if you also want it to have a reddish tone, just multiply a (smallish) constant > 1 to OutColor.r. Also note that the color channels have a different percieved luminance: blue looks darker than red, which look darker than green.[/QUOTE] I want something by the lines of sin city, where its all black & white save for blood and other red things.
Oh, then just do the grayscaling on r and b, but leave the r channel alone?
[QUOTE=ZeekyHBomb;42713952]Oh, then just do the grayscaling on r and b, but leave the r channel alone?[/QUOTE] Then it makes things yellow.
Makes sense. Try OutColor.r = max(OutColor.g, OutColor.r); after applying the grayscaling on g and b.
Post this on StackOverflow but just wondering if you guys have any ideas: So for a recent project I am required to use Python, C#, and MySQL, this is not a debatable thing, it is the requirements. I currently have a Python file that needs to be executed, and have input entered, from C#. So basically it needs to work like this >Run C# .EXE >Open form with a textbox, label, and a button >Enter "1" into the textbox and hit the button >Button opens python file, enters the number 1 into the 'console' >Python 'console' returns a value based on what was inputted >C# pulls that return and displays it in the label Current Python File: [code] import mysql.connector from mysql.connector import errorcode print "CONNECTION TO MYSQL DATABASE REQUIRED" username = raw_input("PLEASE INPUT USER: ") database = raw_input("PLEASE ENTER DATABASE NAME: ") hostname = raw_input("PLEASE ENTER HOST: ") try: cnx = mysql.connector.connect(user=username,database=database,port="4800") except mysql.connector.Error as err: print("Something went wrong: {}".format(err)) else: cur = cnx.cursor() cur.execute("select address, address_state from table1") data = cur.fetchall() print "--STARTING DATA DUMP--" for row in data : print row[0], row[1] print "--END DATA DUMP--" cnx.close() print "PLEASE HIT ENTER TO TERMINATE THE PROCESS" raw_input() [/code] The C# form isn't written yet, but it is very simple, basically I need to know how to, on the buttons click method, connect to the python file and get the return values IronPython cannot be used, by the way
Use [url=http://msdn.microsoft.com/en-us/library/System.Diagnostics.ProcessStartInfo(v=vs.110).aspx]ProcessStartInfo[/url] to redirect stdin and stdout.
[QUOTE=JazZ5109AI;42716768]Post this on StackOverflow but just wondering if you guys have any ideas: So for a recent project I am required to use Python, C#, and MySQL, this is not a debatable thing, it is the requirements. I currently have a Python file that needs to be executed, and have input entered, from C#. So basically it needs to work like this >Run C# .EXE >Open form with a textbox, label, and a button >Enter "1" into the textbox and hit the button >Button opens python file, enters the number 1 into the 'console' >Python 'console' returns a value based on what was inputted >C# pulls that return and displays it in the label Current Python File: [code] import mysql.connector from mysql.connector import errorcode print "CONNECTION TO MYSQL DATABASE REQUIRED" username = raw_input("PLEASE INPUT USER: ") database = raw_input("PLEASE ENTER DATABASE NAME: ") hostname = raw_input("PLEASE ENTER HOST: ") try: cnx = mysql.connector.connect(user=username,database=database,port="4800") except mysql.connector.Error as err: print("Something went wrong: {}".format(err)) else: cur = cnx.cursor() cur.execute("select address, address_state from table1") data = cur.fetchall() print "--STARTING DATA DUMP--" for row in data : print row[0], row[1] print "--END DATA DUMP--" cnx.close() print "PLEASE HIT ENTER TO TERMINATE THE PROCESS" raw_input() [/code] The C# form isn't written yet, but it is very simple, basically I need to know how to, on the buttons click method, connect to the python file and get the return values IronPython cannot be used, by the way[/QUOTE] [url]http://stackoverflow.com/questions/11779143/run-a-python-script-from-c-sharp[/url] The accepted answer seems to be exactly what you need. This was also the first result on google.
[QUOTE=ZeekyHBomb;42716863]Use [url=http://msdn.microsoft.com/en-us/library/System.Diagnostics.ProcessStartInfo(v=vs.110).aspx]ProcessStartInfo[/url] to redirect stdin and stdout.[/QUOTE] I knew I had to use this but going about using the correct arguments and methods have blown me away, and no resources online quite help me, could you provide a small code snippet of what would do it correctly? EDIT: This is what I currently have for the C# program: [CODE] namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { run_cmd("C:/Users/Zac/Desktop/data_connection.py", ""); } private void run_cmd(string cmd, string args) { ProcessStartInfo start = new ProcessStartInfo(); start.FileName = "C:/Python27/python.exe"; start.Arguments = string.Format("{0} {1}", cmd, args); start.UseShellExecute = false; start.RedirectStandardOutput = true; using (Process process = Process.Start(start)) { using (StreamReader reader = process.StandardOutput) { string result = reader.ReadToEnd(); Console.Write(result); } } } } }[/CODE] all it does is launch the python.exe and close it nearly instantly
I can imagine that stdin is not available, thus raw_input throws an exception or something. Set RedirectStandardInput to true and write stuff to process.StandardInput, to satisfy the raw_input. Alternatively you could make the Python script accept these via command-line parameters.
Hey guys, i need help with an assignment that i am COMPLETELY lost on. I dont even have any code to show because i am so lost that i cant even attempt it. I have to write a program that tells the user to think of a number between 1-1000, then java will guess it in 10 tries or less. Two things to note are : If the users number is higher than the guess, then the new smallest guess should be one more than the previous guess.If the users number is lower than the guess, then the new largest guess should be one less than the previous guess. I.E the first guess is always 500, and if i say its higher than the next guess will be between 501 and 1000 Can someone help me out? I am completely lost, we are not supposed to use any Math classes (i.e Math.random).
Hi, I'm trying to make a bsp viewer in xna, and I have some troubles rendering patches. I extracted the 9 controls and I tried many things but I can't get it to work. Does anyone of you know a tutorial on bi quadratic bezier surfaces? I tried googling it but I can't find anything that will help. I just don't understand how they work.
[QUOTE=PyRe;42717914]Hey guys, i need help with an assignment that i am COMPLETELY lost on. I dont even have any code to show because i am so lost that i cant even attempt it. I have to write a program that tells the user to think of a number between 1-1000, then java will guess it in 10 tries or less. Two things to note are : If the users number is higher than the guess, then the new smallest guess should be one more than the previous guess.If the users number is lower than the guess, then the new largest guess should be one less than the previous guess. I.E the first guess is always 500, and if i say its higher than the next guess will be between 501 and 1000 Can someone help me out? I am completely lost, we are not supposed to use any Math classes (i.e Math.random).[/QUOTE] [url]http://docs.oracle.com/javase/7/docs/api/java/util/Random.html[/url] I don't know your exact requirements, but Random is a class of java.util, not java.lang.math so I'd guess they're trying to let you find out about the Random class by yourself? Very strange requirement regardless, they should just tell you to use Random. If you're not allowed to use Random either, then the only other thing I can think of right now is perhaps create an ArrayList with the answer pool, use Collections.shuffle(yourArrayList) and pick the first ArrayList item as your answer. [editline]time[/editline] I'm being silly, what you're probably expected to do is half your guess pool each turn, when the answer is higher than the guess you pick the top half next turn, otherwise the bottom half. answer is 200 first guess is 500 if guess is equal to answer you've won else if guess is lower than answer, next guess is guess - (guess / 2) else if guess is higher than answer, next guess is guess + (guess / 2)
[QUOTE=ZeekyHBomb;42717709]I can imagine that stdin is not available, thus raw_input throws an exception or something. Set RedirectStandardInput to true and write stuff to process.StandardInput, to satisfy the raw_input. Alternatively you could make the Python script accept these via command-line parameters.[/QUOTE] I went with just using command line arguments, seeing as I don't have an excessive amount, and accessed them via sys.argv All is well, and it works fine now, now to do the lovely task or error exception
[QUOTE=mobrockers;42718098][url]http://docs.oracle.com/javase/7/docs/api/java/util/Random.html[/url] I don't know your exact requirements, but Random is a class of java.util, not java.lang.math so I'd guess they're trying to let you find out about the Random class by yourself? Very strange requirement regardless, they should just tell you to use Random. If you're not allowed to use Random either, then the only other thing I can think of right now is perhaps create an ArrayList with the answer pool, use Collections.shuffle(yourArrayList) and pick the first ArrayList item as your answer.[/QUOTE] We have not learned about Arrays so we probably definitely have to use that class.....Although it still dosnt help me with the code as i am still completely lost ;_;
[QUOTE=PyRe;42718220]We have not learned about Arrays so we probably definitely have to use that class.....Although it still dosnt help me with the code as i am still completely lost ;_;[/QUOTE] I edited my answer as I was being extremely silly. The answer isn't that hard.
[QUOTE=JazZ5109AI;42716936][...] all it does is launch the python.exe and close it nearly instantly[/QUOTE] You probably have a race condition, wait for the process to exit and then read the output or you'll just get an empty stream.
I'm trying to write a simple chat program in VB that will be used on a server for basic live help chat for the IT help desk, what I am trying to do here, is make the name of the help desk Employee be a different colour to the person who is just asking a question. My code so far is like this: [CODE]'Posts the message from the textbox with a date and time, then the username, followed by a colon, and then the text from the textbox. rtbChatWindow.AppendText(Format(Now, "[dd,MM | hh:mm:ss tt] ") & userName & ": " & rtbTextWindow.Text & vbCrLf)[/CODE] Where my variable "userName" is, that is declared when a user logs in, so after the helpdesk employee logs in, they are assigned a username relative to their login name, so if Bob logged in, his userName variable would become "Bob". What I want to do is make "userName" to have a Color.Blue value but I have no idea how to go about doing that, I've done some searching on google but I mostly come back with crap or completely different programming languages. [B]tl:dr version[/B] - I need to make a variable that contains a string to display that string with a blue colour in a rich textbox
You could assign the text RTF-formatted to the [url=http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.rtf(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1]Rtf[/url] property. [editline]1st November 2013[/editline] Also, [url=http://msdn.microsoft.com/en-us/library/office/aa140283(v=office.10).aspx#rtfspec_21]RTF spec about text-stuff[/url] and [url=http://msdn.microsoft.com/en-us/library/office/aa140301(v=office.10).aspx#rtfspec_12]about color-stuff[/url].
Gentlemen, I am facing a bizarre problem with C++ and SFML. I am trying to implement inputs listening to move an sf::Shape, but using the [url=http://www.sfml-dev.org/tutorials/2.1/window-inputs.php]traditional sf::Keyboard class[/url] makes my project impossible to build in Code::Blocks and I can't find why. There is no error displayed in my compiler, it just doesn't build anything after 2 minutes of wait. [code]void Player::handleInput(){ //TODO: implement input listening and move player accordingly if(Keyboard::isKeyPressed(Keyboard::Space)){ //IT BUILDS NOTHING *tableflip* _shape->move(5, 0); } }[/code] Here's the [url=http://codepad.org/KPtsWcpX]full .cc[/url] and also the [url=http://codepad.org/RTiRrmnI]header file[/url] if needed
So if you just remove these 3 lines (if(...){...}) it builds? Try to build in a terminal (not as a solution, but to hopefully get an error message) On Linux [code]g++ $(pkg-config --cflags --libs sfml) *.cpp[/code] should do it. Otherwise something like [code]g++ -I/path/to/SFML/include -L/path/to/SFML/lib/dir -lsfml *.cpp[/code]
[QUOTE=ZeekyHBomb;42724809] On Linux[/QUOTE] I forgot to mention I'm on Windows for this and I'm using MinGW to compile.
The Otherwise-part should work. MingGW ships gcc.
[QUOTE=ZeekyHBomb;42724809] [code]g++ -I/path/to/SFML/include -L/path/to/SFML/lib/dir -lsfml *.cpp[/code][/QUOTE] This command gives undefined references. [code]C:\MinGW\bin>g++.exe -IC:\SFMLMinGW-2.1\include -LC:\SFMLMinGW-2.1\lib -lsfml-graphics-d -lsfml-system-d -lsfml-window-d C:\Users\Tom\workspace\ReversalMayhem\src\*.cpp C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x73): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh' C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x8b): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE' C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x16d): undefined reference to `_imp___ZNK2sf13Transformable11getPositionEv' C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x19f): undefined reference to `_imp___ZNK2sf13Transformable11getPositionEv' C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x1d0): undefined reference to `_imp___ZNK2sf14RectangleShape7getSizeEv' C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o:Ball.cpp:(.text+0x200): undefined reference to `_imp___ZNK2sf14RectangleShape7getSizeEv' c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: C:\Users\Tom\AppData\Local\Temp\ccxOwfP1.o: bad reloc address 0x4 in section `.rdata$_ZTV4Ball[__ZTV4Ball]' collect2.exe: error: ld returned 1 exit status[/code] However, the following command (inspired from the Code::Blocks build log): [code]C:\MinGW\bin>mingw32-g++.exe -Wall -g -DSFML_STATIC -IC:\SFMLMinGW-2.1\include -c C:\Users\Tom\workspace\ReversalMayhem\src\*.cpp[/code] builds all .o files without error. [editline]2nd November 2013[/editline] [code]C:\MinGW\bin>mingw32-g++.exe -Wall -g -DSFML_STATIC -LC:\SFMLMinGW-2.1\lib -o RM.exe *.o -lsfml-graphics-d -lsfml-system-d -lsfml-window-d[/code] Builds the .exe correctly. The commands I used in the windows terminal are practically the same used by Code::Blocks, in fact I just slightly modified the commands displayed in the build log. I'm a bit alienated by the problem right now.
Try to clean and build. Perhaps this was just some timestamp issue.
[QUOTE=ZeekyHBomb;42731478]Try to clean and build. Perhaps this was just some timestamp issue.[/QUOTE] I have tried to clean and build again, it doesn't do anything. CB builds all the .o files, but no .exe is made.
[QUOTE=Sonic4Ever;42731515]I have tried to clean and build again, it doesn't do anything. CB builds all the .o files, but no .exe is made.[/QUOTE] Out of curiosity, could this be a permission issue? Try running codeblocks as admin I used to have this issue all the time, tho codeblocks errored saying the location .../sfoo.exe was inaccessible
Sorry, you need to Log In to post a reply to this thread.