@blockly/field-angle
v13.3.0
Published
A Blockly angle field.
Readme
@blockly/field-angle 
A Blockly angle field.
Installation
Yarn
yarn add @blockly/field-anglenpm
npm install @blockly/field-angle --saveUsage
Installation
You must register this field with Blockly. You can do this by calling
registerFieldAngle before instantiating your blocks. If another field is
registered under the same name, this field will overwrite it.
Parameters
This field accepts up to 9 parameters, in addition to the 4 accepted by the number field:
valueto specify the default value of the angle field. Defaults to 0.modeto specify the basic setup of the angle field. EitherMode.COMPASSorMode.PROTRACTOR.Mode.COMPASSspecifiesclockwiseshould betrue, and theoffsetshould be 90.Mode.PROTRACTORspecifies thatclockwise: falseshould befalseand theoffsetshould be 0. These settings can be overridden by the following options. Defaults toMode.PROTRACTOR.clockwiseto specify whether the value of the angle field should increase in the clockwise direction (if true) or in the counter-clockwise direction (if false). Defaults to false.offsetto specify where the minimum/maximum displayed value of the angle field should be. Theoffsetis in degree units that consider the circle to be 360 degrees. A 0offset(or multiple of 360) specifies the right side of the circle as the minimum/maximum value. More positive values rotate clockwise and more negative values rotate counter clockwise (regardless of theclockwisesetting). Defaults to 0.displayMinto specify the minimum displayed value of the angle field. The minimum displayed value may not actually be a selectable value. For example, you may have a full 0-360 degree circle (displayMinof 0), but only be able to select angle values from 90-270. Defaults to 0.displayMaxto specify the maximum displayed value of the angle field. The maximum displayed value may not actually be a selectable value. For example, you may have a full 0-360 degree circle (displayMaxof 360), but only be able to select angle values from 90-270. Defaults to 360.minorTickto specify the distance between small tick marks on the angle picker. TheminorTickis in units from yourdisplayMin-displayMax. The ticks start at yourdisplayMinrounded up to a multiple of yourminorTick. The ticks end at youmaxrounded down to a multiple of yourminorTick. Defaults to 15.majorTickto specify the distance between big tick marks on the angle picker. ThemajorTickis in units from yourdisplayMin-displayMax. The ticks start at yourdisplayMinrounded up to a multiple of yourmajorTick. The ticks end at youdisplayMaxrounded down to a multiple of yourmajorTick. Defaults to 45.symbolto specify the unit symbol to append to your number. Defaults to °. If this is used to specify "radians" or similar,Blockly.Msg['ARIA_LABEL_FIELD_ANGLE']should be overridden accordingly to ensure that the screenreader description remains consistent.
JavaScript
import * as Blockly from 'blockly';
import {registerFieldAngle} from '@blockly/field-angle';
registerFieldAngle();
Blockly.Blocks['test_field_angle'] = {
init: function () {
this.appendDummyInput()
.appendField('angle: ')
.appendField(new FieldAngle(90), 'FIELDNAME');
},
};JSON
import * as Blockly from 'blockly';
import {registerFieldAngle} from '@blockly/field-angle';
registerFieldAngle();
Blockly.defineBlocksWithJsonArray([
{
type: 'test_field_angle',
message0: 'angle: %1',
args0: [
{
type: 'field_angle',
name: 'FIELDNAME',
value: 50,
},
],
},
]);License
Apache 2.0
