| Графика |
void |
setColor(Color color)
|
Устанавливает основной цвет для области рисования.
После установки все фигуры, нарисованные методами типа
fillCircle(x, y, radius) будут иметь этот цвет.
|
void |
setBackgroundColor(Color color)
|
Устанавливает фоновый цвет для области рисования.
|
void |
drawLine(int x1,
int y1, int x2, int y2)
|
Рисует линию от точки (x1, y1) до точки (x2, y2).
|
void |
drawRectangle(int x,
int y, int width, int height)
|
Рисует незаполненный прямоугольник с левым верхним углом
в точке (x, y), с указанной шириной и высотой.
|
void |
fillRectangle(int x,
int y, int width, int height)
|
Рисует заполненный прямоугольник с левым верхним углом
в точке (x, y), с указанной шириной и высотой.
|
void |
drawCircle(int x,
int y, int radius)
|
Рисует окружность с левым верхним углом
в точке (x, y) и указанным радиусом.
|
void |
fillCircle(int x,
int y, int radius)
|
Рисует круг с левым верхним углом
в точке (x, y) и указанным радиусом.
|
void |
drawOval(int x,
int y, int width, int height)
|
Рисует незаполненный овал с левым верхним углом
в точке (x, y) и указанными шириной и высотой.
|
void |
fillOval(int x,
int y, int width, int height)
|
Рисует заполненный овал с левым верхним углом
в точке (x, y) и указанными шириной и высотой.
|
void |
drawPolygon(int[] xPoints, int[] yPoints, int numPoints)
|
Рисует незаполненный многоугольник с x-координатами,
заданными массивом xPoints, и y-координатами,
заданными массивом yPoints.
Параметр numPoints определяет количество вершин
в многоугольнике.
|
void |
fillPolygon(int[] xPoints, int[] yPoints, int numPoints)
|
Рисует заполненный многоугольник с x-координатами,
заданными массивом xPoints, и y-координатами,
заданными массивом yPoints.
Параметр numPoints определяет количество вершин
в многоугольнике.
|
void |
drawString(String str,
int x, int y)
|
Рисует указанную строку, начиная с точки (x, y).
|
void |
drawString(String str,
boolean bold, boolean italics, int size, int x,
int y)
|
Рисует указанную строку, начиная с точки (x, y).
Буквы будут иметь высоту size. Можно задавать жирный шрифт (bold)
и/или курсив (italic).
|
void |
clearDrawing()
|
Очищает область рисования.
|
void |
clearRectangle(int x,
int y, int width, int height)
|
Очищает прямоугольник с левым верхним углом
в точке (x, y), с указанной шириной и высотой. |
int |
getDrawingHeight()
|
Возвращает целое значение - высоту области рисования в пикселах.
|
int |
getDrawingWidth()
|
Возвращает целое значение - ширину области рисования в пикселах.
|
| Input/Output |
int |
readInt()
|
Returns int value typed in by user, expects any integer value (ex: -5)
|
double |
readDouble()
| Returns double value typed in by user, expects any double value (ex: 3.25) |
String |
readString()
| Returns String value typed in by user, expects any String value (ex: I like to ride my bike.) |
boolean |
readBoolean()
| Returns boolean value typed in by user, expects true or false |
Color |
readColor()
| Returns Color value typed in by user, expects any of the names of Color Vales listed in the Color Values page (ex: Light blue) |
void |
printLine(int num)
| Prints out an int to the screen on its own line |
void |
printLine(double num)
| Prints out a double to the screen on its own line |
void |
printLine(String str)
| Prints out a String to the screen on its own line |
void |
printLine(boolean bool)
| Prints out a boolean to the screen on its own line |
void |
printLine(Color color)
| Prints out a Color to the screen on its own line |
void |
print(int num)
| Prints out an int to the screen |
void |
print(double num)
| Prints out a double to the screen |
void |
print(String str)
| Prints out a String to the screen |
void |
print(boolean bool)
| Prints out a boolean to the screen |
void |
print(Color color)
| Prints out a Color to the screen |
| Math |
double |
floor(double num)
| Returns the floor of the given number (ex: floor of 17.81 = 17) |
double |
ceiling(double num)
| Returns the ceiling of the given number (ex: ceiling of 3.45 = 4) |
double |
round(double num)
| Returns the rounded number of the given number (ex: round of 3.45 = 3, round of 17.81 = 18) |
double |
absoluteValue(double num)
| Returns the absolute value of the given double (ex: if you give it -1.4, it will return 1.4) |
int |
absoluteValue(int num)
| Returns the absolute value of the given double (ex: if you give it -72, it will return 72) |
double |
squareRoot(double num)
| Returns the square root of the given number |
double |
power(double a, double b)
| Returns of value of the first argument raised to the power of the second argument
|
double |
log(double num)
| Returns the logarithm (base e) of the given number |
double |
sin(double angle)
| Returns the sine of an angle specified in radians |
double |
cos(double angle)
| Returns the cosine of an angle specified in radians |
double |
tan(double angle)
| Returns the tangent of an angle specified in radians |
double |
arcsin(double angle)
| Returns the arc sine of an angle specified in radians (in the range -pi/2 through pi/2) |
double |
arccos(double angle)
| Returns the arc cosine of an angle specified in radians (in the range 0.0 through pi) |
double |
arctan(double angle)
| Returns the arc tangent of an angle specified in radians (in the range -pi/2 through pi/2) |
double |
degreesToRadians(double degrees)
| Returns the angle measured in degrees converted to the equivalent angle measured in radians
|
double |
radiansToDegrees(double radians)
| Returns the angle measured in radians converted to the equivalent angle measured in degrees
|
double |
PI
| The value of the ratio of the circumference of a circle to its diameter |
double |
E
| The value of the base of natural logarithms |
int |
MIN_INT
| The minimum integer value (readInt() and readDouble() return this if a valid number is not entered) |
int |
MAX_INT
| The maximum integer value |
| Strings |
int |
stringLength(String str)
| Returns the length of the string |
int |
indexOf(String haystack,
String needle)
| Returns the index of where the string needle is found in the string haystack, or -1 if not found |
int |
lastIndexOf(String haystack,
String needle)
| Returns the last index of where the string needle is found in the string haystack, or -1 if not found |
String |
substring(String str,
int beginIndex, int endIndex)
| Returns the substring beginning at beginIndex and ending at endIndex - 1 (so the length of the substring is endIndex - beginIndex) |
String |
substring(String str,
int beginIndex)
| Returns the substring beginning at beginIndex and extending to the end of the string |
String |
characterAt(String str, int index)
| Returns the character in str at index (as a String) |
int |
compareStrings(String str1, String str2)
| Compares two Strings alphabetically; returns a negative int if str1 is before str2, 0 if they are equal, and a positive int if str1 is after str2 |
String |
toUpperCase(String str)
| Returns the string will all letters converted to upper case |
String |
toLowerCase(String str)
| Returns the string will all letters converted to lower case |
| Colors |
Color |
getColor(int red, int green, int blue)
| Returns the color value defined by the red, green, blue combination (each color component should be in the range 0 to 255) |
int |
getRed(Color color)
| Returns the red component of the color as an int between 0 and 255 |
int |
getGreen(Color color)
| Returns the green component of the color as an int between 0 and 255 |
int |
getBlue(Color color)
| Returns the blue component of the color as an int between 0 and 255 |
Color |
brighter(Color color)
| Returns a brighter copy of the given Color |
Color |
darker(Color color)
| Returns a darker copy of the given Color |
| Mouse Handling |
boolean |
getMouseEvent()
| Returns true if there was a mouse event (mouse button pressed, mouse button released, mouse moved, or mouse dragged) |
int |
getMouseX()
| Returns the x location of the mouse (use after getMouseEvent() returns true) |
int |
getMouseY()
| Returns the y location of the mouse (use after getMouseEvent() returns true) |
boolean |
getMouseButton(int buttonNumber)
| Returns true if the specified mouse button is down (use after getMouseEvent() returns true) |
int |
getDragStartX()()
| Returns the x location of where mouse dragging started (use after getMouseEvent() returns true) |
int |
getDragStartY()()
| Returns the y location of where mouse dragging started (use after getMouseEvent() returns true) |
int |
getDragEndX()()
| Returns the x location of where mouse dragging ended (use after getMouseEvent() returns true) |
int |
getDragEndY()()
| Returns the y location of where mouse dragging ended (use after getMouseEvent() returns true) |
| Keyboard Handling |
String |
readKey()
| Waits for the user to press a key. Returns the key they pressed as a String |
boolean |
getKeyState(String key)
| Returns true if the keyboard key is currently pressed down |
| Время |
void |
delay(double seconds)
|
Задерживает выполнение программы на указанное количество
секунд (например: 3 или 0.5)
|
boolean |
getTimerEvent(double seconds)
|
Запускает таймер на указанное количество секунд.
Задерживает выполнение программы до момента очередного срабатывания
таймера и возвращает true.
Если возникают события от мыши или клавиатуры, то возвращает false,
не дожидаясь таймера.
|
void |
startTimer()
|
Начинает отсчет времени
|
double |
stopTimer()
|
Возвращает количество секунд с момента начала отсчета времени.
Начинает отсчет заново.
|
| Разное |
int |
doubleToInt(double num)
| Returns the given double converted to an int |
double |
intToDouble(int num)
| Returns the given int converted to a double |
boolean |
equal(int firstInt,
int secondInt)
| Test to see if two int values are equal |
boolean |
equal(double firstDouble,
double secondDouble)
| Test to see if two double values are equal |
boolean |
equal(String firstString,
String secondString)
| Test to see if two String values are equal. Note: it is important that you do not use == to test if two Strings are equal |
boolean |
equal(boolean firstBoolean,
boolean secondBoolean)
| Test to see if two boolean values are equal |
boolean |
equal(Color firstColor,
Color secondColor)
| Test to see if two Color values are equal |
int |
arrayLength(int[] intArray)
| Returns the length of the given int array |
int |
arrayLength(double[] doubleArray)
| Returns the length of the given double array |
int |
arrayLength(String[] stringArray)
| Returns the length of the given String array |
int |
arrayLength(boolean[] booleanArray)
| Returns the length of the given boolean array |
int |
arrayLength(Color[] colorArray)
| Returns the length of the given Color array |
| Random Values |
int |
randomInt(int max)
| Returns a random int value between 0 and max |
double |
randomDouble()
| Returns a random double value between 0 and 1 (ex: 0.614566671372701) |
boolean |
randomBoolean()
| Returns a random boolean (ex: true or false) |
Color |
randomColor()
| Returns a random Color value (ex: darkSeaGreen) |