Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 移除文字模版相关类型定义 #36

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 10 additions & 27 deletions src/image.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { RenderLevel } from './type';
import type { StringTemplate } from './text';
import type { BinaryPointer } from './binary';
import type { DataType } from './components';

Expand Down Expand Up @@ -57,39 +56,23 @@ export type TextureJSONOptions = SerializedTextureSource;

export type TextureDefine = TextureJSONOptions;

export interface TemplateContentBase {
x?: number,
y?: number,
variables: Record<string, number | string>,
/**
* 当template宽高和image不相同时,会对template进行缩放,使其和image相同。
*/
width: number,
height: number,
}

export interface TemplateContentV1 extends TemplateContentBase {
/**
* 贴图属性,svg 字段
*/
content: string,
asImage?: boolean,
backgroundWidth: number,
backgroundHeight: number,
}

/**
* 动态换图类型
* @since 1.3.0
* @since 1.1.0
*/
export enum BackgroundType {
video = 'video',
image = 'image',
}

export interface TemplateContentV2 extends TemplateContentBase {
v: 2,
content?: StringTemplate,
export interface TemplateContent {
variables: Record<string, number | string>,
/**
* 当 template 宽高和 image 不相同时,会对 template 进行缩放,使其和 image 相同。
*/
width: number,
height: number,
// 绘制 canvas 的背景图片,替换掉原来的那张图片,如果没有就不替换
background?: {
type: BackgroundType,
name: string,
Expand Down Expand Up @@ -133,7 +116,7 @@ export interface Image {
* 模板贴图属性
*/
export interface TemplateImage extends Image {
template: TemplateContentV1 | TemplateContentV2,
template: TemplateContent,
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/item/camera-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface CameraContent {
clipMode?: CameraClipMode,

/**
* 默认不提供,等于canvas width/height
* 默认不提供,等于 canvas width/height
*/
aspect?: number,
},
Expand Down
8 changes: 0 additions & 8 deletions src/text.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import type { RGBAColor } from './number-expression';

export interface StringTemplate {
fonts: FontBase[],
texts: Text[],
colors: RGBAColor[], //rgba rgba(0-255), a default 255
}

/**
* 字体资源
* @version 2.3
Expand Down
Loading