Skip to content

Commit

Permalink
MOAIDraw: Rearranged some functions and removed commented out code
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmah committed Aug 9, 2016
1 parent c231ead commit 7018f09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 189 deletions.
205 changes: 20 additions & 185 deletions src/moaicore/MOAIDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,14 +1461,14 @@ int MOAIDraw::_fillRoundedRectangularGradient ( lua_State *L ) {
@in cornerRadius
@in blurMargin
@in steps The number of steps to make each corner.
@in number centerR red of central color
@in number centerG green of central color
@in number centerB blue of central color
@in number centerA alpha of central color
@in number edgeR red of outer color
@in number edgeG green of outer color
@in number edgeB blue of outer color
@in number edgeA alpha of outer color
@in number centerR red of left color
@in number centerG green of left color
@in number centerB blue of left color
@in number centerA alpha of left color
@in number edgeR red of right color
@in number edgeG green of right color
@in number edgeB blue of right color
@in number edgeA alpha of right color
@overload
@in number x0
Expand Down Expand Up @@ -1537,14 +1537,14 @@ int MOAIDraw::_fillRoundedRectangularHorizontalGradient ( lua_State *L ) {
@in cornerRadius
@in blurMargin
@in steps The number of steps to make each corner.
@in number centerR red of central color
@in number centerG green of central color
@in number centerB blue of central color
@in number centerA alpha of central color
@in number edgeR red of outer color
@in number edgeG green of outer color
@in number edgeB blue of outer color
@in number edgeA alpha of outer color
@in number centerR red of top color
@in number centerG green of top color
@in number centerB blue of top color
@in number centerA alpha of top color
@in number edgeR red of bottom color
@in number edgeG green of bottom color
@in number edgeB blue of bottom color
@in number edgeA alpha of bottom color
@overload
@in number x0
Expand Down Expand Up @@ -3359,8 +3359,6 @@ void MOAIDraw::DrawEllipticalSliceHorizontalGradientFill(float x, float y, float

MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();

bool renderBlur = blurMargin > 0.0f;

float theta = angle * ( float )D2R / ( float )steps;
float thetaStep = offset * (float)D2R;

Expand Down Expand Up @@ -3396,41 +3394,6 @@ void MOAIDraw::DrawEllipticalSliceHorizontalGradientFill(float x, float y, float
gfxDevice.EndPrim();

// TODO: Implement blur code
// if (renderBlur) {
// USColorVec transColor(edgeColor);
// transColor.mA = 0.0f;
// if (gfxDevice.GetColorPremultiply()) {
// transColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
// }
//
// thetaStep = offset * (float)D2R;
// // render the arc section
// gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );
// for (i = 0; i <= steps; ++i, thetaStep += theta ) {
//
// // point at blur margin
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx (
// x + ( Sin ( thetaStep ) * (xRad + blurMargin) ),
// y + ( Cos ( thetaStep ) * (yRad + blurMargin) ),
// 0.0f
// );
// gfxDevice.WriteFinalColor4b ();
//
//
// gfxDevice.SetPenColor(edgeColor);
// gfxDevice.WriteVtx (
// x + ( Sin ( thetaStep ) * xRad ),
// y + ( Cos ( thetaStep ) * yRad ),
// 0.0f
// );
// gfxDevice.WriteFinalColor4b ();
//
// }
//
// gfxDevice.EndPrim();
//
// }
gfxDevice.SetPenColor(penColor);

}
Expand All @@ -3441,8 +3404,6 @@ void MOAIDraw::DrawEllipticalSliceVerticalGradientFill(float x, float y, float x

MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();

bool renderBlur = blurMargin > 0.0f;

float theta = angle * ( float )D2R / ( float )steps;
float thetaStep = offset * (float)D2R;

Expand Down Expand Up @@ -3477,42 +3438,7 @@ void MOAIDraw::DrawEllipticalSliceVerticalGradientFill(float x, float y, float x

gfxDevice.EndPrim();

// TODO: Implement blur code
// if (renderBlur) {
// USColorVec transColor(edgeColor);
// transColor.mA = 0.0f;
// if (gfxDevice.GetColorPremultiply()) {
// transColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
// }
//
// thetaStep = offset * (float)D2R;
// // render the arc section
// gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );
// for (i = 0; i <= steps; ++i, thetaStep += theta ) {
//
// // point at blur margin
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx (
// x + ( Sin ( thetaStep ) * (xRad + blurMargin) ),
// y + ( Cos ( thetaStep ) * (yRad + blurMargin) ),
// 0.0f
// );
// gfxDevice.WriteFinalColor4b ();
//
//
// gfxDevice.SetPenColor(edgeColor);
// gfxDevice.WriteVtx (
// x + ( Sin ( thetaStep ) * xRad ),
// y + ( Cos ( thetaStep ) * yRad ),
// 0.0f
// );
// gfxDevice.WriteFinalColor4b ();
//
// }
//
// gfxDevice.EndPrim();
//
// }
// TODO: Implement blur code
gfxDevice.SetPenColor(penColor);

}
Expand Down Expand Up @@ -6054,7 +5980,6 @@ void MOAIDraw::DrawRoundedRectHorizontalGradientFill(float left, float top, floa

MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();

bool renderBlur = blurMargin > 0.0f;
// make sure left is less than right
if (left > right) {
float temp = left;
Expand All @@ -6075,15 +6000,9 @@ void MOAIDraw::DrawRoundedRectHorizontalGradientFill(float left, float top, floa

float width = right - left;

// TODO: Implement blur code
USColorVec penColor = gfxDevice.GetPenColor();
USColorVec workingColor = penColor;
// USColorVec transColor(edgeColor);

// transColor.mA = 0.0f;
// if (gfxDevice.GetColorPremultiply()) {
// transColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
// }


// draw rect in center (left + cornerRadius, bottom + cornerRadius, right - cornerRadius, top - cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );
Expand Down Expand Up @@ -6134,31 +6053,11 @@ void MOAIDraw::DrawRoundedRectHorizontalGradientFill(float left, float top, floa
gfxDevice.WriteVtx(right - cornerRadius, top);
gfxDevice.WriteFinalColor4b();

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left + cornerRadius, top + blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right - cornerRadius, top + blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// }

gfxDevice.EndPrim();

// draw bottom rect (left + cornerRadius, bottom , right - cornerRadius, bottom + cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left + cornerRadius, bottom - blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right - cornerRadius, bottom - blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// }

t = cornerRadius / width;
workingColor.Lerp(leftColor, rightColor, t);
gfxDevice.SetPenColor(workingColor);
Expand All @@ -6184,15 +6083,6 @@ void MOAIDraw::DrawRoundedRectHorizontalGradientFill(float left, float top, floa
// draw left rect (left, bottom + cornerRadius, left + cornerRadius, top - cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left - blurMargin, bottom + cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(left - blurMargin, top - cornerRadius);
// gfxDevice.WriteFinalColor4b();
// }

workingColor = leftColor;
gfxDevice.SetPenColor(workingColor);

Expand Down Expand Up @@ -6236,16 +6126,6 @@ void MOAIDraw::DrawRoundedRectHorizontalGradientFill(float left, float top, floa
gfxDevice.WriteVtx(right, top - cornerRadius);
gfxDevice.WriteFinalColor4b();

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(right + blurMargin, bottom + cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right + blurMargin, top - cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// }

gfxDevice.EndPrim();

float angle = 90.0f;
Expand Down Expand Up @@ -6285,7 +6165,6 @@ void MOAIDraw::DrawRoundedRectVerticalGradientFill(float left, float top, float

MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();

bool renderBlur = blurMargin > 0.0f;
// make sure left is less than right
if (left > right) {
float temp = left;
Expand All @@ -6306,15 +6185,10 @@ void MOAIDraw::DrawRoundedRectVerticalGradientFill(float left, float top, float

float height = top - bottom;

// TODO: Implement blur code

USColorVec penColor = gfxDevice.GetPenColor();
USColorVec workingColor = penColor;
// USColorVec transColor(edgeColor);

// transColor.mA = 0.0f;
// if (gfxDevice.GetColorPremultiply()) {
// transColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
// }


// draw rect in center (left + cornerRadius, bottom + cornerRadius, right - cornerRadius, top - cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );
Expand Down Expand Up @@ -6364,31 +6238,11 @@ void MOAIDraw::DrawRoundedRectVerticalGradientFill(float left, float top, float
gfxDevice.WriteVtx(right - cornerRadius, top);
gfxDevice.WriteFinalColor4b();

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left + cornerRadius, top + blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right - cornerRadius, top + blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// }

gfxDevice.EndPrim();

// draw bottom rect (left + cornerRadius, bottom , right - cornerRadius, bottom + cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left + cornerRadius, bottom - blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right - cornerRadius, bottom - blurMargin);
// gfxDevice.WriteFinalColor4b();
//
// }

workingColor = bottomColor;

gfxDevice.SetPenColor(workingColor);
Expand All @@ -6413,15 +6267,6 @@ void MOAIDraw::DrawRoundedRectVerticalGradientFill(float left, float top, float
// draw left rect (left, bottom + cornerRadius, left + cornerRadius, top - cornerRadius)
gfxDevice.BeginPrim( GL_TRIANGLE_STRIP );

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(left - blurMargin, bottom + cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(left - blurMargin, top - cornerRadius);
// gfxDevice.WriteFinalColor4b();
// }

t = cornerRadius / height;
workingColor.Lerp (bottomColor, topColor, t);

Expand Down Expand Up @@ -6467,16 +6312,6 @@ void MOAIDraw::DrawRoundedRectVerticalGradientFill(float left, float top, float
gfxDevice.WriteVtx(right, top - cornerRadius);
gfxDevice.WriteFinalColor4b();

// if (renderBlur) {
// gfxDevice.SetPenColor(transColor);
// gfxDevice.WriteVtx(right + blurMargin, bottom + cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// gfxDevice.WriteVtx(right + blurMargin, top - cornerRadius);
// gfxDevice.WriteFinalColor4b();
//
// }

gfxDevice.EndPrim();

float angle = 90.0f;
Expand Down
8 changes: 4 additions & 4 deletions src/moaicore/MOAIDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class MOAIDraw :
static int _fillCircularGradient ( lua_State* L );
static int _fillCircularSlice ( lua_State* L );
static int _fillCircularSliceGradient ( lua_State* L );
static int _fillCircularSliceVerticalGradient ( lua_State* L );
static int _fillCircularSliceHorizontalGradient ( lua_State* L );
static int _fillCircularSliceVerticalGradient ( lua_State* L );
static int _fillEllipse ( lua_State* L );
static int _fillEllipticalGradient ( lua_State* L );
static int _fillEllipticalSlice( lua_State* L );
Expand All @@ -63,8 +63,8 @@ class MOAIDraw :
static int _fillRect ( lua_State* L );
static int _fillRoundedRect ( lua_State* L );
static int _fillRoundedRectangularGradient ( lua_State* L );
static int _fillRoundedRectangularVerticalGradient ( lua_State* L );
static int _fillRoundedRectangularHorizontalGradient ( lua_State* L );
static int _fillRoundedRectangularVerticalGradient ( lua_State* L );
static int _fillTriangularGradient ( lua_State* L );
static int _fillVerticalRectangularGradient ( lua_State* L );
static int _drawTexture ( lua_State* L );
Expand Down Expand Up @@ -100,8 +100,8 @@ class MOAIDraw :
static void DrawEllipticalGradientFill ( float x, float y, float xRad, float yRad, u32 steps, const USColorVec &centerColor, const USColorVec &edgeColor );
static void DrawEllipticalSliceFill ( float x, float y, float xRad, float yRad, float angle, float offset, float blurMargin, u32 steps );
static void DrawEllipticalSliceGradientFill ( float x, float y, float xRad, float yRad, float angle, float offset, float blurMargin, u32 steps, const USColorVec &centerColor, const USColorVec &edgeColor );
static void DrawEllipticalSliceVerticalGradientFill ( float x, float y, float xRad, float yRad, float angle, float offset, float blurMargin, u32 steps, const USColorVec &startColor, const USColorVec &endColor );
static void DrawEllipticalSliceHorizontalGradientFill ( float x, float y, float xRad, float yRad, float angle, float offset, float blurMargin, u32 steps, const USColorVec &startColor, const USColorVec &endColor );
static void DrawEllipticalSliceVerticalGradientFill ( float x, float y, float xRad, float yRad, float angle, float offset, float blurMargin, u32 steps, const USColorVec &startColor, const USColorVec &endColor );
static void DrawGrid ( const USRect& rect, u32 xCells, u32 yCells );
static void DrawJoinedCorner ( float x0, float y0, float x1, float y1, float x2, float y2, float lineWidth, float blurMargin );
static void DrawJoinedLine ( lua_State* L, float lineWidth, float blurMargin );
Expand All @@ -125,8 +125,8 @@ class MOAIDraw :
static void DrawRoundBeveledLine ( lua_State* L, float lineWidth, float blurMargin, u32 steps );
static void DrawRoundedRectFill ( float left, float top, float right, float bottom, float cornerRadius, float blurMargin, u32 steps );
static void DrawRoundedRectGradientFill ( float left, float top, float right, float bottom, float cornerRadius, float blurMargin, u32 steps, const USColorVec &centerColor, const USColorVec &edgeColor );
static void DrawRoundedRectVerticalGradientFill ( float left, float top, float right, float bottom, float cornerRadius, float blurMargin, u32 steps, const USColorVec &topColor, const USColorVec &bottomColor );
static void DrawRoundedRectHorizontalGradientFill ( float left, float top, float right, float bottom, float cornerRadius, float blurMargin, u32 steps, const USColorVec &leftColor, const USColorVec &rightColor );
static void DrawRoundedRectVerticalGradientFill ( float left, float top, float right, float bottom, float cornerRadius, float blurMargin, u32 steps, const USColorVec &topColor, const USColorVec &bottomColor );
static void DrawRoundedRectOutline ( float left, float top, float right, float bottom, float cornerRadius, u32 steps );
static void DrawTexture ( float left, float top, float right, float bottom, MOAITexture* texture );
static void DrawTriangularGradientFill (const USVec2D& v0, const USVec2D& v1, const USVec2D& v2, const USColorVec &color0, const USColorVec &color1, const USColorVec &color2);
Expand Down

0 comments on commit 7018f09

Please sign in to comment.