Commit 283315e1 authored by Oleg Korshul's avatar Oleg Korshul Committed by Alexander.Trofimov

градиент rotateWithShape, эффекты tint, shade, gamma, invGamma

parent ad56c9f4
......@@ -4,7 +4,10 @@ call npm install
rem call grunt --level=WHITESPACE_ONLY --builder=true --formatting=PRETTY_PRINT
call grunt --level=ADVANCED --builder=true
copy ..\word\sdk-all.js ..\..\core\build\jsbuilder\sdkjs\word\sdk-all.js
copy ..\word\sdk-all-min.js ..\..\core\build\jsbuilder\sdkjs\word\sdk-all-min.js
copy ..\slide\sdk-all.js ..\..\core\build\jsbuilder\sdkjs\slide\sdk-all.js
copy ..\slide\sdk-all-min.js ..\..\core\build\jsbuilder\sdkjs\slide\sdk-all-min.js
copy ..\cell\sdk-all.js ..\..\core\build\jsbuilder\sdkjs\cell\sdk-all.js
copy ..\cell\sdk-all-min.js ..\..\core\build\jsbuilder\sdkjs\cell\sdk-all-min.js
copy ..\common\Native\native.js ..\..\core\build\jsbuilder\sdkjs\common\Native\native.js
pause
\ No newline at end of file
......@@ -921,66 +921,104 @@ CColorModifiers.prototype =
this.HSL2RGB(HSL, RGBA);
}
else if (colorMod.name == "wordShade")
{
var val_ = colorMod.val/255;
//GBA.R = Math.max(0, (RGBA.R * (1 - val_)) >> 0);
//GBA.G = Math.max(0, (RGBA.G * (1 - val_)) >> 0);
//GBA.B = Math.max(0, (RGBA.B * (1 - val_)) >> 0);
//RGBA.R = Math.max(0, ((1 - val_)*(- RGBA.R) + RGBA.R) >> 0);
//RGBA.G = Math.max(0, ((1 - val_)*(- RGBA.G) + RGBA.G) >> 0);
//RGBA.B = Math.max(0, ((1 - val_)*(- RGBA.B) + RGBA.B) >> 0);
var HSL = {H: 0, S: 0, L: 0};
this.RGB2HSL(RGBA.R, RGBA.G, RGBA.B, HSL);
if(HSL.L*val_ > max_hls)
HSL.L = max_hls;
else
HSL.L = Math.max(0, (HSL.L * val_) >> 0);
this.HSL2RGB(HSL, RGBA);
}
else if (colorMod.name == "wordTint")
{
var _val = colorMod.val/255;
//RGBA.R = Math.max(0, ((1 - _val)*(255 - RGBA.R) + RGBA.R) >> 0);
//RGBA.G = Math.max(0, ((1 - _val)*(255 - RGBA.G) + RGBA.G) >> 0);
//RGBA.B = Math.max(0, ((1 - _val)*(255 - RGBA.B) + RGBA.B) >> 0);
var HSL = {H: 0, S: 0, L: 0};
this.RGB2HSL(RGBA.R, RGBA.G, RGBA.B, HSL);
var L_ = HSL.L*_val + (255 - colorMod.val);
if(L_ > max_hls)
HSL.L = max_hls;
else
HSL.L = Math.max(0, (L_) >> 0);
this.HSL2RGB(HSL, RGBA);
}
else if (colorMod.name == "shade")
{
RGBA.R = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.R/255) * val)*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.G/255) * val)*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.B/255) * val)*255 >> 0);
}
else if (colorMod.name == "tint")
{
if(val > 0)
{
RGBA.R = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.R/255)) * val)*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.G/255)) * val)*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.B/255)) * val)*255 >> 0);
}
else
{
RGBA.R = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.R/255)) * (1-val))*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.G/255)) * (1-val))*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.B/255)) * (1-val))*255 >> 0);
}
}
else if (colorMod.name == "wordShade")
{
var val_ = colorMod.val/255;
//GBA.R = Math.max(0, (RGBA.R * (1 - val_)) >> 0);
//GBA.G = Math.max(0, (RGBA.G * (1 - val_)) >> 0);
//GBA.B = Math.max(0, (RGBA.B * (1 - val_)) >> 0);
//RGBA.R = Math.max(0, ((1 - val_)*(- RGBA.R) + RGBA.R) >> 0);
//RGBA.G = Math.max(0, ((1 - val_)*(- RGBA.G) + RGBA.G) >> 0);
//RGBA.B = Math.max(0, ((1 - val_)*(- RGBA.B) + RGBA.B) >> 0);
var HSL = {H: 0, S: 0, L: 0};
this.RGB2HSL(RGBA.R, RGBA.G, RGBA.B, HSL);
if(HSL.L*val_ > max_hls)
HSL.L = max_hls;
else
HSL.L = Math.max(0, (HSL.L * val_) >> 0);
this.HSL2RGB(HSL, RGBA);
}
else if (colorMod.name == "wordTint")
{
var _val = colorMod.val/255;
//RGBA.R = Math.max(0, ((1 - _val)*(255 - RGBA.R) + RGBA.R) >> 0);
//RGBA.G = Math.max(0, ((1 - _val)*(255 - RGBA.G) + RGBA.G) >> 0);
//RGBA.B = Math.max(0, ((1 - _val)*(255 - RGBA.B) + RGBA.B) >> 0);
var HSL = {H: 0, S: 0, L: 0};
this.RGB2HSL(RGBA.R, RGBA.G, RGBA.B, HSL);
var L_ = HSL.L*_val + (255 - colorMod.val);
if(L_ > max_hls)
HSL.L = max_hls;
else
HSL.L = Math.max(0, (L_) >> 0);
this.HSL2RGB(HSL, RGBA);
}
else if (colorMod.name == "shade")
{
/*
RGBA.R = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.R/255) * val)*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.G/255) * val)*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(sRGB_to_scRGB(RGBA.B/255) * val)*255 >> 0);
*/
if (val < 0) val = 0;
if (val > 1) val = 1;
RGBA.R = (RGBA.R * val) >> 0;
RGBA.G = (RGBA.G * val) >> 0;
RGBA.B = (RGBA.B * val) >> 0;
}
else if (colorMod.name == "tint")
{
/*
if(val > 0)
{
RGBA.R = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.R/255)) * val)*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.G/255)) * val)*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.B/255)) * val)*255 >> 0);
}
else
{
RGBA.R = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.R/255)) * (1-val))*255 >> 0);
RGBA.G = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.G/255)) * (1-val))*255 >> 0);
RGBA.B = Math.max(0, scRGB_to_sRGB(1 - (1 - sRGB_to_scRGB(RGBA.B/255)) * (1-val))*255 >> 0);
}
*/
if (val < 0) val = 0;
if (val > 1) val = 1;
RGBA.R = (255 - (255 - RGBA.R) * val) >> 0;
RGBA.G = (255 - (255 - RGBA.G) * val) >> 0;
RGBA.B = (255 - (255 - RGBA.B) * val) >> 0;
}
else if (colorMod.name == "gamma")
{
// LO
// 1/2.3 = 0.4347826;
RGBA.R = this.applyGamma(RGBA.R, 0.4347826);
RGBA.G = this.applyGamma(RGBA.G, 0.4347826);
RGBA.B = this.applyGamma(RGBA.B, 0.4347826);
}
else if (colorMod.name == "invGamma")
{
RGBA.R = this.applyGamma(RGBA.R, 2.3);
RGBA.G = this.applyGamma(RGBA.G, 2.3);
RGBA.B = this.applyGamma(RGBA.B, 2.3);
}
}
},
applyGamma : function(c, gamma)
{
// LO
var _max = 256;
var _ret = (Math.pow(c / _max, gamma) * _max) >> 0;
if (_ret > 255)
_ret = 255;
return _ret;
}
};
......@@ -2511,6 +2549,8 @@ function CGradFill()
this.lin = null;
this.path = null;
this.rotateWithShape = null;
}
CGradFill.prototype =
......@@ -2689,6 +2729,9 @@ CGradFill.prototype =
if (this.path)
duplicate.path = this.path.createDuplicate();
if (this.rotateWithShape != null)
duplicate.rotateWithShape = this.rotateWithShape;
return duplicate;
},
......
......@@ -2330,10 +2330,34 @@ CMatrix.prototype =
var y1 = 0.0;
var x2 = 1.0;
var y2 = 0.0;
this.TransformPoint(x1, y1);
this.TransformPoint(x2, y2);
var a = Math.atan2(y2-y1,x2-x1);
return rad2deg(a);
var _x1 = this.TransformPointX(x1, y1);
var _y1 = this.TransformPointY(x1, y1);
var _x2 = this.TransformPointX(x2, y2);
var _y2 = this.TransformPointY(x2, y2);
var _y = _y2 - _y1;
var _x = _x2 - _x1;
if (Math.abs(_y) < 0.001)
{
if (_x > 0)
return 0;
else
return 180;
}
if (Math.abs(_x) < 0.001)
{
if (_y > 0)
return 90;
else
return 270;
}
var a = Math.atan2(_y,_x);
a = rad2deg(a);
if (a < 0)
a += 360;
return a;
},
// ������� ���������
CreateDublicate : function(){
......@@ -2373,47 +2397,7 @@ CMatrix.prototype =
}
};
function CMatrixL()
{
this.sx = 1.0;
this.shx = 0.0;
this.shy = 0.0;
this.sy = 1.0;
this.tx = 0.0;
this.ty = 0.0;
}
CMatrixL.prototype =
{
CreateDublicate : function()
{
var m = new CMatrixL();
m.sx = this.sx;
m.shx = this.shx;
m.shy = this.shy;
m.sy = this.sy;
m.tx = this.tx;
m.ty = this.ty;
return m;
},
Reset : function()
{
this.sx = 1.0;
this.shx = 0.0;
this.shy = 0.0;
this.sy = 1.0;
this.tx = 0.0;
this.ty = 0.0;
},
TransformPointX : function(x,y)
{
return x * this.sx + y * this.shx + this.tx;
},
TransformPointY : function(x,y)
{
return x * this.shy + y * this.sy + this.ty;
}
};
var CMatrixL = CMatrix;
function CGlobalMatrixTransformer()
{
......
......@@ -2167,7 +2167,7 @@ function BinaryPPTYLoader()
s.Skip2(1);
break;
case 1:
s.Skip2(1);
uni_fill.fill.rotateWithShape = s.GetBool();
break;
default:
break;
......
......@@ -2208,6 +2208,12 @@ function CBinaryFileWriter()
oThis.StartRecord(c_oAscFill.FILL_TYPE_GRAD);
oThis.WriteUChar(g_nodeAttributeStart);
if (fill.rotateWithShape === false)
{
oThis._WriteBool1(1, false);
}
oThis.WriteUChar(g_nodeAttributeEnd);
oThis.StartRecord(0);
......
......@@ -1059,7 +1059,13 @@ CShapeDrawer.prototype =
var gradObj = null;
if (_fill.lin)
{
var points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _fill.lin.angle, _fill.lin.scale);
var _angle = _fill.lin.angle;
if (_fill.rotateWithShape === false && this.Graphics.m_oTransform)
{
_angle -= (60000 * this.Graphics.m_oTransform.GetRotation());
}
var points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _angle, _fill.lin.scale);
gradObj = _ctx.createLinearGradient(points.x0, points.y0, points.x1, points.y1);
}
else if (_fill.path)
......@@ -1408,7 +1414,13 @@ CShapeDrawer.prototype =
var points = null;
if (_fill.lin)
{
points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _fill.lin.angle, _fill.lin.scale);
var _angle = _fill.lin.angle;
if (_fill.rotateWithShape === false && this.Graphics.m_oTransform)
{
_angle -= (60000 * this.Graphics.m_oTransform.GetRotation());
}
points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _angle, _fill.lin.scale);
}
else if (_fill.path)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment