Skip to content

Commit

Permalink
dump_tilt.py: support new stroke flags
Browse files Browse the repository at this point in the history
Add support for 'seed' and 'group'

Change-Id: Id000b0155c7ecd9e05b62976922d9c002eaf3e95
  • Loading branch information
dubois committed Oct 10, 2019
1 parent a1e235d commit f30d95b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Python/tiltbrush/tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
STROKE_EXTENSION_BITS = {
0x1: ('flags', 'I'),
0x2: ('scale', 'f'),
0x4: ('group', 'I'),
0x8: ('seed', 'I'),
'unknown': lambda bit: ('stroke_ext_%d' % math.log(bit, 2),
'I' if (bit & 0xffff) else '@')
}
Expand Down
31 changes: 21 additions & 10 deletions bin/dump_tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ def dump_sketch(sketch):
cooky, version, unused = sketch.header[0:3]
print 'Cooky:0x%08x Version:%s Unused:%s Extra:(%d bytes)' % (
cooky, version, unused, len(sketch.additional_header))
if len(sketch.strokes):
stroke = sketch.strokes[0] # choose one representative one
def extension_names(lookup):
# lookup is a dict mapping name -> idx
extensions = sorted(lookup.items(), key=lambda (n,i): i)
return ', '.join(name for (name, idx) in extensions)
print "Stroke Ext: %s" % extension_names(stroke.stroke_ext_lookup)
if len(stroke.controlpoints):
print "CPoint Ext: %s" % extension_names(stroke.cp_ext_lookup)

# Create dicts that are the union of all the stroke-extension and
# control-point-extension # lookup tables.
union_stroke_extension = {}
union_cp_extension = {}
for stroke in sketch.strokes:
union_stroke_extension.update(stroke.stroke_ext_lookup)
union_cp_extension.update(stroke.cp_ext_lookup)

print "Stroke Ext: %s" % ', '.join(union_stroke_extension.keys())
print "CPoint Ext: %s" % ', '.join(union_cp_extension.keys())

for (i, stroke) in enumerate(sketch.strokes):
print "%3d: " % i,
Expand All @@ -65,12 +67,21 @@ def dump_stroke(stroke):
except KeyError:
scale = 1

print "Brush: %2d Size: %.3f Color: #%02X%02X%02X %s [%4d]" % (
if 'group' in stroke.stroke_ext_lookup:
group = stroke.extension[stroke.stroke_ext_lookup['group']]
else: group = '--'

if 'seed' in stroke.stroke_ext_lookup:
seed = '%08x' % stroke.extension[stroke.stroke_ext_lookup['seed']]
else: seed = '-none-'

print "B:%2d S:%.3f C:#%02X%02X%02X g:%2s s:%8s %s [%4d]" % (
stroke.brush_idx, stroke.brush_size * scale,
int(stroke.brush_color[0] * 255),
int(stroke.brush_color[1] * 255),
int(stroke.brush_color[2] * 255),
#stroke.brush_color[3],
group, seed,
start_ts,
len(stroke.controlpoints))

Expand Down

0 comments on commit f30d95b

Please sign in to comment.