get-canvas-context

WebJar for get-canvas-context

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

get-canvas-context
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

get-canvas-context
WebJar for get-canvas-context
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/Jam3/get-canvas-context

Скачать get-canvas-context

Как подключить последнюю версию

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

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

get-canvas-context

stable

Creates a new HTML5 Canvas Context with the given dimensions and options. Returns null if not supported.

Supports 'webgl', 'webgl2' and '2d', handles vendor prefixing, and runs in Node and the Browser.

Install

npm install get-canvas-context --save

Example

var getContext = require('get-canvas-context')

// create a new 50x50 2D canvas
var ctx = getContext('2d', {
  width: 50,
  height: 50
})

// add to DOM
document.body.appendChild(ctx.canvas)

// draw to it
ctx.fillRect(0, 0, 50, 50)

Or, WebGL using an existing canvas:

var canvas = document.createElement('canvas')

var gl = getContext('webgl', {
  canvas: canvas,
  antialias: true
})

if (!gl) {
  throw new Error('webgl not supported')
}

Usage

NPM

ctx = createContext(type, [opt])

Returns a new canvas context for the given type, a string which is either '2d', 'webgl' or 'webgl2'. The options:

  • canvas - an existing canvas element to re-use rather than creating a new one
  • width - if specified, will set the canvas width
  • height - if specified, will set the canvas height
  • {...contextAttributes} any other options for the rendering context, like alpha

Handles vendor prefixing for WebGL contexts. Returns null if we are not in a browser, or if the context is not available, or if there was an error creating the context.

Note: As of the time of writing (Jun 2015), "webgl2" is only supported through special flags in Chrome Canary and FireFox Nightly.

License

MIT, see LICENSE.md for details.

org.webjars.npm

Jam3

We create modern experiences for tomorrow’s brands

Версии библиотеки

Версия
1.0.2