optimize: clear WARNING C4353 & no exception thrown in time::Now
refactoring: Transform move to base package
This commit is contained in:
parent
5875f0d2b1
commit
6ec03fa0c9
|
|
@ -20,22 +20,13 @@
|
|||
|
||||
#pragma once
|
||||
#include "macros.h"
|
||||
#include "Color.h"
|
||||
#include "Size.h"
|
||||
#include "Point.hpp"
|
||||
#include "Size.hpp"
|
||||
#include "Rect.hpp"
|
||||
#include "../math/vector.hpp"
|
||||
#include "Color.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
// 坐标
|
||||
//
|
||||
// Usage:
|
||||
// 表示一个二维空间的坐标: Point origin(0, 0);
|
||||
// 计算两点间距离: float distance = p1.Distance(p2);
|
||||
// 坐标可以相加减: Point p = Point(10, 10) + Point(20, 20); // p 的坐标是 (30, 30)
|
||||
//
|
||||
using Point = math::Vector2;
|
||||
|
||||
using String = std::wstring;
|
||||
|
||||
// 方向
|
||||
|
|
|
|||
|
|
@ -515,12 +515,12 @@ namespace easy2d
|
|||
this->SetSize(size.width, size.height);
|
||||
}
|
||||
|
||||
math::Transform const& Node::GetTransform() const
|
||||
Transform const& Node::GetTransform() const
|
||||
{
|
||||
return transform_;
|
||||
}
|
||||
|
||||
void Node::SetTransform(math::Transform const& transform)
|
||||
void Node::SetTransform(Transform const& transform)
|
||||
{
|
||||
transform_ = transform;
|
||||
dirty_transform_ = true;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@
|
|||
#include "MouseEvent.h"
|
||||
#include "ActionManager.h"
|
||||
#include "TaskManager.h"
|
||||
#include "Transform.hpp"
|
||||
#include "intrusive/List.hpp"
|
||||
#include "../math/Transform.hpp"
|
||||
#include "../math/Matrix.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -281,10 +280,10 @@ namespace easy2d
|
|||
const Color& color
|
||||
);
|
||||
|
||||
math::Transform const& GetTransform() const;
|
||||
Transform const& GetTransform() const;
|
||||
|
||||
void SetTransform(
|
||||
math::Transform const& transform
|
||||
Transform const& transform
|
||||
);
|
||||
|
||||
// 判断点是否在节点内
|
||||
|
|
@ -383,7 +382,7 @@ namespace easy2d
|
|||
Color border_color_;
|
||||
Children children_;
|
||||
ID2D1Geometry* border_;
|
||||
math::Transform transform_;
|
||||
Transform transform_;
|
||||
math::Matrix initial_matrix_;
|
||||
math::Matrix final_matrix_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../math/vector.hpp"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
// 坐标
|
||||
//
|
||||
// Usage:
|
||||
// 表示一个二维空间的坐标: Point origin(0, 0);
|
||||
// 计算两点间距离: float distance = p1.Distance(p2);
|
||||
// 坐标可以相加减: Point p = Point(10, 10) + Point(20, 20); // p 的坐标是 (30, 30)
|
||||
//
|
||||
class Point
|
||||
: public math::Vector2
|
||||
{
|
||||
public:
|
||||
Point() {}
|
||||
|
||||
Point(float x, float y) : math::Vector2(x, y) {}
|
||||
|
||||
Point(Point const& other) : math::Vector2(other.x, other.y) {}
|
||||
|
||||
inline float Distance(Point const& v)
|
||||
{
|
||||
return Point(x - v.x, y - v.y).Length();
|
||||
}
|
||||
|
||||
inline const Point operator + (const Point & other) const
|
||||
{
|
||||
return Point(x + other.x, y + other.y);
|
||||
}
|
||||
|
||||
inline const Point operator - (const Point & other) const
|
||||
{
|
||||
return Point(x - other.x, y - other.y);
|
||||
}
|
||||
|
||||
inline const Point operator * (float val) const
|
||||
{
|
||||
return Point(x * val, y * val);
|
||||
}
|
||||
|
||||
inline const Point operator / (float val) const
|
||||
{
|
||||
return Point(x / val, y / val);
|
||||
}
|
||||
|
||||
inline const Point operator - () const
|
||||
{
|
||||
return Point(-x, -y);
|
||||
}
|
||||
|
||||
inline bool operator == (const Point& other) const
|
||||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
|
||||
inline operator D2D1_POINT_2F () const
|
||||
{
|
||||
return D2D1_POINT_2F{ x, y };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../math/vector.hpp"
|
||||
#include "Size.h"
|
||||
#include "Point.hpp"
|
||||
#include "Size.hpp"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -35,8 +35,6 @@ namespace easy2d
|
|||
//
|
||||
class Rect
|
||||
{
|
||||
using Point = math::Vector2;
|
||||
|
||||
public:
|
||||
Point origin; // 左上角坐标
|
||||
Size size; // 宽度和高度
|
||||
|
|
@ -100,18 +98,14 @@ namespace easy2d
|
|||
inline float GetBottom() const { return origin.y + size.height; }
|
||||
|
||||
// 判断点是否在矩形内
|
||||
inline bool ContainsPoint(
|
||||
const Point& point
|
||||
) const
|
||||
inline bool ContainsPoint(const Point& point) const
|
||||
{
|
||||
return point.x >= origin.x && point.x <= (origin.y + size.height) &&
|
||||
point.y >= origin.y && point.y <= (origin.y + size.height);
|
||||
}
|
||||
|
||||
// 判断两矩形是否相交
|
||||
inline bool Intersects(
|
||||
const Rect& rect
|
||||
) const
|
||||
inline bool Intersects(const Rect& rect) const
|
||||
{
|
||||
return !((origin.x + size.width) < rect.origin.x ||
|
||||
(rect.origin.x + rect.size.width) < origin.x ||
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Size.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
Size::Size()
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
Size::Size(float width, float height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
Size::Size(const Size & other)
|
||||
{
|
||||
width = other.width;
|
||||
height = other.height;
|
||||
}
|
||||
|
||||
const Size Size::operator+(const Size & other) const
|
||||
{
|
||||
return Size(width + other.width, height + other.height);
|
||||
}
|
||||
|
||||
const Size Size::operator-(const Size & other) const
|
||||
{
|
||||
return Size(width - other.width, height - other.height);
|
||||
}
|
||||
|
||||
const Size Size::operator*(float val) const
|
||||
{
|
||||
return Size(width * val, height * val);
|
||||
}
|
||||
|
||||
const Size Size::operator/(float val) const
|
||||
{
|
||||
return Size(width / val, height / val);
|
||||
}
|
||||
|
||||
const Size Size::operator-() const
|
||||
{
|
||||
return Size(-width, -height);
|
||||
}
|
||||
|
||||
bool Size::operator==(const Size & other) const
|
||||
{
|
||||
return (width == other.width) && (height == other.height);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,23 +36,53 @@ namespace easy2d
|
|||
float height; // 高度
|
||||
|
||||
public:
|
||||
Size();
|
||||
Size()
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
Size(
|
||||
float width,
|
||||
float height
|
||||
);
|
||||
Size(float width, float height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
Size(
|
||||
const Size& other
|
||||
);
|
||||
Size(const Size & other)
|
||||
{
|
||||
width = other.width;
|
||||
height = other.height;
|
||||
}
|
||||
|
||||
const Size operator + (const Size & other) const;
|
||||
const Size operator - (const Size & other) const;
|
||||
const Size operator * (float val) const;
|
||||
const Size operator / (float val) const;
|
||||
const Size operator - () const;
|
||||
bool operator== (const Size& other) const;
|
||||
inline const Size operator+(const Size & other) const
|
||||
{
|
||||
return Size(width + other.width, height + other.height);
|
||||
}
|
||||
|
||||
inline const Size operator-(const Size & other) const
|
||||
{
|
||||
return Size(width - other.width, height - other.height);
|
||||
}
|
||||
|
||||
inline const Size operator*(float val) const
|
||||
{
|
||||
return Size(width * val, height * val);
|
||||
}
|
||||
|
||||
inline const Size operator/(float val) const
|
||||
{
|
||||
return Size(width / val, height / val);
|
||||
}
|
||||
|
||||
inline const Size operator-() const
|
||||
{
|
||||
return Size(-width, -height);
|
||||
}
|
||||
|
||||
inline bool operator==(const Size & other) const
|
||||
{
|
||||
return (width == other.width) && (height == other.height);
|
||||
}
|
||||
|
||||
inline operator D2D1_SIZE_F () const
|
||||
{
|
||||
|
|
@ -19,22 +19,22 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../base/BaseTypes.hpp"
|
||||
#include "Matrix.hpp"
|
||||
#include "Size.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "../math/Matrix.hpp"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
class Transform
|
||||
{
|
||||
public:
|
||||
Size size; // 大小
|
||||
float rotation; // 旋转
|
||||
math::Vector2 position; // ×ø±ê
|
||||
math::Vector2 scale; // Ëõ·Å
|
||||
math::Vector2 skew; // ´íÇнǶÈ
|
||||
math::Vector2 pivot; // Ö§µã
|
||||
Point position; // ×ø±ê
|
||||
Point scale; // Ëõ·Å
|
||||
Point skew; // ´íÇнǶÈ
|
||||
Point pivot; // Ö§µã
|
||||
|
||||
public:
|
||||
Transform()
|
||||
|
|
@ -46,13 +46,13 @@ namespace easy2d
|
|||
, pivot(0.f, 0.f)
|
||||
{}
|
||||
|
||||
inline Matrix ToMatrix() const
|
||||
inline math::Matrix ToMatrix() const
|
||||
{
|
||||
auto center = Vector2{ size.width * pivot.x, size.height * pivot.y };
|
||||
return Matrix{} * Matrix::Scaling(scale.x, scale.y, center)
|
||||
* Matrix::Skewing(skew.x, skew.y, center)
|
||||
* Matrix::Rotation(rotation, center)
|
||||
* Matrix::Translation(position - center);
|
||||
math::Vector2 center{ size.width * pivot.x, size.height * pivot.y };
|
||||
return math::Matrix::Scaling(scale.x, scale.y, center)
|
||||
* math::Matrix::Skewing(skew.x, skew.y, center)
|
||||
* math::Matrix::Rotation(rotation, center)
|
||||
* math::Matrix::Translation(position.x - center.x, position.y - center.y);
|
||||
}
|
||||
|
||||
bool operator== (const Transform& other) const
|
||||
|
|
@ -66,4 +66,3 @@ namespace easy2d
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -276,12 +276,12 @@ namespace easy2d
|
|||
|
||||
if (out_scene_)
|
||||
{
|
||||
out_scene_->SetTransform(math::Transform{});
|
||||
out_scene_->SetTransform(Transform{});
|
||||
}
|
||||
|
||||
if (in_scene_)
|
||||
{
|
||||
auto transform = math::Transform{};
|
||||
auto transform = Transform{};
|
||||
transform.position = start_pos_;
|
||||
in_scene_->SetTransform(transform);
|
||||
}
|
||||
|
|
@ -293,14 +293,14 @@ namespace easy2d
|
|||
|
||||
if (out_scene_)
|
||||
{
|
||||
auto transform = math::Transform{};
|
||||
auto transform = Transform{};
|
||||
transform.position = pos_delta_ * process_;
|
||||
out_scene_->SetTransform(transform);
|
||||
}
|
||||
|
||||
if (in_scene_)
|
||||
{
|
||||
auto transform = math::Transform{};
|
||||
auto transform = Transform{};
|
||||
transform.position = start_pos_ + pos_delta_ * process_;
|
||||
in_scene_->SetTransform(transform);
|
||||
}
|
||||
|
|
@ -310,12 +310,12 @@ namespace easy2d
|
|||
{
|
||||
if (out_scene_)
|
||||
{
|
||||
out_scene_->SetTransform(math::Transform{});
|
||||
out_scene_->SetTransform(Transform{});
|
||||
}
|
||||
|
||||
if (in_scene_)
|
||||
{
|
||||
in_scene_->SetTransform(math::Transform{});
|
||||
in_scene_->SetTransform(Transform{});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ namespace easy2d
|
|||
{
|
||||
Transition::Init(prev, next);
|
||||
|
||||
auto transform = math::Transform{};
|
||||
auto transform = Transform{};
|
||||
transform.pivot = Point{ 0.5f, 0.5f };
|
||||
transform.position = Point{ window_size_.width / 2, window_size_.height / 2 };
|
||||
|
||||
|
|
@ -384,12 +384,12 @@ namespace easy2d
|
|||
{
|
||||
if (out_scene_)
|
||||
{
|
||||
out_scene_->SetTransform(math::Transform{});
|
||||
out_scene_->SetTransform(Transform{});
|
||||
}
|
||||
|
||||
if (in_scene_)
|
||||
{
|
||||
in_scene_->SetTransform(math::Transform{});
|
||||
in_scene_->SetTransform(Transform{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
#include <mfreadwrite.h>
|
||||
|
||||
#include <assert.h>
|
||||
namespace easy2d
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#pragma once
|
||||
#include "BaseTypes.hpp"
|
||||
#include "intrusive/SmartPointer.hpp"
|
||||
#include "RefCounter.hpp"
|
||||
#include "intrusive/SmartPointer.hpp"
|
||||
|
||||
|
||||
#ifndef E2D_DECLARE_SMART_PTR
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@
|
|||
#include <stdexcept>
|
||||
#include <functional>
|
||||
|
||||
#undef DEBUG_CHECK_LIST
|
||||
#ifdef E2D_DEBUG
|
||||
# define DEBUG_CHECK_LIST(list_ptr) list_ptr->Check()
|
||||
#else
|
||||
# define DEBUG_CHECK_LIST __noop
|
||||
#endif
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
namespace intrusive
|
||||
|
|
@ -95,9 +102,7 @@ namespace easy2d
|
|||
last_ = child;
|
||||
++size_;
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
Check();
|
||||
#endif
|
||||
DEBUG_CHECK_LIST(this);
|
||||
}
|
||||
|
||||
void PushFront(T& child)
|
||||
|
|
@ -117,9 +122,7 @@ namespace easy2d
|
|||
first_ = child;
|
||||
++size_;
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
Check();
|
||||
#endif
|
||||
DEBUG_CHECK_LIST(this);
|
||||
}
|
||||
|
||||
void Remove(T& child)
|
||||
|
|
@ -156,9 +159,7 @@ namespace easy2d
|
|||
child->next_ = nullptr;
|
||||
--size_;
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
Check();
|
||||
#endif
|
||||
DEBUG_CHECK_LIST(this);
|
||||
}
|
||||
|
||||
void Insert(T& child, T& before)
|
||||
|
|
@ -173,9 +174,7 @@ namespace easy2d
|
|||
before->prev_ = child;
|
||||
++size_;
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
Check();
|
||||
#endif
|
||||
DEBUG_CHECK_LIST(this);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
|
|
@ -229,9 +228,7 @@ namespace easy2d
|
|||
first_ = *temp_vec.begin();
|
||||
last_ = *temp_vec.rbegin();
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
Check();
|
||||
#endif
|
||||
DEBUG_CHECK_LIST(this);
|
||||
}
|
||||
|
||||
#ifdef E2D_DEBUG
|
||||
|
|
@ -271,3 +268,5 @@ namespace easy2d
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
#undef DEBUG_CHECK_LIST
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
# ifdef E2D_DEBUG
|
||||
# define E2D_LOG(format, ...) easy2d::logs::Println(format, ##__VA_ARGS__)
|
||||
# else
|
||||
# define E2D_LOG ((void)0)
|
||||
# define E2D_LOG __noop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,18 @@ namespace easy2d
|
|||
{
|
||||
namespace devices
|
||||
{
|
||||
namespace
|
||||
{
|
||||
inline D2D1_MATRIX_3X2_F ConvertToD2DMatrix(math::Matrix const& matrix)
|
||||
{
|
||||
return D2D1_MATRIX_3X2_F{
|
||||
matrix.m[0], matrix.m[1],
|
||||
matrix.m[2], matrix.m[3],
|
||||
matrix.m[4], matrix.m[5]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsDevice::GraphicsDevice()
|
||||
: fps_text_format_(nullptr)
|
||||
, fps_text_layout_(nullptr)
|
||||
|
|
@ -211,7 +223,7 @@ namespace easy2d
|
|||
{
|
||||
hr = d2d.factory->CreateTransformedGeometry(
|
||||
rectangle,
|
||||
matrix,
|
||||
ConvertToD2DMatrix(matrix),
|
||||
&transformed
|
||||
);
|
||||
}
|
||||
|
|
@ -340,7 +352,7 @@ namespace easy2d
|
|||
if (!d2d.render_target)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
d2d.render_target->SetTransform(clip_matrix);
|
||||
d2d.render_target->SetTransform(ConvertToD2DMatrix(clip_matrix));
|
||||
d2d.render_target->PushAxisAlignedClip(
|
||||
D2D1::RectF(0, 0, clip_size.width, clip_size.height),
|
||||
D2D1_ANTIALIAS_MODE_PER_PRIMITIVE
|
||||
|
|
@ -591,7 +603,7 @@ namespace easy2d
|
|||
if (!d2d.render_target)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
d2d.render_target->SetTransform(matrix);
|
||||
d2d.render_target->SetTransform(ConvertToD2DMatrix(matrix));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -434,17 +434,13 @@ namespace easy2d
|
|||
// Functions
|
||||
//-------------------------------------------------------
|
||||
|
||||
TimePoint easy2d::time::Now()
|
||||
TimePoint easy2d::time::Now() E2D_NOEXCEPT
|
||||
{
|
||||
static LARGE_INTEGER freq = {};
|
||||
if (freq.QuadPart == 0LL)
|
||||
{
|
||||
if (QueryPerformanceFrequency(&freq) == 0)
|
||||
{
|
||||
const char* err = "QueryPerformanceFrequency not supported";
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), err);
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
// the function will always succceed on systems that run Windows XP or later
|
||||
QueryPerformanceFrequency(&freq);
|
||||
}
|
||||
|
||||
LARGE_INTEGER count;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace easy2d
|
|||
};
|
||||
|
||||
// 获取当前时间
|
||||
TimePoint Now();
|
||||
TimePoint Now() E2D_NOEXCEPT;
|
||||
|
||||
// 时间段格式化
|
||||
// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace easy2d
|
|||
::UnregisterClass(REGISTER_CLASS, hinstance);
|
||||
|
||||
const char* err = "Create window failed!";
|
||||
logs::Errorln(err);
|
||||
logs::Errorln(HRESULT_FROM_WIN32(GetLastError()), err);
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,14 @@
|
|||
#include "base/time.h"
|
||||
#include "base/logs.h"
|
||||
|
||||
#include "base/Size.h"
|
||||
#include "base/Point.hpp"
|
||||
#include "base/Size.hpp"
|
||||
#include "base/Rect.hpp"
|
||||
#include "base/Font.hpp"
|
||||
#include "base/TextStyle.hpp"
|
||||
#include "base/Color.h"
|
||||
#include "base/Resource.h"
|
||||
#include "base/Transform.hpp"
|
||||
#include "base/TextStyle.hpp"
|
||||
|
||||
#include "base/intrusive/SmartPointer.hpp"
|
||||
#include "base/intrusive/List.hpp"
|
||||
|
|
@ -78,9 +80,8 @@
|
|||
|
||||
#include "math/scalar.hpp"
|
||||
#include "math/vector.hpp"
|
||||
#include "math/Matrix.hpp"
|
||||
#include "math/Transform.hpp"
|
||||
#include "math/rand.h"
|
||||
#include "math/Matrix.hpp"
|
||||
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "vector.hpp"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -41,6 +40,7 @@ namespace easy2d
|
|||
|
||||
class Matrix
|
||||
{
|
||||
public:
|
||||
float m[6]; // m[3][2]
|
||||
|
||||
public:
|
||||
|
|
@ -91,15 +91,6 @@ namespace easy2d
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline operator D2D1_MATRIX_3X2_F () const
|
||||
{
|
||||
return D2D1_MATRIX_3X2_F{
|
||||
m[0], m[1],
|
||||
m[2], m[3],
|
||||
m[4], m[5]
|
||||
};
|
||||
}
|
||||
|
||||
inline Matrix& Identity()
|
||||
{
|
||||
m[0] = 1.f; m[1] = 0.f;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "scalar.hpp"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -55,11 +54,6 @@ namespace easy2d
|
|||
return math::Sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
inline float Distance(const Vector2& v)
|
||||
{
|
||||
return Vector2(x - v.x, y - v.y).Length();
|
||||
}
|
||||
|
||||
inline const Vector2 operator + (const Vector2 & other) const
|
||||
{
|
||||
return Vector2(x + other.x, y + other.y);
|
||||
|
|
@ -89,11 +83,6 @@ namespace easy2d
|
|||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
|
||||
inline operator D2D1_POINT_2F () const
|
||||
{
|
||||
return D2D1_POINT_2F{ x, y };
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -43,13 +43,14 @@
|
|||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Point.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
<ClInclude Include="..\..\core\base\Singleton.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Size.h" />
|
||||
<ClInclude Include="..\..\core\base\Size.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Sprite.h" />
|
||||
<ClInclude Include="..\..\core\base\Task.h" />
|
||||
<ClInclude Include="..\..\core\base\TaskManager.h" />
|
||||
|
|
@ -57,13 +58,13 @@
|
|||
<ClInclude Include="..\..\core\base\TextRenderer.h" />
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp" />
|
||||
<ClInclude Include="..\..\core\base\time.h" />
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Transition.h" />
|
||||
<ClInclude Include="..\..\core\base\window.h" />
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||
<ClInclude Include="..\..\core\math\rand.h" />
|
||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\math\vector.hpp" />
|
||||
<ClInclude Include="..\..\core\ui\Button.h" />
|
||||
<ClInclude Include="..\..\core\ui\Menu.h" />
|
||||
|
|
@ -93,7 +94,6 @@
|
|||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Size.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Task.cpp" />
|
||||
<ClCompile Include="..\..\core\base\TaskManager.cpp" />
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Scene.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Sprite.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -137,9 +134,6 @@
|
|||
<ClInclude Include="..\..\core\base\TaskManager.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -158,6 +152,15 @@
|
|||
<ClInclude Include="..\..\core\base\BaseTypes.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Point.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -222,9 +225,6 @@
|
|||
<ClCompile Include="..\..\core\base\Scene.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Size.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -43,13 +43,14 @@
|
|||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Point.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
<ClInclude Include="..\..\core\base\Singleton.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Size.h" />
|
||||
<ClInclude Include="..\..\core\base\Size.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Sprite.h" />
|
||||
<ClInclude Include="..\..\core\base\Task.h" />
|
||||
<ClInclude Include="..\..\core\base\TaskManager.h" />
|
||||
|
|
@ -57,13 +58,13 @@
|
|||
<ClInclude Include="..\..\core\base\TextRenderer.h" />
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp" />
|
||||
<ClInclude Include="..\..\core\base\time.h" />
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Transition.h" />
|
||||
<ClInclude Include="..\..\core\base\window.h" />
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||
<ClInclude Include="..\..\core\math\rand.h" />
|
||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\math\vector.hpp" />
|
||||
<ClInclude Include="..\..\core\ui\Button.h" />
|
||||
<ClInclude Include="..\..\core\ui\Menu.h" />
|
||||
|
|
@ -93,7 +94,6 @@
|
|||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Size.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Task.cpp" />
|
||||
<ClCompile Include="..\..\core\base\TaskManager.cpp" />
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Scene.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Sprite.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -137,9 +134,6 @@
|
|||
<ClInclude Include="..\..\core\base\TaskManager.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -158,6 +152,15 @@
|
|||
<ClInclude Include="..\..\core\base\BaseTypes.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Point.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -222,9 +225,6 @@
|
|||
<ClCompile Include="..\..\core\base\Scene.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Size.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -43,13 +43,14 @@
|
|||
<ClInclude Include="..\..\core\base\MouseEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Point.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
<ClInclude Include="..\..\core\base\Singleton.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Size.h" />
|
||||
<ClInclude Include="..\..\core\base\Size.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Sprite.h" />
|
||||
<ClInclude Include="..\..\core\base\Task.h" />
|
||||
<ClInclude Include="..\..\core\base\TaskManager.h" />
|
||||
|
|
@ -57,13 +58,13 @@
|
|||
<ClInclude Include="..\..\core\base\TextRenderer.h" />
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp" />
|
||||
<ClInclude Include="..\..\core\base\time.h" />
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\base\Transition.h" />
|
||||
<ClInclude Include="..\..\core\base\window.h" />
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||
<ClInclude Include="..\..\core\math\rand.h" />
|
||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp" />
|
||||
<ClInclude Include="..\..\core\math\vector.hpp" />
|
||||
<ClInclude Include="..\..\core\ui\Button.h" />
|
||||
<ClInclude Include="..\..\core\ui\Menu.h" />
|
||||
|
|
@ -93,7 +94,6 @@
|
|||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Size.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Task.cpp" />
|
||||
<ClCompile Include="..\..\core\base\TaskManager.cpp" />
|
||||
|
|
@ -201,7 +201,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Scene.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Sprite.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -137,9 +134,6 @@
|
|||
<ClInclude Include="..\..\core\base\TaskManager.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\math\Transform.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\TextStyle.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -158,6 +152,15 @@
|
|||
<ClInclude Include="..\..\core\base\BaseTypes.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Transform.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Point.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Size.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -222,9 +225,6 @@
|
|||
<ClCompile Include="..\..\core\base\Scene.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Size.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\Sprite.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
Loading…
Reference in New Issue