add rotation line
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Владимир Фёдоров 2023-07-02 16:24:31 +07:00
parent 5b31613ebd
commit 9a53efea60
4 changed files with 63 additions and 18 deletions

View File

@ -8,3 +8,26 @@ Thanks to [icons8](https://icons8.com/icon/vPDvU8cYImOg/noodles) for the logo
___ ___
[![Build Status](https://drone.3crabs.ru/api/badges/VLADIMIR/lapsha/status.svg)](https://drone.3crabs.ru/VLADIMIR/lapsha) [![Build Status](https://drone.3crabs.ru/api/badges/VLADIMIR/lapsha/status.svg)](https://drone.3crabs.ru/VLADIMIR/lapsha)
## Цвета проекта
<div class="color-block light-text" style="background-color: #0A0908"><h2>#0A0908</h2>Black</div>
<div class="color-block light-text" style="background-color: #22333B"><h2>#22333B</h2>Gunmetal</div>
<div class="color-block dark-text" style="background-color: #EAE0D5"><h2>#EAE0D5</h2>Almond</div>
<div class="color-block dark-text" style="background-color: #C6AC8F"><h2>#C6AC8F</h2>Hhaki</div>
<div class="color-block light-text" style="background-color: #5E503F"><h2>#5E503F</h2>Walnun brown</div>
<style>
.color-block {
padding: 30px;
display: inline-block;
margin: 5px;
text-align: center;
}
.light-text {
color: #eeeeee;
}
.dark-text {
color: #222222;
}
</style>

View File

@ -13,11 +13,14 @@ import {
DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_WIDTH,
DEFAULT_VERTICAL_MARGIN, DEFAULT_VERTICAL_MARGIN,
DEFAULT_IMAGE_BACKGROUND_COLOR, DEFAULT_IMAGE_BACKGROUND_COLOR,
DEFAULT_VERTICAL_ROTATION,
} from "./const"; } from "./const";
import { ButtonSize, InputType } from "./types"; import { ButtonSize, InputType } from "./types";
const vMargin = ref(DEFAULT_VERTICAL_MARGIN); const vMargin = ref(DEFAULT_VERTICAL_MARGIN);
const vRotation = ref(DEFAULT_VERTICAL_ROTATION);
const hMargin = ref(DEFAULT_HORIZONTAL_MARGIN); const hMargin = ref(DEFAULT_HORIZONTAL_MARGIN);
const hMargin2 = ref(DEFAULT_HORIZONTAL_MARGIN);
const imageWidth = ref(DEFAULT_IMAGE_WIDTH); const imageWidth = ref(DEFAULT_IMAGE_WIDTH);
const imageHeight = ref(DEFAULT_IMAGE_HEIGHT); const imageHeight = ref(DEFAULT_IMAGE_HEIGHT);
const imageBackgroundColor = ref(DEFAULT_IMAGE_BACKGROUND_COLOR); const imageBackgroundColor = ref(DEFAULT_IMAGE_BACKGROUND_COLOR);
@ -49,25 +52,29 @@ const rotatePage = () => {
Цвет {{ imageBackgroundColor }} Цвет {{ imageBackgroundColor }}
</Input> </Input>
</SidebarBlock> </SidebarBlock>
<SidebarBlock title="Линии"> <SidebarBlock title="Вертикальные линии">
<Input v-model="vMargin">Отступ по горизонтали, мм</Input> <Input v-model="vMargin">Отступ, мм</Input>
<Input v-model="hMargin">Отступ по вертикали, мм</Input> <Input v-model="vRotation">Поворот, градусы</Input>
</SidebarBlock>
<SidebarBlock title="Горизонтальные линии">
<Input v-model="hMargin">Отступ, мм</Input>
<Input v-model="hMargin2">Дополнительный отступ, мм</Input>
</SidebarBlock> </SidebarBlock>
<SidebarBlock title="Изображение"> <SidebarBlock title="Изображение">
<Input v-model="imageHeight">Высота, мм</Input> <Input v-model="imageHeight">Высота, мм</Input>
<Input v-model="imageWidth">Ширина, мм</Input> <Input v-model="imageWidth">Ширина, мм</Input>
<ButtonsBar> <ButtonsBar>
<Button :size="ButtonSize.Small" :click="() => { <Button :size="ButtonSize.Small" :click="() => {
imageWidth = 148; imageWidth = 148;
imageHeight = 210; imageHeight = 210;
} }
"> ">
A5 A5
</Button> </Button>
<Button :size="ButtonSize.Small" :click="() => { <Button :size="ButtonSize.Small" :click="() => {
imageWidth = 210; imageWidth = 210;
imageHeight = 297; imageHeight = 297;
} }
"> ">
A4 A4
</Button> </Button>
@ -79,8 +86,8 @@ const rotatePage = () => {
</SidebarBlock> </SidebarBlock>
</Sidebar> </Sidebar>
<Page> <Page>
<Canvas :vMargin="vMargin" :hMargin="hMargin" :imageWidth="imageWidth" :imageHeight="imageHeight" <Canvas :vMargin="vMargin" :vRotation="vRotation" :hMargin="hMargin" :hMargin2="hMargin2" :imageWidth="imageWidth"
:imageBackgroundColor="imageBackgroundColor" /> :imageHeight="imageHeight" :imageBackgroundColor="imageBackgroundColor" />
</Page> </Page>
</div> </div>
</template> </template>

View File

@ -4,7 +4,9 @@ import { ONE_MM } from "../const";
const props = defineProps<{ const props = defineProps<{
vMargin: number; vMargin: number;
vRotation: number;
hMargin: number; hMargin: number;
hMargin2: number;
imageWidth: number; imageWidth: number;
imageHeight: number; imageHeight: number;
imageBackgroundColor: string; imageBackgroundColor: string;
@ -24,22 +26,34 @@ const clearCanvas = () => {
}; };
const render = () => { const render = () => {
const { vMargin, hMargin, imageWidth, imageHeight } = props; const { vMargin, vRotation, hMargin, hMargin2, imageWidth, imageHeight } = props;
clearCanvas(); clearCanvas();
var hMargins = [hMargin, hMargin2];
var imageHeightPx = imageHeight * ONE_MM;
var imageWidthPx = imageWidth * ONE_MM;
var vMarginPx = vMargin * ONE_MM;
var rotationDelta = imageHeightPx / Math.tan(vRotation / 180 * Math.PI);
if (ctx.value) { if (ctx.value) {
for (let i = 1; i < 100; i++) { var y = 0;
const y = i * hMargin * ONE_MM; for (let i = 0; i < 100; i++) {
y += hMargins[i%2] * ONE_MM;
ctx.value.moveTo(0, y); ctx.value.moveTo(0, y);
ctx.value.lineTo(imageWidth * ONE_MM, y); ctx.value.lineTo(imageWidthPx, y);
ctx.value.stroke(); ctx.value.stroke();
} }
for (let i = 1; i < 100; i++) { for (let i = 1; i < 100; i++) {
const x = i * vMargin * ONE_MM; const x = i * vMarginPx;
ctx.value.moveTo(x, 0); var x0 = x;
ctx.value.lineTo(x, imageHeight * ONE_MM); var y0 = 0;
var x1 = x - rotationDelta;
var y1 = imageHeightPx;
ctx.value.moveTo(x0, y0);
ctx.value.lineTo(x1, y1);
ctx.value.stroke(); ctx.value.stroke();
} }
} }

View File

@ -6,5 +6,6 @@ export const DEFAULT_IMAGE_HEIGHT = 100;
export const DEFAULT_VERTICAL_MARGIN = 10; export const DEFAULT_VERTICAL_MARGIN = 10;
export const DEFAULT_HORIZONTAL_MARGIN = 10; export const DEFAULT_HORIZONTAL_MARGIN = 10;
export const DEFAULT_VERTICAL_ROTATION = 90;
export const DEFAULT_IMAGE_BACKGROUND_COLOR = "#ffffff" export const DEFAULT_IMAGE_BACKGROUND_COLOR = "#ffffff"