Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p5-bbox-aligned-text

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p5-bbox-aligned-text

A p5.js module for drawing text aligned with its bounding box

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Bounding Box Aligned Text

A JavaScript module for positioning p5.js text based on its bounding box. If you are looking to go just straight to the API documentation, you'll want to start here: BboxAlignedText.

(Note: if you are viewing this on GitHub or NPM, you might want to check out the HTML documentation here.)

Introduction

p5.js is a wonderful creative coding library for JavaScript. The methods that p5.js provides for text placement (i.e. text anchor points) are based on a font's ascent, descent & baseline (see "Typography Metrics"). This is exactly what you want when laying out words as legible text.

Still, there are times when you would want to position text based on its exact bounding box. For example, you might have a particle system where words are particles that you want to position based on the center of the word and/or you want to do collision detection between words. (Demo code coming soon.)

That's what this module provides - an easy way to position (and rotate) p5.js text based on its exact bounding box.

Examples

Example 1 & 2 (live demo):

Example 1 & 2

Example 3 (live version):

Example 3:

Typography Metrics


[Typography metrics]](//en.wikipedia.org/wiki/Typeface)

Installation

Standalone Script

If you just want the standalone script to drop into a project:

NPM

If you have Node.js & NPM (packaged with Node) installed, open a terminal in your project and run:

npm install p5-bbox-aligned-text

This will install the module in ./node_modules/p5-bbox-aligned-text. You can then include the code into your project like this:

<script src="./node_modules/p5-bbox-aligned-text/dist/p5-bbox-aligned-text/bbox-aligned-text.min.js"></script>

Or, if you are using browserify with your project, you can import the constructor function in your JS via:

var BboxText = require("p5-bbox-aligned-text");

Full API Documentation

Documentation is online here.

Keywords

FAQs

Package last updated on 18 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc