#include "fsCNativeLine.h"
#include <base/Director.h>
#include <2d/DrawNode.h>
#include <fsCore/fsSColour.h>
#include <fsCore/fsAffineMtx2d.h>
void fsCNativeLine::renderDo()
{
mImpl->visit(ax::Director::getInstance()->getRenderer(), mRenderMatrix, ax::Node::FLAGS_TRANSFORM_DIRTY);
}
void fsCNativeLine::alphaBlendModeSetDo(fsS32 pAlphaBlendMode)
{
// if (fsCMaterial::eALPHA_ADD == pAlphaBlendMode)
// {
// mImpl->setBlendFunc(ax::BlendFunc::ALPHA_PREMULTIPLIED);
// }
// mImpl->setOpacityModifyRGB(true);
}
void fsCNativeLine::vertsSetDo(std::vector<fsVec2d> const& pVerts)
{
mRawVerts.clear();
for (auto vert : pVerts)
{
mRawVerts.push_back(ax::Vec2(vert.x, vert.y));<--- Consider using std::transform algorithm instead of a raw loop.
}
mImpl->clear();
mImpl->drawPoly(
&mRawVerts[0],
mRawVerts.size(),
false,
mColour,
3.0f);
}
ax::Node* fsCNativeLine::implGet() const
{
return mImpl;
}
void fsCNativeLine::matrixApplyDo(const fsAffineMtx2d& pRenderMatrix)
{
mRenderMatrix.m[12] = pRenderMatrix.get(0, 2);
mRenderMatrix.m[13] = pRenderMatrix.get(1, 2);
mRenderMatrix.m[0] = pRenderMatrix.get(0, 0);
mRenderMatrix.m[1] = pRenderMatrix.get(1, 0);
mRenderMatrix.m[4] = pRenderMatrix.get(0, 1);
mRenderMatrix.m[5] = pRenderMatrix.get(1, 1);
}
void fsCNativeLine::colourSetDo(const fsSColour4B& pColour)
{
#ifdef AXMOL_V3
mColour = ax::Color32(pColour.mR / 255.f, pColour.mG / 255.f, pColour.mB / 255.f, pColour.mA / 255.f);
#else
mColour = ax::Color4F(pColour.mR / 255.f, pColour.mG / 255.f, pColour.mB / 255.f, pColour.mA / 255.f);
#endif
}
fsCNativeLine::fsCNativeLine():
fsINative(),
mRawVerts(2)
{
mImpl = ax::DrawNode::create();
mImpl->retain();
}
fsCNativeLine::~fsCNativeLine()
{
if (mImpl->getParent())
{
mImpl->removeFromParentAndCleanup(true);
}
mImpl->release();
mImpl = nullptr;
}