class

PointClickEngine::Scenes::BackgroundRenderer

Inherits Reference < Object

Manages background rendering and scaling for scenes

The BackgroundRenderer handles all background-related functionality including:

  • Background texture loading and management
  • Automatic scaling calculations
  • Camera-aware background positioning
  • Background rendering optimization

Constructors

new(scene_width : Int32, scene_height : Int32)
Source

Instance methods

background_offset

Background offset for centering

Source
background_offset=(background_offset : RL::Vector2)

Background offset for centering

Source
background_path

Path to the background image file

Source
background_path=(background_path : String | Nil)

Path to the background image file

Source
background_scale

Calculated background scale factor

Source
background_scale=(background_scale : Float32)

Calculated background scale factor

Source
background_texture

Background texture

Source
background_texture=(background_texture : RL::Texture2D | Nil)

Background texture

Source
covers_scene?

Checks if background covers the entire scene

Source
create_tiled_background(tile_texture : RL::Texture2D, tile_width : Int32, tile_height : Int32)

Creates a tiled background pattern

Source
draw(camera_offset : RL::Vector2, parallax_factor : Float32 = 1.0_f32)

Renders the background with camera offset

Draws the background texture with proper scaling and positioning, accounting for camera movement for parallax effects.

  • camera_offset : Current camera offset for scene scrolling
  • parallax_factor : Parallax factor (0.0 = no parallax, 1.0 = full parallax)
Source
draw_static

Draws background without camera effects (for UI backgrounds)

Source
draw_with_tint(camera_offset : RL::Vector2, tint : RL::Color, parallax_factor : Float32 = 1.0_f32)

Applies a color tint to the background

Source
get_scaled_size

Gets scaled background dimensions

Source
get_texture_size

Gets background texture dimensions

Source
get_visible_area(camera_offset : RL::Vector2, viewport_width : Int32, viewport_height : Int32) : RL::Rectangle

Gets the visible area of the background for the given camera position

Source
load_background(path : String)

Loads a background image from file

Loads the texture and calculates appropriate scaling and positioning based on scene dimensions and scaling mode.

  • path : File path to the background image
Source
load_background_from_texture(texture : RL::Texture2D)

Loads background from texture data

  • texture : Pre-loaded texture to use as background
Source
loaded?

Checks if background is loaded

Source
maintain_aspect_ratio

Whether to maintain aspect ratio when scaling

Source
maintain_aspect_ratio=(maintain_aspect_ratio : Bool)

Whether to maintain aspect ratio when scaling

Source
reload

Reloads background from the stored path

Source
scaling_mode
Source
scaling_mode=(scaling_mode : ScalingMode)
Source
scene_height
Source
scene_height=(scene_height : Int32)
Source
scene_width

Scene dimensions

Source
scene_width=(scene_width : Int32)

Scene dimensions

Source
set_scaling_mode(mode : ScalingMode)

Sets scaling mode and recalculates transform

Source
unload

Unloads background texture and frees memory

Source
update_scene_size(width : Int32, height : Int32)

Updates scene dimensions and recalculates scaling

Source

Nested types