WIP annotations

This commit is contained in:
Ruben van de Ven 2022-06-01 16:08:49 +02:00
parent 9c54b2f8d7
commit 232903c0ff
4 changed files with 178 additions and 80 deletions

View file

@ -12,6 +12,9 @@ import svgwrite
import tempfile
import io
import logging
from anytree import NodeMixin, RenderTree
from anytree.exporter import JsonExporter
from anytree.importer import JsonImporter, DictImporter
logger = logging.getLogger('svganim.strokes')
@ -232,7 +235,7 @@ class AnimationSlice:
strokes = self.getStrokeSlices(frame_in, frame_out, t_in)
# TODO shift t of points with t_in
viewboxes = self.getViewboxesSlice(t_in, t_out)
audio = self.audio.getSlice(t_in, t_out) if self.audio else None
return AnimationSlice([self.id[0], t_in, t_out], strokes, viewboxes, t_in, t_out, audio)
@ -693,3 +696,31 @@ def strokes2D(strokes):
d += f"{rel_stroke[0]},{rel_stroke[1]} "
last_stroke = stroke
return d
class Tag(NodeMixin):
def __init__(self, id, name = None, description = "", color = "black", parent=None, children=None):
self.id = id
self.name = self.id if name is None else name
self.color = color
self.description = description
self.parent = parent
if children:
self.children = children
class TagTree(NodeMixin):
def __init__(self, parent=None, children=None):
self.parent = parent
if children:
self.children = children
my0 = Tag('root')
my1 = Tag('my1', 1, 0, parent=my0)
my2 = Tag('my2', 0, 2, parent=my0)
print(RenderTree(my0))
tree = JsonExporter(indent=2).export(my0)
print(tree)
print(RenderTree(JsonImporter(DictImporter(Tag)).import_(tree)))
with open('www/tags.json', 'r') as fp:
print(RenderTree(JsonImporter(DictImporter(Tag)).read(fp)))

View file

@ -1,81 +1,116 @@
{
"human-machine": {
"fullname": "Human/machine Entanglements (Appearance/disappearance)",
"color": "orange",
"sub": {
"vision": {
"fullname": "Vision",
"color": "orange"
},
"sound": {},
"behaviour": {},
"other-senses": {
"fullname": "Other senses"
}
"id": "root",
"children": [
{
"id": "human-machine",
"name": "Human/machine Entanglements (Appearance/disappearance)",
"color": "orange",
"children": [
{
"id": "vision",
"name": "Vision",
"color": "orange"
},
{
"id": "sound"
},
{
"id": "behaviour"
},
{
"id": "other-senses",
"name": "Other senses"
}
]
},
{
"id": "tensions",
"name": "Tensions, contestations & problems",
"description": "Which problems are identified?, when do they become problems?",
"color": "gray"
},
{
"id": "security",
"color": "blue",
"name": "Security & types of data",
"children": [
{
"id": "definitions",
"description": "e.g. domain knowledge"
},
{
"id": "input",
"description": "e.g. fake data"
}
]
},
{
"id": "actants",
"name": "Actants in relation",
"color": "pink",
"children": [
{
"id": "algorithm"
},
{
"id": "technologies"
},
{
"id": "frt"
},
{
"id": "cameras",
"name": "CCTV & camera's"
},
{
"id": "entities",
"name": "Entities: people, institutions etc."
},
{
"id": "positioning",
"name": "Positioning",
"description": "the positioning of a field/person/oneself in relation to others"
},
{
"id": "inside-outside"
},
{
"id": "public-private"
}
]
},
{
"id": "consequences",
"color": "green",
"children": [
{
"id": "effects"
},
{
"id": "future-imaginaries"
},
{
"id": "speculations",
"description": "what is & what will/can be done."
},
{
"id": "innovations"
}
]
},
{
"id": "hesitation",
"name": "Hesitations & corrections",
"color": "yellow"
},
{
"id": "skip",
"color": "black"
},
{
"id": "todo",
"name": "to do / interesting",
"color": "red"
}
},
"tensions": {
"fullname": "Tensions, contestations & problems",
"description" : "Which problems are identified?, when do they become problems?",
"color": "gray"
},
"security": {
"color": "blue",
"fullname": "Security & types of data",
"sub": {
"definitions": {
"description": "e.g. domain knowledge"
},
"input": {
"description": "e.g. fake data"
}
}
},
"actants":{
"fullname": "Actants in relation",
"color": "pink",
"sub":{
"algorithm": {},
"technologies": {},
"frt": {},
"cameras": {
"fullname": "CCTV & camera's"
},
"entities":{
"fullname": "Entities: people, institutions etc."
},
"positioning":{
"fullname": "Positioning",
"description": "the positioning of a field/person/oneself in relation to others"
},
"inside-outside":{},
"public-private":{}
}
},
"consequences":{
"color": "green",
"sub":{
"effects":{},
"future-imaginaries":{},
"speculations": {
"description": "what is & what will/can be done."
},
"innovations": {}
}
},
"hesitation":{
"fullname": "Hesitations & corrections",
"color": "yellow"
},
"skip":{
"color": "black"
},
"todo":{
"fullname": "to do / interesting",
"color": "red"
}
]
}

33
poetry.lock generated
View file

@ -1,3 +1,18 @@
[[package]]
name = "anytree"
version = "2.8.0"
description = "Powerful and Lightweight Python Tree Data Structure.."
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
six = ">=1.9.0"
[package.extras]
dev = ["check-manifest"]
test = ["coverage"]
[[package]]
name = "coloredlogs"
version = "15.0.1"
@ -39,6 +54,14 @@ category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "svgwrite"
version = "1.4.2"
@ -58,9 +81,13 @@ python-versions = ">= 3.5"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "b989d535550aaf74b32cd9d2ff48ab7ed8d7d3fd5f0386bc2d6385d65adbf438"
content-hash = "1ad87cd5b37157a20ee2ec8f23d84b0275ca9f3aa3218c98eb18859d43aa5080"
[metadata.files]
anytree = [
{file = "anytree-2.8.0-py2.py3-none-any.whl", hash = "sha256:14c55ac77492b11532395049a03b773d14c7e30b22aa012e337b1e983de31521"},
{file = "anytree-2.8.0.tar.gz", hash = "sha256:3f0f93f355a91bc3e6245319bf4c1d50e3416cc7a35cc1133c1ff38306bbccab"},
]
coloredlogs = [
{file = "coloredlogs-15.0.1-py2.py3-none-any.whl", hash = "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934"},
{file = "coloredlogs-15.0.1.tar.gz", hash = "sha256:7c991aa71a4577af2f82600d8f8f3a89f936baeaf9b50a9c197da014e5bf16b0"},
@ -77,6 +104,10 @@ pyreadline3 = [
{file = "pyreadline3-3.4.1-py3-none-any.whl", hash = "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"},
{file = "pyreadline3-3.4.1.tar.gz", hash = "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae"},
]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
svgwrite = [
{file = "svgwrite-1.4.2-py3-none-any.whl", hash = "sha256:ca63d76396d1f6f099a2b2d8cf1419e1c1de8deece9a2b7f4da0632067d71d43"},
{file = "svgwrite-1.4.2.zip", hash = "sha256:d304a929f197d31647c287c10eee0f64378058e1c83a9df83433a5980864e59f"},

View file

@ -10,6 +10,7 @@ tornado = "^6.1"
coloredlogs = "^15.0.1"
pydub = "^0.25.1"
svgwrite = "^1.4.1"
anytree = "^2.8.0"
[tool.poetry.dev-dependencies]