All pages
Powered by GitBook
1 of 13

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Class «battery»

This article is automatically translated from Russian by Google Translator.

Provides access to information about the battery or power supply unit.

readVoltage

Returns the current-voltage of the battery (or power supply) in volts.

Syntax

brick.battery().readVoltage();
brick.battery().readVoltage();

Class «colorSensor»

This article is automatically translated from Russian by Google Translator.

The camera in color sensor mode.

Method

Description

Turns the camera on and initializes it in color sensor mode.

Returns an array with the coordinates of the dominant color in the RGB color scale in the specified area of the frame.

Turns off the camera and stops the sensor.

init

Turns the camera on and initializes it in color sensor mode.

Syntax

brick.colorSensor("video1").init(true);
brick.colorSensor("video1").init(True);

The boolean parameter defines whether to display the image from the camera:

  • true — output,

  • false — do not output

read

Returns an array with the coordinates of the dominant color in the RGB color scale in the specified area of the frame.

The frame is divided into squares by a grid, by default 3 by 3, the dimensionality of the grid can be set in model-config.xml on the robot. Squares are indexed from 1. That is, (1, 1) is the upper-left edge of the frame, (2, 2) is its center.

The return value is an array of three elements from 0 to 255, indexed from 0. The zero element contains the intensity of red (0 - none at all, 255 - very much), the first - the intensity of green, the second - the intensity of blue. For example, (0, 0, 0) is black, (255, 255, 255) is white, (255, 0, 0) is red.

Syntax

brick.colorSensor("video1").read(x, y);
brick.colorSensor("video1").read(x, y);

As a parameter, it is necessary to specify the indices of the square x and y.

stop

Turns off the camera and stops the sensor.

Syntax

brick.colorSensor("video1").stop();
brick.colorSensor("video1").stop();

Object «brick»

This article is automatically translated from Russian by Google Translator.

The object "brick" represents the TRIK controller and provides access to the robot devices.

Method

Description

Provides access to the accelerometer.

Provides access to battery information.

Provides access to the color sensor by the camera.

Provides access to the display of the robot.

Provides access to the encoder on the specified port.

Get a photo from the camera as an array of bytes.

Provides access to the gyroscope.

Provides access to the buttons on the body of the robot.

Play the audio file.

Provides access to the LED on the body of the robot.

Provides access to the line sensor by the camera.

Provides access to the motor on the specified port.

Provides access to the object sensor by the camera.

Pronounce the string passed as a parameter (in Russian or English).

Provides access to the sensor on the specified port.

Stops all motors and active sensors, and removes what is drawn on the display.

accelerometer

Provides access to the accelerometer (class "Accelerometer").

Syntax

brick.accelerometer();
brick.accelerometer();

battery

Provides access to battery information (class "Battery").

Syntax

brick.battery();
brick.battery();

colorSensor

Provides access to the color sensor by the camera (class "ColorSensor").

Syntax

brick.colorSensor("video1");
brick.colorSensor("video1");

display

Provides access to the display of the robot (class "Display").

Syntax

brick.display();
brick.display();

encoder

Provides access to the encoder on the specified port (class "Encoder").

Syntax

brick.encoder(portName);
brick.encoder("portName");
brick.encoder(portName);
brick.encoder("portName");

As a parameter, you must specify the port.

Example

brick.encoder(E1); // encoder call on port E1
brick.encoder("E2"); // encoder call on port E2
brick.encoder(E1); # encoder call on port E1
brick.encoder("E2"); # encoder call on port E2

getStillImage

Get a photo from the camera as an array of bytes.

Syntax

brick.getStillImage();
brick.getStillImage();

gyroscope

Provides access to the gyroscope (class "Gyroscope").

Syntax

brick.gyroscope();
brick.gyroscope();

keys

Provides access to the buttons on the robot body (class "Keys").

Syntax

brick.keys();
brick.keys();

led

Provides access to the LED on the robot body (class "Led").

Syntax

brick.led();
brick.led();

lineSensor

Provides access to the line sensor by the camera (class "LineSensor").

Syntax

brick.lineSensor();
brick.lineSensor();

motor

Provides access to the motor (power or servomotor) on the specified port (class "Motor").

Syntax

brick.motor(motorName);
brick.motor("motorName");
brick.motor(motorName);
brick.motor("motorName");

As a parameter, you must specify the port.

Example

brick.motor(M1) // motor call on port M1
brick.motor("M2") // motor call on port M2
brick.motor(M1) # motor call on port M1
brick.motor("M2") # motor call on port M2

objectSensor

Provides access to the object sensor by the camera (class "ObjectSensor").

Syntax

brick.objectSensor();
brick.objectSensor();

playSound

Play the audio file.

Syntax

brick.playSound("filename");
brick.playSound("filename");

As a parameter, you must specify the name of the file with an absolute path or the path relative to the folder trik on the controller.

Warning! The file must be pre-loaded on the controller.

Example

brick.playSound("media/sound.mp3"); // Play the sound.mp3 file in the media folder
brick.playSound("media/sound.mp3"); # Play the sound.mp3 file in the media folder

say

Say the line (in Russian or English).

Syntax

brick.say(string);
brick.say(string);

As a parameter, you must specify a string in English or Russian.

Example

brick.say("Привет, я ТРИК");
brick.say("Привет, я ТРИК");

sensor

Provides access to the sensor on the specified port (class "Sensor").

Syntax

brick.sensor(portName);
brick.sensor("portName");
brick.sensor(portName);
brick.sensor("portName");

As a parameter, you must specify the port.

Example

brick.sensor(A1) // call a sensor on port A1
brick.sensor("A2") // call a sensor on port A2
brick.sensor(A1) # call a sensor on port A1
brick.sensor("A2") # call a sensor on port A2

stop

Stops all motors and active sensors, and removes what is drawn on the display.

Syntax

brick.stop();
brick.stop();
init​
read​
stop
accelerometer
battery
colorSensor
display
encoder
getStillImage
gyroscope
keys
playSound
led
lineSensor
motor
objectSensor
say
sensor
stop

Class «encoder»

This article is automatically translated from Russian by Google Translator.

Represents power motor encoders connected to ports E1, E2, E3, E4.

Method

Description

Returns the current encoder reading in degrees on the specified port.

Resets the current encoder reading to 0.

Returns the current encoder reading in "ticks" on the specified port.

read

Returns the current encoder reading in degrees on the specified port.

Syntax

brick.encoder(portName).read();
brick.encoder("portName").read();
brick.encoder(portName).read();
brick.encoder("portName").read();

As a parameter, you must specify the port.

Example

brick.encoder(E1).read();
brick.encoder("E2").read();
brick.encoder(E1).read();
brick.encoder("E2").read();

reset

Resets the current encoder reading to 0.

Syntax

brick.encoder(portName).reset();
brick.encoder("portName").reset();
brick.encoder(portName).reset();
brick.encoder("portName").reset();

As a parameter, you must specify the port.

Example

brick.encoder(E1).reset();
brick.encoder("E2").reset();
brick.encoder(E1).reset();
brick.encoder("E2").reset();

readRawData

Returns the current encoder reading in "ticks" on the specified port.

Syntax

brick.encoder(portName).readRawData();
brick.encoder("portName").readRawData();
brick.encoder(portName).readRawData();
brick.encoder("portName").readRawData();

Example

brick.encoder(E1).readRawData();
brick.encoder("E2").readRawData();
brick.encoder(E1).readRawData();
brick.encoder("E2").readRawData();

Class «led»

This article is automatically translated from Russian by Google Translator.

Provides control of the LED on the body of the robot.

red

Turns the LED on in "red" mode.

Syntax

green

Turns the LED on in the "green" mode.

Syntax

orange

Turns the LED on in the "orange" mode.

Syntax

off

Turns off the LED.

Syntax

Class «accelerometer»

This article is automatically translated from Russian by Google Translator.

Represents the of the TRIK controller.

read

Returns the current sensor reading as an array of three elements corresponding to the sensor readings along each axis.

Syntax

newData

The signal sent by the sensor when new data is ready.

read
reset
readRawData

Method

Description

red

Turns the LED on in "red" mode.

green

Turns the LED on in the "green" mode.

orange

Turns the LED on in the "orange" mode.

off

Turns off the LED.

brick.led().orange();
brick.led().orange();
brick.led().off();
brick.led().off();
brick.led().red();
brick.led().green();
brick.led().red();	
brick.led().green();	

Method

Description

read

Returns the current sensor reading as an array of three elements corresponding to the sensor readings along each axis.

Signal

Description

newData

The signal sent by the sensor when new data is ready.

accelerometer
brick.accelerometer().read();
brick.accelerometer().read();

Class «lineSensor»

This article is automatically translated from Russian by Google Translator.

Camera in line sensor mode.

Method

Description

Detects the dominant color in the vertical bar in the center of the frame and remembers it as a line color.

Turns the camera on and initializes it inline sensor mode.

Returns an array with the X coordinate of the center of the line relative to the center of the frame, the probability of a crossover, and the relative size of the line.

Turns off the video camera and stops the sensor.

detect

Detects the dominant color in the vertical bar in the center of the frame and remembers it as a line color. Then the "read" method starts returning data for that line.

Syntax

brick.lineSensor().detect();
brick.lineSensor().detect();

init

Turns the camera on and initializes it inline sensor mode. The boolean parameter determines whether to display the image from the camera (true - display).

Syntax

brick.lineSensor().init(true);
brick.lineSensor().init(True);

The boolean parameter defines whether to display the image from the camera:

  • true — output,

  • false — don't output.

read

Returns an array with the following data in its cells:

  • the zero cell is the X coordinate of the line center relative to the center of the frame (from -100 to 100, -100 is the center of the line on the edge of the frame on the left);

  • in the first cell - the probability of crossing (the number from 0 to 100, showing how many points of the line color are in the horizontal stripe in the frame center);

  • the second cell - the relative size of the line, a number from 0 to 100 (100 - the line occupies almost the whole frame, 0 - the line is absent in the frame).

Syntax

brick.lineSensor().read();
brick.lineSensor().read();

stop

Turns off the video camera and stops the sensor.

Syntax

brick.lineSensor().stop();
brick.lineSensor().stop();

Class «keys»

This article is automatically translated from Russian by Google Translator.

Used to operate the buttons on the robot's remote control.

Method

Description

Sent when the button with the specified code is pressed or released.

Returns true if the button with the specified code is currently pressed.

Сбрасывает запомненные нажатия кнопок.

Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button.

buttonPressed

Sent when the button with the specified code is pressed or released.

Syntax

brick.keys().buttonPressed.connect(function(code, value){if (code==KeysEnum.Up)brick.stop() ; });
brick.keys().buttonPressed.connect(lambda code, value: brick.stop() if code == KeysEnum.Up else print(code));

The first parameter is the code of the button, the second - 1 if the button is pressed, 0 if released.

isPressed

Returns true if the button with the specified code is currently pressed. Possible options:

  • KeysEnum.Left (code105),

  • KeysEnum.Up (code 103),

  • KeysEnum.Down (code 108),

  • KeysEnum.Enter (code 28),

  • KeysEnum.Right (code 106),

  • KeysEnum.Power (code 116),

  • KeysEnum.Esc (code 1).

Syntax

brick.keys().isPressed(KeysEnum.Up);
brick.keys().isPressed(KeysEnum.Up);

reset

Resets memorized button presses.

Syntax

brick.keys().reset();
brick.keys().reset();

wasPressed

Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button. Possible options:

  • KeysEnum.Left (code 105),

  • KeysEnum.Up (code 103),

  • KeysEnum.Down (code 108),

  • KeysEnum.Enter (code 28),

  • KeysEnum.Right (code 106),

  • KeysEnum.Power (code 116),

  • KeysEnum.Esc (code 1).

Syntax

brick.keys().wasPressed(KeysEnum.Up);
brick.keys().wasPressed(KeysEnum.Up);

Class «sensor»

This article is automatically translated from Russian by Google Translator.

Represents a sensor (analog or digital) connected to ports A1, ..., A6, D1, D2.

Method

Description

Returns the current reading of the sensor (digital or analog) connected to this port.

Returns the current raw reading of the sensor (digital or analog) connected to this port.

read

Returns the current reading of the sensor (digital or analog) connected to this port. The present value is returned, depending on the port configuration, which is described in the file model-config.xml in the trik folder on the robot.

For example, the IR distance sensor returns a value in centimeters.

Syntax

var data1 = brick.sensor(sensorName).read();
var data2 = brick.sensor("sensorName").read();
data1 = brick.sensor(sensorName).read();
data2 = brick.sensor("sensorName").read();

readRawData

Returns the current raw reading of the sensor (digital or analog) connected to this port. The range of values depends on the specific sensor and does not take into account the configuration of the robot (the physical readings of the sensor are returned, e.g. the delay of the received ultrasonic signal).

Syntax

var data1 = brick.sensor(sensorName).readRawData();
var data2 = brick.sensor("sensorName").readRawData();
data1 = brick.sensor(sensorName).readRawData();
data2 = brick.sensor("sensorName").readRawData();

Class «objectSensor»

This article is automatically translated from Russian by Google Translator.

Camera in object sensor mode. Captures a contrasting object in the center of the frame and returns its coordinates and size in the frame.

detect

Detects the dominant color in the center of the frame and remembers it as the color of the object. After that, the "" method starts to return data for the object.

Syntax

init

Switches the camcorder on and initializes it in object sensor mode. The boolean parameter determines whether to display the image from the camera (true — display).

Syntax

The boolean parameter defines whether to display the image from the camera:

  • true — output,

  • false — don't output.

read

Returns an array that contains the following data in its cells:

  • In the zero cell, the X-axis coordinate of the object center relative to the center of the frame (-100 to 100, -100 is the center of the object on the edge of the frame on the left);

  • The Y-coordinate of the object's center relative to the frame center (from -100 to 100, -100 is the center of the object on the frame edge at the top);

  • The second cell is the relative size of the object, a number from 0 to 100 (100 - the object occupies almost the entire frame, 0 - the object is not on the frame).

Syntax

stop

Turns off the camera and stops the sensor.

Syntax

detect
init
read
stop
buttonPressed
isPressed
reset
wasPressed
read
readRawData

Method

Description

detect

Detects the dominant color in the center of the frame and remembers it as the color of the object.

init

Switches the camcorder on and initializes it in object sensor mode.

read

Returns an array with the X coordinate of the object center relative to the center of the frame, the Y coordinate of the object center relative to the center of the frame, and the relative size of the object.

stop

Turns off the camera and stops the sensor.

brick.objectSensor().read();
brick.objectSensor().read();
brick.objectSensor().stop();
brick.objectSensor().stop();
read
brick.objectSensor().detect();
brick.objectSensor().init(True);
brick.objectSensor().detect();
brick.objectSensor().init(true);

Class «motor»

This article is automatically translated from Russian by Google Translator.

Provides control of the robot motor (power or servo motor) connected to ports M1, ..., M4, S1, ..., S6.

Method

Description

Blocking of motors for braking for a specified time.

Returns the current motor power.

Turns the motor off.

Turns on the motor with the specified power.

brake

Blocking of motors for braking for a specified time in milliseconds.

Syntax

brick.motor(motorName).brake(durationMs);
brick.motor("motorName").brake(durationMs);
brick.motor(motorName).brake(durationMs);
brick.motor("motorName").brake(durationMs);

As a parameter, you must specify the time in milliseconds.

power

Returns the current motor power (-100 to 100).

Syntax

var pow1 = brick.motor(motorName).power();
var pow2 = brick.motor("motorName").power();
pow1 = brick.motor(motorName).power();
pow2 = brick.motor("motorName").power();

powerOff

Turns the motor off.

Syntax

brick.motor(motorName).powerOff();
brick.motor("motorName").powerOff();
brick.motor(motorName).powerOff();
brick.motor("motorName").powerOff();

setPower

Turns on the motor with the specified power.

Syntax

brick.motor(motorName).setPower(power);
brick.motor("motorName").setPower(power);
brick.motor(motorName).setPower(power);
brick.motor("motorName").setPower(power);

As a parameter, you must specify the power. The power is set in the range from -100 ("full reverse") to 100 ("full forward"). 0 corresponds to a force break, i.e. the motor stops, it is blocked and remains energized.

brake
power
powerOff
setPower

Class «gyroscope»

This article is automatically translated from Russian by Google Translator.

Represents the gyroscope of the TRIK controller. At rest, the average value of the gyroscope output is not zero and is called a bias or bias error.

The parameter is determined by many factors and can vary, for example, depending on the ambient temperature.

In order for the gyroscope to work properly it is necessary to subtract the zero offset from the incoming values. This can be calculated using the "calibrate" method.

Since calibration takes a long time, if you run the model frequently, you can do it once, then store the value in a variable with "getCalibrationVaules", and call "setCalibrationValues" instead of calibration when you run the program.

Method

Description

Calculates a zero offset within a specified time and initializes the gyroscope with this parameter, resets the current tilt angles.

Returns an object that contains the necessary zero-offset data.

Returns true if calibration is complete, false otherwise.

Returns an array of seven elements: angular velocities on the three axes, time of the last measurement, tilt angles on the three axes.

Returns an array of three elements with angular velocities on the three axes.

Sets the object containing the necessary parameters about the zero offset.

Сигнал

Описание

The signal sent by the sensor after the end of the calibration.

The signal sent by the sensor when it has new data ready.

calibrate

Calculates a zero offset within a specified time and initializes the gyroscope with this parameter, resets the current tilt angles. The recommended calibration time is 10-20 seconds.

Syntax

brick.gyroscope().calibrate(msec);
brick.gyroscope().calibrate(msec);

Parameter:

  • msec — time in milliseconds.

calibrationFinished

The signal sent by the sensor after the end of the calibration.

getCalibrationValues

Returns an object that contains the necessary zero-offset data.

Syntax

brick.gyroscope().getCalibrationValues();
brick.gyroscope().getCalibrationValues();

isCalibrated

Returns true if calibration is complete, false otherwise.

Syntax

brick.gyroscope().isCalibrated();
brick.gyroscope().isCalibrated();

newData

The signal sent by the sensor when it has new data ready.

read

Returns an array of seven elements:

  • 0−2 — angular velocities on the three axes (in milligrades/seconds),

  • 3 — a time of the last measurement (in microseconds),

  • 4−6 — tilt angles on the three axes (in milligrads).

Syntax

brick.gyroscope().read();
brick.gyroscope().read();

readRawData

Returns an array of three elements with angular velocities on the three axes.

Syntax

brick.gyroscope().readRawData();
brick.gyroscope().readRawData();

setCalibrationValues

Sets the object containing the necessary parameters about the zero offset.

Since calibration takes a long time, if you run the model frequently, you can do it once, then store the value in a variable with "getCalibrationVaules", and call "setCalibrationValues" instead of calibration when you run the program.

Syntax

brick.gyroscope().setCalibrationValues(values);
brick.gyroscope().setCalibrationValues(values);

Parameter:

  • values — object containing bias data.

calibrate
getCalibrationValues
isCalibrated
read
readRawData
setCalibrationValues
calibrationFinished
newData

Class «display»

This article is automatically translated from Russian by Google Translator.

Provides access to the display of the robot.

Screen size: 240*320 pixels.

Method

Description

Print the specified text on the screen, starting from the specified coordinate.

Clear the drawing window.

Draw an arc of an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height.

Draw an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height.

Draw a line with the beginning and the end at the given coordinates.

Draw a point at given coordinates.

Draw a rectangle with the upper left corner at the specified coordinates and having the specified width and height.

Close and clear the drawing window.

Redraw the window to draw. The changes to the display will only happen after this method is called.

Remove from the screen all text added to it by calls to the "addLabel" method.

Set the screen background to the color you specify.

Set the color of the brush used to draw the graphical primitives.

Set the thickness of the brush used to draw the graphical primitives, in pixels.

Display the image generated in the one-dimensional array on the controller.

Display the image previously loaded on the robot.

addLabel

Print the specified text on the screen, starting from the specified coordinate. If there was already text in the specified coordinates, it will be replaced by the new text.

The changes on the display will occur only after calling the method "redraw".

brick.display().addLabel("text", x, y);
brick.display().addLabel("text", x, y);

Parameters:

  • text — display text,

  • x, y — screen coordinates.

Example

brick.display().addLabel('Hello, world!', 1, 1);
brick.display().addLabel('Hello, world!', 1, 1);

clear

Clear the drawing window.

brick.display().clear();
brick.display().clear();

drawArc

Draw an arc of an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height. The changes on the display will occur only after calling the method "redraw".

brick.display().drawArc(x, y, l, h, from, to);
brick.display().drawArc(x, y, l, h, from, to);

Parameters:

  • x, y — the coordinates of the upper left corner of the rectangle on the screen,

  • l — rectangle width,

  • h — rectangle height,

  • from — initial angle bounding the arc,

  • to — finite angle bounding the arc.

Example

brick.display().drawArc(0, 0, 10, 10, 20, 50);
brick.display().drawArc(0, 0, 10, 10, 20, 50);

drawEllipse

Draw an ellipse inscribed into a rectangle with the upper left corner at specified coordinates and having a given width and height. The changes on the display will occur only after calling the method "redraw".

brick.display().drawEllipse(x, y, l, h);
brick.display().drawEllipse(x, y, l, h);

Parameters:

  • x, y — coordinates of the upper left corner of the rectangle,

  • l — rectangle width,

  • h — rectangle height.

Example

brick.display().drawEllipse(0, 0, 10, 10);
brick.display().drawEllipse(0, 0, 10, 10);

drawLine

Draw a line with the beginning and the end at the given coordinates. The changes on the display will occur only after calling the method "redraw".

brick.display().drawLine(x0, y0, x1, y1);
brick.display().drawLine(x0, y0, x1, y1);

Parameters:

  • x0, y0 — line origin coordinates,

  • x1, y1 — line end coordinates.

Example

brick.display().drawLine(0, 0, 10, 10);
brick.display().drawLine(0, 0, 10, 10);

drawPoint

Draw a point at given coordinates. The changes on the display will occur only after calling the method "redraw".

brick.display().drawPoint(x, y);
brick.display().drawPoint(x, y);

Parameters:

  • point coordinates x, y.

Example

brick.display().drawPoint(10, 10);
brick.display().drawPoint(10, 10);

drawRect

Draw a rectangle with the upper left corner at the specified coordinates and having the specified width and height. The changes on the display will occur only after calling the method "redraw".

brick.display().drawRect(x, y, l, h);
brick.display().drawRect(x, y, l, h);

Parameters:

  • x, y — coordinates of the upper left corner of the rectangle,

  • l — rectangle width,

  • h — rectangle height.

Example

brick.display().drawRect(0, 0, 10, 10);
brick.display().drawRect(0, 0, 10, 10);

hide

Close and clear the drawing window.

brick.display().hide();
brick.display().hide();

redraw

Redraw the window to draw. The changes to the display will only happen after this method is called.

brick.display().redraw();
brick.display().redraw();

removeLabels

Remove from the screen all text added to it by calls to the "addLabel" method.

brick.display().removeLabels();
brick.display().removeLabels();

setBackground

Set the screen background to the color you specify.

Available colors:

  • white,

  • red, darkRed,

  • green, darkGreen,

  • blue, darkBlue,

  • cyan, darkCyan,

  • magenta, darkMagenta,

  • yellow, darkYellow,

  • gray, darkGray, lightGray,

  • black.

brick.display().setBackground("color");
brick.display().setBackground("color");

As a parameter, you must specify the color.

Example

brick.display().setBackground("red");
brick.display().setBackground("red");

setPainterColor

Set the color of the brush used to draw the graphical primitives.

Available colors:

  • white,

  • red, darkRed,

  • green, darkGreen,

  • blue, darkBlue,

  • cyan, darkCyan,

  • magenta, darkMagenta,

  • yellow, darkYellow,

  • gray, darkGray, lightGray,

  • black.

brick.display().setPainterColor("color");
brick.display().setPainterColor("color");

As a parameter, you must specify the color.

Example

brick.display().setPainterColor("red");
brick.display().setPainterColor("red");

setPainterWidth

Set the thickness of the brush used to draw the graphical primitives, in pixels.

brick.display().setPainterWidth(d);
brick.display().setPainterWidth(d);

As a parameter, you must specify the thickness d.

Example

brick.display().setPainterWidth(5);
brick.display().setPainterWidth(5);

show

Display the image generated in the one-dimensional array on the controller.

brick.display().show(array, width, height, format)
brick.display().show(array, width, height, format)

Parameters:

  • array — a one-dimensional integer array with dimensions width×height

  • width и height — the width and height of the image, respectively

  • The format in which each element of the array is represented should be passed as the format parameter. The formats currently supported are: «rgb32», «grayscale8», «rgb888».

Example

Examples of using show() on an image taken withgetPhoto().

//rgb32
var photo = getPhoto();
brick.display().show(photo, 160, 120, "rgb32");
script.wait(5000);

//rgb888
pic = []
photo = getPhoto();
l = photo.length;
for (i = 0; i < l; i++) {
    var p = photo[i];
    pic.push((p&0xff0000)>>16);
    pic.push((p&0xff00)>>8);
    pic.push((p&0xff));
}
brick.display().show(pic, 160, 120, "rgb888");
script.wait(5000);                            

//grayscale8                                   
pic = []                                      
photo = getPhoto();
l = photo.length;                             
for (i = 0; i < l; i++) {                     
        var p = photo[i];                     
        pic.push(((p&0xff0000)>>18) + ((p&0xff00)>>10) + ((p&0xff)>>2));                
}                                             
                                              
brick.display().show(pic, 160, 120, "grayscale8");
script.wait(5000);
#rgb32
photo = getPhoto();
brick.display().show(photo, 160, 120, "rgb32");
script.wait(5000);

#rgb888
pic = []
photo = getPhoto();
l = len(photo);
for i in range(l):
    p = photo[i];
    pic.append((p&0xff0000)>>16);
    pic.append((p&0xff00)>>8);
    pic.append((p&0xff));

brick.display().show(pic, 160, 120, "rgb888");
script.wait(5000);                            

#grayscale8                                   
pic = []                                      
photo = getPhoto();
l = len(photo);                             
for i in range(l):                    
    p = photo[i];                     
    pic.append(((p&0xff0000)>>18) + ((p&0xff00)>>10) + ((p&0xff)>>2));                
                                         
                                              
brick.display().show(pic, 160, 120, "grayscale8");
script.wait(5000);

showImage

Display the image previously loaded on the robot.

brick.display().showImage("imagePath");
brick.display().showImage("imagePath");

The name of the image file (in BMP, GIF, JPG, JPEG, PNG, PBM, PGM, PPM, TIFF, XBM, XPM formats) must be specified as a parameter, the path is specified either as absolute or relative to the trik folder.

Example

brick.display().showImage("media/trik_smile_sad.png");
brick.display().showImage("media/trik_smile_sad.png");
addLabel
clear
drawArc
drawEllipse
drawLine
drawPoint
drawRect
hide
redraw
removeLabels
setBackground
setPainterColor
setPainterWidth
show
showImage