npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ray-js/lamp-bead-strip

v1.0.1

Published

动画灯珠条带

Downloads

147

Readme

English | 简体中文

@ray-js/lamp-bead-strip

latest download

Animated LED strip

Directly using canvas to draw animation effects, and internally preventing duplicate rendering, achieving simultaneous rendering of multiple animations on low-end machine pages without stuttering.

Installation

$ npm install @ray-js/lamp-bead-strip
# or
$ yarn add @ray-js/lamp-bead-strip

Develop

# watch compile component code
yarn watch
# watch compile demo
yarn start:tuya

Usage

Basic usage

colorsand canvasIdare mandatory, otherwise the animation cannot runcanvasIdmust ensure page uniqueness. When we input different animation modesmode, the component will automatically play the animation.

import LampBeadStrip from '@ray-js/lamp-bead-strip';
export default () => (
  <LampBeadStrip
    canvasId="diy-scene"
    speed={80}
    mode={10}
    colors={['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)']}
    contentValue={{ segmented: 1 }}
  />
);

Pauses

readyallows you to set whether the animation of the component plays or pauses.

import LampBeadStrip from '@ray-js/lamp-bead-strip';
export default () => (
  <LampBeadStrip
    canvasId="diy-scene1"
    mode={2}
    ready={false}
    colors={['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)']}
    contentValue={{ segmented: 1, direction: 1 }}
  />
);

Customize Scaling Size

Since the components are drawn through canvas, the internal dimensions are fixed. The component internally handles screen scaling logic, which is controlled through thescaleproperty. If you want to modify the size of a component, you can customize thescaleproperty to achieve your goal. The following use case expects the component size to be1.1times larger than before.

It should be noted that the component only sets the scale once during initialization, so if the scale property is changed or set after initialization, it will be invalid

import LampBeadStrip from '@ray-js/lamp-bead-strip';
import { getSystemInfoSync } from '@ray-js/ray';

const { windowWidth = 375 } = getSystemInfoSync();
export default () => {
  const scale = (windowWidth / 375) * 1.1;
  return (
    <LampBeadStrip
      containerStyle={`height: ${48 * 1.1}rpx;width:${570 * 1.1}rpx;`}
      mode={16}
      canvasId="template2"
      scale={scale}
      colors={['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)']}
      contentValue={{ expand: 1 }}
    />
  );
};

Set the light off color

closeColor can set the color of lights that do not have color in the animation, that is, the color of the light beads that turn off the lights in the device. This way, the light strip component can adapt to multiple background colors, preventing the node color that turns off the lights from being the same as the background color.

import LampBeadStrip from '@ray-js/lamp-bead-strip';

export default () => {
  return (
    <LampBeadStrip
      mode={16}
      canvasId="template3"
      closeColor="rgba(255,255,255,.6)"
      colors={['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)']}
    />
  );
};

Animation Mode

Phase 1: 6, 1. Gradient, 2. Jump, 3. Breath, 4. Blink, 10. Flowing Water, 11. Rainbow
Phase 2 10, 5 shooting stars, 6 accumulation, 7 falling, 8 chasing light, 9 drifting, 12 flashing, 13 rebounding, 14 shuttling, 15 chaotic flashing, 16 opening and closing

| Animation mode value | description | Contains control types contentValue | | -------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------ | | 1 | (Phase 1)Gradient | segmented(intact 0/subsection 1) | | 2 | (Phase 1)Jump | segmented(intact 0/subsection 1) | | 3 | (Phase 1)Breath | segmented(intact 0/subsection 1) | | 4 | (Phase 1)Blink | segmented(intact 0/subsection 1) | | 10 | (Phase 1)Flowing Water | direction(Clockwise 0/anti-clockwise 1) | | 11 | (Phase 1)Rainbow | direction(Clockwise 0/anti-clockwise 1) | | 5 | (Phase 2)shooting stars | direction(Clockwise 0/anti-clockwise 1) expand(shooting-stars 0/meteor-shower 1/Colorful-meteor 2) | | 6 | (Phase 2)accumulation | direction(Clockwise 0/anti-clockwise 1) segmented(intact 0/subsection 1) | | 7 | (Phase 2)falling | direction(Clockwise 0/anti-clockwise 1) segmented(intact 0/subsection 1) | | 8 | (Phase 2)chasing light | direction(Clockwise 0/anti-clockwise 1) | | 9 | (Phase 2)drifting | direction(Clockwise 0/anti-clockwise 1) | | 12 | (Phase 2)flashing | segmented(intact 0/subsection 1) | | 13 | (Phase 2)rebounding | expand(rebound 0/Colorful rebound 1) | | 14 | (Phase 2)shuttling | - | | 15 | (Phase 2)chaotic flashing | - | | 16 | (Phase 2)opening and closing | expand(Same Time 0/staggered 1) |