npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blockly/field-angle

v4.0.3

Published

A Blockly angle field.

Downloads

2,990

Readme

@blockly/field-angle Built on Blockly

A Blockly angle field.

Installation

Yarn

yarn add @blockly/field-angle

npm

npm install @blockly/field-angle --save

Usage

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:

  • "value" to specify the default value of the angle field. Defaults to 0.
  • "mode" to specify the basic setup of the angle field. Either Mode.COMPASS or Mode.PROTRACTOR. COMPASS specifies "clockwise" should be "true", and the "offset" should be "90". PROTRACTOR specifies that "clockwise" should be "false" and the "offset" should be 0. These settings can be overridden by the following options. Defaults to PROTRACTOR.
  • "clockwise" to 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.
  • "offset" to specify where the minimum/maximum displayed value of the angle field should be. The offset is in degree units that consider the circle to be 360 degrees. A 0 offset (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 the "clockwise" setting). Defaults to 0.
  • "displayMin" to 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 ("displayMin" of 0), but only be able to select angle values from 90-270. Defaults to 0.
  • "displayMax" to 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 ("displayMax" of 360), but only be able to select angle values from 90-270. Defaults to 360.
  • "minorTick" to specify the distance between small tick marks on the angle picker. The minorTick is in units from your displayMin-displayMax. The ticks start at your "min" rounded up to a multiple of your "minorTick". The ticks end at you "max" rounded down to a multiple of your "minorTick". Defaults to 15.
  • "majorTick" to specify the distance between big tick marks on the angle picker. The majorTick is in units from your displayMin-displayMax. The ticks start at your "min" rounded up to a multiple of your "majorTick". The ticks end at you "max" rounded down to a multiple of your "majorTick". Defaults to 45.
  • "symbol" to specify the unit symbol to append to your number. Defaults to °.

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