replaced all crappy spaces with proper tabs

kept this in its own changeset so it doesn't interfere with real changes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1334 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-01-06 20:37:29 +00:00
parent 8431753ba3
commit 2f2fc5d4fa
56 changed files with 8094 additions and 8094 deletions

View file

@ -1,42 +1,42 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.all;
public import
dsfml.graphics.blendmode,
dsfml.graphics.color,
dsfml.graphics.font,
dsfml.graphics.idrawable,
dsfml.graphics.image,
dsfml.graphics.shader,
dsfml.graphics.rect,
dsfml.graphics.renderwindow,
dsfml.graphics.shape,
dsfml.graphics.sprite,
dsfml.graphics.text,
dsfml.graphics.textstyle,
dsfml.graphics.view;
dsfml.graphics.blendmode,
dsfml.graphics.color,
dsfml.graphics.font,
dsfml.graphics.idrawable,
dsfml.graphics.image,
dsfml.graphics.shader,
dsfml.graphics.rect,
dsfml.graphics.renderwindow,
dsfml.graphics.shape,
dsfml.graphics.sprite,
dsfml.graphics.text,
dsfml.graphics.textstyle,
dsfml.graphics.view;

View file

@ -1,38 +1,38 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.blendmode;
/**
* Enumerate the blending modes for drawable objects.
* Enumerate the blending modes for drawable objects.
*/
enum BlendMode
{
ALPHA, /// Pixel = Src * a + Dest * (1 - a)
ADD, /// Pixel = Src + Dest
ALPHA, /// Pixel = Src * a + Dest * (1 - a)
ADD, /// Pixel = Src + Dest
MULTIPLY, /// Pixel = Src * Dest
NONE /// No blending
NONE /// No blending
}

View file

@ -1,132 +1,132 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.color;
/**
* Color is an utility structure for manipulating colors
* Color is an utility structure for manipulating colors
*/
struct Color
{
ubyte r; /// Red component
ubyte g; /// Green component
ubyte b; /// Blue component
ubyte a = 255; /// Alpha (transparency) component
ubyte r; /// Red component
ubyte g; /// Green component
ubyte b; /// Blue component
ubyte a = 255; /// Alpha (transparency) component
/**
* Construct the color from its 4 RGBA components
*
* Params:
* r = Red component (0 .. 255)
* g = Green component (0 .. 255)
* b = Blue component (0 .. 255)
* a = Alpha component (0 .. 255) (255 by default)
*/
/**
* Construct the color from its 4 RGBA components
*
* Params:
* r = Red component (0 .. 255)
* g = Green component (0 .. 255)
* b = Blue component (0 .. 255)
* a = Alpha component (0 .. 255) (255 by default)
*/
/*
static Color opCall(ubyte r, ubyte g, ubyte b, ubyte a = 255)
static Color opCall(ubyte r, ubyte g, ubyte b, ubyte a = 255)
{
Color c;
c.r = r;
c.g = g;
c.b = b;
c.a = a;
return c;
c.r = r;
c.g = g;
c.b = b;
c.a = a;
return c;
}
*/
/**
* Operator == and != overload to compare two colors
*/
const bool opEquals(ref const(Color) color2)
{
return
(r == color2.r)
&& (g == color2.g)
&& (b == color2.b)
&& (a == color2.a);
}
/**
* Operator + overload to add two colors
*/
Color opAdd(Color color2)
{
ubyte r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
ubyte g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
ubyte b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
ubyte a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
return Color(r, g, b, a);
}
/**
* Operator == and != overload to compare two colors
*/
const bool opEquals(ref const(Color) color2)
{
return
(r == color2.r)
&& (g == color2.g)
&& (b == color2.b)
&& (a == color2.a);
}
/**
* Operator + overload to add two colors
*/
Color opAdd(Color color2)
{
ubyte r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
ubyte g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
ubyte b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
ubyte a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
return Color(r, g, b, a);
}
/**
* Operator += overload
*/
Color opAddAssign(Color color2)
{
this.r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
this.g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
this.b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
this.a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
return this;
}
/**
* Operator += overload
*/
Color opAddAssign(Color color2)
{
this.r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
this.g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
this.b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
this.a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
return this;
}
/**
* Operator * overload to modulate colors
*/
Color opMul(Color color2)
{
ubyte r = cast(ubyte) (this.r * color2.r / 255);
ubyte g = cast(ubyte) (this.g * color2.g / 255);
ubyte b = cast(ubyte) (this.b * color2.b / 255);
ubyte a = cast(ubyte) (this.a * color2.a / 255);
return Color(r, g, b, a);
}
/**
* Operator * overload to modulate colors
*/
Color opMul(Color color2)
{
ubyte r = cast(ubyte) (this.r * color2.r / 255);
ubyte g = cast(ubyte) (this.g * color2.g / 255);
ubyte b = cast(ubyte) (this.b * color2.b / 255);
ubyte a = cast(ubyte) (this.a * color2.a / 255);
return Color(r, g, b, a);
}
/**
* Operator *= overload
*/
Color opMulAssign(Color color2)
{
this.r = cast(ubyte) (this.r * color2.r / 255);
this.g = cast(ubyte) (this.g * color2.g / 255);
this.b = cast(ubyte) (this.b * color2.b / 255);
this.a = cast(ubyte) (this.a * color2.a / 255);
return this;
}
static const Color BLACK = {0, 0, 0}; /// Black predefined color
static const Color WHITE = {255, 255, 255}; /// White predefined color
static const Color RED = {255, 0, 0}; /// Red predefined color
static const Color GREEN = {0, 255, 0}; /// Green predefined color
static const Color BLUE = {0, 0, 255}; /// Blue predefined color
static const Color YELLOW = {255, 0, 255}; /// Yellow predefined color
static const Color MAGENTA = {255, 0, 255}; /// Magenta predefined color
static const Color CYAN = {0, 255, 255}; /// Cyan predefined color
/**
* Operator *= overload
*/
Color opMulAssign(Color color2)
{
this.r = cast(ubyte) (this.r * color2.r / 255);
this.g = cast(ubyte) (this.g * color2.g / 255);
this.b = cast(ubyte) (this.b * color2.b / 255);
this.a = cast(ubyte) (this.a * color2.a / 255);
return this;
}
static const Color BLACK = {0, 0, 0}; /// Black predefined color
static const Color WHITE = {255, 255, 255}; /// White predefined color
static const Color RED = {255, 0, 0}; /// Red predefined color
static const Color GREEN = {0, 255, 0}; /// Green predefined color
static const Color BLUE = {0, 0, 255}; /// Blue predefined color
static const Color YELLOW = {255, 0, 255}; /// Yellow predefined color
static const Color MAGENTA = {255, 0, 255}; /// Magenta predefined color
static const Color CYAN = {0, 255, 255}; /// Cyan predefined color
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.common;

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.drawableimpl;
@ -37,14 +37,14 @@ import dsfml.graphics.shader;
package
{
struct sfSprite{};
struct sfShape{};
struct sfText{};
struct sfSprite{};
struct sfShape{};
struct sfText{};
}
/*
* Package base class of all drawable.
* Provide implementation of IDrawable and functions aliases.
* Package base class of all drawable.
* Provide implementation of IDrawable and functions aliases.
*/
package class Drawableimpl(T) : DSFMLObject, IDrawable
{
@ -60,274 +60,274 @@ protected:
}
public:
void setX(float x)
{
sfDrawable_SetX(m_ptr, x);
}
void setX(float x)
{
sfDrawable_SetX(m_ptr, x);
}
void setY(float y)
{
sfDrawable_SetY(m_ptr, y);
}
void setY(float y)
{
sfDrawable_SetY(m_ptr, y);
}
void setPosition(float x, float y)
{
sfDrawable_SetPosition(m_ptr, x, y);
}
void setPosition(float x, float y)
{
sfDrawable_SetPosition(m_ptr, x, y);
}
void setPosition(Vector2f vec)
{
sfDrawable_SetPosition(m_ptr, vec.x, vec.y);
}
void setPosition(Vector2f vec)
{
sfDrawable_SetPosition(m_ptr, vec.x, vec.y);
}
void setScaleX(float scale)
{
if (scale > 0)
sfDrawable_SetScaleX(m_ptr, scale);
}
void setScaleY(float scale)
{
if (scale > 0)
sfDrawable_SetScaleY(m_ptr, scale);
}
void setScaleX(float scale)
{
if (scale > 0)
sfDrawable_SetScaleX(m_ptr, scale);
}
void setScaleY(float scale)
{
if (scale > 0)
sfDrawable_SetScaleY(m_ptr, scale);
}
void setScale(float scaleX, float scaleY)
{
if (scaleX > 0 && scaleY > 0)
sfDrawable_SetScale(m_ptr, scaleX, scaleY);
}
void setScale(float scaleX, float scaleY)
{
if (scaleX > 0 && scaleY > 0)
sfDrawable_SetScale(m_ptr, scaleX, scaleY);
}
void setScale(Vector2f scale)
{
if (scale.x > 0 && scale.y > 0)
sfDrawable_SetScale(m_ptr, scale.x, scale.y);
}
void setScale(Vector2f scale)
{
if (scale.x > 0 && scale.y > 0)
sfDrawable_SetScale(m_ptr, scale.x, scale.y);
}
void setOrigin(float originX, float originY)
{
sfDrawable_SetOrigin(m_ptr, originX, originY);
}
void setOrigin(float originX, float originY)
{
sfDrawable_SetOrigin(m_ptr, originX, originY);
}
void setOrigin(Vector2f origin)
{
sfDrawable_SetOrigin(m_ptr, origin.x, origin.y);
}
void setOrigin(Vector2f origin)
{
sfDrawable_SetOrigin(m_ptr, origin.x, origin.y);
}
void setRotation(float angle)
{
sfDrawable_SetRotation(m_ptr, angle);
}
void setRotation(float angle)
{
sfDrawable_SetRotation(m_ptr, angle);
}
void setColor(Color c)
{
sfDrawable_SetColor(m_ptr, c);
}
void setBlendMode(BlendMode mode)
void setColor(Color c)
{
sfDrawable_SetColor(m_ptr, c);
}
void setBlendMode(BlendMode mode)
{
sfDrawable_SetBlendMode(m_ptr, mode);
}
Vector2f getPosition()
{
return Vector2f(sfDrawable_GetX(m_ptr), sfDrawable_GetY(m_ptr));
}
Vector2f getPosition()
{
return Vector2f(sfDrawable_GetX(m_ptr), sfDrawable_GetY(m_ptr));
}
Vector2f getScale()
{
return Vector2f(sfDrawable_GetScaleX(m_ptr), sfDrawable_GetScaleY(m_ptr));
}
Vector2f getScale()
{
return Vector2f(sfDrawable_GetScaleX(m_ptr), sfDrawable_GetScaleY(m_ptr));
}
Vector2f getOrigin()
{
return Vector2f(sfDrawable_GetOriginX(m_ptr), sfDrawable_GetOriginY(m_ptr));
}
float getRotation()
{
return sfDrawable_GetRotation(m_ptr);
}
Vector2f getOrigin()
{
return Vector2f(sfDrawable_GetOriginX(m_ptr), sfDrawable_GetOriginY(m_ptr));
}
float getRotation()
{
return sfDrawable_GetRotation(m_ptr);
}
Color getColor()
{
return sfDrawable_GetColor(m_ptr);
}
Color getColor()
{
return sfDrawable_GetColor(m_ptr);
}
BlendMode getBlendMode()
BlendMode getBlendMode()
{
return cast(BlendMode)(sfDrawable_GetBlendMode(m_ptr));
}
void rotate(float angle)
{
sfDrawable_Rotate(m_ptr, angle);
}
void rotate(float angle)
{
sfDrawable_Rotate(m_ptr, angle);
}
void move(float offsetX, float offsetY)
{
sfDrawable_Move(m_ptr, offsetX, offsetY);
}
void move(float offsetX, float offsetY)
{
sfDrawable_Move(m_ptr, offsetX, offsetY);
}
void move(Vector2f offset)
{
sfDrawable_Move(m_ptr, offset.x, offset.y);
}
void move(Vector2f offset)
{
sfDrawable_Move(m_ptr, offset.x, offset.y);
}
void scale(float scaleX, float scaleY)
{
if (scaleX > 0 && scaleY > 0)
sfDrawable_SetScale(m_ptr, scaleX, scaleY);
}
void scale(float scaleX, float scaleY)
{
if (scaleX > 0 && scaleY > 0)
sfDrawable_SetScale(m_ptr, scaleX, scaleY);
}
void scale(Vector2f scale)
{
if (scale.x > 0 && scale.y > 0)
sfDrawable_SetScale(m_ptr, scale.x, scale.y);
}
Vector2f tranformToLocal(Vector2f point)
{
Vector2f ret;
sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y);
return ret;
}
void scale(Vector2f scale)
{
if (scale.x > 0 && scale.y > 0)
sfDrawable_SetScale(m_ptr, scale.x, scale.y);
}
Vector2f tranformToLocal(Vector2f point)
{
Vector2f ret;
sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y);
return ret;
}
Vector2f tranformToGlobal(Vector2f point)
{
Vector2f ret;
sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y);
return ret;
}
Vector2f tranformToGlobal(Vector2f point)
{
Vector2f ret;
sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y);
return ret;
}
void render(RenderWindow window)
{
sfRenderWindow_DrawThis(window.getNativePointer, m_ptr);
}
void renderWithShader(RenderWindow window, Shader shader)
{
sfRenderWindow_DrawThisWithShader(window.getNativePointer, m_ptr, shader.getNativePointer);
}
void render(RenderWindow window)
{
sfRenderWindow_DrawThis(window.getNativePointer, m_ptr);
}
void renderWithShader(RenderWindow window, Shader shader)
{
sfRenderWindow_DrawThisWithShader(window.getNativePointer, m_ptr, shader.getNativePointer);
}
override void dispose()
{
sfDrawable_Destroy(m_ptr);
}
override void dispose()
{
sfDrawable_Destroy(m_ptr);
}
private:
extern (C)
{
typedef void* function() pf_sfDrawable_Create;
typedef void function(void*) pf_sfDrawable_Destroy;
typedef void function(void*, float) pf_sfDrawable_SetX;
typedef void function(void*, float) pf_sfDrawable_SetY;
typedef void function(void*, float, float) pf_sfDrawable_SetPosition;
typedef void function(void*, float) pf_sfDrawable_SetScaleX;
typedef void function(void*, float) pf_sfDrawable_SetScaleY;
typedef void function(void*, float, float) pf_sfDrawable_SetScale;
typedef void function(void*, float) pf_sfDrawable_SetRotation;
typedef void function(void*, float, float) pf_sfDrawable_SetOrigin;
typedef void function(void*, Color) pf_sfDrawable_SetColor;
typedef void function(void*, BlendMode) pf_sfDrawable_SetBlendMode;
typedef float function(void*) pf_sfDrawable_GetX;
typedef float function(void*) pf_sfDrawable_GetY;
typedef float function(void*) pf_sfDrawable_GetScaleX;
typedef float function(void*) pf_sfDrawable_GetScaleY;
typedef float function(void*) pf_sfDrawable_GetRotation;
typedef float function(void*) pf_sfDrawable_GetOriginX;
typedef float function(void*) pf_sfDrawable_GetOriginY;
typedef Color function(void*) pf_sfDrawable_GetColor;
typedef BlendMode function(void*) pf_sfDrawable_GetBlendMode;
typedef void function(void*, float, float) pf_sfDrawable_Move;
typedef void function(void*, float, float) pf_sfDrawable_Scale;
typedef void function(void*, float) pf_sfDrawable_Rotate;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToLocal;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToGlobal;
typedef void function(void*, void*) pf_sfRenderWindow_DrawThis;
typedef void function(void*, void*, void*) pf_sfRenderWindow_DrawThisWithShader;
static pf_sfDrawable_Create sfDrawable_Create;
static pf_sfDrawable_Destroy sfDrawable_Destroy;
static pf_sfDrawable_SetX sfDrawable_SetX;
static pf_sfDrawable_SetY sfDrawable_SetY;
static pf_sfDrawable_SetPosition sfDrawable_SetPosition;
static pf_sfDrawable_SetScaleX sfDrawable_SetScaleX;
static pf_sfDrawable_SetScaleY sfDrawable_SetScaleY;
static pf_sfDrawable_SetScale sfDrawable_SetScale;
static pf_sfDrawable_SetRotation sfDrawable_SetRotation;
static pf_sfDrawable_SetOrigin sfDrawable_SetOrigin;
static pf_sfDrawable_SetColor sfDrawable_SetColor;
static pf_sfDrawable_SetBlendMode sfDrawable_SetBlendMode;
static pf_sfDrawable_GetX sfDrawable_GetX;
static pf_sfDrawable_GetY sfDrawable_GetY;
static pf_sfDrawable_GetScaleX sfDrawable_GetScaleX;
static pf_sfDrawable_GetScaleY sfDrawable_GetScaleY;
static pf_sfDrawable_GetRotation sfDrawable_GetRotation;
static pf_sfDrawable_GetOriginX sfDrawable_GetOriginX;
static pf_sfDrawable_GetOriginY sfDrawable_GetOriginY;
static pf_sfDrawable_GetColor sfDrawable_GetColor;
static pf_sfDrawable_GetBlendMode sfDrawable_GetBlendMode;
static pf_sfDrawable_Move sfDrawable_Move;
static pf_sfDrawable_Scale sfDrawable_Scale;
static pf_sfDrawable_Rotate sfDrawable_Rotate;
static pf_sfDrawable_TransformToLocal sfDrawable_TransformToLocal;
static pf_sfDrawable_TransformToGlobal sfDrawable_TransformToGlobal;
static pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis;
static pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader;
}
extern (C)
{
typedef void* function() pf_sfDrawable_Create;
typedef void function(void*) pf_sfDrawable_Destroy;
typedef void function(void*, float) pf_sfDrawable_SetX;
typedef void function(void*, float) pf_sfDrawable_SetY;
typedef void function(void*, float, float) pf_sfDrawable_SetPosition;
typedef void function(void*, float) pf_sfDrawable_SetScaleX;
typedef void function(void*, float) pf_sfDrawable_SetScaleY;
typedef void function(void*, float, float) pf_sfDrawable_SetScale;
typedef void function(void*, float) pf_sfDrawable_SetRotation;
typedef void function(void*, float, float) pf_sfDrawable_SetOrigin;
typedef void function(void*, Color) pf_sfDrawable_SetColor;
typedef void function(void*, BlendMode) pf_sfDrawable_SetBlendMode;
typedef float function(void*) pf_sfDrawable_GetX;
typedef float function(void*) pf_sfDrawable_GetY;
typedef float function(void*) pf_sfDrawable_GetScaleX;
typedef float function(void*) pf_sfDrawable_GetScaleY;
typedef float function(void*) pf_sfDrawable_GetRotation;
typedef float function(void*) pf_sfDrawable_GetOriginX;
typedef float function(void*) pf_sfDrawable_GetOriginY;
typedef Color function(void*) pf_sfDrawable_GetColor;
typedef BlendMode function(void*) pf_sfDrawable_GetBlendMode;
typedef void function(void*, float, float) pf_sfDrawable_Move;
typedef void function(void*, float, float) pf_sfDrawable_Scale;
typedef void function(void*, float) pf_sfDrawable_Rotate;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToLocal;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToGlobal;
typedef void function(void*, void*) pf_sfRenderWindow_DrawThis;
typedef void function(void*, void*, void*) pf_sfRenderWindow_DrawThisWithShader;
static pf_sfDrawable_Create sfDrawable_Create;
static pf_sfDrawable_Destroy sfDrawable_Destroy;
static pf_sfDrawable_SetX sfDrawable_SetX;
static pf_sfDrawable_SetY sfDrawable_SetY;
static pf_sfDrawable_SetPosition sfDrawable_SetPosition;
static pf_sfDrawable_SetScaleX sfDrawable_SetScaleX;
static pf_sfDrawable_SetScaleY sfDrawable_SetScaleY;
static pf_sfDrawable_SetScale sfDrawable_SetScale;
static pf_sfDrawable_SetRotation sfDrawable_SetRotation;
static pf_sfDrawable_SetOrigin sfDrawable_SetOrigin;
static pf_sfDrawable_SetColor sfDrawable_SetColor;
static pf_sfDrawable_SetBlendMode sfDrawable_SetBlendMode;
static pf_sfDrawable_GetX sfDrawable_GetX;
static pf_sfDrawable_GetY sfDrawable_GetY;
static pf_sfDrawable_GetScaleX sfDrawable_GetScaleX;
static pf_sfDrawable_GetScaleY sfDrawable_GetScaleY;
static pf_sfDrawable_GetRotation sfDrawable_GetRotation;
static pf_sfDrawable_GetOriginX sfDrawable_GetOriginX;
static pf_sfDrawable_GetOriginY sfDrawable_GetOriginY;
static pf_sfDrawable_GetColor sfDrawable_GetColor;
static pf_sfDrawable_GetBlendMode sfDrawable_GetBlendMode;
static pf_sfDrawable_Move sfDrawable_Move;
static pf_sfDrawable_Scale sfDrawable_Scale;
static pf_sfDrawable_Rotate sfDrawable_Rotate;
static pf_sfDrawable_TransformToLocal sfDrawable_TransformToLocal;
static pf_sfDrawable_TransformToGlobal sfDrawable_TransformToGlobal;
static pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis;
static pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-graphics-d");
else
DllLoader dll = DllLoader.load("csfml-graphics");
static if (is (T : sfSprite))
{
string symbol = "sfSprite";
}
else static if (is (T : sfText))
{
string symbol = "sfText";
}
else static if (is (T : sfShape))
{
string symbol = "sfShape";
}
sfDrawable_Create = cast(pf_sfDrawable_Create)dll.getSymbol(symbol ~ "_Create");
sfDrawable_Destroy = cast(pf_sfDrawable_Destroy)dll.getSymbol(symbol ~ "_Destroy");
sfDrawable_SetX = cast(pf_sfDrawable_SetX)dll.getSymbol(symbol ~ "_SetX");
sfDrawable_SetY = cast(pf_sfDrawable_SetY)dll.getSymbol(symbol ~ "_SetY");
sfDrawable_SetPosition = cast(pf_sfDrawable_SetPosition)dll.getSymbol(symbol ~ "_SetPosition");
sfDrawable_SetScaleX = cast(pf_sfDrawable_SetScaleX)dll.getSymbol(symbol ~ "_SetScaleX");
sfDrawable_SetScaleY = cast(pf_sfDrawable_SetScaleY)dll.getSymbol(symbol ~ "_SetScaleY");
sfDrawable_SetScale = cast(pf_sfDrawable_SetScale)dll.getSymbol(symbol ~ "_SetScale");
sfDrawable_SetRotation = cast(pf_sfDrawable_SetRotation)dll.getSymbol(symbol ~ "_SetRotation");
sfDrawable_SetOrigin = cast(pf_sfDrawable_SetOrigin)dll.getSymbol(symbol ~ "_SetOrigin");
sfDrawable_SetColor = cast(pf_sfDrawable_SetColor)dll.getSymbol(symbol ~ "_SetColor");
sfDrawable_SetBlendMode = cast(pf_sfDrawable_SetBlendMode)dll.getSymbol(symbol ~ "_SetBlendMode");
sfDrawable_GetX = cast(pf_sfDrawable_GetX)dll.getSymbol(symbol ~ "_GetX");
sfDrawable_GetY = cast(pf_sfDrawable_GetY)dll.getSymbol(symbol ~ "_GetY");
sfDrawable_GetScaleX = cast(pf_sfDrawable_GetScaleX)dll.getSymbol(symbol ~ "_GetScaleX");
sfDrawable_GetScaleY = cast(pf_sfDrawable_GetScaleY)dll.getSymbol(symbol ~ "_GetScaleX");
sfDrawable_GetRotation = cast(pf_sfDrawable_GetRotation)dll.getSymbol(symbol ~ "_GetRotation");
sfDrawable_GetOriginX = cast(pf_sfDrawable_GetOriginX)dll.getSymbol(symbol ~ "_GetOriginX");
sfDrawable_GetOriginY = cast(pf_sfDrawable_GetOriginY)dll.getSymbol(symbol ~ "_GetOriginY");
sfDrawable_GetColor = cast(pf_sfDrawable_GetColor)dll.getSymbol(symbol ~ "_GetColor");
sfDrawable_GetBlendMode = cast(pf_sfDrawable_GetBlendMode)dll.getSymbol(symbol ~ "_GetBlendMode");
sfDrawable_Move = cast(pf_sfDrawable_Move)dll.getSymbol(symbol ~ "_Move");
sfDrawable_Scale = cast(pf_sfDrawable_Scale)dll.getSymbol(symbol ~ "_Scale");
sfDrawable_Rotate = cast(pf_sfDrawable_Rotate)dll.getSymbol(symbol ~ "_Rotate");
sfDrawable_TransformToLocal = cast(pf_sfDrawable_TransformToLocal)dll.getSymbol(symbol ~ "_TransformToLocal");
sfDrawable_TransformToGlobal = cast(pf_sfDrawable_TransformToGlobal)dll.getSymbol(symbol ~ "_TransformToGlobal");
sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$]);
sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$] ~ "WithShader");
}
static if (is (T : sfSprite))
{
string symbol = "sfSprite";
}
else static if (is (T : sfText))
{
string symbol = "sfText";
}
else static if (is (T : sfShape))
{
string symbol = "sfShape";
}
sfDrawable_Create = cast(pf_sfDrawable_Create)dll.getSymbol(symbol ~ "_Create");
sfDrawable_Destroy = cast(pf_sfDrawable_Destroy)dll.getSymbol(symbol ~ "_Destroy");
sfDrawable_SetX = cast(pf_sfDrawable_SetX)dll.getSymbol(symbol ~ "_SetX");
sfDrawable_SetY = cast(pf_sfDrawable_SetY)dll.getSymbol(symbol ~ "_SetY");
sfDrawable_SetPosition = cast(pf_sfDrawable_SetPosition)dll.getSymbol(symbol ~ "_SetPosition");
sfDrawable_SetScaleX = cast(pf_sfDrawable_SetScaleX)dll.getSymbol(symbol ~ "_SetScaleX");
sfDrawable_SetScaleY = cast(pf_sfDrawable_SetScaleY)dll.getSymbol(symbol ~ "_SetScaleY");
sfDrawable_SetScale = cast(pf_sfDrawable_SetScale)dll.getSymbol(symbol ~ "_SetScale");
sfDrawable_SetRotation = cast(pf_sfDrawable_SetRotation)dll.getSymbol(symbol ~ "_SetRotation");
sfDrawable_SetOrigin = cast(pf_sfDrawable_SetOrigin)dll.getSymbol(symbol ~ "_SetOrigin");
sfDrawable_SetColor = cast(pf_sfDrawable_SetColor)dll.getSymbol(symbol ~ "_SetColor");
sfDrawable_SetBlendMode = cast(pf_sfDrawable_SetBlendMode)dll.getSymbol(symbol ~ "_SetBlendMode");
sfDrawable_GetX = cast(pf_sfDrawable_GetX)dll.getSymbol(symbol ~ "_GetX");
sfDrawable_GetY = cast(pf_sfDrawable_GetY)dll.getSymbol(symbol ~ "_GetY");
sfDrawable_GetScaleX = cast(pf_sfDrawable_GetScaleX)dll.getSymbol(symbol ~ "_GetScaleX");
sfDrawable_GetScaleY = cast(pf_sfDrawable_GetScaleY)dll.getSymbol(symbol ~ "_GetScaleX");
sfDrawable_GetRotation = cast(pf_sfDrawable_GetRotation)dll.getSymbol(symbol ~ "_GetRotation");
sfDrawable_GetOriginX = cast(pf_sfDrawable_GetOriginX)dll.getSymbol(symbol ~ "_GetOriginX");
sfDrawable_GetOriginY = cast(pf_sfDrawable_GetOriginY)dll.getSymbol(symbol ~ "_GetOriginY");
sfDrawable_GetColor = cast(pf_sfDrawable_GetColor)dll.getSymbol(symbol ~ "_GetColor");
sfDrawable_GetBlendMode = cast(pf_sfDrawable_GetBlendMode)dll.getSymbol(symbol ~ "_GetBlendMode");
sfDrawable_Move = cast(pf_sfDrawable_Move)dll.getSymbol(symbol ~ "_Move");
sfDrawable_Scale = cast(pf_sfDrawable_Scale)dll.getSymbol(symbol ~ "_Scale");
sfDrawable_Rotate = cast(pf_sfDrawable_Rotate)dll.getSymbol(symbol ~ "_Rotate");
sfDrawable_TransformToLocal = cast(pf_sfDrawable_TransformToLocal)dll.getSymbol(symbol ~ "_TransformToLocal");
sfDrawable_TransformToGlobal = cast(pf_sfDrawable_TransformToGlobal)dll.getSymbol(symbol ~ "_TransformToGlobal");
sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$]);
sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$] ~ "WithShader");
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.font;
@ -43,8 +43,8 @@ struct Glyph
}
/**
* Font is the low-level class for loading and
* manipulating character fonts.
* Font is the low-level class for loading and
* manipulating character fonts.
*/
class Font : DSFMLObject
{
@ -53,54 +53,54 @@ private:
public:
/**
* Get SFML default built-in font (Arial)
*/
static Font getDefaultFont()
{
if (s_default is null)
s_default = new Font(sfFont_GetDefaultFont());
return s_default;
}
* Get SFML default built-in font (Arial)
*/
static Font getDefaultFont()
{
if (s_default is null)
s_default = new Font(sfFont_GetDefaultFont());
return s_default;
}
/**
* construct the Font from a file
*
* Params:
* filename = font file to load
*/
this(string filename)
{
if (filename is null || filename.length == 0)
throw new LoadingException("LoadingException : Filename is invalid.");
/**
* construct the Font from a file
*
* Params:
* filename = font file to load
*/
this(string filename)
{
if (filename is null || filename.length == 0)
throw new LoadingException("LoadingException : Filename is invalid.");
super(sfFont_CreateFromFile(toStringz(filename)));
}
/**
* construct the Font from a file in memory
*
* Params:
* data = data to load
*/
this(ubyte[] data)
{
if (data is null || data.length == 0)
throw new Exception("LoadingException : Memory stream is invalid.");
super(sfFont_CreateFromFile(toStringz(filename)));
}
/**
* construct the Font from a file in memory
*
* Params:
* data = data to load
*/
this(ubyte[] data)
{
if (data is null || data.length == 0)
throw new Exception("LoadingException : Memory stream is invalid.");
super(sfFont_CreateFromMemory(data.ptr, data.length));
}
super(sfFont_CreateFromMemory(data.ptr, data.length));
}
override void dispose()
{
sfFont_Destroy(m_ptr);
}
override void dispose()
{
sfFont_Destroy(m_ptr);
}
package:
this(void* ptr)
{
super(ptr, true);
}
this(void* ptr)
{
super(ptr, true);
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.idrawable;
@ -35,259 +35,259 @@ import dsfml.graphics.color,
/**
* Interface for drawable object
*
* Shape, Text and Sprite implement IDrawable
* Interface for drawable object
*
* Shape, Text and Sprite implement IDrawable
*/
interface IDrawable
{
/**
* Set the left position of the object
*
* Params:
* x = New left coordinate
*/
void setX(float x);
/**
* Set the left position of the object
*
* Params:
* x = New left coordinate
*/
void setX(float x);
/**
* Set the top position of the object
*
* Params:
* y = New top coordinate
*/
void setY(float y);
/**
* Set the top position of the object
*
* Params:
* y = New top coordinate
*/
void setY(float y);
/**
* Set the position of the object
*
* Params:
* x = New left coordinate
* y = New top coordinate
*/
void setPosition(float x, float y);
/**
* Set the position of the object
*
* Params:
* vec = new position
*/
void setPosition(Vector2f vec);
/**
* Set the horizontal scale of the object
*
* Params:
* scale = New horizontal scale (Strictly positive)
*/
void setScaleX(float scale);
/**
* Set the vertical scale of the object
*
* Params:
* scale = New vertical scale (Strictly positive)
*/
void setScaleY(float scale);
/**
* Set the position of the object
*
* Params:
* x = New left coordinate
* y = New top coordinate
*/
void setPosition(float x, float y);
/**
* Set the position of the object
*
* Params:
* vec = new position
*/
void setPosition(Vector2f vec);
/**
* Set the horizontal scale of the object
*
* Params:
* scale = New horizontal scale (Strictly positive)
*/
void setScaleX(float scale);
/**
* Set the vertical scale of the object
*
* Params:
* scale = New vertical scale (Strictly positive)
*/
void setScaleY(float scale);
/**
* Set the scale of the object
*
* Params:
* scaleX = New horizontal scale
* scaleY = New vertical scale
*/
void setScale(float scaleX, float scaleY);
/**
* Set the scale of the object
*
* Params:
* scale = new scale
*/
void setScale(Vector2f scale);
/**
* Set the origin of the object, in coordinates relative to the
* top-left of the object (take 2 values).
* The default origin is (0, 0)
*
* Params:
* originX : X coordinate of the origin
* originY : Y coordinate of the origin
*/
void setOrigin(float originX, float originY);
/**
* Set the scale of the object
*
* Params:
* scaleX = New horizontal scale
* scaleY = New vertical scale
*/
void setScale(float scaleX, float scaleY);
/**
* Set the scale of the object
*
* Params:
* scale = new scale
*/
void setScale(Vector2f scale);
/**
* Set the origin of the object, in coordinates relative to the
* top-left of the object (take 2 values).
* The default origin is (0, 0)
*
* Params:
* originX : X coordinate of the origin
* originY : Y coordinate of the origin
*/
void setOrigin(float originX, float originY);
/**
* Set the origin of the object, in coordinates relative to the
* top-left of the object (take a 2D vector).
* The default origin is (0, 0)
*
* Params:
* origin : New origin
*/
void setOrigin(Vector2f origin);
/**
* Set the origin of the object, in coordinates relative to the
* top-left of the object (take a 2D vector).
* The default origin is (0, 0)
*
* Params:
* origin : New origin
*/
void setOrigin(Vector2f origin);
/**
* Set the rotation of the object
*
* Params:
* angle = Angle of rotation, in degree
*/
void setRotation(float angle);
/**
* Set the color
*
* Params:
* c = New color
*/
void setColor(Color c);
/**
* Set the blending mode for the object.
* The default blend mode is Blend.Alpha
*
* Params:
* mode = New blending mode
*/
void setBlendMode(BlendMode mode);
/**
* Set the rotation of the object
*
* Params:
* angle = Angle of rotation, in degree
*/
void setRotation(float angle);
/**
* Set the color
*
* Params:
* c = New color
*/
void setColor(Color c);
/**
* Set the blending mode for the object.
* The default blend mode is Blend.Alpha
*
* Params:
* mode = New blending mode
*/
void setBlendMode(BlendMode mode);
/**
* Get the position of the object
*
* Returns:
* Current position
*
*/
Vector2f getPosition();
/**
* Get the position of the object
*
* Returns:
* Current position
*
*/
Vector2f getPosition();
/**
* Get the current scale of the object
*
* Returns:
* Current scale
*/
Vector2f getScale();
/**
* Get the origin of the object
*
* Returns:
* Current position of the origin
*
*/
Vector2f getOrigin();
/**
* Get the rotation angle of the object
*
* Returns:
* Angle of rotation, in degree
*/
float getRotation();
/**
* Get the color of the string
*
* Returns:
* Current color
*/
Color getColor();
/**
* Get the current scale of the object
*
* Returns:
* Current scale
*/
Vector2f getScale();
/**
* Get the origin of the object
*
* Returns:
* Current position of the origin
*
*/
Vector2f getOrigin();
/**
* Get the rotation angle of the object
*
* Returns:
* Angle of rotation, in degree
*/
float getRotation();
/**
* Get the color of the string
*
* Returns:
* Current color
*/
Color getColor();
/**
* Get the current blending mode
*
* Returns:
* Current blending mode
*/
BlendMode getBlendMode();
/**
* Get the current blending mode
*
* Returns:
* Current blending mode
*/
BlendMode getBlendMode();
/**
* Rotate the object
* Angle is added to the current orientation of the objet
*
* Params:
* angle = Angle of rotation in degree
*/
void rotate(float angle);
/**
* Rotate the object
* Angle is added to the current orientation of the objet
*
* Params:
* angle = Angle of rotation in degree
*/
void rotate(float angle);
/**
* Move the object
* New offset is added to object current position
*
* Params:
* offsetX = Offset on the X axis
* offsetY = Offset on the Y axis
*/
void move(float offsetX, float offsetY);
/**
* Move the object
* New offset is added to object current position
*
* Params:
* offset = Amount of units to move the object of
*/
void move(Vector2f offset);
/**
* Move the object
* New offset is added to object current position
*
* Params:
* offsetX = Offset on the X axis
* offsetY = Offset on the Y axis
*/
void move(float offsetX, float offsetY);
/**
* Move the object
* New offset is added to object current position
*
* Params:
* offset = Amount of units to move the object of
*/
void move(Vector2f offset);
/**
* Set the scale of the object
*
* Params:
* scaleX = New horizontal scale (Strictly positive)
* scaleY = New vertical scale (Strictly positive)
*/
void scale(float scaleX, float scaleY);
/**
* Scale the object (take a 2D vector)
*
* Params:
* factor = Scaling factors (both values must be strictly positive)
*/
void scale(Vector2f factor);
/**
* Transform a point from global coordinates into local coordinates
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
*
* Params:
* point = Point to transform
*
* Returns:
* Transformed point
*/
Vector2f tranformToLocal(Vector2f point);
/**
* Set the scale of the object
*
* Params:
* scaleX = New horizontal scale (Strictly positive)
* scaleY = New vertical scale (Strictly positive)
*/
void scale(float scaleX, float scaleY);
/**
* Scale the object (take a 2D vector)
*
* Params:
* factor = Scaling factors (both values must be strictly positive)
*/
void scale(Vector2f factor);
/**
* Transform a point from global coordinates into local coordinates
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
*
* Params:
* point = Point to transform
*
* Returns:
* Transformed point
*/
Vector2f tranformToLocal(Vector2f point);
/**
* Transform a point from local coordinates into global coordinates
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
*
* Params:
* point = Point to transform
*
* Returns:
* Transformed point
*/
Vector2f tranformToGlobal(Vector2f point);
/**
* Render the specific geometry of the object
*
* Params:
* window = Target into which render the object
*/
void render(RenderWindow window);
/**
* Render the specific geometry of the object with a shader
*
* Params:
* window = Render target
* shader = Shader to use
*/
void renderWithShader(RenderWindow window, Shader shader);
/**
* Transform a point from local coordinates into global coordinates
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
*
* Params:
* point = Point to transform
*
* Returns:
* Transformed point
*/
Vector2f tranformToGlobal(Vector2f point);
/**
* Render the specific geometry of the object
*
* Params:
* window = Target into which render the object
*/
void render(RenderWindow window);
/**
* Render the specific geometry of the object with a shader
*
* Params:
* window = Render target
* shader = Shader to use
*/
void renderWithShader(RenderWindow window, Shader shader);
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
@ -37,331 +37,331 @@ import dsfml.system.common,
/**
* Image is the low-level class for loading and
* manipulating images
* Image is the low-level class for loading and
* manipulating images
*/
class Image : DSFMLObject
{
/**
* Default constructor
*/
this()
/**
* Default constructor
*/
this()
{
super(sfImage_Create());
}
/**
* Construct an empty image
*
* Params:
* width = Image width
* height = Image height
* col = Image color (black by default)
*/
this(uint width, uint height, Color col = Color.BLACK)
/**
* Construct an empty image
*
* Params:
* width = Image width
* height = Image height
* col = Image color (black by default)
*/
this(uint width, uint height, Color col = Color.BLACK)
{
super(sfImage_CreateFromColor(width, height, col));
}
/**
* Construct the image from a file
*
* Params:
* filename = Path of the image file to load
*
* Throws:
* LoadingException if filename is empty or null.
*/
this(string filename)
/**
* Construct the image from a file
*
* Params:
* filename = Path of the image file to load
*
* Throws:
* LoadingException if filename is empty or null.
*/
this(string filename)
{
if (filename is null || filename.length == 0)
throw new LoadingException("LoadingException : Filename is invalid.");
if (filename is null || filename.length == 0)
throw new LoadingException("LoadingException : Filename is invalid.");
super(sfImage_CreateFromFile(toStringz(filename)));
}
/**
* Construct the image from a file in memory
*
* Params:
* data = array of data in memory
* Throws:
* LoadingException if data is empty or null.
*/
this(ubyte[] data)
/**
* Construct the image from a file in memory
*
* Params:
* data = array of data in memory
* Throws:
* LoadingException if data is empty or null.
*/
this(ubyte[] data)
{
if (data is null || data.length == 0)
throw new LoadingException("LoadingException : Memory stream is invalid.");
if (data is null || data.length == 0)
throw new LoadingException("LoadingException : Memory stream is invalid.");
super(sfImage_CreateFromMemory(data.ptr, data.length));
}
/**
* Construct the image directly from an array of pixels
*
* Params:
* width = Image width
* height = Image height
* data = array of pixels in memory (assumed format is RGBA)
*
* Throws:
* LoadingException if data length doesn't match Width * Height * 4
*/
this(uint width, uint height, ubyte[] data)
/**
* Construct the image directly from an array of pixels
*
* Params:
* width = Image width
* height = Image height
* data = array of pixels in memory (assumed format is RGBA)
*
* Throws:
* LoadingException if data length doesn't match Width * Height * 4
*/
this(uint width, uint height, ubyte[] data)
{
if (width * height * 4 != data.length)
throw new LoadingException("LoadingException : Pixels array length doesn't match the specified size.");
if (width * height * 4 != data.length)
throw new LoadingException("LoadingException : Pixels array length doesn't match the specified size.");
super(sfImage_CreateFromPixels(width, height, data.ptr));
}
override void dispose()
override void dispose()
{
sfImage_Destroy(m_ptr);
}
/**
* Save the content of the image to a file
*
* Params:
* filename = Path of the file to save (overwritten if already exist)
*
* Returns:
* True if saving was successful
*/
bool saveToFile(string filename)
/**
* Save the content of the image to a file
*
* Params:
* filename = Path of the file to save (overwritten if already exist)
*
* Returns:
* True if saving was successful
*/
bool saveToFile(string filename)
{
return cast(bool)sfImage_SaveToFile(m_ptr, toStringz(filename));
}
/**
* Create an empty image
*
* Params:
* width = Image width
* height = Image height
* col = Image color (black by default)
*
* Returns:
* True if creation was successful
*/
bool create(uint width, uint height, Color col = Color.BLACK)
/**
* Create an empty image
*
* Params:
* width = Image width
* height = Image height
* col = Image color (black by default)
*
* Returns:
* True if creation was successful
*/
bool create(uint width, uint height, Color col = Color.BLACK)
{
m_ptr = sfImage_CreateFromColor(width, height, col);
return (m_ptr !is null);
}
/**
* Create transparency mask from a specified colorkey
*
* Params:
* colorKey = Color to become transparent
* alpha = Alpha value to use for transparent pixels (0 by default)
*/
void createMaskFromColor(Color colorKey, ubyte alpha = 0)
/**
* Create transparency mask from a specified colorkey
*
* Params:
* colorKey = Color to become transparent
* alpha = Alpha value to use for transparent pixels (0 by default)
*/
void createMaskFromColor(Color colorKey, ubyte alpha = 0)
{
sfImage_CreateMaskFromColor(m_ptr, colorKey, alpha);
}
// /**
// * Create the image from the current contents of the
// * given window
// *
// * Params:
// * window = Window to capture
// * sourceRect = Sub-rectangle of the screen to copy (empty by default - entire image)
// *
// * Returns:
// * True if copy was successful
// */
// void copyScreen(RenderWindow window, IntRect sourceRect = new IntRect())
// {
// return cast(bool)sfImage_CopyScreen(m_ptr, window.getNativePointer, sourceRect.toCIntRect());
// }
/**
* Copy pixels from another image onto this one.
* This function does a slow pixel copy and should only
* be used at initialization time
*
* Params:
* source = Source image to copy
* destX = X coordinate of the destination position
* destY = Y coordinate of the destination position
* sourceRect = Sub-rectangle of the source image to copy
*/
void copy(Image source, uint destX, uint destY, IntRect sourceRect = new IntRect())
{
sfImage_Copy(m_ptr, source.getNativePointer, destX, destY, sourceRect.toCIntRect());
}
// /**
// * Create the image from the current contents of the
// * given window
// *
// * Params:
// * window = Window to capture
// * sourceRect = Sub-rectangle of the screen to copy (empty by default - entire image)
// *
// * Returns:
// * True if copy was successful
// */
// void copyScreen(RenderWindow window, IntRect sourceRect = new IntRect())
// {
// return cast(bool)sfImage_CopyScreen(m_ptr, window.getNativePointer, sourceRect.toCIntRect());
// }
/**
* Copy pixels from another image onto this one.
* This function does a slow pixel copy and should only
* be used at initialization time
*
* Params:
* source = Source image to copy
* destX = X coordinate of the destination position
* destY = Y coordinate of the destination position
* sourceRect = Sub-rectangle of the source image to copy
*/
void copy(Image source, uint destX, uint destY, IntRect sourceRect = new IntRect())
{
sfImage_Copy(m_ptr, source.getNativePointer, destX, destY, sourceRect.toCIntRect());
}
/**
* Change the color of a pixel
* Don't forget to call Update when you end modifying pixels
*
* Params:
* x = X coordinate of pixel in the image
* y = Y coordinate of pixel in the image
* col = New color for pixel (X, Y)
*/
void setPixel(uint x, uint y, Color col)
/**
* Change the color of a pixel
* Don't forget to call Update when you end modifying pixels
*
* Params:
* x = X coordinate of pixel in the image
* y = Y coordinate of pixel in the image
* col = New color for pixel (X, Y)
*/
void setPixel(uint x, uint y, Color col)
{
sfImage_SetPixel(m_ptr, x, y, col);
}
/**
* Get a pixel from the image
*
* Params:
* x = X coordinate of pixel in the image
* y = Y coordinate of pixel in the image
*
* Returns:
* Color of pixel (x, y)
*/
Color getPixel(uint x, uint y)
/**
* Get a pixel from the image
*
* Params:
* x = X coordinate of pixel in the image
* y = Y coordinate of pixel in the image
*
* Returns:
* Color of pixel (x, y)
*/
Color getPixel(uint x, uint y)
{
return sfImage_GetPixel(m_ptr, x, y);
}
/**
* Get an array of pixels (8 bits integers RGBA)
* Array size is GetWidth() x GetHeight() x 4
* This array becomes invalid if you reload or resize the image
*
* Returns:
* array of pixels
*/
ubyte[] getPixelsArray()
/**
* Get an array of pixels (8 bits integers RGBA)
* Array size is GetWidth() x GetHeight() x 4
* This array becomes invalid if you reload or resize the image
*
* Returns:
* array of pixels
*/
ubyte[] getPixelsArray()
{
return sfImage_GetPixelsPtr(m_ptr)[0..getWidth() * getHeight() * 4];
}
/**
* Bind the image for rendering
*/
void bind()
/**
* Bind the image for rendering
*/
void bind()
{
sfImage_Bind(m_ptr);
}
/**
* Enable or disable image smooth filter.
* This parameter is enabled by default
*
* Params:
* smooth = True to enable smoothing filter, false to disable it
*/
void setSmooth(bool smooth)
/**
* Enable or disable image smooth filter.
* This parameter is enabled by default
*
* Params:
* smooth = True to enable smoothing filter, false to disable it
*/
void setSmooth(bool smooth)
{
sfImage_SetSmooth(m_ptr, smooth);
}
/**
* Return the width of the image
*
* Returns:
* Width in pixels
*/
uint getWidth()
/**
* Return the width of the image
*
* Returns:
* Width in pixels
*/
uint getWidth()
{
return sfImage_GetWidth(m_ptr);
}
/**
* Return the height of the image
*
* Returns:
* Height in pixels
*/
uint getHeight()
/**
* Return the height of the image
*
* Returns:
* Height in pixels
*/
uint getHeight()
{
return sfImage_GetHeight(m_ptr);
}
/**
* Tells whether the smooth filtering is enabled or not
*
* Returns:
* True if image smoothing is enabled
*/
bool isSmooth()
{
return cast(bool)sfImage_IsSmooth(m_ptr);
}
/**
* Tells whether the smooth filtering is enabled or not
*
* Returns:
* True if image smoothing is enabled
*/
bool isSmooth()
{
return cast(bool)sfImage_IsSmooth(m_ptr);
}
package:
this(void* ptr)
{
super(ptr);
}
this(void* ptr)
{
super(ptr);
}
private:
extern (C)
{
typedef void* function() pf_sfImage_Create;
typedef void* function(uint, uint, Color) pf_sfImage_CreateFromColor;
typedef void* function(uint, uint, ubyte*) pf_sfImage_CreateFromPixels;
typedef void* function(cchar*) pf_sfImage_CreateFromFile;
typedef void* function(ubyte* ,size_t) pf_sfImage_CreateFromMemory;
typedef void function(void*) pf_sfImage_Destroy;
typedef int function(void*, cchar*) pf_sfImage_SaveToFile;
typedef void function(void*, Color, ubyte) pf_sfImage_CreateMaskFromColor;
typedef int function(void*, void*, sfIntRect) pf_sfImage_CopyScreen;
typedef void function(void*, void*, uint, uint, sfIntRect) pf_sfImage_Copy;
typedef void function(void*, uint, uint, Color) pf_sfImage_SetPixel;
typedef Color function(void*, uint, uint) pf_sfImage_GetPixel;
typedef ubyte* function(void*) pf_sfImage_GetPixelsPtr;
typedef void function(void*) pf_sfImage_Bind;
typedef void function(void*, int) pf_sfImage_SetSmooth;
typedef uint function(void*) pf_sfImage_GetWidth;
typedef uint function(void*) pf_sfImage_GetHeight;
typedef int function(void*) pf_sfImage_IsSmooth;
static pf_sfImage_Create sfImage_Create;
static pf_sfImage_CreateFromColor sfImage_CreateFromColor;
static pf_sfImage_CreateFromPixels sfImage_CreateFromPixels;
static pf_sfImage_CreateFromFile sfImage_CreateFromFile;
static pf_sfImage_CreateFromMemory sfImage_CreateFromMemory;
static pf_sfImage_Destroy sfImage_Destroy;
static pf_sfImage_SaveToFile sfImage_SaveToFile;
static pf_sfImage_CreateMaskFromColor sfImage_CreateMaskFromColor;
static pf_sfImage_CopyScreen sfImage_CopyScreen;
static pf_sfImage_Copy sfImage_Copy;
static pf_sfImage_SetPixel sfImage_SetPixel;
static pf_sfImage_GetPixel sfImage_GetPixel;
static pf_sfImage_GetPixelsPtr sfImage_GetPixelsPtr;
static pf_sfImage_Bind sfImage_Bind;
static pf_sfImage_SetSmooth sfImage_SetSmooth;
static pf_sfImage_GetWidth sfImage_GetWidth;
static pf_sfImage_GetHeight sfImage_GetHeight;
static pf_sfImage_IsSmooth sfImage_IsSmooth;
}
extern (C)
{
typedef void* function() pf_sfImage_Create;
typedef void* function(uint, uint, Color) pf_sfImage_CreateFromColor;
typedef void* function(uint, uint, ubyte*) pf_sfImage_CreateFromPixels;
typedef void* function(cchar*) pf_sfImage_CreateFromFile;
typedef void* function(ubyte* ,size_t) pf_sfImage_CreateFromMemory;
typedef void function(void*) pf_sfImage_Destroy;
typedef int function(void*, cchar*) pf_sfImage_SaveToFile;
typedef void function(void*, Color, ubyte) pf_sfImage_CreateMaskFromColor;
typedef int function(void*, void*, sfIntRect) pf_sfImage_CopyScreen;
typedef void function(void*, void*, uint, uint, sfIntRect) pf_sfImage_Copy;
typedef void function(void*, uint, uint, Color) pf_sfImage_SetPixel;
typedef Color function(void*, uint, uint) pf_sfImage_GetPixel;
typedef ubyte* function(void*) pf_sfImage_GetPixelsPtr;
typedef void function(void*) pf_sfImage_Bind;
typedef void function(void*, int) pf_sfImage_SetSmooth;
typedef uint function(void*) pf_sfImage_GetWidth;
typedef uint function(void*) pf_sfImage_GetHeight;
typedef int function(void*) pf_sfImage_IsSmooth;
static pf_sfImage_Create sfImage_Create;
static pf_sfImage_CreateFromColor sfImage_CreateFromColor;
static pf_sfImage_CreateFromPixels sfImage_CreateFromPixels;
static pf_sfImage_CreateFromFile sfImage_CreateFromFile;
static pf_sfImage_CreateFromMemory sfImage_CreateFromMemory;
static pf_sfImage_Destroy sfImage_Destroy;
static pf_sfImage_SaveToFile sfImage_SaveToFile;
static pf_sfImage_CreateMaskFromColor sfImage_CreateMaskFromColor;
static pf_sfImage_CopyScreen sfImage_CopyScreen;
static pf_sfImage_Copy sfImage_Copy;
static pf_sfImage_SetPixel sfImage_SetPixel;
static pf_sfImage_GetPixel sfImage_GetPixel;
static pf_sfImage_GetPixelsPtr sfImage_GetPixelsPtr;
static pf_sfImage_Bind sfImage_Bind;
static pf_sfImage_SetSmooth sfImage_SetSmooth;
static pf_sfImage_GetWidth sfImage_GetWidth;
static pf_sfImage_GetHeight sfImage_GetHeight;
static pf_sfImage_IsSmooth sfImage_IsSmooth;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-graphics-d");
else
DllLoader dll = DllLoader.load("csfml-graphics");
sfImage_Create = cast(pf_sfImage_Create)dll.getSymbol("sfImage_Create");
sfImage_CreateFromColor = cast(pf_sfImage_CreateFromColor)dll.getSymbol("sfImage_CreateFromColor");
sfImage_CreateFromPixels = cast(pf_sfImage_CreateFromPixels)dll.getSymbol("sfImage_CreateFromPixels");
sfImage_CreateFromFile = cast(pf_sfImage_CreateFromFile)dll.getSymbol("sfImage_CreateFromFile");
sfImage_CreateFromMemory = cast(pf_sfImage_CreateFromMemory)dll.getSymbol("sfImage_CreateFromMemory");
sfImage_Destroy = cast(pf_sfImage_Destroy)dll.getSymbol("sfImage_Destroy");
sfImage_SaveToFile = cast(pf_sfImage_SaveToFile)dll.getSymbol("sfImage_SaveToFile");
sfImage_CreateMaskFromColor = cast(pf_sfImage_CreateMaskFromColor)dll.getSymbol("sfImage_CreateMaskFromColor");
sfImage_CopyScreen = cast(pf_sfImage_CopyScreen)dll.getSymbol("sfImage_CopyScreen");
sfImage_Copy = cast(pf_sfImage_Copy)dll.getSymbol("sfImage_Copy");
sfImage_SetPixel = cast(pf_sfImage_SetPixel)dll.getSymbol("sfImage_SetPixel");
sfImage_GetPixel = cast(pf_sfImage_GetPixel)dll.getSymbol("sfImage_GetPixel");
sfImage_GetPixelsPtr = cast(pf_sfImage_GetPixelsPtr)dll.getSymbol("sfImage_GetPixelsPtr");
sfImage_Bind = cast(pf_sfImage_Bind)dll.getSymbol("sfImage_Bind");
sfImage_SetSmooth = cast(pf_sfImage_SetSmooth)dll.getSymbol("sfImage_SetSmooth");
sfImage_GetWidth = cast(pf_sfImage_GetWidth)dll.getSymbol("sfImage_GetWidth");
sfImage_GetHeight = cast(pf_sfImage_GetHeight)dll.getSymbol("sfImage_GetHeight");
sfImage_IsSmooth = cast(pf_sfImage_IsSmooth)dll.getSymbol("sfImage_IsSmooth");
}
sfImage_Create = cast(pf_sfImage_Create)dll.getSymbol("sfImage_Create");
sfImage_CreateFromColor = cast(pf_sfImage_CreateFromColor)dll.getSymbol("sfImage_CreateFromColor");
sfImage_CreateFromPixels = cast(pf_sfImage_CreateFromPixels)dll.getSymbol("sfImage_CreateFromPixels");
sfImage_CreateFromFile = cast(pf_sfImage_CreateFromFile)dll.getSymbol("sfImage_CreateFromFile");
sfImage_CreateFromMemory = cast(pf_sfImage_CreateFromMemory)dll.getSymbol("sfImage_CreateFromMemory");
sfImage_Destroy = cast(pf_sfImage_Destroy)dll.getSymbol("sfImage_Destroy");
sfImage_SaveToFile = cast(pf_sfImage_SaveToFile)dll.getSymbol("sfImage_SaveToFile");
sfImage_CreateMaskFromColor = cast(pf_sfImage_CreateMaskFromColor)dll.getSymbol("sfImage_CreateMaskFromColor");
sfImage_CopyScreen = cast(pf_sfImage_CopyScreen)dll.getSymbol("sfImage_CopyScreen");
sfImage_Copy = cast(pf_sfImage_Copy)dll.getSymbol("sfImage_Copy");
sfImage_SetPixel = cast(pf_sfImage_SetPixel)dll.getSymbol("sfImage_SetPixel");
sfImage_GetPixel = cast(pf_sfImage_GetPixel)dll.getSymbol("sfImage_GetPixel");
sfImage_GetPixelsPtr = cast(pf_sfImage_GetPixelsPtr)dll.getSymbol("sfImage_GetPixelsPtr");
sfImage_Bind = cast(pf_sfImage_Bind)dll.getSymbol("sfImage_Bind");
sfImage_SetSmooth = cast(pf_sfImage_SetSmooth)dll.getSymbol("sfImage_SetSmooth");
sfImage_GetWidth = cast(pf_sfImage_GetWidth)dll.getSymbol("sfImage_GetWidth");
sfImage_GetHeight = cast(pf_sfImage_GetHeight)dll.getSymbol("sfImage_GetHeight");
sfImage_IsSmooth = cast(pf_sfImage_IsSmooth)dll.getSymbol("sfImage_IsSmooth");
}
}

View file

@ -1,287 +1,287 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.rect;
struct sfFloatRect
{
float Left;
float Top;
float Right;
float Bottom;
float Left;
float Top;
float Right;
float Bottom;
}
struct sfIntRect
{
int Left;
int Top;
int Right;
int Bottom;
int Left;
int Top;
int Right;
int Bottom;
}
version (Tango)
{
import tango.core.Traits;
import tango.core.Traits;
}
else
{
template isIntegerType(T)
{
const bool isIntegerType =
is (T == byte) ||
is (T == short) ||
is (T == int) ||
is (T == long);
}
template isIntegerType(T)
{
const bool isIntegerType =
is (T == byte) ||
is (T == short) ||
is (T == int) ||
is (T == long);
}
template isRealType(T)
{
const bool isRealType =
is (T == float) ||
is (T == double) ||
is (T == real);
}
}
template isRealType(T)
{
const bool isRealType =
is (T == float) ||
is (T == double) ||
is (T == real);
}
}
/**
* Rect is an utility class for manipulating rectangles.
* Template parameter defines the type of coordinates (integer float, ...)
* Rect is an utility class for manipulating rectangles.
* Template parameter defines the type of coordinates (integer float, ...)
*/
class Rect (T)
{
private:
T m_Left; // Left coordinate of the rectangle
T m_Top; // Top coordinate of the rectangle
T m_Right; // Right coordinate of the rectangle
T m_Bottom; // Bottom coordinate of the rectangle
T m_Left; // Left coordinate of the rectangle
T m_Top; // Top coordinate of the rectangle
T m_Right; // Right coordinate of the rectangle
T m_Bottom; // Bottom coordinate of the rectangle
public:
static if (!isIntegerType!(T) && !isRealType!(T))
{
static assert (0, "This type is not supported by Rectangle");
}
T min(T)(T i, T j)
{
return i < j ? i : j;
}
T max(T)(T i, T j)
{
return i > j ? i : j;
}
/**
* Default constructor
*/
this()
{
m_Left = 0;
m_Top = 0;
m_Right = 0;
m_Bottom = 0;
}
{
static assert (0, "This type is not supported by Rectangle");
}
T min(T)(T i, T j)
{
return i < j ? i : j;
}
T max(T)(T i, T j)
{
return i > j ? i : j;
}
/**
* Default constructor
*/
this()
{
m_Left = 0;
m_Top = 0;
m_Right = 0;
m_Bottom = 0;
}
/**
* Construct the rectangle from its coordinates
*
* Params:
* leftCoord = Left coordinate of the rectangle
* topCoord = Top coordinate of the rectangle
* rightCoord = Right coordinate of the rectangle
* bottomCoord = Bottom coordinate of the rectangle
*/
this(T leftCoord, T topCoord, T rightCoord, T bottomCoord)
{
m_Left = leftCoord;
m_Top = topCoord;
m_Right = rightCoord;
m_Bottom = bottomCoord;
}
/**
* Construct the rectangle from its coordinates
*
* Params:
* leftCoord = Left coordinate of the rectangle
* topCoord = Top coordinate of the rectangle
* rightCoord = Right coordinate of the rectangle
* bottomCoord = Bottom coordinate of the rectangle
*/
this(T leftCoord, T topCoord, T rightCoord, T bottomCoord)
{
m_Left = leftCoord;
m_Top = topCoord;
m_Right = rightCoord;
m_Bottom = bottomCoord;
}
/**
* Get the width of the rectangle
*
* Returns:
* Width of rectangle
*/
T getWidth()
{
return m_Right - m_Left;
}
/**
* Get the width of the rectangle
*
* Returns:
* Width of rectangle
*/
T getWidth()
{
return m_Right - m_Left;
}
/**
* Get the height of the rectangle
*
* Returns:
* Height of rectangle
*/
T getHeight()
{
return m_Bottom - m_Top;
}
/**
* Get the height of the rectangle
*
* Returns:
* Height of rectangle
*/
T getHeight()
{
return m_Bottom - m_Top;
}
/**
* Move the whole rectangle by the given offset
*
* Params:
* offsetX = Horizontal offset
* offsetY = Vertical offset
*/
void offset(T offsetX, T offsetY)
{
m_Left += offsetX;
m_Right += offsetX;
m_Top += offsetY;
m_Bottom += offsetY;
}
/**
* Move the whole rectangle by the given offset
*
* Params:
* offsetX = Horizontal offset
* offsetY = Vertical offset
*/
void offset(T offsetX, T offsetY)
{
m_Left += offsetX;
m_Right += offsetX;
m_Top += offsetY;
m_Bottom += offsetY;
}
/**
* Check if a point is inside the rectangle's area
*
* Params:
* x = X coordinate of the point to test
* y = Y coordinate of the point to test
*
* Returns:
* True if the point is inside
*/
bool contains(T x, T y)
{
return (x >= m_Left) && (x <= m_Right) && (y >= m_Top) && (y <= m_Bottom);
}
/**
* Check if a point is inside the rectangle's area
*
* Params:
* x = X coordinate of the point to test
* y = Y coordinate of the point to test
*
* Returns:
* True if the point is inside
*/
bool contains(T x, T y)
{
return (x >= m_Left) && (x <= m_Right) && (y >= m_Top) && (y <= m_Bottom);
}
/**
* Check intersection between two rectangles
*
* Params:
* rectangle = Rectangle to test
* overlappingRect = Rectangle to be filled with overlapping rect (NULL by default)
*
* Returns:
* True if rectangles overlap
*/
bool intersects(Rect!(T) rectangle, out Rect!(T) overlappingRect = null)
{
// Compute overlapping rect
Rect!(T) overlapping = new Rect!(T)(
max(m_Left, rectangle.getLeft),
max(m_Top, rectangle.getTop),
min(m_Right, rectangle.getRight),
min(m_Bottom, rectangle.getBottom)
);
// If overlapping rect is valid, then there is intersection
if ((overlapping.getLeft() < overlapping.getRight() ) && (overlapping.getTop() < overlapping.getBottom()))
{
overlappingRect = overlapping;
return true;
}
else
{
overlappingRect = new Rect!(T)();
return false;
}
}
/**
* Set left Coordinate
*/
void setLeft(T left)
{
m_Left = left;
}
/**
* Check intersection between two rectangles
*
* Params:
* rectangle = Rectangle to test
* overlappingRect = Rectangle to be filled with overlapping rect (NULL by default)
*
* Returns:
* True if rectangles overlap
*/
bool intersects(Rect!(T) rectangle, out Rect!(T) overlappingRect = null)
{
// Compute overlapping rect
Rect!(T) overlapping = new Rect!(T)(
max(m_Left, rectangle.getLeft),
max(m_Top, rectangle.getTop),
min(m_Right, rectangle.getRight),
min(m_Bottom, rectangle.getBottom)
);
// If overlapping rect is valid, then there is intersection
if ((overlapping.getLeft() < overlapping.getRight() ) && (overlapping.getTop() < overlapping.getBottom()))
{
overlappingRect = overlapping;
return true;
}
else
{
overlappingRect = new Rect!(T)();
return false;
}
}
/**
* Set left Coordinate
*/
void setLeft(T left)
{
m_Left = left;
}
/**
* Set top Coordinate
*/
void setTop(T top)
{
m_Top = top;
}
/**
* Set top Coordinate
*/
void setTop(T top)
{
m_Top = top;
}
/**
* Set right Coordinate
*/
void setRight(T right)
{
m_Right = right;
}
/**
* Set right Coordinate
*/
void setRight(T right)
{
m_Right = right;
}
/**
* Set bottom Coordinate
*/
void setBottom(T bottom)
{
m_Bottom = bottom;
}
/**
* Set bottom Coordinate
*/
void setBottom(T bottom)
{
m_Bottom = bottom;
}
/**
* Get left Coordinate
*/
T getLeft()
{
return m_Left;
}
/**
* Get left Coordinate
*/
T getLeft()
{
return m_Left;
}
/**
* Get top Coordinate
*/
T getTop()
{
return m_Top;
}
/**
* Get top Coordinate
*/
T getTop()
{
return m_Top;
}
/**
* Get right Coordinate
*/
T getRight()
{
return m_Right;
}
/**
* Get right Coordinate
*/
T getRight()
{
return m_Right;
}
/**
* Get bottom Coordinate
*/
T getBottom()
{
return m_Bottom;
}
/**
* Get bottom Coordinate
*/
T getBottom()
{
return m_Bottom;
}
package:
sfFloatRect toCFloatRect()
{
return sfFloatRect(m_Left, m_Top, m_Right, m_Bottom);
}
sfIntRect toCIntRect()
{
return sfIntRect(cast(int)m_Left, cast(int)m_Top, cast(int)m_Right, cast(int)m_Bottom);
}
sfFloatRect toCFloatRect()
{
return sfFloatRect(m_Left, m_Top, m_Right, m_Bottom);
}
sfIntRect toCIntRect()
{
return sfIntRect(cast(int)m_Left, cast(int)m_Top, cast(int)m_Right, cast(int)m_Bottom);
}
}
///Alias

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.renderwindow;
@ -48,190 +48,190 @@ import dsfml.system.common,
dsfml.system.vector2;
/**
* Simple wrapper for Window that allows easy 2D rendering.
* Simple wrapper for Window that allows easy 2D rendering.
*/
class RenderWindow : Window
{
private:
private:
View m_view = null;
View m_defaultView = null;
public:
/**
* Construct the window
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
this(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings));
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Construct the window from an existing control
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
this(WindowHandle handle, ContextSettings settings = ContextSettings())
{
super(sfRenderWindow_CreateFromHandle(handle, &settings));
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
override void dispose()
{
sfRenderWindow_Destroy(m_ptr);
}
/**
* Create (or recreate) the window
*
* Input created with getInput will become invalid.
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*
*/
void create(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings);
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Create (or recreate) the window from an existing control
*
* Input created with getInput become invalid.
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*
*/
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfRenderWindow_CreateFromHandle(handle, &settings);
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Draw a sprite, shape or text on the window with a shader
* Construct the window
*
* Params:
* drawable = IDrawable to draw
* shader = Shader to use
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
this(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings));
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Construct the window from an existing control
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
this(WindowHandle handle, ContextSettings settings = ContextSettings())
{
super(sfRenderWindow_CreateFromHandle(handle, &settings));
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
override void dispose()
{
sfRenderWindow_Destroy(m_ptr);
}
/**
* Create (or recreate) the window
*
* Input created with getInput will become invalid.
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*
*/
void create(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings);
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Create (or recreate) the window from an existing control
*
* Input created with getInput become invalid.
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*
*/
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfRenderWindow_CreateFromHandle(handle, &settings);
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
}
/**
* Draw a sprite, shape or text on the window with a shader
*
* Params:
* drawable = IDrawable to draw
* shader = Shader to use
*/
void draw(IDrawable drawable, Shader shader)
{
drawable.renderWithShader(this, shader);
}
/**
* Draw a sprite, shape or text
*
* Params:
* drawable = IDrawable to draw
*/
void draw(IDrawable drawable)
{
drawable.render(this);
}
/**
* Clear the screen with the given color.
*
* Params:
* col = Fill color
*/
void clear(Color col = Color.BLACK)
{
sfRenderWindow_Clear(m_ptr, col);
}
* Draw a sprite, shape or text
*
* Params:
* drawable = IDrawable to draw
*/
void draw(IDrawable drawable)
{
drawable.render(this);
}
/**
* Clear the screen with the given color.
*
* Params:
* col = Fill color
*/
void clear(Color col = Color.BLACK)
{
sfRenderWindow_Clear(m_ptr, col);
}
/**
* Change the current active view.
* The current view is defined with the initial size of the window
*
* Params:
* newView = Pointer to the new view (pass getDefaultView to set the default view)
*/
void setView(View newView)
{
if (m_view !is null)
{
m_view.setHandled(false);
}
sfRenderWindow_SetView(m_ptr, newView.getNativePointer);
m_view = newView;
m_view.setHandled(true);
}
/**
* Change the current active view.
* The current view is defined with the initial size of the window
*
* Params:
* newView = Pointer to the new view (pass getDefaultView to set the default view)
*/
void setView(View newView)
{
if (m_view !is null)
{
m_view.setHandled(false);
}
sfRenderWindow_SetView(m_ptr, newView.getNativePointer);
m_view = newView;
m_view.setHandled(true);
}
/**
* Get the current view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View getView()
{
if (m_view is null)
{
void* cView = sfRenderWindow_GetView(m_ptr);
m_view = new View(cView, true);
}
return m_view;
}
/**
* Get the current view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View getView()
{
if (m_view is null)
{
void* cView = sfRenderWindow_GetView(m_ptr);
m_view = new View(cView, true);
}
return m_view;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View getDefaultView()
{
if (m_defaultView is null)
{
void* cView = sfRenderWindow_GetDefaultView(m_ptr);
m_defaultView = new View(cView, true);
}
return m_defaultView;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View getDefaultView()
{
if (m_defaultView is null)
{
void* cView = sfRenderWindow_GetDefaultView(m_ptr);
m_defaultView = new View(cView, true);
}
return m_defaultView;
}
/**
* Convert a point in window coordinates into view coordinates
*
* Params:
* windowX = X coordinate of the point to convert, relative to the window
* windowY = Y coordinate of the point to convert, relative to the window
* targetView = Target view to convert the point to (pass NULL to use the current view)
*
* Returns:
* Converted point
*/
Vector2f convertCoords(uint windowX, uint windowY, View targetView = null)
{
Vector2f vec;
sfRenderWindow_ConvertCoords(m_ptr, windowX, windowY, &vec.x, &vec.y, targetView is null ? null : targetView.getNativePointer);
return vec;
}
/**
* Convert a point in window coordinates into view coordinates
*
* Params:
* windowX = X coordinate of the point to convert, relative to the window
* windowY = Y coordinate of the point to convert, relative to the window
* targetView = Target view to convert the point to (pass NULL to use the current view)
*
* Returns:
* Converted point
*/
Vector2f convertCoords(uint windowX, uint windowY, View targetView = null)
{
Vector2f vec;
sfRenderWindow_ConvertCoords(m_ptr, windowX, windowY, &vec.x, &vec.y, targetView is null ? null : targetView.getNativePointer);
return vec;
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.shader;
@ -35,100 +35,100 @@ import dsfml.system.stringutil;
/**
* Define loading methods for effect
* Define loading methods for effect
*/
enum LoadingType
{
FROMFILE, /// string represents a file path
FROMSTRING /// string represents effect code
FROMFILE, /// string represents a file path
FROMSTRING /// string represents effect code
}
/**
* Shader is used to apply a post effect to a window
* Shader is used to apply a post effect to a window
*
* See_Also:
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
* See_Also:
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
*/
class Shader : DSFMLObject
{
/**
* construct the effect
*
* Params:
* effect = Path of a file or string containing the effect.
* type = type of the effect (default is FROMFILE)
*/
this(string effect, LoadingType type = LoadingType.FROMFILE)
/**
* construct the effect
*
* Params:
* effect = Path of a file or string containing the effect.
* type = type of the effect (default is FROMFILE)
*/
this(string effect, LoadingType type = LoadingType.FROMFILE)
{
if (effect is null || effect.length == 0)
throw new LoadingException("LoadingException : Effect is invalid.");
if (type == LoadingType.FROMFILE)
super(sfShader_CreateFromFile(toStringz(effect)));
else
super(sfShader_CreateFromMemory(toStringz(effect)));
if (effect is null || effect.length == 0)
throw new LoadingException("LoadingException : Effect is invalid.");
if (type == LoadingType.FROMFILE)
super(sfShader_CreateFromFile(toStringz(effect)));
else
super(sfShader_CreateFromMemory(toStringz(effect)));
}
override void dispose()
override void dispose()
{
sfShader_Destroy(m_ptr);
}
/**
* Change parameters of the effect
*
* Params:
* name = Parameter name in the effect
*/
void setParameter(string name, float x)
/**
* Change parameters of the effect
*
* Params:
* name = Parameter name in the effect
*/
void setParameter(string name, float x)
{
sfShader_SetParameter1(m_ptr, toStringz(name), x);
}
/**
* ditto
*/
void setParameter(string name, float x, float y)
/**
* ditto
*/
void setParameter(string name, float x, float y)
{
sfShader_SetParameter2(m_ptr, toStringz(name), x, y);
}
/**
* ditto
*/
void setParameter(string name, float x, float y, float z)
/**
* ditto
*/
void setParameter(string name, float x, float y, float z)
{
sfShader_SetParameter3(m_ptr, toStringz(name), x, y, z);
}
/**
* ditto
*/
void setParameter(string name, float x, float y, float z, float w)
/**
* ditto
*/
void setParameter(string name, float x, float y, float z, float w)
{
sfShader_SetParameter4(m_ptr, toStringz(name), x, y, z, w);
}
/**
* Set a texture parameter
*
* Params:
* name = Texture name in the effect
* texture = Image to set (pass NULL to use content of current framebuffer)
*/
void setTexture(string name, Image texture)
/**
* Set a texture parameter
*
* Params:
* name = Texture name in the effect
* texture = Image to set (pass NULL to use content of current framebuffer)
*/
void setTexture(string name, Image texture)
{
m_texture = texture;
m_texture = texture;
sfShader_SetTexture(m_ptr, toStringz(name), texture is null ? null : texture.getNativePointer);
}
/**
* Tell whether or not the system supports shaders
*
* Returns:
* True if the system can use shaders
*/
static bool isAvailable()
/**
* Tell whether or not the system supports shaders
*
* Returns:
* True if the system can use shaders
*/
static bool isAvailable()
{
return cast(bool)sfShader_IsAvailable();
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.shape;
@ -33,305 +33,305 @@ import dsfml.graphics.color;
import dsfml.graphics.drawableimpl;
/**
* Shape defines a drawable convex shape ; it also defines
* helper functions to draw simple shapes like
* lines, rectangles, circles, etc.
* Shape defines a drawable convex shape ; it also defines
* helper functions to draw simple shapes like
* lines, rectangles, circles, etc.
*/
class Shape : Drawableimpl!(sfShape)
{
this()
{
super();
}
this()
{
super();
}
/**
* Add a point to the shape
*
* Params:
* x = X position of the point
* y = Y position of the point
* col = Color of the point (white by default)
* outlineCol = Outline color of the point (black by default)
*/
void addPoint(float x, float y, Color col = Color.WHITE, Color outlineCol = Color.BLACK)
{
sfShape_AddPoint(m_ptr, x, y, col, outlineCol);
}
/**
* Add a point to the shape
*
* Params:
* x = X position of the point
* y = Y position of the point
* col = Color of the point (white by default)
* outlineCol = Outline color of the point (black by default)
*/
void addPoint(float x, float y, Color col = Color.WHITE, Color outlineCol = Color.BLACK)
{
sfShape_AddPoint(m_ptr, x, y, col, outlineCol);
}
/**
* Add a point to the shape
*
* Params:
* position = position of the point
* col = Color of the point (white by default)
* outlineCol = Outline color of the point (black by default)
*/
void addPoint(Vector2f position, Color col = Color.WHITE, Color outlineCol = Color.BLACK)
{
sfShape_AddPoint(m_ptr, position.x, position.x, col, outlineCol);
}
/**
* Add a point to the shape
*
* Params:
* position = position of the point
* col = Color of the point (white by default)
* outlineCol = Outline color of the point (black by default)
*/
void addPoint(Vector2f position, Color col = Color.WHITE, Color outlineCol = Color.BLACK)
{
sfShape_AddPoint(m_ptr, position.x, position.x, col, outlineCol);
}
/**
* Enable or disable filling the shape.
* Fill is enabled by default.
*
* Params:
* enable = True to enable, false to disable
*/
void enableFill(bool enable)
{
sfShape_EnableFill(m_ptr, enable);
}
/**
* Enable or disable filling the shape.
* Fill is enabled by default.
*
* Params:
* enable = True to enable, false to disable
*/
void enableFill(bool enable)
{
sfShape_EnableFill(m_ptr, enable);
}
/**
* Enable or disable drawing a shape outline.
* Outline is enabled by default
*
* Params:
* enable = True to enable, false to disable
*/
void enableOutline(bool enable)
{
sfShape_EnableOutline(m_ptr, enable);
}
/**
* Enable or disable drawing a shape outline.
* Outline is enabled by default
*
* Params:
* enable = True to enable, false to disable
*/
void enableOutline(bool enable)
{
sfShape_EnableOutline(m_ptr, enable);
}
/**
* Change the width of a shape outline
*
* Params:
* width = New width
*/
void setOutlineWidth(float width)
{
sfShape_SetOutlineWidth(m_ptr, width);
}
/**
* Change the width of a shape outline
*
* Params:
* width = New width
*/
void setOutlineWidth(float width)
{
sfShape_SetOutlineWidth(m_ptr, width);
}
/**
* Get the width of the shape outline
*
* Returns:
* Current outline width
*
*/
float getOutlineWidth()
{
return sfShape_GetOutlineWidth(m_ptr);
}
/**
* Get the width of the shape outline
*
* Returns:
* Current outline width
*
*/
float getOutlineWidth()
{
return sfShape_GetOutlineWidth(m_ptr);
}
/**
* Get the number of points composing a shape
*
* Returns:
* Total number of points
*/
uint getNbPoints()
{
return sfShape_GetNbPoints(m_ptr);
}
/**
* Get the number of points composing a shape
*
* Returns:
* Total number of points
*/
uint getNbPoints()
{
return sfShape_GetNbPoints(m_ptr);
}
/**
* Get a point of the shape
*
* Params:
* index = Index of the point
*
* Returns:
* position of the point
*/
Vector2f getPointPosition(uint index)
{
float x, y;
sfShape_GetPointPosition(m_ptr, index, &x, &y);
return Vector2f(x, y);
}
/**
* Get a point of the shape
*
* Params:
* index = Index of the point
*
* Returns:
* position of the point
*/
Vector2f getPointPosition(uint index)
{
float x, y;
sfShape_GetPointPosition(m_ptr, index, &x, &y);
return Vector2f(x, y);
}
/**
* Set the position of a shape point
*
* Params:
* index = Index of the point
* position = New position of the point
*/
void setPointPosition(uint index, Vector2f position)
{
sfShape_SetPointPosition(m_ptr, index, position.x, position.y);
}
/**
* Set the position of a shape point
*
* Params:
* index = Index of the point
* position = New position of the point
*/
void setPointPosition(uint index, Vector2f position)
{
sfShape_SetPointPosition(m_ptr, index, position.x, position.y);
}
/**
* Get the color of a shape's point
*
* Params:
* index = Index of the point
*
* Returns:
* Color of the point
*/
Color getPointColor(uint index)
{
return sfShape_GetPointColor(m_ptr, index);
}
/**
* Get the color of a shape's point
*
* Params:
* index = Index of the point
*
* Returns:
* Color of the point
*/
Color getPointColor(uint index)
{
return sfShape_GetPointColor(m_ptr, index);
}
/**
* Set the color of a shape's point
*
* Params:
* index = Index of the point
* color = new color of the point
*/
void setPointColor(uint index, Color color)
{
sfShape_SetPointColor(m_ptr, index, color);
}
/**
* Set the color of a shape's point
*
* Params:
* index = Index of the point
* color = new color of the point
*/
void setPointColor(uint index, Color color)
{
sfShape_SetPointColor(m_ptr, index, color);
}
/**
* Get the outline color of a shape's point
*
* Params:
* index = Index of the point
*
* Returns:
* Color of the outline
*/
Color getPointOutlineColor(uint index)
{
return sfShape_GetPointOutlineColor(m_ptr, index);
}
/**
* Get the outline color of a shape's point
*
* Params:
* index = Index of the point
*
* Returns:
* Color of the outline
*/
Color getPointOutlineColor(uint index)
{
return sfShape_GetPointOutlineColor(m_ptr, index);
}
/**
* Set the outline color of a shape's point
*
* Params:
* index = Index of the point
* color = new color of the point
*/
void setPointOutlineColor(uint index, Color color)
{
sfShape_SetPointOutlineColor(m_ptr, index, color);
}
/**
* Set the outline color of a shape's point
*
* Params:
* index = Index of the point
* color = new color of the point
*/
void setPointOutlineColor(uint index, Color color)
{
sfShape_SetPointOutlineColor(m_ptr, index, color);
}
/**
* Create a shape made of a single line
*
* Params:
* p1X, p1Y = Position of the first point
* p2X, p2Y = Position second point
* thickness = Line thickness
* col = Color used to draw the line
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* New line shape
*/
static Shape line(float p1X, float p1Y, float p2X, float p2Y, float thickness, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateLine(p1X, p1Y, p2X, p2Y, thickness, col, outline, outlineCol));
}
/**
* Create a shape made of a single line
*
* Params:
* p1X, p1Y = Position of the first point
* p2X, p2Y = Position second point
* thickness = Line thickness
* col = Color used to draw the line
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* New line shape
*/
static Shape line(float p1X, float p1Y, float p2X, float p2Y, float thickness, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateLine(p1X, p1Y, p2X, p2Y, thickness, col, outline, outlineCol));
}
/**
* Create a shape made of a single rectangle
*
* Params:
* p1X = X position of the first point
* p1Y = Y position of the first point
* p2X = X position second point
* p2Y = Y position second point
* col = Color used to fill the rectangle
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* new rectangle shape
*/
static Shape rectangle(float p1X, float p1Y, float p2X, float p2Y, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateRectangle(p1X, p1Y, p2X, p2Y, col, outline, outlineCol));
}
/**
* Create a shape made of a single rectangle
*
* Params:
* p1X = X position of the first point
* p1Y = Y position of the first point
* p2X = X position second point
* p2Y = Y position second point
* col = Color used to fill the rectangle
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* new rectangle shape
*/
static Shape rectangle(float p1X, float p1Y, float p2X, float p2Y, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateRectangle(p1X, p1Y, p2X, p2Y, col, outline, outlineCol));
}
/**
* Create a shape made of a single circle
*
* Params:
* x = X position of the center
* y = Y position of the center
* radius = Radius
* col = Color used to fill the circle
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* new circle shape
*/
static Shape circle(float x, float y, float radius, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateCircle(x, y, radius, col, outline, outlineCol));
}
/**
* Create a shape made of a single circle
*
* Params:
* x = X position of the center
* y = Y position of the center
* radius = Radius
* col = Color used to fill the circle
* outline = Outline width (0 by default)
* outlineCol = Color used to draw the outline (black by default)
*
* Returns:
* new circle shape
*/
static Shape circle(float x, float y, float radius, Color col, float outline = 0.f, Color outlineCol = Color.BLACK)
{
return new Shape(sfShape_CreateCircle(x, y, radius, col, outline, outlineCol));
}
private:
this (void* ptr)
{
super(ptr);
}
extern (C)
{
typedef void* function(float, float, float, float, float, Color, float, Color) pf_sfShape_CreateLine;
typedef void* function(float, float, float, float, Color, float, Color) pf_sfShape_CreateRectangle;
typedef void* function(float, float, float, Color, float, Color) pf_sfShape_CreateCircle;
typedef void function(void* Shape, float, float, Color, Color) pf_sfShape_AddPoint;
typedef void function(void* Shape, int) pf_sfShape_EnableFill;
typedef void function(void* Shape, int) pf_sfShape_EnableOutline;
typedef void function (void* Shape, float Width) pf_sfShape_SetOutlineWidth;
typedef float function (void* Shape) pf_sfShape_GetOutlineWidth;
typedef uint function (void* Shape) pf_sfShape_GetNbPoints;
typedef void function (void* Shape, uint Index, float* X, float* Y) pf_sfShape_GetPointPosition;
typedef void function (void* Shape, uint Index, float X, float Y) pf_sfShape_SetPointPosition;
typedef Color function (void* Shape, uint index) pf_sfShape_GetPointColor;
typedef void function (void* Shape, uint index, Color color) pf_sfShape_SetPointColor;
typedef Color function (void* Shape, uint index) pf_sfShape_GetPointOutlineColor;
typedef void function (void* Shape, uint index, Color color) pf_sfShape_SetPointOutlineColor;
static pf_sfShape_CreateLine sfShape_CreateLine;
static pf_sfShape_CreateRectangle sfShape_CreateRectangle;
static pf_sfShape_CreateCircle sfShape_CreateCircle;
static pf_sfShape_AddPoint sfShape_AddPoint;
static pf_sfShape_EnableFill sfShape_EnableFill;
static pf_sfShape_EnableOutline sfShape_EnableOutline;
static pf_sfShape_SetOutlineWidth sfShape_SetOutlineWidth;
static pf_sfShape_GetOutlineWidth sfShape_GetOutlineWidth;
static pf_sfShape_GetNbPoints sfShape_GetNbPoints;
static pf_sfShape_GetPointPosition sfShape_GetPointPosition;
static pf_sfShape_SetPointPosition sfShape_SetPointPosition;
static pf_sfShape_GetPointColor sfShape_GetPointColor;
static pf_sfShape_SetPointColor sfShape_SetPointColor;
static pf_sfShape_GetPointOutlineColor sfShape_GetPointOutlineColor;
static pf_sfShape_SetPointOutlineColor sfShape_SetPointOutlineColor;
}
this (void* ptr)
{
super(ptr);
}
extern (C)
{
typedef void* function(float, float, float, float, float, Color, float, Color) pf_sfShape_CreateLine;
typedef void* function(float, float, float, float, Color, float, Color) pf_sfShape_CreateRectangle;
typedef void* function(float, float, float, Color, float, Color) pf_sfShape_CreateCircle;
typedef void function(void* Shape, float, float, Color, Color) pf_sfShape_AddPoint;
typedef void function(void* Shape, int) pf_sfShape_EnableFill;
typedef void function(void* Shape, int) pf_sfShape_EnableOutline;
typedef void function (void* Shape, float Width) pf_sfShape_SetOutlineWidth;
typedef float function (void* Shape) pf_sfShape_GetOutlineWidth;
typedef uint function (void* Shape) pf_sfShape_GetNbPoints;
typedef void function (void* Shape, uint Index, float* X, float* Y) pf_sfShape_GetPointPosition;
typedef void function (void* Shape, uint Index, float X, float Y) pf_sfShape_SetPointPosition;
typedef Color function (void* Shape, uint index) pf_sfShape_GetPointColor;
typedef void function (void* Shape, uint index, Color color) pf_sfShape_SetPointColor;
typedef Color function (void* Shape, uint index) pf_sfShape_GetPointOutlineColor;
typedef void function (void* Shape, uint index, Color color) pf_sfShape_SetPointOutlineColor;
static pf_sfShape_CreateLine sfShape_CreateLine;
static pf_sfShape_CreateRectangle sfShape_CreateRectangle;
static pf_sfShape_CreateCircle sfShape_CreateCircle;
static pf_sfShape_AddPoint sfShape_AddPoint;
static pf_sfShape_EnableFill sfShape_EnableFill;
static pf_sfShape_EnableOutline sfShape_EnableOutline;
static pf_sfShape_SetOutlineWidth sfShape_SetOutlineWidth;
static pf_sfShape_GetOutlineWidth sfShape_GetOutlineWidth;
static pf_sfShape_GetNbPoints sfShape_GetNbPoints;
static pf_sfShape_GetPointPosition sfShape_GetPointPosition;
static pf_sfShape_SetPointPosition sfShape_SetPointPosition;
static pf_sfShape_GetPointColor sfShape_GetPointColor;
static pf_sfShape_SetPointColor sfShape_SetPointColor;
static pf_sfShape_GetPointOutlineColor sfShape_GetPointOutlineColor;
static pf_sfShape_SetPointOutlineColor sfShape_SetPointOutlineColor;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-graphics-d");
else
DllLoader dll = DllLoader.load("csfml-graphics");
sfShape_CreateLine = cast(pf_sfShape_CreateLine)dll.getSymbol("sfShape_CreateLine");
sfShape_CreateRectangle = cast(pf_sfShape_CreateRectangle)dll.getSymbol("sfShape_CreateRectangle");
sfShape_CreateCircle = cast(pf_sfShape_CreateCircle)dll.getSymbol("sfShape_CreateCircle");
sfShape_AddPoint = cast(pf_sfShape_AddPoint)dll.getSymbol("sfShape_AddPoint");
sfShape_EnableFill = cast(pf_sfShape_EnableFill)dll.getSymbol("sfShape_EnableFill");
sfShape_EnableOutline = cast(pf_sfShape_EnableOutline)dll.getSymbol("sfShape_EnableOutline");
sfShape_SetOutlineWidth = cast(pf_sfShape_SetOutlineWidth)dll.getSymbol("sfShape_SetOutlineWidth");
sfShape_GetOutlineWidth = cast(pf_sfShape_GetOutlineWidth)dll.getSymbol("sfShape_GetOutlineWidth");
sfShape_GetNbPoints = cast(pf_sfShape_GetNbPoints)dll.getSymbol("sfShape_GetNbPoints");
sfShape_GetPointPosition = cast(pf_sfShape_GetPointPosition)dll.getSymbol("sfShape_GetPointPosition");
sfShape_SetPointPosition = cast(pf_sfShape_SetPointPosition)dll.getSymbol("sfShape_SetPointPosition");
sfShape_GetPointColor = cast (pf_sfShape_GetPointColor)dll.getSymbol("sfShape_GetPointColor");
sfShape_SetPointColor = cast (pf_sfShape_SetPointColor)dll.getSymbol("sfShape_SetPointColor");
sfShape_GetPointOutlineColor = cast(pf_sfShape_GetPointOutlineColor)dll.getSymbol("sfShape_GetPointOutlineColor");
sfShape_SetPointOutlineColor = cast(pf_sfShape_SetPointOutlineColor)dll.getSymbol("sfShape_SetPointOutlineColor");
}
sfShape_CreateLine = cast(pf_sfShape_CreateLine)dll.getSymbol("sfShape_CreateLine");
sfShape_CreateRectangle = cast(pf_sfShape_CreateRectangle)dll.getSymbol("sfShape_CreateRectangle");
sfShape_CreateCircle = cast(pf_sfShape_CreateCircle)dll.getSymbol("sfShape_CreateCircle");
sfShape_AddPoint = cast(pf_sfShape_AddPoint)dll.getSymbol("sfShape_AddPoint");
sfShape_EnableFill = cast(pf_sfShape_EnableFill)dll.getSymbol("sfShape_EnableFill");
sfShape_EnableOutline = cast(pf_sfShape_EnableOutline)dll.getSymbol("sfShape_EnableOutline");
sfShape_SetOutlineWidth = cast(pf_sfShape_SetOutlineWidth)dll.getSymbol("sfShape_SetOutlineWidth");
sfShape_GetOutlineWidth = cast(pf_sfShape_GetOutlineWidth)dll.getSymbol("sfShape_GetOutlineWidth");
sfShape_GetNbPoints = cast(pf_sfShape_GetNbPoints)dll.getSymbol("sfShape_GetNbPoints");
sfShape_GetPointPosition = cast(pf_sfShape_GetPointPosition)dll.getSymbol("sfShape_GetPointPosition");
sfShape_SetPointPosition = cast(pf_sfShape_SetPointPosition)dll.getSymbol("sfShape_SetPointPosition");
sfShape_GetPointColor = cast (pf_sfShape_GetPointColor)dll.getSymbol("sfShape_GetPointColor");
sfShape_SetPointColor = cast (pf_sfShape_SetPointColor)dll.getSymbol("sfShape_SetPointColor");
sfShape_GetPointOutlineColor = cast(pf_sfShape_GetPointOutlineColor)dll.getSymbol("sfShape_GetPointOutlineColor");
sfShape_SetPointOutlineColor = cast(pf_sfShape_SetPointOutlineColor)dll.getSymbol("sfShape_SetPointOutlineColor");
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.sprite;
@ -35,218 +35,218 @@ import dsfml.graphics.rect;
import dsfml.system.vector2;
/**
* Sprite defines a sprite : texture, transformations,
* color, and draw on screen
* See_Also:
* IDrawable
* Sprite defines a sprite : texture, transformations,
* color, and draw on screen
* See_Also:
* IDrawable
*/
class Sprite : Drawableimpl!(sfSprite)
{
/**
* Default constructor
*/
this()
{
}
/**
* Default constructor
*/
this()
{
}
/**
* Construct the sprite from a source image
*
* Params:
* img = Image of the sprite
* left = Left coordinate of the sprite (0 by default)
* top = Top coordinate of the sprite (0 by default)
* scaleX = Horizontal scale (1 by default)
* scaleY= Vertical scale (1 by default)
* rotation = Orientation, in degrees (0 by default)
* col = Color of the sprite (white by default)
*/
this(Image img, float left = 0.f, float top = 0.f, float scaleX = 1.f, float scaleY = 1.f, float rotation = 0.f, Color col = Color.WHITE)
{
m_image = img;
sfSprite_SetImage(m_ptr, img.getNativePointer);
setX(left);
setY(top);
setScaleX(scaleX);
setScaleY(scaleY);
setRotation(rotation);
setColor(col);
}
/**
* Construct the sprite from a source image
*
* Params:
* img = Image of the sprite
* left = Left coordinate of the sprite (0 by default)
* top = Top coordinate of the sprite (0 by default)
* scaleX = Horizontal scale (1 by default)
* scaleY= Vertical scale (1 by default)
* rotation = Orientation, in degrees (0 by default)
* col = Color of the sprite (white by default)
*/
this(Image img, float left = 0.f, float top = 0.f, float scaleX = 1.f, float scaleY = 1.f, float rotation = 0.f, Color col = Color.WHITE)
{
m_image = img;
sfSprite_SetImage(m_ptr, img.getNativePointer);
setX(left);
setY(top);
setScaleX(scaleX);
setScaleY(scaleY);
setRotation(rotation);
setColor(col);
}
/**
* Change the image of the sprite
*
* Params:
* img = New image
*/
void setImage(Image img)
{
assert(img !is null, "Trying to set a null image.");
sfSprite_SetImage(m_ptr, img.getNativePointer);
m_image = img;
}
/**
* Change the image of the sprite
*
* Params:
* img = New image
*/
void setImage(Image img)
{
assert(img !is null, "Trying to set a null image.");
sfSprite_SetImage(m_ptr, img.getNativePointer);
m_image = img;
}
/**
* Set the sub-rectangle of a sprite inside the source image.
*
* Params:
* rect = New sub-rectangle
*/
void setSubRect(IntRect rect)
{
sfIntRect r = rect.toCIntRect();
sfSprite_SetSubRect(m_ptr, &r);
m_subRect = rect;
}
/**
* Set the sub-rectangle of a sprite inside the source image.
*
* Params:
* rect = New sub-rectangle
*/
void setSubRect(IntRect rect)
{
sfIntRect r = rect.toCIntRect();
sfSprite_SetSubRect(m_ptr, &r);
m_subRect = rect;
}
/**
* Resize the sprite (by changing its scale factors).
* The default size is defined by the subrect
*
* Params:
* width = New width (must be strictly positive)
* height = New height (must be strictly positive)
*/
void resize(float width, float height)
{
if (width > 0 && height > 0)
sfSprite_Resize(m_ptr, width, height);
}
/**
* Resize the sprite (by changing its scale factors).
* The default size is defined by the subrect
*
* Params:
* width = New width (must be strictly positive)
* height = New height (must be strictly positive)
*/
void resize(float width, float height)
{
if (width > 0 && height > 0)
sfSprite_Resize(m_ptr, width, height);
}
/**
* Resize the sprite (by changing its scale factors).
* The default size is defined by the subrect
*
* Params:
* size = New size (both coordinates must be strictly positive)
*/
void resize(Vector2f size)
{
if (size.x > 0 && size.y > 0)
sfSprite_Resize(m_ptr, size.x, size.y);
}
/**
* Resize the sprite (by changing its scale factors).
* The default size is defined by the subrect
*
* Params:
* size = New size (both coordinates must be strictly positive)
*/
void resize(Vector2f size)
{
if (size.x > 0 && size.y > 0)
sfSprite_Resize(m_ptr, size.x, size.y);
}
/**
* Flip the sprite horizontally
*
* Params:
* flipped = True to flip the sprite
*/
void flipX(bool flipped)
{
sfSprite_FlipX(m_ptr, flipped);
}
/**
* Flip the sprite horizontally
*
* Params:
* flipped = True to flip the sprite
*/
void flipX(bool flipped)
{
sfSprite_FlipX(m_ptr, flipped);
}
/**
* Flip the sprite vertically
*
* Params:
* flipped = True to flip the sprite
*/
void flipY(bool flipped)
{
sfSprite_FlipY(m_ptr, flipped);
}
/**
* Flip the sprite vertically
*
* Params:
* flipped = True to flip the sprite
*/
void flipY(bool flipped)
{
sfSprite_FlipY(m_ptr, flipped);
}
/**
* Get the source image of the sprite
*
* Returns:
* Pointer to the image (can be NULL)
*/
Image getImage()
{
return m_image;
}
/**
* Get the source image of the sprite
*
* Returns:
* Pointer to the image (can be NULL)
*/
Image getImage()
{
return m_image;
}
/**
* Get the sub-rectangle of the sprite inside the source image
*
* Returns:
* Sub-rectangle
*/
IntRect getSubRect()
{
if (m_subRect is null)
m_subRect = new IntRect(0, 0, m_image.getWidth(), m_image.getHeight());
return m_subRect;
}
/**
* Get the sub-rectangle of the sprite inside the source image
*
* Returns:
* Sub-rectangle
*/
IntRect getSubRect()
{
if (m_subRect is null)
m_subRect = new IntRect(0, 0, m_image.getWidth(), m_image.getHeight());
return m_subRect;
}
/**
* Get the sprite size
*
* Returns:
* Size of the sprite
*/
Vector2f getSize()
{
return Vector2f(sfSprite_GetWidth(m_ptr), sfSprite_GetHeight(m_ptr));
}
/**
* Get the sprite size
*
* Returns:
* Size of the sprite
*/
Vector2f getSize()
{
return Vector2f(sfSprite_GetWidth(m_ptr), sfSprite_GetHeight(m_ptr));
}
/**
* Get the color of a given pixel in the sprite
*
* Params:
* x = X coordinate
* y = Y coordinate
*
* Returns:
* Color of pixel
*/
Color getPixel(uint x, uint y)
{
return sfSprite_GetPixel(m_ptr, x, y);
}
/**
* Get the color of a given pixel in the sprite
*
* Params:
* x = X coordinate
* y = Y coordinate
*
* Returns:
* Color of pixel
*/
Color getPixel(uint x, uint y)
{
return sfSprite_GetPixel(m_ptr, x, y);
}
private:
Image m_image; //< Image used to draw the sprite
IntRect m_subRect; //< Sub-rectangle of source image to assign to the sprite
extern (C)
{
typedef void function(void*, void*) pf_sfSprite_SetImage;
typedef void function(void*, sfIntRect*) pf_sfSprite_SetSubRect;
typedef void function(void*, float, float) pf_sfSprite_Resize;
typedef void function(void*, int) pf_sfSprite_FlipX;
typedef void function(void*, int) pf_sfSprite_FlipY;
typedef void* function(void*) pf_sfSprite_GetImage;
typedef void* function(void*) pf_sfSprite_GetSubRect;
typedef float function(void*) pf_sfSprite_GetWidth;
typedef float function(void*) pf_sfSprite_GetHeight;
typedef Color function(void*, uint, uint) pf_sfSprite_GetPixel;
static pf_sfSprite_SetImage sfSprite_SetImage;
static pf_sfSprite_SetSubRect sfSprite_SetSubRect;
static pf_sfSprite_Resize sfSprite_Resize;
static pf_sfSprite_FlipX sfSprite_FlipX;
static pf_sfSprite_FlipY sfSprite_FlipY;
static pf_sfSprite_GetImage sfSprite_GetImage;
static pf_sfSprite_GetSubRect sfSprite_GetSubRect;
static pf_sfSprite_GetWidth sfSprite_GetWidth;
static pf_sfSprite_GetHeight sfSprite_GetHeight;
static pf_sfSprite_GetPixel sfSprite_GetPixel;
}
Image m_image; //< Image used to draw the sprite
IntRect m_subRect; //< Sub-rectangle of source image to assign to the sprite
extern (C)
{
typedef void function(void*, void*) pf_sfSprite_SetImage;
typedef void function(void*, sfIntRect*) pf_sfSprite_SetSubRect;
typedef void function(void*, float, float) pf_sfSprite_Resize;
typedef void function(void*, int) pf_sfSprite_FlipX;
typedef void function(void*, int) pf_sfSprite_FlipY;
typedef void* function(void*) pf_sfSprite_GetImage;
typedef void* function(void*) pf_sfSprite_GetSubRect;
typedef float function(void*) pf_sfSprite_GetWidth;
typedef float function(void*) pf_sfSprite_GetHeight;
typedef Color function(void*, uint, uint) pf_sfSprite_GetPixel;
static pf_sfSprite_SetImage sfSprite_SetImage;
static pf_sfSprite_SetSubRect sfSprite_SetSubRect;
static pf_sfSprite_Resize sfSprite_Resize;
static pf_sfSprite_FlipX sfSprite_FlipX;
static pf_sfSprite_FlipY sfSprite_FlipY;
static pf_sfSprite_GetImage sfSprite_GetImage;
static pf_sfSprite_GetSubRect sfSprite_GetSubRect;
static pf_sfSprite_GetWidth sfSprite_GetWidth;
static pf_sfSprite_GetHeight sfSprite_GetHeight;
static pf_sfSprite_GetPixel sfSprite_GetPixel;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-graphics-d");
else
DllLoader dll = DllLoader.load("csfml-graphics");
sfSprite_SetImage = cast(pf_sfSprite_SetImage)dll.getSymbol("sfSprite_SetImage");
sfSprite_SetSubRect = cast(pf_sfSprite_SetSubRect)dll.getSymbol("sfSprite_SetSubRect");
sfSprite_Resize = cast(pf_sfSprite_Resize)dll.getSymbol("sfSprite_Resize");
sfSprite_FlipX = cast(pf_sfSprite_FlipX)dll.getSymbol("sfSprite_FlipX");
sfSprite_FlipY = cast(pf_sfSprite_FlipY)dll.getSymbol("sfSprite_FlipY");
sfSprite_GetImage = cast(pf_sfSprite_GetImage)dll.getSymbol("sfSprite_GetImage");
sfSprite_GetSubRect = cast(pf_sfSprite_GetSubRect)dll.getSymbol("sfSprite_GetSubRect");
sfSprite_GetWidth = cast(pf_sfSprite_GetWidth)dll.getSymbol("sfSprite_GetWidth");
sfSprite_GetHeight = cast(pf_sfSprite_GetHeight)dll.getSymbol("sfSprite_GetHeight");
sfSprite_GetPixel = cast(pf_sfSprite_GetPixel)dll.getSymbol("sfSprite_GetPixel");
}
sfSprite_SetImage = cast(pf_sfSprite_SetImage)dll.getSymbol("sfSprite_SetImage");
sfSprite_SetSubRect = cast(pf_sfSprite_SetSubRect)dll.getSymbol("sfSprite_SetSubRect");
sfSprite_Resize = cast(pf_sfSprite_Resize)dll.getSymbol("sfSprite_Resize");
sfSprite_FlipX = cast(pf_sfSprite_FlipX)dll.getSymbol("sfSprite_FlipX");
sfSprite_FlipY = cast(pf_sfSprite_FlipY)dll.getSymbol("sfSprite_FlipY");
sfSprite_GetImage = cast(pf_sfSprite_GetImage)dll.getSymbol("sfSprite_GetImage");
sfSprite_GetSubRect = cast(pf_sfSprite_GetSubRect)dll.getSymbol("sfSprite_GetSubRect");
sfSprite_GetWidth = cast(pf_sfSprite_GetWidth)dll.getSymbol("sfSprite_GetWidth");
sfSprite_GetHeight = cast(pf_sfSprite_GetHeight)dll.getSymbol("sfSprite_GetHeight");
sfSprite_GetPixel = cast(pf_sfSprite_GetPixel)dll.getSymbol("sfSprite_GetPixel");
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.text;
@ -38,35 +38,35 @@ import dsfml.system.vector2;
/**
* Text defines a graphical 2D text, that can be drawn on screen
*
* All string litterals used must be prefixed with c for utf-8
* and d for utf-32 string.
*
* Examples :
* ---------------------------------------------------------------
* Text s = new Text("Hello"c);
* //this(string, Font, float)
* s = new Text("Hello"d);
* //this(dstring, Font, float)
* ---------------------------------------------------------------
*
* See_Also:
* IDrawable
* Text defines a graphical 2D text, that can be drawn on screen
*
* All string litterals used must be prefixed with c for utf-8
* and d for utf-32 string.
*
* Examples :
* ---------------------------------------------------------------
* Text s = new Text("Hello"c);
* //this(string, Font, float)
* s = new Text("Hello"d);
* //this(dstring, Font, float)
* ---------------------------------------------------------------
*
* See_Also:
* IDrawable
*/
class Text : Drawableimpl!(sfText)
{
/**
* Construct the string from a text
*
* Prefixs string litterals with c
*
* Params:
* text = Text assigned to the string
* font = Font used to draw the string (use default font)
* size = Characters size, in pixels (32 by default)
*/
this(string text, Font font = Font.getDefaultFont(), uint size = 30)
/**
* Construct the string from a text
*
* Prefixs string litterals with c
*
* Params:
* text = Text assigned to the string
* font = Font used to draw the string (use default font)
* size = Characters size, in pixels (32 by default)
*/
this(string text, Font font = Font.getDefaultFont(), uint size = 30)
{
super();
m_font = font;
@ -75,17 +75,17 @@ class Text : Drawableimpl!(sfText)
setCharacterSize(size);
}
/**
* Construct the string from a unicode text
*
* Prefixs string litterals with d
*
* Params:
* text = Text assigned to the string
* font = Font used to draw the string (use default font)
* size = Characters size, in pixels (32 by default)
*/
this(dstring text, Font font = Font.getDefaultFont(), uint size = 30)
/**
* Construct the string from a unicode text
*
* Prefixs string litterals with d
*
* Params:
* text = Text assigned to the string
* font = Font used to draw the string (use default font)
* size = Characters size, in pixels (32 by default)
*/
this(dstring text, Font font = Font.getDefaultFont(), uint size = 30)
{
super();
m_font = font;
@ -94,145 +94,145 @@ class Text : Drawableimpl!(sfText)
setCharacterSize(size);
}
/**
* Set the text (from a multibyte string)
*
* Params:
* text = New text
*
*/
void setString(string text)
/**
* Set the text (from a multibyte string)
*
* Params:
* text = New text
*
*/
void setString(string text)
{
sfText_SetString(m_ptr,toStringz(text));
}
/**
* Set the text (from a unicode string)
*
* Params:
* text = New text
*/
void setString(dstring text)
/**
* Set the text (from a unicode string)
*
* Params:
* text = New text
*/
void setString(dstring text)
{
sfText_SetUnicodeString(m_ptr, toStringz(text));
}
/**
* Set the font of the string
*
* Params:
* font = Font filename
*/
void setFont(Font font)
/**
* Set the font of the string
*
* Params:
* font = Font filename
*/
void setFont(Font font)
{
m_font = font;
m_font = font;
sfText_SetFont(m_ptr, font.getNativePointer);
}
/**
* Set the size of the string
*
* Params:
* size = New size, in pixels
*/
void setCharacterSize(uint size)
/**
* Set the size of the string
*
* Params:
* size = New size, in pixels
*/
void setCharacterSize(uint size)
{
sfText_SetCharacterSize(m_ptr, size);
}
/**
* Set the style of the text
* The default style is Regular
*
* Params:
* TextStyle = New text style, (combination of Style enum values)
*
*/
void setStyle(TextStyle style)
{
sfText_SetStyle(m_ptr, style);
}
/**
* Set the style of the text
* The default style is Regular
*
* Params:
* TextStyle = New text style, (combination of Style enum values)
*
*/
void setStyle(TextStyle style)
{
sfText_SetStyle(m_ptr, style);
}
/**
* Get the text (returns a unicode string)
*
* Returns:
* Text
*/
dstring getUnicodeText()
/**
* Get the text (returns a unicode string)
*
* Returns:
* Text
*/
dstring getUnicodeText()
{
return fromStringz(sfText_GetUnicodeString(m_ptr));
}
/**
* Get the text (returns a multibyte string)
*
* Returns:
* Text
*/
string getText()
/**
* Get the text (returns a multibyte string)
*
* Returns:
* Text
*/
string getText()
{
return fromStringz(sfText_GetString(m_ptr));
}
/**
* Get the font used by the string
*
* Returns:
* Font name
*/
Font getFont()
/**
* Get the font used by the string
*
* Returns:
* Font name
*/
Font getFont()
{
return m_font;
}
/**
* Get the size of the characters
*
* Returns:
* Size of the characters
*/
uint getCharacterSize()
/**
* Get the size of the characters
*
* Returns:
* Size of the characters
*/
uint getCharacterSize()
{
return sfText_GetCharacterSize(m_ptr);
}
/**
* Get the current font style
*
* Returns:
* Font style
*/
TextStyle getStyle()
{
return sfText_GetStyle(m_ptr);
}
/**
* Return the visual position of the Index-th character of the string,
* in coordinates relative to the string
* (note : translation, center, rotation and scale are not applied)
*
* Params:
* index = Index of the character
*
* Returns:
* Position of the Index-th character (end of string of Index is out of range)
*/
Vector2f getCharacterPos(size_t index)
{
Vector2f ret;
sfText_GetCharacterPos(m_ptr, index, &ret.x, &ret.y);
return ret;
}
/**
* Get the string rectangle on screen
*
* Returns:
* Rectangle contaning the string in screen coordinates
*/
FloatRect getRect()
/**
* Get the current font style
*
* Returns:
* Font style
*/
TextStyle getStyle()
{
return sfText_GetStyle(m_ptr);
}
/**
* Return the visual position of the Index-th character of the string,
* in coordinates relative to the string
* (note : translation, center, rotation and scale are not applied)
*
* Params:
* index = Index of the character
*
* Returns:
* Position of the Index-th character (end of string of Index is out of range)
*/
Vector2f getCharacterPos(size_t index)
{
Vector2f ret;
sfText_GetCharacterPos(m_ptr, index, &ret.x, &ret.y);
return ret;
}
/**
* Get the string rectangle on screen
*
* Returns:
* Rectangle contaning the string in screen coordinates
*/
FloatRect getRect()
{
sfFloatRect sfRect = sfText_GetRect(m_ptr);
@ -240,55 +240,55 @@ class Text : Drawableimpl!(sfText)
}
private:
Font m_font;
extern (C)
{
typedef void function(void*, cchar*) pf_sfText_SetString;
typedef void function(void*, cdchar*) pf_sfText_SetUnicodeString;
typedef void function(void*, void*) pf_sfText_SetFont;
typedef void function(void*, uint) pf_sfText_SetCharacterSize;
typedef void function(void*, TextStyle) pf_sfText_SetStyle;
typedef idchar* function(void*) pf_sfText_GetUnicodeString;
typedef ichar* function(void*) pf_sfText_GetString;
typedef void* function(void*) pf_sfText_GetFont;
typedef uint function(void*) pf_sfText_GetCharacterSize;
typedef TextStyle function (void*) pf_sfText_GetStyle;
typedef void function(void*, size_t, float*, float*) pf_sfText_GetCharacterPos;
typedef sfFloatRect function(void*) pf_sfText_GetRect;
static pf_sfText_SetString sfText_SetString;
static pf_sfText_SetUnicodeString sfText_SetUnicodeString;
static pf_sfText_SetFont sfText_SetFont;
static pf_sfText_SetCharacterSize sfText_SetCharacterSize;
static pf_sfText_SetStyle sfText_SetStyle;
static pf_sfText_GetUnicodeString sfText_GetUnicodeString;
static pf_sfText_GetString sfText_GetString;
static pf_sfText_GetFont sfText_GetFont;
static pf_sfText_GetCharacterSize sfText_GetCharacterSize;
static pf_sfText_GetStyle sfText_GetStyle;
static pf_sfText_GetCharacterPos sfText_GetCharacterPos;
static pf_sfText_GetRect sfText_GetRect;
}
Font m_font;
extern (C)
{
typedef void function(void*, cchar*) pf_sfText_SetString;
typedef void function(void*, cdchar*) pf_sfText_SetUnicodeString;
typedef void function(void*, void*) pf_sfText_SetFont;
typedef void function(void*, uint) pf_sfText_SetCharacterSize;
typedef void function(void*, TextStyle) pf_sfText_SetStyle;
typedef idchar* function(void*) pf_sfText_GetUnicodeString;
typedef ichar* function(void*) pf_sfText_GetString;
typedef void* function(void*) pf_sfText_GetFont;
typedef uint function(void*) pf_sfText_GetCharacterSize;
typedef TextStyle function (void*) pf_sfText_GetStyle;
typedef void function(void*, size_t, float*, float*) pf_sfText_GetCharacterPos;
typedef sfFloatRect function(void*) pf_sfText_GetRect;
static pf_sfText_SetString sfText_SetString;
static pf_sfText_SetUnicodeString sfText_SetUnicodeString;
static pf_sfText_SetFont sfText_SetFont;
static pf_sfText_SetCharacterSize sfText_SetCharacterSize;
static pf_sfText_SetStyle sfText_SetStyle;
static pf_sfText_GetUnicodeString sfText_GetUnicodeString;
static pf_sfText_GetString sfText_GetString;
static pf_sfText_GetFont sfText_GetFont;
static pf_sfText_GetCharacterSize sfText_GetCharacterSize;
static pf_sfText_GetStyle sfText_GetStyle;
static pf_sfText_GetCharacterPos sfText_GetCharacterPos;
static pf_sfText_GetRect sfText_GetRect;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-graphics-d");
else
DllLoader dll = DllLoader.load("csfml-graphics");
sfText_SetString = cast(pf_sfText_SetString)dll.getSymbol("sfText_SetString");
sfText_SetUnicodeString = cast(pf_sfText_SetUnicodeString)dll.getSymbol("sfText_SetUnicodeString");
sfText_SetFont = cast(pf_sfText_SetFont)dll.getSymbol("sfText_SetFont");
sfText_SetCharacterSize = cast(pf_sfText_SetCharacterSize)dll.getSymbol("sfText_SetCharacterSize");
sfText_SetStyle = cast(pf_sfText_SetStyle)dll.getSymbol("sfText_SetStyle");
sfText_GetUnicodeString = cast(pf_sfText_GetUnicodeString)dll.getSymbol("sfText_GetUnicodeString");
sfText_GetString = cast(pf_sfText_GetString)dll.getSymbol("sfText_GetString");
sfText_GetFont = cast(pf_sfText_GetFont)dll.getSymbol("sfText_GetFont");
sfText_GetCharacterSize = cast(pf_sfText_GetCharacterSize)dll.getSymbol("sfText_GetCharacterSize");
sfText_GetStyle = cast(pf_sfText_GetStyle)dll.getSymbol("sfText_GetStyle");
sfText_GetCharacterPos = cast(pf_sfText_GetCharacterPos)dll.getSymbol("sfText_GetCharacterPos");
sfText_GetRect = cast(pf_sfText_GetRect)dll.getSymbol("sfText_GetRect");
}
sfText_SetString = cast(pf_sfText_SetString)dll.getSymbol("sfText_SetString");
sfText_SetUnicodeString = cast(pf_sfText_SetUnicodeString)dll.getSymbol("sfText_SetUnicodeString");
sfText_SetFont = cast(pf_sfText_SetFont)dll.getSymbol("sfText_SetFont");
sfText_SetCharacterSize = cast(pf_sfText_SetCharacterSize)dll.getSymbol("sfText_SetCharacterSize");
sfText_SetStyle = cast(pf_sfText_SetStyle)dll.getSymbol("sfText_SetStyle");
sfText_GetUnicodeString = cast(pf_sfText_GetUnicodeString)dll.getSymbol("sfText_GetUnicodeString");
sfText_GetString = cast(pf_sfText_GetString)dll.getSymbol("sfText_GetString");
sfText_GetFont = cast(pf_sfText_GetFont)dll.getSymbol("sfText_GetFont");
sfText_GetCharacterSize = cast(pf_sfText_GetCharacterSize)dll.getSymbol("sfText_GetCharacterSize");
sfText_GetStyle = cast(pf_sfText_GetStyle)dll.getSymbol("sfText_GetStyle");
sfText_GetCharacterPos = cast(pf_sfText_GetCharacterPos)dll.getSymbol("sfText_GetCharacterPos");
sfText_GetRect = cast(pf_sfText_GetRect)dll.getSymbol("sfText_GetRect");
}
}

View file

@ -1,38 +1,38 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.textstyle;
/**
* Enumerate the string drawing styles
* Enumerate the string drawing styles
*/
enum TextStyle
{
REGULAR = 0, /// Regular characters, no style
BOLD = 1 << 0, /// Characters are bold
ITALIC = 1 << 1, /// Characters are in italic
UNDERLINED = 1 << 2 /// Characters are underlined
REGULAR = 0, /// Regular characters, no style
BOLD = 1 << 0, /// Characters are bold
ITALIC = 1 << 1, /// Characters are in italic
UNDERLINED = 1 << 2 /// Characters are underlined
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.graphics.view;
@ -33,8 +33,8 @@ import dsfml.system.common,
dsfml.system.vector2;
/**
* This class defines a view (position, size and zoom) ;
* you can consider it as a camera
* This class defines a view (position, size and zoom) ;
* you can consider it as a camera
*/
class View : DSFMLObject
{
@ -43,200 +43,200 @@ private:
bool m_isModified = true;
public:
/**
* Constructor
*
* Default view (1000 x 1000)
*/
this()
{
super(sfView_Create());
}
/**
* Constructor
*
* Params:
* center = center of the view
* size = size of the view (width, height)
*/
this(Vector2f center, Vector2f size)
{
super(sfView_CreateFromRect(sfFloatRect(center.x - size.x / 2, center.y - size.y / 2, center.x + size.x / 2, center.y + size.y / 2) ));
}
/**
* Constructor
*
* Params:
* rect = Rectangle defining the position and size of the view
*/
this(FloatRect rect)
{
super(sfView_CreateFromRect(rect.toCFloatRect()));
}
/**
* Constructor
*
* Default view (1000 x 1000)
*/
this()
{
super(sfView_Create());
}
/**
* Constructor
*
* Params:
* center = center of the view
* size = size of the view (width, height)
*/
this(Vector2f center, Vector2f size)
{
super(sfView_CreateFromRect(sfFloatRect(center.x - size.x / 2, center.y - size.y / 2, center.x + size.x / 2, center.y + size.y / 2) ));
}
/**
* Constructor
*
* Params:
* rect = Rectangle defining the position and size of the view
*/
this(FloatRect rect)
{
super(sfView_CreateFromRect(rect.toCFloatRect()));
}
override void dispose()
{
sfView_Destroy(m_ptr);
}
/**
* Change the center of the view
*
* Params:
* x = X coordinates of the new center
* y = Y coordinates of the new center
*/
void setCenter(float x, float y)
{
sfView_SetCenter(m_ptr, x, y);
m_isModified = true;
}
override void dispose()
{
sfView_Destroy(m_ptr);
}
/**
* Change the center of the view
*
* Params:
* x = X coordinates of the new center
* y = Y coordinates of the new center
*/
void setCenter(float x, float y)
{
sfView_SetCenter(m_ptr, x, y);
m_isModified = true;
}
/**
* Change the center of the view
*
* Params:
* center = New center
*/
void setCenter(Vector2f center)
{
sfView_SetCenter(m_ptr, center.x, center.y);
m_isModified = true;
}
/**
* Change the center of the view
*
* Params:
* center = New center
*/
void setCenter(Vector2f center)
{
sfView_SetCenter(m_ptr, center.x, center.y);
m_isModified = true;
}
/**
* Change the size of the view (take 2 values)
*
* Params:
* width = New width
* height = New height
*/
void setSize(float width, float height)
{
sfView_SetSize(m_ptr, width, height);
m_isModified = true;
}
/**
* Change the size of the view (take 2 values)
*
* Params:
* width = New width
* height = New height
*/
void setSize(float width, float height)
{
sfView_SetSize(m_ptr, width, height);
m_isModified = true;
}
/**
* Change the size of the view (take 2 values)
*
* Params:
* size = New size
*/
void setSize(Vector2f size)
{
sfView_SetSize(m_ptr, size.x, size.y);
m_isModified = true;
}
/**
* Change the size of the view (take 2 values)
*
* Params:
* size = New size
*/
void setSize(Vector2f size)
{
sfView_SetSize(m_ptr, size.x, size.y);
m_isModified = true;
}
/**
* Rebuild the view from a rectangle
*
* Params:
* viewport : Rectangle defining the position and size of the view
*/
void setViewport(FloatRect viewport)
{
sfView_SetViewport(m_ptr, viewport.toCFloatRect());
m_viewport = viewport;
}
/**
* Rebuild the view from a rectangle
*
* Params:
* viewport : Rectangle defining the position and size of the view
*/
void setViewport(FloatRect viewport)
{
sfView_SetViewport(m_ptr, viewport.toCFloatRect());
m_viewport = viewport;
}
/**
* Get the center of the view
*
* Returns:
* Center of the view
*/
Vector2f GetCenter()
{
return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr));
}
/**
* Get the center of the view
*
* Returns:
* Center of the view
*/
Vector2f GetCenter()
{
return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr));
}
/**
* Get the size of the view
*
* Returns:
* size of the view
*/
Vector2f getSize()
{
return Vector2f(sfView_GetWidth(m_ptr), sfView_GetHeight(m_ptr));
}
/**
* Get the width of the view
*
* Returns:
* width of the view
*/
float getWidth()
{
return sfView_GetWidth(m_ptr);
}
/**
* Get the size of the view
*
* Returns:
* size of the view
*/
Vector2f getSize()
{
return Vector2f(sfView_GetWidth(m_ptr), sfView_GetHeight(m_ptr));
}
/**
* Get the width of the view
*
* Returns:
* width of the view
*/
float getWidth()
{
return sfView_GetWidth(m_ptr);
}
/**
* Get the height of the view
*
* Returns:
* height of the view
*/
float getHeight()
{
return sfView_GetHeight(m_ptr);
}
/**
* Get the bounding retangle of the view
*/
FloatRect getViewport()
{
if (m_isModified)
{
m_isModified = false;
sfFloatRect cViewport = sfView_GetViewport(m_ptr);
m_viewport = new FloatRect(cViewport.Left, cViewport.Top, cViewport.Right, cViewport.Bottom);
}
return m_viewport;
}
/**
* Move the view
*
* Params:
* offsetX = Offset to move the view, on X axis
* offsetY = Offset to move the view, on Y axis
*/
void move(float offsetX, float offsetY)
{
sfView_Move(m_ptr, offsetX, offsetY);
m_isModified = true;
}
/**
* Get the height of the view
*
* Returns:
* height of the view
*/
float getHeight()
{
return sfView_GetHeight(m_ptr);
}
/**
* Get the bounding retangle of the view
*/
FloatRect getViewport()
{
if (m_isModified)
{
m_isModified = false;
sfFloatRect cViewport = sfView_GetViewport(m_ptr);
m_viewport = new FloatRect(cViewport.Left, cViewport.Top, cViewport.Right, cViewport.Bottom);
}
return m_viewport;
}
/**
* Move the view
*
* Params:
* offsetX = Offset to move the view, on X axis
* offsetY = Offset to move the view, on Y axis
*/
void move(float offsetX, float offsetY)
{
sfView_Move(m_ptr, offsetX, offsetY);
m_isModified = true;
}
/**
* Move the view
*
* Params:
* offset = offsetto move the view
*/
void move(Vector2f offset)
{
sfView_Move(m_ptr, offset.x, offset.y);
m_isModified = true;
}
/**
* Resize the view rectangle to simulate a zoom / unzoom effect
*
* Params:
* factor = Zoom factor to apply, relative to the current zoom
*/
void zoom(float factor)
{
sfView_Zoom(m_ptr, factor);
m_isModified = true;
}
/**
* Move the view
*
* Params:
* offset = offsetto move the view
*/
void move(Vector2f offset)
{
sfView_Move(m_ptr, offset.x, offset.y);
m_isModified = true;
}
/**
* Resize the view rectangle to simulate a zoom / unzoom effect
*
* Params:
* factor = Zoom factor to apply, relative to the current zoom
*/
void zoom(float factor)
{
sfView_Zoom(m_ptr, factor);
m_isModified = true;
}
/**
* Rotate the view relatively to its current orientation.