Skip to content

Instantly share code, notes, and snippets.

/* Center of Gravity Finder
This script will find the center of gravity (centroid) of all closed paths in the selection set. It was built for a specific purpose so does not have much error
handling. For example, if you get errors it may be the result of the selection set containing compound shapes or a self-intersecting polygon.
References for the math:
http://paulbourke.net/geometry/polygonmesh/ (Calculating the area and centroid of a polygon)
https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
Save this file with a jsx extension and place in your Illustrator/Presets/en_US/Scripts folder. You can then access it from the File > Scripts menu
function doGet() {
var app = UiApp.createApplication();
var vpanel1 = app.createVerticalPanel().setBorderWidth(1);
var vpanel2 = app.createVerticalPanel().setBorderWidth(2);
var vpanel1Label = app.createLabel("Unformatted Vertical Panel 1");
var vpanel2Label = app.createLabel("Formatted Vertical Panel 2");
var label1 = app.createLabel("Label 1");
var label2 = app.createLabel("Label 2");
function doGet() {
var app = UiApp.createApplication();
var tb = app.createTextBox().setName("tb1");
var lab1 = app.createLabel("This box wants only numbers. If you put in something other than a number, it will turn red.");
var badInput = app.createClientHandler().validateNotNumber(tb).forEventSource().setStyleAttribute("background", "red"); // turns red when a non-number is entered
var goodInput = app.createClientHandler().validateNumber(tb).forEventSource().setStyleAttribute("background", "white"); // turns white again when a number is entered
tb.addChangeHandler(badInput).addChangeHandler(goodInput);
app.add(lab1).add(tb);
return app;
}
function doGet() {
var app = UiApp.createApplication().setTitle("The Math Machine");
app.setStyleAttribute('background', 'black');
var formPanel = app.createFormPanel();
var verticalPanel = app.createVerticalPanel();
var label1 = app.createLabel("First Number: ").setStyleAttribute('color', 'white');
var textBox1 = app.createTextBox().setName('textBoxResult1');
var label2 = app.createLabel("Second Number: ").setStyleAttribute('color', 'white');
var textBox2 = app.createTextBox().setName('textBoxResult2');
var lb = app.createListBox().setName('lb1').addItem('Addition').addItem('Subtraction').addItem('Multiplication');
function doGet() {
var app = UiApp.createApplication().setTitle("The Adding Machine");
var formPanel = app.createFormPanel();
var verticalPanel = app.createVerticalPanel();
var label1 = app.createLabel("First Number: ");
var textBox1 = app.createTextBox().setName('textBoxResult1');
var label2 = app.createLabel("Second Number: ");
var textBox2 = app.createTextBox().setName('textBoxResult2');
var submitButton = app.createSubmitButton("Click to add the numbers together.");
verticalPanel.add(label1).add(textBox1).add(label2).add(textBox2).add(submitButton);
function doGet() {
var app = UiApp.createApplication();
var formPanel = app.createFormPanel();
var verticalPanel = app.createVerticalPanel();
var label1 = app.createLabel("Enter a thing here: ");
var textBox1 = app.createTextBox().setName('textBoxResult1');
var label2 = app.createLabel("Enter a feeling here: ");
var textBox2 = app.createTextBox().setName('textBoxResult2');
var submitButton = app.createSubmitButton("Click to submit");
function doGet() {
var app = UiApp.createApplication();
var button = app.createButton("Click Me!");
button.addClickHandler(app.createServerHandler("handlerFunction"));
app.add(button);
return app;
}
function handlerFunction(eventInfo) {
var app = UiApp.getActiveApplication();
function doGet() {
var app = UiApp.createApplication();
var label = app.createLabel("Hello World");
app.add(label);
return app;
}
if( age > 55) {
Serial.println("You are a Senior Citizen");
}
if( age >= 13 && age <= 19) {
Serial.println("You are a teenager");
}
if( age < 13 || age > 65 ) {
Serial.println("Your either too old or too young to be playing with an Arduino");
int i = 0;
while(i<10) {
Serial.print("I am on # ");
Serial.println(i);
i = i+1;
}