gl-text

WebJar for gl-text

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

gl-text
Last Version

Last Version

1.1.8
Release Date

Release Date

Type

Type

jar
Description

Description

gl-text
WebJar for gl-text
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/a-vis/gl-text

Download gl-text

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/gl-text/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>gl-text</artifactId>
    <version>1.1.8</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/gl-text/
implementation 'org.webjars.npm:gl-text:1.1.8'
// https://jarcasting.com/artifacts/org.webjars.npm/gl-text/
implementation ("org.webjars.npm:gl-text:1.1.8")
'org.webjars.npm:gl-text:jar:1.1.8'
<dependency org="org.webjars.npm" name="gl-text" rev="1.1.8">
  <artifact name="gl-text" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='gl-text', version='1.1.8')
)
libraryDependencies += "org.webjars.npm" % "gl-text" % "1.1.8"
[org.webjars.npm/gl-text "1.1.8"]

Dependencies

compile (17)

Group / Artifact Type Version
org.webjars.npm : object-assign jar [4.1.1,5)
org.webjars.npm : parse-rect jar [1.2.0,2)
org.webjars.npm : color-normalize jar [1.5.0,2)
org.webjars.npm : parse-unit jar [1.0.1,2)
org.webjars.npm : es6-weak-map jar [2.0.3,3)
org.webjars.npm : flatten-vertex-data jar [1.0.2,2)
org.webjars.npm : regl jar [1.3.11,2)
org.webjars.npm : css-font jar [1.2.0,2)
org.webjars.npm : detect-kerning jar [2.1.2,3)
org.webjars.npm : bit-twiddle jar [1.0.2,2)
org.webjars.npm : typedarray-pool jar [1.1.0,2)
org.webjars.npm : is-plain-obj jar [1.1.0,2)
org.webjars.npm : gl-util jar [3.1.2,4)
org.webjars.npm : to-px jar [1.0.1,2)
org.webjars.npm : pick-by-alias jar [1.2.0,2)
org.webjars.npm : font-atlas jar [2.1.0,3)
org.webjars.npm : font-measure jar [1.2.2,2)

Project Modules

There are no modules declared in this project.

gl-text unstable

Render bitmap text with WebGL.

Usage

npm install gl-text

const Text = require('gl-text')

let text1 = new Text()

text1.update({
	position: [50, 50],
	text: 'ABC',
	font: '16px Helvetica, sans-serif'
})
text1.render()

// create another text renderer on the same context
let text2 = new Text(text1.gl)
text2.update({
	font: {
		family: ['Helvetica', 'Arial', 'sans-serif'],
		size: '1rem'
	}
})

API

let text = new Text(gl|regl|canvas|container|options?)

Create text renderer instance for the WebGL context gl, regl instance, canvas/container element or based on options:

Option Meaning
regl Existing regl instance. By default new one is created.
gl/context Existing WebGL context. By default new one is created.
canvas Existing canvas element.
container Existing container element. By default new canvas is created within the container.

No arguments call creates new fullscreen canvas.

text.update(options)

Update state of a Text instance.

Option Description
text Text string or array of strings to display.
position Position of the text on the screen within the range, a couple [x, y] or array [[x ,y], [x, y], ...] corresponding to text.
align Horizontal alignment relative to the position. Can be one of left, right, center/middle, start, end, or a number of em units. By default left. Can be an array, corresponding to text.
baseline Vertical alignment value, by default middle. Can be a string one of top, hanging, middle, alphabetic, ideographic, bottom etc. (see font-measure) or a number of em units, denoting 0 as alphabetic baseline. Can be an array corresponding to text.
color Text color or array of colors. By default black.
font Font family, CSS font string or an object with font properties like {family, size, style}, see css-font. Can be an array.
fontSize/em Font-size, can be changed independently of font.
kerning Enable font kerning, by default true. Disable for the case of monospace fonts. See detect-kerning package.
offset Shift position by the number of ems. Useful for organizing multiple lines, indentation, sub/sup script etc. Does not get affected by position change. Can be a number for x-offset only or a couple [x, y] for single position or array [[x, y], [x, y], ...] for multiple positions.
range Data area corresponding to position in viewport. Useful for organizing zoom/pan. By default is the same as the viewport [0, 0, canvas.width, canvas.height].
scale/translate An alternative to range.
viewport Visible area within the canvas, an array [left, top, width, height] or rectangle {x, y, width, height}, see parse-rect.

text.render()

Draw text.

text.destroy()

Dispose text renderer.

Properties

  • text.gl - WebGL context.
  • text.canvas - canvas element.
  • text.regl - regl instance.

License

© 2018 Dmitry Yv. MIT License

Development supported by plot.ly.

org.webjars.npm

Versions

Version
1.1.8
1.1.6