This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#176 2012-12-05 20:14:23

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Javascript topic

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:

Code:

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.

Code:

var hexi;//lets say I put them all into this var by order
ctx.strokeStyle=hexi; //wouldn't work

Offline

 

#177 2012-12-05 22:22:20

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Javascript topic

@TorbyForky re-read ur code it worked for me  tongue  and also for paul irish

http://paulirish.com/2009/random-hex-color-code-snippets/


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#178 2012-12-05 22:42:33

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: Javascript topic

hey...I'm "F" years old!  big_smile

btw I'm learning Javascript


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#179 2012-12-05 23:30:50

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Javascript topic

fanofcena wrote:

@TorbyForky re-read ur code it worked for me  tongue  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

 

#180 2012-12-06 09:27:40

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Javascript topic

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)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#181 2012-12-07 23:19:40

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Javascript topic

technoguyx wrote:

Why bother converting the decimal number to hex and back yourself, when JS has built-in functions to do it?

Good Point!


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#182 2012-12-08 00:34:48

bananaman99
New Scratcher
Registered: 2012-02-04
Posts: 100+

Re: Javascript topic

Are there any LEGAL free javascript compilers? I wanna learn it but not pay for it :3

Offline

 

#183 2012-12-08 00:38:29

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Javascript topic

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.


http://i46.tinypic.com/6yd4c0.png

Offline

 

#184 2012-12-08 00:44:33

bananaman99
New Scratcher
Registered: 2012-02-04
Posts: 100+

Re: Javascript topic

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

 

#185 2012-12-08 00:58:32

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Javascript topic

xD


http://i46.tinypic.com/6yd4c0.png

Offline

 

#186 2012-12-08 05:28:04

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Javascript topic

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  tongue  ,, 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)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#187 2012-12-08 10:41:34

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Javascript topic

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  tongue  ,, 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


http://i46.tinypic.com/6yd4c0.png

Offline

 

#188 2012-12-08 17:31:06

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Javascript topic

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.  tongue

Plus, why would you pay to use a programming language, really?


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#189 2012-12-10 01:48:07

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Javascript topic

Laternenpfahl wrote:

<--- removed for supporting forums -->
Also, minimizing

WHAT ??


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#190 2012-12-12 23:07:54

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: Javascript topic

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.


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#191 2012-12-14 16:35:47

transparent
Scratcher
Registered: 2011-04-19
Posts: 1000+

Re: Javascript topic

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. >_>


yes, yes i do.

Offline

 

#192 2013-02-06 21:09:03

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Javascript topic

Hey guys how would show a specific picture and move it along the mouse when it is being clicked on?

(HTML5 + Canvas)


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#193 2013-03-15 04:20:36

catachresis
New Scratcher
Registered: 2012-12-11
Posts: 70

Re: Javascript topic

Does anyone know of any lightweight, standalone JavaScript effects/tweening/animation libraries?

Offline

 

#194 2013-03-15 10:04:49

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Javascript topic

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.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#195 2013-03-15 10:40:17

catachresis
New Scratcher
Registered: 2012-12-11
Posts: 70

Re: Javascript topic

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

 

#196 2013-03-15 12:59:11

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Javascript topic

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)


http://i.imgur.com/BAEgGDL.png

Offline

 

#197 2013-03-22 10:27:41

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Javascript topic

I can Javascript too!!

Code:

                        // 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);
                                        }
                                }
                        }

Posts: 20000 - Show all posts

Offline

 

#198 2013-03-22 11:18:05

transparent
Scratcher
Registered: 2011-04-19
Posts: 1000+

Re: Javascript topic

wow jquery ur lazy omg
(im too)


yes, yes i do.

Offline

 

#199 2013-03-22 18:27:16

YMIBANWAH
Scratcher
Registered: 2012-06-26
Posts: 100+

Re: Javascript topic

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.


Ingarts read it today!

Offline

 

#200 2013-03-22 20:25:52

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Javascript topic

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.


Posts: 20000 - Show all posts

Offline

 

Board footer