2009-01-29 00:18:34 +08:00
|
|
|
/*
|
2010-03-10 02:58:41 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
module dsfml.graphics.idrawable;
|
|
|
|
|
|
|
|
import dsfml.system.vector2;
|
|
|
|
|
2010-03-10 02:58:41 +08:00
|
|
|
import dsfml.graphics.irendertarget;
|
2010-01-07 04:25:45 +08:00
|
|
|
import dsfml.graphics.color,
|
|
|
|
dsfml.graphics.blendmode,
|
|
|
|
dsfml.graphics.renderwindow,
|
2010-01-08 02:07:22 +08:00
|
|
|
dsfml.graphics.renderimage,
|
2010-01-07 04:25:45 +08:00
|
|
|
dsfml.graphics.shader;
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Interface for drawable object
|
|
|
|
*
|
|
|
|
* Shape, Text and Sprite implement IDrawable
|
|
|
|
*/
|
2009-01-29 00:18:34 +08:00
|
|
|
interface IDrawable
|
|
|
|
{
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the left position of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* x = New left coordinate
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setX(float x);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the top position of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* y = New top coordinate
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setY(float y);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the position of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* x = New left coordinate
|
|
|
|
* y = New top coordinate
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setPosition(float x, float y);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the position of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* vec = new position
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setPosition(Vector2f vec);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the horizontal scale of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* scale = New horizontal scale (Strictly positive)
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setScaleX(float scale);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the vertical scale of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* scale = New vertical scale (Strictly positive)
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setScaleY(float scale);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the scale of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* scaleX = New horizontal scale
|
|
|
|
* scaleY = New vertical scale
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setScale(float scaleX, float scaleY);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the scale of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* scale = new scale
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setScale(Vector2f scale);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* 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
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setOrigin(float originX, float originY);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* 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
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setOrigin(Vector2f origin);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the rotation of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* angle = Angle of rotation, in degree
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setRotation(float angle);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the color
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* c = New color
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setColor(Color c);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the blending mode for the object.
|
|
|
|
* The default blend mode is Blend.Alpha
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* mode = New blending mode
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void setBlendMode(BlendMode mode);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the position of the object
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Current position
|
|
|
|
*
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Vector2f getPosition();
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the current scale of the object
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Current scale
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Vector2f getScale();
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the origin of the object
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Current position of the origin
|
|
|
|
*
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Vector2f getOrigin();
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the rotation angle of the object
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Angle of rotation, in degree
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
float getRotation();
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the color of the string
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Current color
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Color getColor();
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Get the current blending mode
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Current blending mode
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
BlendMode getBlendMode();
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Rotate the object
|
|
|
|
* Angle is added to the current orientation of the objet
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* angle = Angle of rotation in degree
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void rotate(float angle);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Move the object
|
|
|
|
* New offset is added to object current position
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* offsetX = Offset on the X axis
|
|
|
|
* offsetY = Offset on the Y axis
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void move(float offsetX, float offsetY);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Move the object
|
|
|
|
* New offset is added to object current position
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* offset = Amount of units to move the object of
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void move(Vector2f offset);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Set the scale of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* scaleX = New horizontal scale (Strictly positive)
|
|
|
|
* scaleY = New vertical scale (Strictly positive)
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void scale(float scaleX, float scaleY);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Scale the object (take a 2D vector)
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* factor = Scaling factors (both values must be strictly positive)
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
void scale(Vector2f factor);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* 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
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Vector2f tranformToLocal(Vector2f point);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
2010-01-07 04:37:29 +08:00
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* 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
|
|
|
|
*/
|
2010-01-07 04:37:29 +08:00
|
|
|
Vector2f tranformToGlobal(Vector2f point);
|
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Render the specific geometry of the object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* window = Target into which render the object
|
|
|
|
*/
|
|
|
|
void render(IRenderTarget window);
|
2010-01-08 02:07:22 +08:00
|
|
|
|
|
|
|
/**
|
2010-03-10 02:58:41 +08:00
|
|
|
* Render the specific geometry of the object with a shader
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* window = Render target
|
|
|
|
* shader = Shader to use
|
2010-01-08 02:07:22 +08:00
|
|
|
*/
|
2010-03-10 02:58:41 +08:00
|
|
|
void renderWithShader(IRenderTarget window, Shader shader);
|
2010-01-07 04:25:45 +08:00
|
|
|
}
|