added more dynamic sizing considerations
This commit is contained in:
@@ -6,10 +6,12 @@ import random
|
|||||||
direction_x = random.choice([-1, 1])
|
direction_x = random.choice([-1, 1])
|
||||||
direction_y = random.choice([-1, 1])
|
direction_y = random.choice([-1, 1])
|
||||||
|
|
||||||
|
video = obs.obs_video_info()
|
||||||
|
obs.obs_get_video_info(video)
|
||||||
|
print(video.base_height, video.base_width)
|
||||||
# Initialize global position
|
# Initialize global position
|
||||||
position_x = 1920/2
|
position_x = video.base_width/2
|
||||||
position_y = 1080/2
|
position_y = video.base_height/2
|
||||||
|
|
||||||
# Global variables holding the values of data settings / properties
|
# Global variables holding the values of data settings / properties
|
||||||
source_name = "Spaceship" # Name of the source to bounce
|
source_name = "Spaceship" # Name of the source to bounce
|
||||||
speed_x = 5.0 # Speed of movement in the X direction
|
speed_x = 5.0 # Speed of movement in the X direction
|
||||||
@@ -43,7 +45,7 @@ def get_scene_item_from_source(source):
|
|||||||
|
|
||||||
# Function to update position
|
# Function to update position
|
||||||
def update_position():
|
def update_position():
|
||||||
global position_x, position_y, direction_x, direction_y
|
global position_x, position_y, direction_x, direction_y, video
|
||||||
|
|
||||||
source = obs.obs_get_source_by_name(source_name)
|
source = obs.obs_get_source_by_name(source_name)
|
||||||
if source is None:
|
if source is None:
|
||||||
@@ -63,8 +65,8 @@ def update_position():
|
|||||||
width = (obs.obs_source_get_width(source) - source_crop.left - source_crop.right) * source_transform.scale.x
|
width = (obs.obs_source_get_width(source) - source_crop.left - source_crop.right) * source_transform.scale.x
|
||||||
height = (obs.obs_source_get_height(source) - source_crop.top - source_crop.bottom) * source_transform.scale.y
|
height = (obs.obs_source_get_height(source) - source_crop.top - source_crop.bottom) * source_transform.scale.y
|
||||||
#print(width, height)
|
#print(width, height)
|
||||||
canvas_width = 1920
|
canvas_width = video.base_width
|
||||||
canvas_height = 1080
|
canvas_height = video.base_height
|
||||||
#print(width, height, canvas_width, canvas_height)
|
#print(width, height, canvas_width, canvas_height)
|
||||||
# Calculate new position
|
# Calculate new position
|
||||||
position_x += direction_x * speed_x
|
position_x += direction_x * speed_x
|
||||||
|
|||||||
Reference in New Issue
Block a user