From 9a53efea6074432fb4a42356be89705093228c30 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sun, 2 Jul 2023 16:24:31 +0700 Subject: [PATCH] add rotation line --- README.md | 23 +++++++++++++++++++++++ src/App.vue | 29 ++++++++++++++++++----------- src/components/Canvas.vue | 28 +++++++++++++++++++++------- src/const.ts | 1 + 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d5eeef0..f5822b6 100644 --- a/README.md +++ b/README.md @@ -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) + +## Цвета проекта + +

#0A0908

Black
+

#22333B

Gunmetal
+

#EAE0D5

Almond
+

#C6AC8F

Hhaki
+

#5E503F

Walnun brown
+ + diff --git a/src/App.vue b/src/App.vue index 7612d5a..f4c4f5b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,11 +13,14 @@ import { DEFAULT_IMAGE_WIDTH, DEFAULT_VERTICAL_MARGIN, DEFAULT_IMAGE_BACKGROUND_COLOR, + DEFAULT_VERTICAL_ROTATION, } from "./const"; import { ButtonSize, InputType } from "./types"; const vMargin = ref(DEFAULT_VERTICAL_MARGIN); +const vRotation = ref(DEFAULT_VERTICAL_ROTATION); const hMargin = ref(DEFAULT_HORIZONTAL_MARGIN); +const hMargin2 = ref(DEFAULT_HORIZONTAL_MARGIN); const imageWidth = ref(DEFAULT_IMAGE_WIDTH); const imageHeight = ref(DEFAULT_IMAGE_HEIGHT); const imageBackgroundColor = ref(DEFAULT_IMAGE_BACKGROUND_COLOR); @@ -49,25 +52,29 @@ const rotatePage = () => { Цвет {{ imageBackgroundColor }} - - Отступ по горизонтали, мм - Отступ по вертикали, мм + + Отступ, мм + Поворот, градусы + + + Отступ, мм + Дополнительный отступ, мм Высота, мм Ширина, мм @@ -79,8 +86,8 @@ const rotatePage = () => { - + diff --git a/src/components/Canvas.vue b/src/components/Canvas.vue index 48fc979..467921a 100644 --- a/src/components/Canvas.vue +++ b/src/components/Canvas.vue @@ -4,7 +4,9 @@ import { ONE_MM } from "../const"; const props = defineProps<{ vMargin: number; + vRotation: number; hMargin: number; + hMargin2: number; imageWidth: number; imageHeight: number; imageBackgroundColor: string; @@ -24,22 +26,34 @@ const clearCanvas = () => { }; const render = () => { - const { vMargin, hMargin, imageWidth, imageHeight } = props; + const { vMargin, vRotation, hMargin, hMargin2, imageWidth, imageHeight } = props; 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) { - for (let i = 1; i < 100; i++) { - const y = i * hMargin * ONE_MM; + var y = 0; + for (let i = 0; i < 100; i++) { + y += hMargins[i%2] * ONE_MM; ctx.value.moveTo(0, y); - ctx.value.lineTo(imageWidth * ONE_MM, y); + ctx.value.lineTo(imageWidthPx, y); ctx.value.stroke(); } for (let i = 1; i < 100; i++) { - const x = i * vMargin * ONE_MM; - ctx.value.moveTo(x, 0); - ctx.value.lineTo(x, imageHeight * ONE_MM); + const x = i * vMarginPx; + var x0 = x; + var y0 = 0; + var x1 = x - rotationDelta; + var y1 = imageHeightPx; + ctx.value.moveTo(x0, y0); + ctx.value.lineTo(x1, y1); ctx.value.stroke(); } } diff --git a/src/const.ts b/src/const.ts index df7e5d5..6edfeca 100644 --- a/src/const.ts +++ b/src/const.ts @@ -6,5 +6,6 @@ export const DEFAULT_IMAGE_HEIGHT = 100; export const DEFAULT_VERTICAL_MARGIN = 10; export const DEFAULT_HORIZONTAL_MARGIN = 10; +export const DEFAULT_VERTICAL_ROTATION = 90; export const DEFAULT_IMAGE_BACKGROUND_COLOR = "#ffffff" \ No newline at end of file