bobbybee wrote:
Hex code to RGB:
Seperate it into letters:
0xFF0000=
red = FF
green = 00
blue = 00;
Convert each value from hexadecimal to decimal (google it).
Modify values.
red = 255
green=255
blue=0
Convert each value from decimal to hexadecimal.
Concatenate together in order red, green, then blue.
0xFFFF00.
??
??
Profit!
I'm not that dumb, I've tried that.
It just doesn't work for me.
I have set up an array full of the letters, kind of like this:
hex[0]="#"; //the first letter of any hex is # hex[1]="F"; hex[2]="F"; hex[3]="F"; hex[4]="F"; hex[5]="F"; hex[6]="F";
and then I just combined them all into one variable, but it never worked.
var hexi;//lets say I put them all into this var by order ctx.strokeStyle=hexi; //wouldn't work
Offline
fanofcena wrote:
@TorbyForky re-read ur code it worked for me and also for paul irish
http://paulirish.com/2009/random-hex-color-code-snippets/
No, I actually was able to do it.
I'm not entirely sure what was happening wrong with it, but I was able to make it work.
What was probably happening was that I was calling a function wrong, or converting it wrong.
But I got it to (kind of) work.
Offline
Why bother converting the decimal number to hex and back yourself, when JS has built-in functions to do it?
Last edited by technoguyx (2012-12-06 09:27:57)
Offline
technoguyx wrote:
Why bother converting the decimal number to hex and back yourself, when JS has built-in functions to do it?
Good Point!
Offline
Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3
Offline
bananaman99 wrote:
Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3
Compiler? You need none. It's a scripting language and needs not be compiled.
Offline
Laternenpfahl wrote:
bananaman99 wrote:
Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3
Compiler? You need none. It's a scripting language and needs not be compiled.
derp, this is javaSCRIPT
*facepalms*
Offline
bananaman99 wrote:
Laternenpfahl wrote:
bananaman99 wrote:
Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3
Compiler? You need none. It's a scripting language and needs not be compiled.
derp, this is javaSCRIPT
*facepalms*
Actually if you see googles implementation its slightly compiled ,, u know pseudo scripted pseudo compiled for performance :-P
wikipedia wrote:
V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS CPUs)[3][6] before executing it, instead of more traditional techniques such as executing bytecode or interpreting it. The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code's execution profile. Optimization techniques used include inlining, ellision of expensive runtime properties, and inline caching, among many others.
Besides that you barely need a web browser to test on javascript , codeacademy.com or mdn shall serve your teaching part nicely :-)
Last edited by fanofcena (2012-12-08 05:28:23)
Offline
fanofcena wrote:
bananaman99 wrote:
Laternenpfahl wrote:
Compiler? You need none. It's a scripting language and needs not be compiled.
derp, this is javaSCRIPT
*facepalms*Actually if you see googles implementation its slightly compiled ,, u know pseudo scripted pseudo compiled for performance :-P
wikipedia wrote:
V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS CPUs)[3][6] before executing it, instead of more traditional techniques such as executing bytecode or interpreting it. The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code's execution profile. Optimization techniques used include inlining, ellision of expensive runtime properties, and inline caching, among many others.
Besides that you barely need a web browser to test on javascript , codeacademy.com or mdn shall serve your teaching part nicely :-)
Also, minimizing
Offline
bananaman99 wrote:
Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3
All you need to learn, and use Javascript in a web context (as many other applications use JS as a scripting language, such as Unity3D or Chrome's extensions), is a web browser created sometime in the last 15 years.
Plus, why would you pay to use a programming language, really?
Offline
For the record, I'm on a 16 day streak in codecademy.
I made a "choose your own adventure" today if anyone wants to see it.
It's about Christmas, and kinda pointless.
my Codecademy page is here.
Offline
I remember when I first started learning about javascript (about 3-4 years ago) and so I searched it on Google. All these things came up about 25% off javascript compiler. >_>
Offline
Hey guys how would show a specific picture and move it along the mouse when it is being clicked on?
(HTML5 + Canvas)
Offline
Does anyone know of any lightweight, standalone JavaScript effects/tweening/animation libraries?
Offline
catachresis wrote:
Does anyone know of any lightweight, standalone JavaScript effects/tweening/animation libraries?
jQuery?
I use it and it has a VERY easy syntax.
Offline
mythbusteranimator wrote:
catachresis wrote:
Does anyone know of any lightweight, standalone JavaScript effects/tweening/animation libraries?
jQuery?
I use it and it has a VERY easy syntax.
Thank you. It's not exactly lightweight, though.
Offline
mythbusteranimator wrote:
Hey guys how would show a specific picture and move it along the mouse when it is being clicked on?
(HTML5 + Canvas)
You could use drawImage(imageObject, x, y).
ImageObject can be constructed like this:
new Image();
Then you must set the src:
imageObject.src = "imageURL";
Last edited by GeonoTRON2000 (2013-03-15 13:00:42)
Offline
I can Javascript too!!
// jQuery function run on page load $(document).ready(function(){ // Create an associative array of empty arrays for each type tabs_content = {"overview":[],"writing":[],"artwork":[],"audio":[],"other":[]}; // Get all of the tab_content elements, which have display:none set on the page pages = document.getElementsByClassName("tab_content"); // Sort each element into one of the arrays based on its name element and with the index of its data-page for(i=0;i<pages.length;i++){ tabs_content[pages[i].getAttribute("name")][pages[i].getAttribute("data-page")] = pages[i].innerHTML; } // If there's no anchor in the window, set the current tab to the default overview tab if(typeof window.location.hash.substring(1) == "undefined"||!window.location.hash.substring(1)){ set_tab("overview",0); } // Otherwise, set the tab to the current anchor else{ // Run function, and if it returns false, set the tab to the default (overview) if(!set_tab(window.location.hash.substring(1),0)){ set_tab("overview",0); } } }); function set_tab(new_tab,page){ // Test whether the category is valid if(!tabs_content.hasOwnProperty(new_tab)){ return false; } // Set the content of the tab container to the tab of the given type and with the given page ID document.getElementById("tabs_content_container").innerHTML=tabs_content[new_tab][page]; // If there's no current tab or the current tab is different than the new tab, show the new tab as "active" (lit up and in front if(typeof current_tab == "undefined" || current_tab != new_tab){ // If there is a current tab that is different than the new tab, deactivate it if (typeof current_tab != "undefined"){ document.getElementById(current_tab+"_tab").className=""; } // Set the current tab to be the new tab current_tab=new_tab; // Activate the new current tab document.getElementById(current_tab+"_tab").className="active"; } } // When the anchor (the text after '#' in the URL) changes, change the tab to the first page of whatever category it changes to // This is used for the links, as each is an anchor link (which is most convenient, since it doesn't require a page reload) if ("onhashchange" in window){ window.onhashchange = function () { new_tab = window.location.hash.substring(1); if(current_tab != new_tab){ set_tab(new_tab,0); } } }
Offline
wow jquery ur lazy omg
(im too)
Offline
transparent wrote:
wow jquery ur lazy omg
(im too)
That was actually already there on the code I rewrote, so I just left it.
YMIBANWAH wrote:
I use javascript on Khan Academy, but otherwise normal Java is better, unless you are messing with the json to mess with scripts in the scratch 2.0 beta.
Contrary to popular belief, Javascript and Java are unrelated (except for similar C-like syntax overall). Some big differences between them include that Javascript is weakly-typed, was intended from its creation to be used with HTML in web browsers, and because of that has many built in methods for manipulating and interacting with HTML and CSS. Plus, there isn't just one Javascript interpreter, whereas all Java applications are run on Sun's JRE.
Offline