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

img-capture

v0.0.22

Published

``` npm install img-capture ```

Downloads

4

Readme

img-capture

游戏

安装
npm install img-capture
使用
必须开启 "enableSkia": "true"
  • json
{
    "usingComponents": {
        "game": "img-capture/index"
    }
}
  • mini.project.json
{
  "node_modules_es6_whitelist": [
    "common-game"
  ]
}
  • js
Page({
  data: {
    gameSource: {
      // 不配做fullScaleShow或fullScreen,居中显示图片原本尺寸
      // fullScaleShow: true,//true:开启以长边撑满容器等比显示
      // fullScreen: true,//宽高拉伸撑满容器 优先级高于fullScaleShow
      imgCheckType: "mask",//图片检测区域边界 bg:最小值为背景框 mask:最小值为裁剪框
      moveOps: {
        openMove: true,//开启移动
      },
      // 左上角拖动图标,其他三个角自动旋转显示
      leftIcon: { src: "https://img.alicdn.com/imgextra/i1/2185320355/O1CN01KzU6b61EUdLvHgOhc_!!2185320355.png" },
      mask: {
        openDrag: true,//开启mask区域尺寸拖动
        isScale: true,//保持等比缩放
        minWidth: 10,//最小宽度
        minHeight: 10,//最小高度
        width: 400,//初始宽度
        height: 200,//初始高度
        alpha: 0.5//背景透明度
      },
      scaleOps: {
        imgShowType: "none",//none:自由缩放,single:保持长边最小缩放为撑满容器 double:保持最短边缩放为撑满容器
        openScale: !false, //是否开启缩放,默认false关闭
        scaleLmd: 100, //值越小越灵敏
        scaleRange: { min: 0.01, max: 10 } //缩放范围
      },
    },
  },
  onLoad() { },

  onRef(ref) {
    this.gameComponent = ref;
  },
  onInitDone() {
    // 更新配置数据
    this.gameComponent.onEvent("resetData", {
      mask: {
        openDrag: true,//开启mask区域尺寸拖动
        isScale: true,//保持等比缩放
        minWidth: 10,//最小宽度
        minHeight: 10,//最小高度
        width: 400,//初始宽度
        height: 200,//初始高度
        alpha: 0.9//背景透明度
      }
    })

    this.gameComponent.onEvent("load", {
      // scale: { x: 0.5, y: 0.5 },
      src: "https://img.alicdn.com/imgextra/i1/2185320355/O1CN01hWEuTv1EUdM8hGA7c_!!2185320355.png",
    })
  },
  async exportFun() {
    // 导出请在手机上预览效果
    /* let base64 = await this.gameComponent.onEvent("getMaskImg", {
      base64: true//true:返回base64路径,false:返回临时路径
    }); */
    let base64 = await this.gameComponent.onEvent("getMaskImg2");
    this.setData({
      imgSrc: base64
    })
  },
  topImgFun() {
    this.gameComponent.onEvent("renderTopImg", {
      src: "https://img.alicdn.com/imgextra/i4/1080040467/O1CN01iMdD9J1FJvfnSBaJW_!!1080040467.png",
      noExport: true,//画布导出图片时,不导出此图
    })
  }
});
  • xaml
  <image mode="scaleToFill" class="img" src="{{imgSrc}}" a:if="{{imgSrc}}" />
  <view class="pageBox">
    <view class="btn1" onTap="exportFun">导出图片</view>
    <game gameSource="{{gameSource}}" onRef="onRef" onInitDone="onInitDone" />
  </view>
  • acss
.pageBox{
  position: absolute;
  width: 750rpx;
  height: 500rpx;
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);

  background-color: #ccc;
}
.btn1{
  position: absolute;
  left:0;
  bottom: -100rpx;
}
.img{
  background-color: red;
  width: 400rpx;
  height: 200rpx;
  position: absolute;
  right: 0;
  bottom: 0;
}