async def slide_in_from_right(source: str, scene: str, step: int, height: int): """Slides a OBS Source in from the right side of the display Args: source (str): Source Name scene (str): Scene Name step (int): How many steps per iteration to move in height (int): Height from the top down, -1 will set it at the bottom. """ # Grab screen output values screen_properties = obs_client.call(requests.GetVideoInfo()).datain # Values of the source item_properties = obs_client.call(requests.GetSceneItemProperties(source, scene_name=scene)).datain # Set Starting position to bottom if -1 if height == -1: height = int(screen_properties["baseHeight"] - item_properties["height"]) - 10 # Send the height, and set off right side of screen obs_client.call( requests.SetSceneItemPosition( source, height, screen_properties["baseWidth"] + 1, ) ) # Save how far in to slide slide_in_to_x = int(screen_properties["baseWidth"] - item_properties["width"]) # Turn on the scene obs_client.call(requests.SetSceneItemRender(True, source, scene_name=scene)) # Slide In r_from = int(screen_properties["baseWidth"]) for x in range(r_from, slide_in_to_x, step * -1): obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene)) # Move to width of item obs_client.call( requests.SetSceneItemPosition( source, height, slide_in_to_x, ) ) # Hold the position for a beat await asyncio.sleep(2) # Slide back out for x in range( slide_in_to_x, int(screen_properties["baseWidth"]) + 2, step * 2, ): obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene))
def SetSceneItemPosition(self, *args): arg = [] arg.append(args[1]) arg.append(float(args[2])) arg.append(float(args[3])) arg.append(args[0]) return self.ws.call(requests.SetSceneItemPosition(*arg))
def main(): ws = obsws(host, port, password) ws.connect() ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) s1 = PROPERTIES(properties.datain) w = WINDOW_EASER(1280, 720) w.setWindow("f1") w.setWindow("f2") w.setKeyFrame("f1", 10 * 2, [0, 0, 1, 1]) w.setKeyFrame("f2", 10 * 2, [1, 0, 1, 1]) w.setKeyFrame("f1", 20 * 2, [0.1, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 20 * 2, [0.9, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 30 * 2, [0.1, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 30 * 2, [0.9, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 40 * 2, [0.5, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 40 * 2, [0.5, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 50 * 2, [0.5, 0.1, 0.4, 0.4]) w.setKeyFrame("f2", 50 * 2, [0.5, 0.5, 0.4, 0.4]) w.setKeyFrame("f1", 80 * 2, [0, 0, 1, 1]) w.setKeyFrame("f2", 80 * 2, [1, 0, 1, 1]) w.setupKeyFrame() while 1: for i in range(80 * 2): #print "=====================",i ret = w.update() #frame = w.draw() for source in sources: scale = s1.getScale(ret[source["name"]][3]) if "f2" == source["name"]: data = requests.SetSceneItemTransform( source["name"], -scale, scale, 0).data() else: data = requests.SetSceneItemTransform( source["name"], scale, scale, 0).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.01) data = requests.SetSceneItemPosition( source["name"], ret[source["name"]][0], ret[source["name"]][1]).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.01) #cv2.imshow("window",frame) #cv2.waitKey(1) w.initKeyFrame() ws.disconnect()
def main(): ws = obsws(host, port, password) ws.connect() PNFactoryX = perlin.PerlinNoiseFactory(1) PNFactoryY = perlin.PerlinNoiseFactory(1) ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) s1 = PROPERTIES(properties.datain) w = WINDOW_EASER(1280, 720) w.setWindow("f1") w.setKeyFrame("f1", 10 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 20 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 40 * 2, [-0.2, -0.2, 1.4, 1.4]) w.setKeyFrame("f1", 50 * 2, [-0.2, -0.2, 1.4, 1.4]) w.setKeyFrame("f1", 70 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setKeyFrame("f1", 80 * 2, [-0.05, -0.05, 1.1, 1.1]) w.setupKeyFrame() while 1: for i in range(80 * 2): #print "=====================",i ret = w.update() #frame = w.draw() for source in sources: scale = s1.getScale(ret["f1"][3]) data = requests.SetSceneItemTransform(source["name"], scale, scale, 0).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( source["name"], ret["f1"][0] + PNFactoryX(i / 30.0) * 20 - 20, ret["f1"][1] + PNFactoryY(i / 30.0) * 20 - 20).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.02) #cv2.imshow("window",frame) #cv2.waitKey(1) w.initKeyFrame() ws.disconnect()
def updateToEnd(self): for i in range(50): for srcName in self.route.keys(): scale = 1.0 * self.route[srcName]["cx"][i] / self.route[ srcName]["source_cx"][i] data = requests.SetSceneItemTransform(srcName, scale, scale, 0).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( srcName, self.route[srcName]["x"][i], self.route[srcName]["y"][i]).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) time.sleep(0.01) return
ws = obsws(host, port, password) ws.connect() ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) t0 = time.time() for i in range(50): for source in sources: properties = ws.call( requests.SetSceneItemPosition(source["name"], np.sin(i / 20.0) * 100 + 100, 0)) t1 = time.time() #command no wait mode for i in range(200): for source in sources: #properties = ws.send(requests.SetSceneItemPosition(source["name"],0,np.sin(i/20.0)*100+100).data()) data = requests.SetSceneItemPosition(source["name"], 0, np.sin(i / 20.0) * 100 + 100).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.03) t2 = time.time() for i in range(50):
password = "******" import perlin if __name__ == "__main__": ws = obsws(host, port, password) ws.connect() ret = ws.call(requests.GetCurrentScene()) print("current scene : ", ret.getName()) sources = ret.getSources() print("current sources : ", sources) for source in sources: properties = ws.call(requests.GetSceneItemProperties(source["name"])) print("properties : ", properties.datain) PNFactoryX = perlin.PerlinNoiseFactory(1) PNFactoryY = perlin.PerlinNoiseFactory(1) for i in range(1200): for source in sources: data = requests.SetSceneItemPosition( source["name"], PNFactoryX(i / 30.0) * 20 - 20, PNFactoryY(i / 30.0) * 20 - 20).data() data["message-id"] = 100 ws.ws.send(json.dumps(data)) time.sleep(0.03) t2 = time.time() ws.disconnect()
def update(self): #bUpdate = False for srcName in self.controlCount.keys(): if self.controlCount[srcName] > 0 and srcName in self.route.keys(): #bUpdate = True i = self.speed - self.controlCount[srcName] self.controlCount[srcName] -= 1 scale = 1.0 * self.route[srcName]["cx"][i] / self.route[ srcName]["source_cx"][i] data = requests.SetSceneItemTransform(srcName, scale, scale, 0).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( srcName, self.route[srcName]["x"][i], self.route[srcName]["y"][i]).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetCurrentScene(self.currentSceneName).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) if self.controlCount[srcName] == 0: time.sleep(0.02) scale = 1.0 * self.route[srcName]["cx"][i] / self.route[ srcName]["source_cx"][i] data = requests.SetSceneItemTransform( srcName, scale, scale, 0).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( srcName, self.route[srcName]["x"][i], self.route[srcName]["y"][i]).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetCurrentScene( self.currentSceneName).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) time.sleep(0.02) scale = 1.0 * self.route[srcName]["cx"][i] / self.route[ srcName]["source_cx"][i] data = requests.SetSceneItemTransform( srcName, scale, scale, 0).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetSceneItemPosition( srcName, self.route[srcName]["x"][i], self.route[srcName]["y"][i]).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) data = requests.SetCurrentScene( self.currentSceneName).data() data["message-id"] = self.messageid self.messageid += 1 self.ws.ws.send(json.dumps(data)) time.sleep(0.02) return
def put_target(self, x, y): adjust_x, adjust_y = self.adjust_image_position(x, y) self.ws.call( requests.SetSceneItemPosition('red_target', adjust_x, adjust_y)) self.set_icon_visible('red_target')