Module uim.codec.base

Expand source code
# -*- coding: utf-8 -*-
# Copyright © 2021-23 Wacom Authors. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
from enum import Enum

WILL_PROTOBUF_ENCODING: str = 'latin1'

# Universal Ink v3.1.0 Constants
RIFF_HEADER: bytes = b'RIFF'
"""RIFF header string"""
UIM_HEADER: bytes = b'UINK'
"""Universal Ink Model file header."""
HEAD_HEADER: bytes = b'HEAD'
"""Header string"""
DATA_HEADER: bytes = b'DATA'
"""Data header string"""
PROPERTIES_HEADER: bytes = b'PRPS'
"""Bytes header for properties chunk"""
INPUT_DATA_HEADER: bytes = b'INPT'
"""Bytes header for input data chunk"""
BRUSHES_HEADER: bytes = b'BRSH'
"""Bytes header for brushes chunk"""
INK_DATA_HEADER: bytes = b'INKD'
"""Bytes header for ink data chunk"""
KNOWLEDGE_HEADER: bytes = b'KNWG'
"""Bytes header for knowledge graph chunk"""
INK_STRUCTURE_HEADER: bytes = b'INKS'
"""Bytes header for ink structure chunk"""
# Constants
CHUNK_DESCRIPTION: int = 8
"""Size of each description chunk in UIM v3.1.0 """
CHUNK_ID_BYTES_SIZE: int = 4
"""Size of the chunk id in UIM v3.1.0 """
SIZE_BYTE_SIZE: int = 4
"""Size of the size bytes in UIM v3.1.0 """
PADDING: bytes = b'\x00'
"""Padding byte"""
RESERVED: bytes = b'\x00'
"""Reserved byte"""


class ContentType(Enum):
    """"Enum of RIFF chunk content types."""
    BINARY = b'\x00'
    """Binary encoding of content, binary/octet-stream."""
    PROTOBUF = b'\x01'
    """Protobuf encoding of content, application/protobuf."""
    JSON = b'\x02'
    """JSON encoding of content, application/json."""
    TEXT = b'\x03'
    """Text encoding of content, text/plain."""


class CompressionType(Enum):
    """Enum of RIFF chunk supported compression types."""
    NONE = b'\x00'
    """Compression not applied"""
    ZIP = b'\x01'
    """ZIP compression for particular chunk"""
    LZMA = b'\x02'
    """LZMA compression for particular chunk"""


class MimeTypes:
    """Mime types for ink formats."""
    UNIVERSAL_INK_MODEL: str = "application/vnd.wacom-ink.model"  # Mime type for Universal Ink Models.
    WILL3_DOCUMENT: str = "application/vnd.wacom-will3.document"  # Mime type for WILL 3 documents.
    WILL2_FILE_FORMAT: str = "application/vnd.wacom-will2.document"  # Mime type for WILL 2 documents.
    WILL2_STROKES_FORMAT: str = "application/vnd.wacom-will2.strokes"  # Mime type for WILL 2 strokes


class FileExtension:
    """File extension of ink content files."""
    JSON_FORMAT_EXTENSION: str = '.json'
    """JSON file encoding."""
    UIM_JSON_FORMAT_EXTENSION: str = '.uim.json'
    """UIM JSON file encoding."""
    UIM_BINARY_FORMAT_EXTENSION: str = '.uim'
    """UIM binary encoding."""
    INKML_FORMAT_EXTENSION: str = '.inkml'
    """InkML encoding."""
    WILL_FORMAT_EXTENSION: str = '.will'
    """Wacom Ink Layer Language (WILL) file encoding."""

Global variables

var BRUSHES_HEADER : bytes

Bytes header for brushes chunk

var CHUNK_DESCRIPTION : int

Size of each description chunk in UIM v3.1.0

var CHUNK_ID_BYTES_SIZE : int

Size of the chunk id in UIM v3.1.0

var DATA_HEADER : bytes

Data header string

var HEAD_HEADER : bytes

Header string

var INK_DATA_HEADER : bytes

Bytes header for ink data chunk

var INK_STRUCTURE_HEADER : bytes

Bytes header for ink structure chunk

var INPUT_DATA_HEADER : bytes

Bytes header for input data chunk

var KNOWLEDGE_HEADER : bytes

Bytes header for knowledge graph chunk

var PADDING : bytes

Padding byte

var PROPERTIES_HEADER : bytes

Bytes header for properties chunk

var RESERVED : bytes

Reserved byte

var RIFF_HEADER : bytes

RIFF header string

var SIZE_BYTE_SIZE : int

Size of the size bytes in UIM v3.1.0

var UIM_HEADER : bytes

Universal Ink Model file header.

Classes

class CompressionType (value, names=None, *, module=None, qualname=None, type=None, start=1)

Enum of RIFF chunk supported compression types.

Expand source code
class CompressionType(Enum):
    """Enum of RIFF chunk supported compression types."""
    NONE = b'\x00'
    """Compression not applied"""
    ZIP = b'\x01'
    """ZIP compression for particular chunk"""
    LZMA = b'\x02'
    """LZMA compression for particular chunk"""

Ancestors

  • enum.Enum

Class variables

var LZMA

LZMA compression for particular chunk

var NONE

Compression not applied

var ZIP

ZIP compression for particular chunk

class ContentType (value, names=None, *, module=None, qualname=None, type=None, start=1)

"Enum of RIFF chunk content types.

Expand source code
class ContentType(Enum):
    """"Enum of RIFF chunk content types."""
    BINARY = b'\x00'
    """Binary encoding of content, binary/octet-stream."""
    PROTOBUF = b'\x01'
    """Protobuf encoding of content, application/protobuf."""
    JSON = b'\x02'
    """JSON encoding of content, application/json."""
    TEXT = b'\x03'
    """Text encoding of content, text/plain."""

Ancestors

  • enum.Enum

Class variables

var BINARY

Binary encoding of content, binary/octet-stream.

var JSON

JSON encoding of content, application/json.

var PROTOBUF

Protobuf encoding of content, application/protobuf.

var TEXT

Text encoding of content, text/plain.

class FileExtension

File extension of ink content files.

Expand source code
class FileExtension:
    """File extension of ink content files."""
    JSON_FORMAT_EXTENSION: str = '.json'
    """JSON file encoding."""
    UIM_JSON_FORMAT_EXTENSION: str = '.uim.json'
    """UIM JSON file encoding."""
    UIM_BINARY_FORMAT_EXTENSION: str = '.uim'
    """UIM binary encoding."""
    INKML_FORMAT_EXTENSION: str = '.inkml'
    """InkML encoding."""
    WILL_FORMAT_EXTENSION: str = '.will'
    """Wacom Ink Layer Language (WILL) file encoding."""

Class variables

var INKML_FORMAT_EXTENSION : str

InkML encoding.

var JSON_FORMAT_EXTENSION : str

JSON file encoding.

var UIM_BINARY_FORMAT_EXTENSION : str

UIM binary encoding.

var UIM_JSON_FORMAT_EXTENSION : str

UIM JSON file encoding.

var WILL_FORMAT_EXTENSION : str

Wacom Ink Layer Language (WILL) file encoding.

class MimeTypes

Mime types for ink formats.

Expand source code
class MimeTypes:
    """Mime types for ink formats."""
    UNIVERSAL_INK_MODEL: str = "application/vnd.wacom-ink.model"  # Mime type for Universal Ink Models.
    WILL3_DOCUMENT: str = "application/vnd.wacom-will3.document"  # Mime type for WILL 3 documents.
    WILL2_FILE_FORMAT: str = "application/vnd.wacom-will2.document"  # Mime type for WILL 2 documents.
    WILL2_STROKES_FORMAT: str = "application/vnd.wacom-will2.strokes"  # Mime type for WILL 2 strokes

Class variables

var UNIVERSAL_INK_MODEL : str
var WILL2_FILE_FORMAT : str
var WILL2_STROKES_FORMAT : str
var WILL3_DOCUMENT : str