MCPcopy Index your code
hub / github.com/Masth0/ScratchCard

github.com/Masth0/ScratchCard @1.5.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.5.5 ↗ · + Follow
41 symbols 66 edges 11 files 8 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Scratchcard-js

Build version

ScratchCard is a js lib to simulate a scratchcard in browser with html5 and canvas.

You can see the demo page.

Install

You can install ScratchCard with npm:

npm install --save scratchcard-js

or just clone this repo:

git clone https://github.com/Masth0/ScratchCard.git

and pick in the folder ./build the file scratchard.min.js

Getting started

import {ScratchCard, SCRATCH_TYPE} from 'scratchcard-js'

const scContainer = document.getElementById('js--sc--container')

// You also can pass HTML Element or a string for querySelector
// new ScratchCard(htmlElement...

const sc = new ScratchCard('#js--sc--container', {
  scratchType: SCRATCH_TYPE.SPRAY,
  containerWidth: scContainer.offsetWidth,
  containerHeight: 300,
  imageForwardSrc: '/images/scratchcard.jpg',
  imageBackgroundSrc: '/images/result.png',
  htmlBackground: '

<strong>Hello i am HTML content !</strong>

',
  clearZoneRadius: 50,
  nPoints: 30,
  pointSize: 4,
  callback: function () {
    alert('Now the window will reload !')
    window.location.reload()
  }
})

// Init
sc.init().then(() => {
  sc.canvas.addEventListener('scratch.move', () => {
    let percent = sc.getPercent().toFixed(2)
    console.log(percent)
  })
}).catch((error) => {
  // image not loaded
  alert(error.message);
});

Events

'scratch.move'

sc.canvas.addEventListener('scratch.move', function() {
  let percent = sc.getPercent();
  console.log(percent);
});

Extension points exported contracts — how you extend this code

SC_CONFIG (Interface)
(no doc)
types/ScratchCardConfig.d.ts
SC_CONFIG (Interface)
(no doc)
src/ScratchCardConfig.ts

Core symbols most depended-on inside this repo

_setScratchPosition
called by 4
src/ScratchCard.ts
updateMousePosition
called by 3
src/Brush.ts
mousePosition
called by 3
src/ScratchCard.ts
loadImage
called by 3
src/utils.ts
throttle
called by 3
src/utils.ts
startLine
called by 2
src/Brush.ts
finish
called by 2
src/ScratchCard.ts
dispatchEvent
called by 2
src/ScratchCard.ts

Shape

Method 22
Class 8
Function 7
Enum 2
Interface 2

Languages

TypeScript100%

Modules by API surface

src/ScratchCard.ts16 symbols
src/Brush.ts10 symbols
src/utils.ts7 symbols
types/ScratchCardConfig.d.ts2 symbols
types/ScratchCard.d.ts2 symbols
types/Brush.d.ts2 symbols
src/ScratchCardConfig.ts2 symbols

For agents

$ claude mcp add ScratchCard \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page