{\rtf1\ansi\ansicpg936\cocoartf2512 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 CourierNewPSMT;} {\colortbl;\red255\green255\blue255;\red42\green55\blue62;\red231\green231\blue231;} {\*\expandedcolortbl;;\cssrgb\c21569\c27843\c30980;\cssrgb\c92549\c92549\c92549\c50196;} \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0 \deftab720 \pard\pardeftab720\partightenfactor0 \f0\fs27\fsmilli13600 \cf2 \cb3 \expnd0\expndtw0\kerning0 import processing.serial.*;\ \ // The primaries are red, yellow, and blue. The secondaries are green,\ // purple, and orange. The tertiaries are yellow-orange, red-orange,\ // red-purple, blue-purple, blue-green, and yellow-green.\ \ int segs = 12; \ int steps = 6; \ float rotAdjust = TWO_PI / segs / 2;\ float radius;\ float segWidth;\ float interval = TWO_PI / segs;\ \ color bc = color(0, 0, 0);\ byte [] rgbdata = new byte[64];\ \ \ Serial ardPort; // DECLARE SERIAL PORT FOR COMMUNICATION\ \ void setup() \{ // setup() runs once\ \ size(200, 200); \ background(0);\ smooth();\ ellipseMode(RADIUS);\ noStroke();\ \ // make the diameter 90% of the sketch area\ radius = min(width, height) * 0.45;\ segWidth = radius / steps;\ \ println(Serial.list()); // Gets a list of all available serial ports. Use println() to write the information to the text window.\ ardPort = new Serial(this, Serial.list()[1], 9600); //initialize the serial port and set the baud rate to 9600\ \ // swap which line is commented out to draw the other version\ // drawTintWheel()\ \ drawTintWheel();\ \}\ \ void draw() \{ // draw() loops forever, until stopped\ // rectMode(CORNER);\ bc = get(mouseX, mouseY); // get the color, when mouse stop\ //println("R G B = " + int(red(bc)) + " " + int(green(bc)) + " " + int(blue(bc)));\ rgbdata[0] = (byte(int(red(bc))));\ rgbdata[1] = (byte(int(green(bc))));\ rgbdata[2] = (byte(int(blue(bc))));\ \ // hold the last value when mouse moves away from the wheel\ if ((rgbdata[0] ^ rgbdata[1] ^ rgbdata[2]) != 0) \{\ ardPort.write(rgbdata[0]);\ ardPort.write(rgbdata[1]);\ ardPort.write(rgbdata[2]);\ \}\ \}\ \ void drawTintWheel() \{ // Set the color of each round to 12 equal \ for (int j = 0; j < steps; j++) \{\ color[] cols = \{ \ color(255, 255, ((255/(steps-1))*j)), \ color(255, ((170)+(170/steps)*j), 255/steps*j), \ color(255, ((127)+(127/steps)*j), (255/steps)*j), \ color(255, ((102)+(102/(steps-2))*j), (255/steps)*j), \ \ color(255, (255/steps)*j, ((255)/steps)*j), \ color(255, (255/steps)*j, ((127)+(127/steps)*j)), \ color(255, (255/steps)*j, 255), \ color(((127)+(127/steps)*j), (255/steps)*j, 255), \ \ color(((255)/steps)*j, (255/steps)*j, 255), \ color((255/steps)*j, 255, ((102)+(102/steps)*j)), \ color((255/(steps))*j, 255, (255/(steps))*j), \ color(((127)+(127/steps)*j), 255, (255/steps)*j)\ \};\ \ //Use the ARC () function to draw the sectors and fill in the colors\ for (int i = 0; i < segs; i++) \{\ fill(cols[i]);\ arc(width/2, height/2, radius, radius, \ interval*i+rotAdjust, interval*(i+1)+rotAdjust);\ \}\ radius -= segWidth;\ \}\ \}}