@gush/candybar
Advanced tools
Comparing version 0.0.0-alpha2 to 0.0.0-alpha20
{ | ||
"name": "@gush/candybar", | ||
"version": "0.0.0-alpha2", | ||
"description": "", | ||
"main": "src/index.js", | ||
"version": "0.0.0-alpha20", | ||
"description": "🍫", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"start": "", | ||
"build": "rollup -c --dir dist", | ||
"build": "NODE_ENV='production' rollup -c --dir dist", | ||
"docs": "documentation build src/index.js -o docs/docs.md -f md", | ||
"prepublishOnly": "npm run build" | ||
@@ -13,3 +14,4 @@ }, | ||
"license": "ISC", | ||
"dependencies": { | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
@@ -20,7 +22,9 @@ "babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-flow": "^6.23.0", | ||
"documentation": "8.1.0", | ||
"flow-bin": "^0.78.0", | ||
"rollup": "^0.63.5", | ||
"rollup-plugin-babel": "^3.0.7", | ||
"rollup-plugin-node-resolve": "^3.3.0" | ||
}, | ||
"devDependencies": {} | ||
} | ||
} |
# Candybar 🍫 | ||
Starter for building things with `<canvas>`. Uses parcel to bundle and transpile code. | ||
A simple `<canvas>` rendering engine and collection of classes and utils. And by "engine" I mean about as advanced as a broken scooter 🛴 | ||
🚨 **This is an alpha release** | ||
_Really, don't use this thing for anything yet._ | ||
## Getting started | ||
Install it, duh. | ||
``` | ||
yarn add @gush/candybar | ||
``` | ||
Then create a canvas. | ||
```javascript | ||
import { Canvas } from '@gush/candybar'; | ||
const canvas = new Canvas({ | ||
canvas: document.getElementById('canvas'), | ||
}); | ||
``` | ||
This will create a beautiful blank canvas. 🙌🏻 | ||
## Canvas options | ||
Canvas classes can be created with a few options: | ||
- `canvas` | ||
- `container` | ||
- `hasPointer` | ||
- `entities` | ||
```javascript | ||
new Canvas({ | ||
// This is the required HTML element that the Canvas class will render to. | ||
canvas: document.getElementById('canvas'), | ||
// Container is the element that the canvas should be fit within, | ||
// if this is not provided it's assumed this is a full screen canvas | ||
container: document.getElementById('container'), | ||
// Indicates if the canvas should capture mouse/touch pointer events. | ||
hasPointer: true, | ||
// Entities are objects that will be renedered by the Canvas engine. | ||
entities: [...things], | ||
}); | ||
``` | ||
## Entities | ||
The engine will loop through each entity and call a couple methods to "render" the entity. First a `draw()` method is called where you should do any drawing using the HTML canvas API. Then an `update()` method is called which should be used to update any properties based on the engine. | ||
```javascript | ||
class MyThing { | ||
constructor() { | ||
this.x = 0; | ||
this.y = 0; | ||
} | ||
setup = ({ canvas }) => { | ||
// setup will be called once before the first draw and is provided the class context | ||
this.w = canvas.width / 10; | ||
}; | ||
draw = ({ ctx }) => { | ||
// draw with canvas API through the provided context | ||
ctx.fillRect(this.x, this.y, 100, 100); | ||
}; | ||
update = ({ pointer }) => { | ||
// update the rect position based on pointer position | ||
const { x, y } = this.pointer.position; | ||
this.x = x; | ||
this.y = y; | ||
}; | ||
resize = (context, event) => { | ||
// handle resize events. | ||
this.w = context.canvas.width / 10; | ||
}; | ||
} | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
312792
0
552
86
12
10
1
- Removedbabel-core@^6.26.3
- Removedbabel-preset-env@^1.7.0
- Removedrollup@^0.63.5
- Removedrollup-plugin-babel@^3.0.7
- Removedrollup-plugin-node-resolve@^3.3.0
- Removed@types/estree@0.0.39(transitive)
- Removed@types/node@22.13.4(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-core@6.26.3(transitive)
- Removedbabel-generator@6.26.1(transitive)
- Removedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
- Removedbabel-helper-call-delegate@6.24.1(transitive)
- Removedbabel-helper-define-map@6.26.0(transitive)
- Removedbabel-helper-explode-assignable-expression@6.24.1(transitive)
- Removedbabel-helper-function-name@6.24.1(transitive)
- Removedbabel-helper-get-function-arity@6.24.1(transitive)
- Removedbabel-helper-hoist-variables@6.24.1(transitive)
- Removedbabel-helper-optimise-call-expression@6.24.1(transitive)
- Removedbabel-helper-regex@6.26.0(transitive)
- Removedbabel-helper-remap-async-to-generator@6.24.1(transitive)
- Removedbabel-helper-replace-supers@6.24.1(transitive)
- Removedbabel-helpers@6.24.1(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-check-es2015-constants@6.22.0(transitive)
- Removedbabel-plugin-external-helpers@6.22.0(transitive)
- Removedbabel-plugin-syntax-async-functions@6.13.0(transitive)
- Removedbabel-plugin-syntax-class-properties@6.13.0(transitive)
- Removedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
- Removedbabel-plugin-syntax-object-rest-spread@6.13.0(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@6.22.0(transitive)
- Removedbabel-plugin-transform-async-to-generator@6.24.1(transitive)
- Removedbabel-plugin-transform-class-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-arrow-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoped-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoping@6.26.0(transitive)
- Removedbabel-plugin-transform-es2015-classes@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-computed-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-destructuring@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-duplicate-keys@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-for-of@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-function-name@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-modules-amd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-commonjs@6.26.2(transitive)
- Removedbabel-plugin-transform-es2015-modules-systemjs@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-umd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-object-super@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-parameters@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-shorthand-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-spread@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-sticky-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-template-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-typeof-symbol@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-unicode-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)
- Removedbabel-plugin-transform-object-rest-spread@6.26.0(transitive)
- Removedbabel-plugin-transform-regenerator@6.26.0(transitive)
- Removedbabel-plugin-transform-strict-mode@6.24.1(transitive)
- Removedbabel-preset-env@1.7.0(transitive)
- Removedbabel-register@6.26.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbrowserslist@3.2.8(transitive)
- Removedbuiltin-modules@2.0.0(transitive)
- Removedcaniuse-lite@1.0.30001699(transitive)
- Removedchalk@1.1.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconvert-source-map@1.9.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddetect-indent@4.0.0(transitive)
- Removedelectron-to-chromium@1.5.100(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedestree-walker@0.2.1(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhome-or-tmp@2.0.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-module@1.0.0(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsesc@0.5.01.3.0(transitive)
- Removedjson5@0.5.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedprivate@0.1.8(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregenerator-transform@0.10.1(transitive)
- Removedregexpu-core@2.0.0(transitive)
- Removedregjsgen@0.2.0(transitive)
- Removedregjsparser@0.1.5(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.10(transitive)
- Removedrollup@0.63.5(transitive)
- Removedrollup-plugin-babel@3.0.7(transitive)
- Removedrollup-plugin-node-resolve@3.4.0(transitive)
- Removedrollup-pluginutils@1.5.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedslash@1.0.0(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-support@0.4.18(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
- Removedtrim-right@1.0.1(transitive)
- Removedundici-types@6.20.0(transitive)