Verified Commit c2e2c609 authored by RobLoach's avatar RobLoach
Browse files

graphics: Add love.graphics.getDimensions()

parent ea290eff
......@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- [Semantic Versioning](https://semver.org/) checks
- Use `t.version = "0.18.0"` in `conf(t)` to specify which ChaiLove version you're targeting
- `love.graphics.getDimensions()`
### Updated
- `love.math.compress()` is now `love.data.compress()`
......
......@@ -255,6 +255,10 @@ int graphics::getHeight() {
return getScreen()->h;
}
Point graphics::getDimensions() {
return Point(getWidth(), getHeight());
}
graphics& graphics::circle(const std::string& drawmode, int x, int y, int radius) {
if (drawmode == "line") {
circleRGBA(getScreen(), x, y, radius, r, g, b, a);
......
......@@ -210,6 +210,16 @@ class graphics {
*/
int getHeight();
/**
* @brief Gets the width and height of the window.
*
* @see love.graphics.getWidth
* @see love.graphics.getHeight
*
* @return A Point refering the x and y size of the window.
*/
Point getDimensions();
/**
* @brief Draws a circle.
*
......
......@@ -54,7 +54,6 @@ float math::rad(float degress) {
return degress * pi / 180.0f;
}
float math::degrees(float rad) {
return rad * 180.0f / pi;
}
......
......@@ -200,6 +200,7 @@ script::script(const std::string& file) {
chai.add(fun(&graphics::ellipse), "ellipse");
chai.add(fun(&graphics::getWidth), "getWidth");
chai.add(fun(&graphics::getHeight), "getHeight");
chai.add(fun(&graphics::getDimensions), "getDimensions");
chai.add(fun(&graphics::circle), "circle");
chai.add(fun(&graphics::line), "line");
chai.add(fun(&graphics::newQuad), "newQuad");
......
......@@ -5,8 +5,10 @@
#include "SDL.h"
#include "config.h"
#include "libretro.h"
#include "Types/Graphics/Point.h"
using ::ChaiLove;
using love::Types::Graphics::Point;
using std::string;
namespace love {
......@@ -82,7 +84,7 @@ void window::showMessageBox(const std::string& msg, int frames) {
}
void window::showMessageBox(const std::string& msg) {
showMessageBox(msg, 4000);
showMessageBox(msg, 3500);
}
} // namespace love
......@@ -3,6 +3,9 @@
#include <string>
#include "config.h"
#include "Types/Graphics/Point.h"
using love::Types::Graphics::Point;
namespace love {
......
assert_equal(love.graphics.getWidth(), 800, "love.graphics.getWidth()")
assert_equal(love.graphics.getHeight(), 600, "love.graphics.getHeight()")
// getWidth() and getHeight()
var graphicWidth = love.graphics.getWidth()
var graphicHeight = love.graphics.getHeight()
assert_equal(graphicWidth, 640, "love.graphics.getWidth()")
assert_equal(graphicHeight, 500, "love.graphics.getHeight()")
// getDimensions()
var graphicSize = love.graphics.getDimensions()
assert_equal(graphicSize.x, graphicWidth, "love.graphics.getDimensions().x")
assert_equal(graphicSize.y, graphicHeight, "love.graphics.getDimensions().y")
// clear()
love.graphics.clear()
love.graphics.clear(233, 200, 100)
love.graphics.clear(233, 200, 100, 200)
// getDefaultFilter() and setDefaultFilter()
assert_equal(love.graphics.getDefaultFilter(), "linear", "love.graphics.getDefaultFilter()")
love.graphics.setDefaultFilter("nearest")
assert_equal(love.graphics.getDefaultFilter(), "nearest", "love.graphics.setDefaultFilter()")
......@@ -2,6 +2,8 @@ global failure = ""
def conf(t) {
t.console = true
t.window.width = 640
t.window.height = 500
}
def load() {
print("\n================================\n")
......
// getTitle()
assert_equal(love.window.getTitle(), "ChaiLove", "love.window.getTitle()")
// setTitle()
love.window.setTitle("ChaiLove Unit Testing")
assert_equal(love.window.getTitle(), "ChaiLove Unit Testing", "love.window.setTitle()")
// showMessageBox()
love.window.showMessageBox("Hello World!")
assert(true, "love.window.showMessageBox()")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment