MCPcopy Create free account
hub / github.com/NyarchLinux/DesktopPuppet / update_position

Method update_position

src/puppets/live2d.py:66–83  ·  view source on GitHub ↗
(obj, result)

Source from the content-addressed store, hash-verified

64 if not self.loaded:
65 return
66 script = """model_proxy.internalModel.width+ "," + model_proxy.internalModel.height + "," + model_proxy.position._x + "," + model_proxy.position._y + "," + model_proxy.scale._x"""
67 def update_position(obj, result):
68 global model_x, model_y, model_width, model_height
69 coord = self.webview.evaluate_javascript_finish(result)
70 coord = coord.to_string().split(",")
71 self.model_height = int(coord[1])
72 self.model_width = int(coord[0])
73 self.model_x = int(coord[2].split(".")[0])
74 self.model_y = int(coord[3].split(".")[0])
75 # Apply model scaling
76 scale = float(coord[4])
77 model_width2 = int(scale * self.model_width)
78 model_height2 = int(scale * self.model_height)
79 # Apply extra scale to fix model extra dimensions
80 self.model_width = int(model_width2 * self.extra_scale_w)
81 self.model_height = int(model_height2 * self.extra_scale_h)
82 # Fix offset caused by the rescaling
83 self.model_x = int(self.model_x + (model_width2 - self.model_width) / 2)
84 self.model_y = int(self.model_y - (model_height2 - self.model_height) / 2)
85
86 self.webview.evaluate_javascript(script, len(script), callback=update_position)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected