1.0.3 • Published 7 months ago

ihm-watermark v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

English | 简体中文

✨ Features

  • Canvas-based Rendering: Utilizes HTML5 canvas to generate clear and efficient watermarks.
  • Dynamic Regeneration: Automatically restores the watermark if it's removed or changed.
  • Lightweight and Easy to Use: Minimal setup and seamless integration into any project.
  • No Dependencies: Completely independent, does not rely on external libraries.
  • Fully Customizable: Fine-tune text, size, rotation, color, opacity, and positioning to meet your needs.

✨ Configuration

ParameterDefault ValueRequiredDescription
containerdocument.bodyYesThe container element to which the watermark will be attached. Typically used to specify the area where the watermark should be displayed
width250NoWidth of the watermark (in pixels)
height150NoHeight of the watermark (in pixels)
fontSize20NoFont size of the watermark text (in pixels)
font"microsoft yahei"NoFont of the watermark text
color"#cccccc"NoColor of the watermark text, default is light gray
content"watermark"NoThe text content of the watermark
rotate-30NoRotation angle of the watermark (in degrees)
zIndex1000Noz-index of the watermark container, used to control its layer in the stacking context
opacity0.5NoOpacity of the watermark, ranging from 0 (completely transparent) to 1 (completely opaque)
xnull (default is centered)NoThe starting X coordinate for the watermark text. If null, the default is width / 2
ynull (default is centered)NoThe starting Y coordinate for the watermark text. If null, the default is height / 2

✨ Usage

① Direct Usage

  • Include the file
<script src="../dist/main.js"></script>
  • Create a DOM element
<div id="water-mark" class="water-mark"></div>
  • Initialize the watermark
const watermark = new ihmWaterMark({
  container: document.getElementById("water-mark"),
});

watermark.output();

② Using as an npm package

  • Install the dependency package
# npm
npm install ihm-watermark
# yarn
yarn add ihm-watermark
  • Import the package
import ihmWaterMark from "ihm-watermark";
  • Initialize the watermark
const watermark = new ihmWaterMark({
  container: document.getElementById("water-mark"),
});

watermark.output();

✨ Development

  1. Clone the repository
git clone https://github.com/InhamiRei/ihm-WaterMark.git
cd ihm-WaterMark/
  1. Install dependencies
yarn
  1. demo.html is an example file that can be run directly to view the effects.

  2. After modifying the code, build the package

yarn build

✨ Pictures

Pictures1

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

8 months ago