public void WRITE() { if (writeEnable == false) return; myPort.write("h"); myPort.write(PApplet.parseInt(PitchP.value() * 100)); myPort.write(PApplet.parseInt(RollP.value() * 100)); myPort.write(PApplet.parseInt(YawP.value() * 100)); myPort.write(PApplet.parseInt(PitchD.value() * 100)); myPort.write(PApplet.parseInt(RollD.value() * 100)); myPort.write(PApplet.parseInt(YawD.value() * 100)); myPort.write(PApplet.parseInt(PitchPWR.value())); myPort.write(PApplet.parseInt(RollPWR.value())); myPort.write(PApplet.parseInt(YawPWR.value())); myPort.write(RCcontrol); myPort.write(YawRCon); myPort.write(PApplet.parseInt(RollCal.value() * 10 + 100)); // println (RollCal.value()); // println (int (RollCal.value()*10+100)); readStatus = "Write OK"; }
public void addPlant(int type, int mouseX, int mouseY) { if (mouseX <= left || mouseX >= right || mouseY <= top || mouseY >= bottom) return; println(mouseX, mouseY); int colIndex = floor((mouseX - left) / wSpacing); int rowIndex = floor((mouseY - top) / hSpacing); int x = PApplet.parseInt(left + colIndex * wSpacing); int y = PApplet.parseInt(top + rowIndex * hSpacing); if (plants[colIndex][rowIndex] == null) plants[colIndex][rowIndex] = new Plant(type, x, y); }
public void gameOver() { // trigger game over this.screen = 2; // sets screen to game over noStroke(); noLoop(); fill(255, 0, 0); rect(0, height / 8, width, height / 8 * 6); stroke(255); this.shooterlist[0] = null; // removes active ball String[] scores = loadStrings("scores.txt"); // loads high score from text file if (PApplet.parseInt(scores[0]) < this.score) { // checks if current score is greater than high score scores[0] = "" + this.score + ""; // makes string saveStrings("data/scores.txt", scores); // saves to the scores.txt in data folder } fill(255); textSize(30); textAlign(CENTER, TOP); text("Game Over", width / 2, height / 8); textSize(20); text("Your Score\n" + this.score, 60, height / 8 * 2); text("High Score\n" + scores[0], width - (60 * width / 320), height / 8 * 2); fill(255, 0, 0); button = new Button(width / 2, 50, width / 4, height / 8 * 6, "Play Again", 18); button.display(); }
// \u30c7\u30fc\u30bf\u53d6\u5f97 public void getAllData() { // xively\u304b\u3089\u306e\u30c7\u30fc\u30bf\u53d6\u5f97 String lines[] = getDataFromXively(URL, MY_KEY); // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d dotLists = new ArrayList<ArrayList<dotObj>>(); // \u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u53d6\u5f97 int max_channel = 0; int min_channel = 9999; for (int i = 0; i < lines.length; i++) { String data[] = split(lines[i], ','); int theChannel = PApplet.parseInt(data[0]); if (min_channel > theChannel) { min_channel = theChannel; } if (max_channel < theChannel) { max_channel = theChannel; } } // \u5168\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u30ea\u30b9\u30c8\u306b\u683c\u7d0d for (int channel = min_channel; channel <= max_channel; channel++) { ArrayList<dotObj> dotList = getDataList(lines, channel); dotLists.add(dotList); } }
// \u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\u3057\u3066\u53d6\u5f97 public ArrayList<dotObj> getDataList(String[] lines, int targetChannel) { ArrayList<dotObj> retList = new ArrayList<dotObj>(); // \u5168\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3057\u3066\u5fc5\u8981\u306a\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059 int index = 0; for (int i = 0; i < lines.length; i++) { // ','\u3067\u533a\u5207\u308a\u914d\u5217\u306b\u683c\u7d0d String data[] = split(lines[i], ','); // channel, date, valuse // \u306e\u9806\u3067\u30c7\u30fc\u30bf\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b int channel = PApplet.parseInt(data[0]); // \u30c1\u30e3\u30f3\u30cd\u30eb String timeStamp = data[1]; // \u65e5\u4ed8 float val = PApplet.parseFloat(data[2]); // \u5024 if (channel == targetChannel) { // println("channel: " + channel); // println("date : " + timeStamp); // println("val : " + val); // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u3001\u914d\u5217\u306b\u683c\u7d0d float m = map(val, -0.5f, 0.5f, height / 4, height); dotObj theObj = new dotObj(index * width / 70, m, 0); theObj.channel = channel; theObj.timeStamp = timeStamp; theObj.val = val; retList.add(theObj); index++; } } return retList; }
public void setup() { size(1000, 1000); background(255); // presets int rows = 12; int cols = 12; float outerRadius = width / cols; // randomly generated int pointCount; int steps; float innerRadius; float innerRadiusRatio; float outerRadiusRatio; float shadeRatio; float rotationRatio; translate(outerRadius / 2, outerRadius / 2); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { pointCount = PApplet.parseInt(random(5, 15)); steps = PApplet.parseInt(random(3, 20)); innerRadius = outerRadius * random(0.3f, 0.9f); innerRadiusRatio = innerRadius / steps; outerRadiusRatio = outerRadius / steps; float randColor = random(225, 255); shadeRatio = randColor / steps; rotationRatio = random(90, 200) / steps; pushMatrix(); translate(outerRadius * j, outerRadius * i); for (int k = 0; k < steps; k++) { float shade = shadeRatio * k; fill(shade); stroke(randColor - shade, 100); pushMatrix(); scale(0.4f); rotate(rotationRatio * k * PI / 180); star(pointCount, outerRadius - outerRadiusRatio * k, innerRadius - innerRadiusRatio * k); popMatrix(); } popMatrix(); } } }
public void mousePressed() { if (mouseButton == LEFT) { int xX = PApplet.parseInt(mouseX) / cellSize; int yY = PApplet.parseInt(mouseY) / cellSize; // fill(255); // textSize(12); // text( xX + " " + yY, mouseX, mouseY); grid[xX][yY].pressed(); } if (mouseButton == RIGHT) { starttime = millis(); if (play == true) { play = false; } else { play = true; } } }
public void draw() { // background(33,22,223); background(0); scale(.45f, .45f); smooth(4); ///////////// // rightline ///////////// int test; pushMatrix(); translate( offsety + width, offsetx - height + 250 - 30); // divide the with by the height of the original photo rotate(PI / 3); for (int i = 1; i < 6; i++) { // if (int(random(1,filecount))%i == 0) { test = PApplet.parseInt(random(1, filecount)); println(test); // println(filecount); smooth(4); image(img[PApplet.parseInt(random(1, filecount))], 250, 250); image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 250); // } } popMatrix(); ///////////// // leftline ///////////// // int test; pushMatrix(); translate(-90, offsetx + height + 550); // divide the with by the height of the original photo rotate(-PI / 3); for (int i = 1; i < 6; i++) { // if (int(random(1,filecount))%i == 0) { // println(filecount); smooth(4); image(img[PApplet.parseInt(random(1, filecount))], 250, 250); image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 250); // } } popMatrix(); ///////////// // bottomline ///////////// pushMatrix(); for (int i = 1; i < 6; i++) { smooth(4); image(img[PApplet.parseInt(random(1, filecount))], 250, 2 * height - 310 + 250); image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 2 * height - 310 + 250); } popMatrix(); pushMatrix(); smooth(4); xint = mouseX; yint = mouseY; println(xint); println(yint); // tri.beginDraw(); // tri.scale(2.2, 2.2); // tri.translate(3,6); // tri.noStroke(); scale(2.2f, 2.2f); translate(3, 6); noStroke(); stroke(0); // stroke(33,22,223); strokeWeight(30); line(88, 655, 450, 18); line(450, 18, 815, 655); line(815, 655, 88, 655); // tri.endDraw(); popMatrix(); }