async def async_execute(self):
    self.websocket_client = WebSocketClient(7008)
    await self.websocket_client.connect()

    url = get_random_photo_url()
    if url:
      await async_set_value(BACKGROUND_IMAGE_URL, url)
      await self.websocket_client.send({"imageUrl": url})

    await self.cleanup()
    return
示例#2
0
    async def async_execute(self):
        self.websocket_client = WebSocketClient(7004)
        await self.websocket_client.connect()

        sleep_time = 0.8
        for j in range(8):
            for i in range(20):
                x = -750 + j * 350 + TILE_INCREMENT * i
                y = -20 + TILE_INCREMENT * i
                if x < -150 or x > 1920 or y > 1080:
                    continue

                await self.websocket_client.send({
                    "type": "create",
                    "id": f"error_{i}_{j}",
                    "html": f"<img src='/assets/images/windows_error.png' />",
                    "position": {
                        "x": x,
                        "y": y
                    }
                })

                if j == 0 or i % 2 == 0:
                    self.sound_manager.play_sound(ERROR_SOUND.sound_file.path,
                                                  sound_name=ERROR_SOUND.name,
                                                  play_multiple=True,
                                                  headphone=True,
                                                  stream=True)

                await asyncio.sleep(sleep_time)
                sleep_time = max(0.025, sleep_time - SPEEDUP)

        await self.websocket_client.send({
            "type":
            "create",
            "id":
            f"blue_screen_of_death",
            "html":
            f"<img src='/assets/images/death.jpg' />"
        })

        await asyncio.sleep(0.5)

        for i in range(20):
            for j in range(8):
                await self.websocket_client.send({
                    "type": "delete",
                    "id": f"error_{i}_{j}"
                })

        await asyncio.sleep(4)
        await self.cleanup()
        return
示例#3
0
    async def async_execute(self):
        self.websocket_client = WebSocketClient(7004)
        await self.websocket_client.connect()

        await self.websocket_client.send({
            "type": "create",
            "id": f"shame_cube_text",
            "html":
            f"<div style='{DIV_CSS}'><span style='{TEXT_CSS}'>SHAME CUBE</span></div>",
            "position": {
                "x": 0,
                "y": 800
            }
        })

        await self.websocket_client.send({
            "type": "create",
            "id": f"shame_cube_style",
            "html": STYLE
        })

        start = -600
        end = (1080 * (2 / 3)) - 600 / 2
        timer = 5000
        await self.websocket_client.send({
            "type": "create",
            "id": f"shame_cube_cube",
            "html": SHAME_CUBE,
            "position": {
                "x": 960 - 600 / 2,
                "y": start
            },
            "velocity": {
                "x": 0,
                "y": (end - start) / (timer / CONSTANTS["CANVAS_TICK"])
            },
            "timer": timer,
            "timerOpacity": False,
            "deleteOnTimeout": False
        })

        self.transition_scene = self.call(GetCurrentScene()).getName()
        self.call(SetCurrentScene("Shame Cube"))

        await asyncio.sleep(3 + timer / 1000)
        await self.cleanup()
        return
  async def async_execute(self):
    self.websocket_client = WebSocketClient(7004)
    await self.websocket_client.connect()

    self.sound_manager.play_sound(
      GRUNT_BIRTHDAY_PARTY.sound_file.path,
      sound_name=GRUNT_BIRTHDAY_PARTY.name,
      play_multiple=False,
      headphone=True,
      stream=True
    )

    for i in range(50):
      x = (i * 343) % 1920
      y = random.randint(-50, 50)
      vx = random.random() + random.random()
      vy = random.randint(5, 11) + random.random() + random.random()
      color = COLORS[i % 4]
      css = TEMPLATE_CSS % (random.randint(1, 360), color)

      await self.websocket_client.send({
        "type": "create",
        "id": f"confetti_{i}",
        "html": f"<div style='{css}'></div>",
        "position": {
          "x": x,
          "y": y
        },
        # Ensure that the confetti stays on screen until it drifts all the
        # way off.
        "timer": (((1080 - y) / vy) + 3) * CONSTANTS["CANVAS_TICK"],
        "timerOpacity": False,
        "velocity": {
          "x": vx,
          "y": vy
        }
      })

      await asyncio.sleep(0.015)


    await asyncio.sleep(2.5)
    await self.cleanup()
    return
    async def async_execute(self):
        self.websocket_client = WebSocketClient(7004)
        await self.websocket_client.connect()

        # 1. Randomize Color Correction Filter Settings
        # print(self.client.get_source_filter_by_name(CAMERA_SOURCE, CAMERA_COLOR_FILTER))
        gamma = get_random(GAMMA)
        contrast = get_random(CONTRAST)
        brightness = get_random(BRIGHTNESS)
        saturation = get_random(SATURATION)
        hue_shift = get_random(HUE_SHIFT)

        self.call(
            SetSourceFilterSettings(
                CAMERA_SOURCE, CAMERA_COLOR_FILTER, {
                    "gamma": gamma,
                    "contrast": contrast,
                    "brightness": brightness,
                    "saturation": saturation,
                    "hue_shift": hue_shift
                }))

        await asyncio.sleep(ONSET_DELAY)

        for current_tick in range(MAX_TICK):
            # Each tick we want to gradually move the camera filter settings back
            # towards the default value.
            scale = (MAX_TICK - current_tick) / (MAX_TICK)
            self.call(
                SetSourceFilterSettings(
                    CAMERA_SOURCE, CAMERA_COLOR_FILTER, {
                        "gamma": gamma * scale,
                        "contrast": contrast * scale,
                        "brightness": brightness * scale,
                        "saturation": saturation * scale,
                        "hue_shift": hue_shift * scale
                    }))
            await asyncio.sleep(TICK)

        self.cleanup()
示例#6
0
 async def notify_socket(self, page):
     socket = WebSocketClient(7009)
     await socket.connect()
     await socket.send({"sound_page": page})
     await socket.close()
示例#7
0
    async def async_execute(self):
        self.websocket_client = WebSocketClient(7004)
        await self.websocket_client.connect()

        # 1. Transition to the "just chatting" scene. This is a full screen view.
        self.transition_scene = self.call(GetCurrentScene()).getName()
        # I need both the preview and transition screens to be just chatting.
        self.call(SetCurrentScene(THE_TWITCH_META))
        self.call(SetCurrentScene(THE_TWITCH_META))

        # 2. Draw some math elements that move around randomly.
        for i in range(MAX_EQUATION_NUM + 1):
            await self.websocket_client.send({
                "type": "create",
                "id": f"equation_{i}",
                "html":
                f"<img src='/assets/images/eq{i}.png?v={random.random()}' />",
                "randomVelocity": True,
                "randomPosition": True,
                "timer": 5000
            })

        await asyncio.sleep(1)

        # 3. Zoom in the camera suddenly.
        self.initial_props = self.call(
            GetSceneItemProperties(CONSTANTS["CAMERA_SOURCE"],
                                   scene_name=THE_TWITCH_META))

        scale = {
            "x": self.initial_props.getScale()["x"],
            "y": self.initial_props.getScale()["y"]
        }
        crop = self.initial_props.getCrop()
        # The source sizes returned are UNSCALED!
        base_width = self.initial_props.getSourcewidth()
        base_height = self.initial_props.getSourceheight()
        initial_scaled_width = base_width * scale["x"]
        initial_scaled_height = base_height * scale["y"]

        # Set bounds to be the current size of the image.
        self.call(
            SetSceneItemProperties(CONSTANTS["CAMERA_SOURCE"],
                                   bounds={
                                       "type": "OBS_BOUNDS_STRETCH",
                                       "x": initial_scaled_width,
                                       "y": initial_scaled_height
                                   }))

        for _ in range(7):
            scale["x"] = scale["x"] + SCALE_INCREMENT
            scale["y"] = scale["y"] + SCALE_INCREMENT

            # The size of the source ignoring cropping / rescaling.
            scaled_height = base_height * scale["y"]
            scaled_width = base_width * scale["x"]

            crop_vertical = (scaled_height - initial_scaled_height) // 2
            crop_horizontal = (scaled_width - initial_scaled_width) // 2

            self.call(
                SetSceneItemProperties(CONSTANTS["CAMERA_SOURCE"],
                                       scale=scale,
                                       crop={
                                           "top": crop_vertical,
                                           "bottom": crop_vertical,
                                           "left": crop_horizontal,
                                           "right": crop_horizontal
                                       }))

            self.call(TransitionToProgram({"name": "Cut", "duration": 0}))

            await asyncio.sleep(0.001)

        await asyncio.sleep(2)
        await self.cleanup()