mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
docs: Add syntax highlighting
This commit is contained in:
14
README.md
14
README.md
@@ -10,17 +10,17 @@ A script for grabbing the color palette from an image. Works in browser and in N
|
|||||||
|
|
||||||
### Install and import
|
### Install and import
|
||||||
_Important: The name of the package is `colorthief`, not `color-thief`._
|
_Important: The name of the package is `colorthief`, not `color-thief`._
|
||||||
```
|
```console
|
||||||
npm i --save colorthief
|
npm i --save colorthief
|
||||||
```
|
```
|
||||||
```
|
```js
|
||||||
const ColorThief = require('colorthief');
|
const ColorThief = require('colorthief');
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get colors
|
### Get colors
|
||||||
Both `getColor` and `getPalette` return a `Promise` when used in Node.
|
Both `getColor` and `getPalette` return a `Promise` when used in Node.
|
||||||
|
|
||||||
```
|
```js
|
||||||
const img = resolve(process.cwd(), 'rainbow.png');
|
const img = resolve(process.cwd(), 'rainbow.png');
|
||||||
|
|
||||||
ColorThief.getColor(img)
|
ColorThief.getColor(img)
|
||||||
@@ -38,13 +38,13 @@ ColorThief.getPalette(img, 5)
|
|||||||
### Install
|
### Install
|
||||||
|
|
||||||
_Important: The name of the package is `colorthief`, not `color-thief`._
|
_Important: The name of the package is `colorthief`, not `color-thief`._
|
||||||
```
|
```console
|
||||||
npm i --save colorthief
|
npm i --save colorthief
|
||||||
```
|
```
|
||||||
|
|
||||||
### Import and use as a global variable
|
### Import and use as a global variable
|
||||||
|
|
||||||
```
|
```html
|
||||||
<script src="node_modules/colorthief/dist/color-thief.umd.js"></script>
|
<script src="node_modules/colorthief/dist/color-thief.umd.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
@@ -54,11 +54,11 @@ npm i --save colorthief
|
|||||||
|
|
||||||
### Import and use as an ES6 module
|
### Import and use as an ES6 module
|
||||||
_index.html_
|
_index.html_
|
||||||
```
|
```html
|
||||||
<script type="module" src="app.js"></script>
|
<script type="module" src="app.js"></script>
|
||||||
```
|
```
|
||||||
_app.js_
|
_app.js_
|
||||||
```
|
```js
|
||||||
import ColorThief from './node_modules/colorthief/dist/color-thief.mjs'
|
import ColorThief from './node_modules/colorthief/dist/color-thief.mjs'
|
||||||
|
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
|
|||||||
Reference in New Issue
Block a user