Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-chailove
Commits
c2e2c609
Verified
Commit
c2e2c609
authored
Apr 02, 2018
by
RobLoach
Browse files
graphics: Add love.graphics.getDimensions()
parent
ea290eff
Changes
10
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
c2e2c609
...
...
@@ -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()`
...
...
src/love/graphics.cpp
View file @
c2e2c609
...
...
@@ -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
);
...
...
src/love/graphics.h
View file @
c2e2c609
...
...
@@ -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.
*
...
...
src/love/math.cpp
View file @
c2e2c609
...
...
@@ -54,7 +54,6 @@ float math::rad(float degress) {
return
degress
*
pi
/
180.0
f
;
}
float
math
::
degrees
(
float
rad
)
{
return
rad
*
180.0
f
/
pi
;
}
...
...
src/love/script.cpp
View file @
c2e2c609
...
...
@@ -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"
);
...
...
src/love/window.cpp
View file @
c2e2c609
...
...
@@ -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
,
40
00
);
showMessageBox
(
msg
,
35
00
);
}
}
// namespace love
src/love/window.h
View file @
c2e2c609
...
...
@@ -3,6 +3,9 @@
#include <string>
#include "config.h"
#include "Types/Graphics/Point.h"
using
love
::
Types
::
Graphics
::
Point
;
namespace
love
{
...
...
test/unittests/graphics.chai
View file @
c2e2c609
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()")
test/unittests/main.chai
View file @
c2e2c609
...
...
@@ -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")
...
...
test/unittests/window.chai
View file @
c2e2c609
// 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()")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment