Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meta2d/core

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meta2d/core - npm Package Compare versions

Comparing version 1.0.20 to 1.0.21

src/utils/time.d.ts

2

package.json
{
"name": "@meta2d/core",
"version": "1.0.20",
"version": "1.0.21",
"description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -174,5 +174,12 @@ var __values = (this && this.__values) || function(o) {

}
// 从有图片画布层切换到无图片画布
var patchFlagsLast = this.store.patchFlagsLast;
if (patchFlagsLast) {
var ctx = this.offscreen.getContext('2d');
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
if (patchFlags) {
var ctx = this.offscreen.getContext('2d');
ctx.save();
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
ctx.translate(this.store.data.x, this.store.data.y);

@@ -179,0 +186,0 @@ try {

@@ -79,3 +79,5 @@ import { EventType, Handler, WildcardHandler } from 'mitt';

open(data?: Meta2dData, render?: boolean): void;
cacheMeta2dData(data?: Meta2dData): void;
extendedFn(): void;
cacheData(id: string): void;
loadCacheData(id: string): void;
initBindDatas(): void;

@@ -82,0 +84,0 @@ initBinds(): void;

@@ -366,2 +366,3 @@ import { Point } from '../point';

imageRadius?: number;
autoPolylineFlag?: boolean;
};

@@ -368,0 +369,0 @@ prevFrame?: Pen;

import { Direction } from '../data';
import { Pen } from '../pen';
import { Meta2dStore } from '../store';
export declare enum PrevNextType {

@@ -15,2 +17,6 @@ Mirror = 0,

}
export declare enum PointType {
Default = 0,
Line = 1
}
export interface Point {

@@ -42,5 +48,8 @@ x: number;

title?: string;
type?: PointType;
length?: number;
distance?: number;
}
export declare function rotatePoint(pt: Point, angle: number, center: Point): void;
export declare function hitPoint(pt: Point, target: Point, radius?: number): boolean;
export declare function hitPoint(pt: Point, target: Point, radius?: number, pen?: Pen): boolean;
export declare function scalePoint(pt: Point, scale: number, center: Point): void;

@@ -58,1 +67,2 @@ export declare function calcRotate(pt: Point, center: Point): number;

export declare function samePoint(pt1: Point, pt2: Point): boolean;
export declare function getDistance(form: Point, to: Point, store: Meta2dStore): void;
import { Direction } from '../data';
import { pointInRect } from '../rect';
export var PrevNextType;

@@ -17,2 +18,7 @@ (function (PrevNextType) {

})(TwoWay || (TwoWay = {}));
export var PointType;
(function (PointType) {
PointType[PointType["Default"] = 0] = "Default";
PointType[PointType["Line"] = 1] = "Line";
})(PointType || (PointType = {}));
export function rotatePoint(pt, angle, center) {

@@ -34,8 +40,34 @@ if (!angle || angle % 360 === 0) {

}
export function hitPoint(pt, target, radius) {
export function hitPoint(pt, target, radius, pen) {
if (radius === void 0) { radius = 5; }
return (pt.x > target.x - radius &&
pt.x < target.x + radius &&
pt.y > target.y - radius &&
pt.y < target.y + radius);
if (target.type === PointType.Line) {
var _rotate = pen.rotate;
if (pen.flipX) {
_rotate *= -1;
}
if (pen.flipY) {
_rotate *= -1;
}
var rotate = target.rotate + _rotate;
if (pen.flipX) {
rotate *= -1;
}
if (pen.flipY) {
rotate *= -1;
}
return pointInRect(pt, {
x: target.x -
(target.length * pen.calculative.canvas.store.data.scale) / 2,
y: target.y - radius,
width: target.length * pen.calculative.canvas.store.data.scale,
height: radius * 2,
rotate: rotate,
});
}
else {
return (pt.x > target.x - radius &&
pt.x < target.x + radius &&
pt.y > target.y - radius &&
pt.y < target.y + radius);
}
}

@@ -121,2 +153,30 @@ export function scalePoint(pt, scale, center) {

}
export function getDistance(form, to, store) {
var dis = Math.sqrt((form.x - to.x) * (form.x - to.x) + (form.y - to.y) * (form.y - to.y)) / store.data.scale;
if (to.rotate === 0) {
if (form.x < to.x) {
if (!store.pens[to.penId].flipX) {
dis *= -1;
}
}
else {
if (store.pens[to.penId].flipX) {
dis *= -1;
}
}
}
else {
if (form.y < to.y) {
if (!store.pens[to.penId].flipY) {
dis *= -1;
}
}
else {
if (store.pens[to.penId].flipY) {
dis *= -1;
}
}
}
form.distance = dis;
}
//# sourceMappingURL=point.js.map

@@ -5,2 +5,3 @@ import { Emitter } from 'mitt';

import { Point } from '../point';
import { Rect } from '../rect';
export interface Meta2dData {

@@ -56,2 +57,3 @@ pens: Pen[];

mockData?: Function;
name?: string;
}

@@ -130,5 +132,8 @@ export interface Network {

patchFlagsTop?: boolean;
bkImg: HTMLImageElement;
bkImg?: HTMLImageElement;
fillWorldTextRect?: boolean;
meta2dDatas?: Meta2dData[];
cacheDatas?: {
data: Meta2dData;
}[];
patchFlagsLast?: boolean;
}

@@ -142,3 +147,3 @@ export interface Meta2dClipboard {

page: string;
initRect?: Point;
initRect?: Rect;
pos?: Point;

@@ -145,0 +150,0 @@ }

@@ -42,3 +42,3 @@ var __assign = (this && this.__assign) || function () {

binds: {},
meta2dDatas: [],
cacheDatas: [],
};

@@ -45,0 +45,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc