/** * Created by guopeng on 16/8/12. */ import {Unit} from "../drawing/Unit"; export const A4 = {name: "A4", width:210, height:297}; export const A5 = {name: "A5", width:148, height:210}; export const A8 = {name: "A8", width:52, height:74}; export const B4 = {name: "B4", width:250, height:353}; export const B5 = {name: "B5", width:176, height:250}; export const B8 = {name: "B8", width:62, height:88}; // 已定义的paper列表 export var papaers = [ A4, A5, A8, B4, B5, B8 ]; export function getPaperWithUnit(paper){ return { name: paper.name, width: Unit.mm(paper["width"]), height: Unit.mm(paper["height"]) }; } /** * 判断配置中是否有此纸张的配置 * @param width * @param height * @returns {boolean} */ export function hasPaper(width: number, height: number): any{ return papaers.find((paper) => paper.width===width && paper.height===height ); } /** * 保存自定义纸张 * @param width * @param height * @param name * @returns {{name: (string|string), width: number, height: number}} */ export function saveCustomPaper(width: number, height: number, name?:string){ const customPaper = { name: name||"Custom", width: width, height: height }; papaers.push(customPaper) return customPaper; }