Designing by coding Google Apps Script.

Published: 04 May 2020
on channel: atom house
35
0

Learn how to create Web App with Google Apps Script and have it interact with Google Sheets using JavaScript & HTML.

Making a geometric design by programming Google Apps Script (GAS).

code:
==================================================
function autoColor() {
const sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(1,1,39,39).setBackground("white");

//----------change those numbers to change colors
const dividerBase = 6;
var redIntNum = sheet.getRange(1,41).getValue();
var greenIntNum = sheet.getRange(5,41).getValue();
var blueIntNum = sheet.getRange(9,41).getValue();

//----------do NOT change these
const redLeft = 255 - redIntNum;
const greenLeft = 255 - greenIntNum;
const blueLeft = 255 - blueIntNum;

for (var i = 0; i[[[ANGLED BRACKET]]]=dividerBase; i++){

//declaration of units that gradates colors
var redGradUnit = Math.round(redIntNum/dividerBase)-1;
var greenGradUnit = Math.round(greenIntNum/dividerBase)-1;
var blueGradUnit = Math.round(blueIntNum/dividerBase)-1;

//declaration of rgba values
var colorValueRed = redLeft + redGradUnit * i;
var colorValueGreen = greenLeft + greenGradUnit * i;
var colorValueBlue = blueLeft + blueGradUnit * i;
var colorCode = "rgb(" + colorValueRed + "," + colorValueGreen + "," + colorValueBlue + ")" ;

//declaration of vertical range
var repeatRangeVert = sheet.getRange(i+1, 14+i, 39-(2*i), 13-(2*i));
repeatRangeVert.setBackground(colorCode);

//declaration of left range
var repeatRangeLeft = sheet.getRange(14+i, 1+i, 13-(2*i), 13);
repeatRangeLeft.setBackground(colorCode);

//declaration of right range
var repeatRangeRight = sheet.getRange(14+i, 27-i, 13-(2*i), 13);
repeatRangeRight.setBackground(colorCode);
}
}
==================================================

Time took: 5 hours
Tools used:
none

Atom house presents drawings using pens, rulers, compass and hands. Paper used in my creation is A4-sized, just ordinary one.
It usually takes days or even weeks to finish one. I really hope I could be of any help for you guys to be creative, inspired or just have fun.

Please leave your comments in the comment box.
Your support will definitely give me more boost.
Suggestion, request and questions are always welcome.

Twitter:   / atomhousetwitt  


On this page of the site you can watch the video online Designing by coding Google Apps Script. with a duration of hours minute second in good quality, which was uploaded by the user atom house 04 May 2020, share the link with friends and acquaintances, this video has already been watched 35 times on youtube and it was liked by 0 viewers. Enjoy your viewing!