diff --git a/packages-user/client-modules/src/render/components/thumbnail.tsx b/packages-user/client-modules/src/render/components/thumbnail.tsx new file mode 100644 index 0000000..34e0ce8 --- /dev/null +++ b/packages-user/client-modules/src/render/components/thumbnail.tsx @@ -0,0 +1,55 @@ +import { + ElementLocator, + MotaOffscreenCanvas2D, + Sprite +} from '@motajs/render-core'; +import { SpriteProps } from '@motajs/render-vue'; +import { defineComponent, ref, watch } from 'vue'; + +export interface ThumbnailProps extends SpriteProps { + loc: ElementLocator; + padStyle: CanvasStyle; + floorId: FloorIds; + map?: Block[]; + hero?: HeroStatus; + // configs + damage?: boolean; + all?: boolean; +} + +export const Thumbnail = defineComponent(props => { + const spriteRef = ref(); + + const update = () => { + spriteRef.value?.update(); + }; + + const drawThumbnail = (canvas: MotaOffscreenCanvas2D) => { + const hero = props.hero; + const options: Partial = { + damage: props.damage, + ctx: canvas.ctx, + x: 0, + y: 0, + size: 1, + all: props.all, + noHD: false, + v2: true, + inFlyMap: false + }; + if (hero) { + options.heroLoc = hero.loc; + options.heroIcon = hero.image; + options.flags = hero.flags; + options.centerX = hero.loc.x; + options.centerY = hero.loc.y; + } + core.drawThumbnail(props.floorId, props.map, options); + }; + + watch(props, update); + + return () => ( + + ); +}); diff --git a/src/types/declaration/map.d.ts b/src/types/declaration/map.d.ts index fa17d96..ae0fb95 100644 --- a/src/types/declaration/map.d.ts +++ b/src/types/declaration/map.d.ts @@ -370,7 +370,7 @@ interface DrawThumbnailConfig { /** * 勇士的位置 */ - heroLoc: LocArr; + heroLoc: Loc; /** * 勇士的图标