0% found this document useful (0 votes)
3 views2 pages

Randomize Icon Colors and Shapes

Uploaded by

gtn0810
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Randomize Icon Colors and Shapes

Uploaded by

gtn0810
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

// List of icons to randomly choose between

var iconsList = ["icon://fa-heart",


"icon://fa-music",
"icon://fa-smile-o",
"icon://fa-globe",
"icon://fa-tree",
"icon://fa-bolt",
"icon://fa-moon-o",
"icon://fa-star"];
//sets up buttons
onEvent("colorsButton", "click", function( ) {
rngcolor();
});
onEvent("shapesButton", "click", function( ) {
rngshapes();
});
onEvent("locationsButton", "click", function( ) {
rngloc();
});
//randomizes the color of the icons
function rngcolor() {
for (var i = 0; i < 20; i++) {
setProperty("icon"+i,
"icon-color",rgb(randomNumber(0,255),randomNumber(0,255),randomNumber(0,255)));
setProperty("homeScreen", "background-color",rgb(randomNumber(0,255)
,randomNumber(0,255),randomNumber(0,255)));

}
}
//randomizes the location and size of the icons
function rngloc() {
for (var i = 0; i < 20; i++) {
setProperty("icon"+i, "x",randomNumber(0, 300));
setProperty("icon"+i, "y",randomNumber(0, 300));
setProperty("icon"+i, "height",randomNumber(0, 300));
setProperty("icon"+i, "width",100);

}
}
//randomizes the shape of the icons
function rngshapes() {
var ranIcon = randomNumber(0,7);
for (var i = 0; i < 20; i++) {
setProperty("icon"+i, "image",iconsList[ranIcon]);
}
}

You might also like