vkit.engine.seal_impression.type

 1# Copyright 2022 vkit-x Administrator. All Rights Reserved.
 2#
 3# This project (vkit-x/vkit) is dual-licensed under commercial and SSPL licenses.
 4#
 5# The commercial license gives you the full rights to create and distribute software
 6# on your own terms without any SSPL license obligations. For more information,
 7# please see the "LICENSE_COMMERCIAL.txt" file.
 8#
 9# This project is also available under Server Side Public License (SSPL).
10# The SSPL licensing is ideal for use cases such as open source projects with
11# SSPL distribution, student/academic purposes, hobby projects, internal research
12# projects without external distribution, or other projects where all SSPL
13# obligations can be met. For more information, please see the "LICENSE_SSPL.txt" file.
14from typing import Sequence, Tuple, Optional
15
16import attrs
17import numpy as np
18
19from vkit.element import Point, Box, Mask
20
21
22@attrs.define
23class CharSlot:
24    angle: int
25    point_up: Point
26    point_down: Point
27
28    @classmethod
29    def build(cls, point_up: Point, point_down: Point):
30        theta = np.arctan2(
31            point_up.smooth_y - point_down.smooth_y,
32            point_up.smooth_x - point_down.smooth_x,
33        )
34        two_pi = 2 * np.pi
35        theta = theta % two_pi
36        angle = round(theta / two_pi * 360)
37        return cls(angle=angle, point_up=point_up, point_down=point_down)
38
39
40@attrs.define
41class TextLineSlot:
42    text_line_height: int
43    char_aspect_ratio: float
44    char_slots: Sequence[CharSlot]
45
46
47@attrs.define
48class SealImpression:
49    alpha: float
50    color: Tuple[int, int, int]
51    background_mask: Mask
52    text_line_slots: Sequence[TextLineSlot]
53    internal_text_line_box: Optional[Box]
54
55    @property
56    def shape(self):
57        return self.background_mask.shape
58
59
60@attrs.define
61class SealImpressionEngineRunConfig:
62    height: int
63    width: int
class CharSlot:
24class CharSlot:
25    angle: int
26    point_up: Point
27    point_down: Point
28
29    @classmethod
30    def build(cls, point_up: Point, point_down: Point):
31        theta = np.arctan2(
32            point_up.smooth_y - point_down.smooth_y,
33            point_up.smooth_x - point_down.smooth_x,
34        )
35        two_pi = 2 * np.pi
36        theta = theta % two_pi
37        angle = round(theta / two_pi * 360)
38        return cls(angle=angle, point_up=point_up, point_down=point_down)
CharSlot( angle: int, point_up: vkit.element.point.Point, point_down: vkit.element.point.Point)
2def __init__(self, angle, point_up, point_down):
3    self.angle = angle
4    self.point_up = point_up
5    self.point_down = point_down

Method generated by attrs for class CharSlot.

@classmethod
def build( cls, point_up: vkit.element.point.Point, point_down: vkit.element.point.Point):
29    @classmethod
30    def build(cls, point_up: Point, point_down: Point):
31        theta = np.arctan2(
32            point_up.smooth_y - point_down.smooth_y,
33            point_up.smooth_x - point_down.smooth_x,
34        )
35        two_pi = 2 * np.pi
36        theta = theta % two_pi
37        angle = round(theta / two_pi * 360)
38        return cls(angle=angle, point_up=point_up, point_down=point_down)
class TextLineSlot:
42class TextLineSlot:
43    text_line_height: int
44    char_aspect_ratio: float
45    char_slots: Sequence[CharSlot]
TextLineSlot( text_line_height: int, char_aspect_ratio: float, char_slots: Sequence[vkit.engine.seal_impression.type.CharSlot])
2def __init__(self, text_line_height, char_aspect_ratio, char_slots):
3    self.text_line_height = text_line_height
4    self.char_aspect_ratio = char_aspect_ratio
5    self.char_slots = char_slots

Method generated by attrs for class TextLineSlot.

class SealImpression:
49class SealImpression:
50    alpha: float
51    color: Tuple[int, int, int]
52    background_mask: Mask
53    text_line_slots: Sequence[TextLineSlot]
54    internal_text_line_box: Optional[Box]
55
56    @property
57    def shape(self):
58        return self.background_mask.shape
SealImpression( alpha: float, color: Tuple[int, int, int], background_mask: vkit.element.mask.Mask, text_line_slots: Sequence[vkit.engine.seal_impression.type.TextLineSlot], internal_text_line_box: Union[vkit.element.box.Box, NoneType])
2def __init__(self, alpha, color, background_mask, text_line_slots, internal_text_line_box):
3    self.alpha = alpha
4    self.color = color
5    self.background_mask = background_mask
6    self.text_line_slots = text_line_slots
7    self.internal_text_line_box = internal_text_line_box

Method generated by attrs for class SealImpression.

class SealImpressionEngineRunConfig:
62class SealImpressionEngineRunConfig:
63    height: int
64    width: int
SealImpressionEngineRunConfig(height: int, width: int)
2def __init__(self, height, width):
3    self.height = height
4    self.width = width

Method generated by attrs for class SealImpressionEngineRunConfig.