0.0
No commit activity in last 3 years
No release in over 3 years
Vector-based shadows for circles and axis-aligned rectangles in the Gosu graphics library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10
~> 3.0

Runtime

~> 1.9
~> 0.8
 Project Readme

Gosu Lighting

Simple vector-based lighting for libgosu.

alt tag

How to use

$ gem install gosu_lighting

Include the Circle and Rectangle module into your own circle and rectangle classes. Your circle class MUST have x, y, and radius properties, and your rectangle class MUST have x, y, width, and height properties. Both your circle and rectangle classes must implement a draw method that takes a depth argument.

To draw circles and rectangles and everything with lighting and shadows, put it in the light source draw block and call the circle/rectangle draw_lit method with the light source instance, which is passed to the block for convenience.

Here's a trivial example:

require 'gosu'
require 'gosu_lighting'

class MyCircle < Struct.new(:x, :y, :radius)
  include GosuLghting::Circle

  def draw depth
    # your own drawing logic
    # use depth to make the object get 'shadowed' by other objects
  end
end

class MyRectangle < Struct.new(:x, :y, :width, :height)
  include GosuLghting::Rectangle

  def draw depth
    # your own drawing logic
  end
end

class MyGame < Gosu::Window
  def init
    @light_source = GosuLighting::Source.new x, y, radius
    @circle = MyCircle.new(...)
    @rectangle = MyRectangle.new(...)
  end

  def draw
    @light_source.draw do |ls|
      @circle.draw_lit ls
      @rectandle.draw_lit ls
    end
  end
end

Limitations

  1. Only handles circles and axis-aligned rectangles
  2. Only really works with one light source