本文整理汇总了Java中lejos.robotics.Color.BLACK属性的典型用法代码示例。如果您正苦于以下问题:Java Color.BLACK属性的具体用法?Java Color.BLACK怎么用?Java Color.BLACK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类lejos.robotics.Color
的用法示例。
在下文中一共展示了Color.BLACK属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertColorToString
public static String convertColorToString(int colorID) {
switch (colorID) {
case Color.BLACK:
return "Black";
case Color.BLUE:
return "Blue";
case Color.CYAN:
return "Cyan";
case Color.DARK_GRAY:
return "Dark Gray";
case Color.GRAY:
return "Gray";
case Color.GREEN:
return "Green";
case Color.LIGHT_GRAY:
return "Light Gray";
case Color.MAGENTA:
return "Magenta";
case Color.NONE:
return "No Color";
case Color.ORANGE:
return "Orange";
case Color.PINK:
return "Pink";
case Color.RED:
return "Red";
case Color.WHITE:
return "White";
case Color.YELLOW:
return "Yellow";
default:
return "No Color";
}
}
示例2: main
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S3);
SensorMode color = colorSensor.getColorIDMode();
float[] sample = new float[color.sampleSize()];
color.fetchSample(sample, 0);
int colorId = (int)sample[0];
String colorName = "";
switch(colorId){
case Color.NONE: colorName = "NONE"; break;
case Color.BLACK: colorName = "BLACK"; break;
case Color.BLUE: colorName = "BLUE"; break;
case Color.GREEN: colorName = "GREEN"; break;
case Color.YELLOW: colorName = "YELLOW"; break;
case Color.RED: colorName = "RED"; break;
case Color.WHITE: colorName = "WHITE"; break;
case Color.BROWN: colorName = "BROWN"; break;
}
lcd.drawString(colorId + " - " + colorName, 0, 0);
keys.waitForAnyPress();
// EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
// SensorMode touch = touchSensor.getTouchMode();
// float[] sample = new float[touch.sampleSize()];
//
// RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
// RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
// RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
// mA.resetTachoCount();
// mB.resetTachoCount();
// mC.resetTachoCount();
//
// mA.rotateTo(760);
// int angle = mA.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
//
// mB.setSpeed(720);// 2 RPM
// mC.setSpeed(720);
// mB.forward();
// mC.forward();
// Delay.msDelay(1000);
// mB.stop();
// mC.stop();
// mB.rotateTo(360);
// mB.rotate(-720, true);
// while (mB.isMoving())
// Thread.yield();
// angle = mB.getTachoCount();
// lcd.drawInt(angle, 0, 1);
//
// mA.rotateTo(-100, true);
// do{
// touch.fetchSample(sample, 0);
// } while (mA.isMoving() && sample[0] == 0);
// mA.stop();
//
// angle = mA.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 2);
// keys.waitForAnyPress();
}
示例3: isBlack
@ScriptApi
public boolean isBlack() {
return value == Color.BLACK;
}