mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
part of functions
This commit is contained in:
@ -1,5 +1,10 @@
|
||||
#include "GraphicsEmbed.h"
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::init(JSSmart<CJSValue> context, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndDraw()
|
||||
{
|
||||
m_pInternal->EndDraw();
|
||||
@ -27,12 +32,20 @@ JSSmart<CJSValue> CGraphicsEmbed::p_color(JSSmart<CJSValue> r, JSSmart<CJSValue>
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::p_width(JSSmart<CJSValue> w)
|
||||
{
|
||||
m_pInternal->p_width(w->toInt32());
|
||||
m_pInternal->p_width(w->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::p_dash(JSSmart<CJSValue> params)
|
||||
{
|
||||
//m_pInternal->p_dash(params->toObject());
|
||||
JSSmart<CJSArray> items = params->toArray();
|
||||
size_t length = items->getCount();
|
||||
double* dash = NULL;
|
||||
if(length > 0)
|
||||
dash = new double[length];
|
||||
for(size_t i = 0; i < length; i++)
|
||||
dash[i] = items->get(i)->toDouble();
|
||||
m_pInternal->p_dash(length, dash);
|
||||
RELEASEARRAYOBJECTS(dash);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::b_color1(JSSmart<CJSValue> r, JSSmart<CJSValue> g, JSSmart<CJSValue> b, JSSmart<CJSValue> a)
|
||||
|
||||
@ -17,6 +17,7 @@ public:
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> init(JSSmart<CJSValue> context, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> EndDraw();
|
||||
JSSmart<CJSValue> put_GlobalAlpha(JSSmart<CJSValue> enable, JSSmart<CJSValue> globalAlpha);
|
||||
JSSmart<CJSValue> Start_GlobalAlpha();
|
||||
|
||||
@ -57,6 +57,7 @@ namespace NSGraphics
|
||||
#define CURRENTWRAPPER CGraphicsEmbed
|
||||
|
||||
// FUNCTION
|
||||
FUNCTION_WRAPPER_V8_5(_init, init)
|
||||
FUNCTION_WRAPPER_V8 (_EndDraw, EndDraw)
|
||||
FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha)
|
||||
FUNCTION_WRAPPER_V8 (_Start_GlobalAlpha, Start_GlobalAlpha)
|
||||
@ -294,6 +295,7 @@ namespace NSGraphics
|
||||
result->SetAccessor(v8::String::NewFromUtf8(current, "dash_no_smart"), _g_dash_no_smart, _s_dash_no_smart);
|
||||
|
||||
// методы
|
||||
NSV8Objects::Template_Set(result, "init", _init);
|
||||
NSV8Objects::Template_Set(result, "EndDraw", _EndDraw);
|
||||
NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha);
|
||||
NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha);
|
||||
|
||||
@ -5,246 +5,109 @@
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
void CGraphics::init(double width_px, double height_px, double width_mm, double height_mm)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGraphics::put_GlobalAlpha(bool enable, double alpha)
|
||||
{
|
||||
if(!enable)
|
||||
{
|
||||
globalAlpha = 1;
|
||||
// m_oContext.globalAlpha = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
globalAlpha = alpha;
|
||||
// m_oContext.globalAlpha = alpha;
|
||||
}
|
||||
pRenderer->put_GlobalAlphaEnabled(enable, alpha);
|
||||
}
|
||||
|
||||
void CGraphics::End_GlobalAlpha()
|
||||
{
|
||||
if (!m_bIntegerGrid)
|
||||
{
|
||||
// m_oContext.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
bool bIsInteger = pRenderer->get_IntegerGrid();
|
||||
pRenderer->put_IntegerGrid(true);
|
||||
|
||||
// ДРУГОЙ МЕТОД КЛАССА
|
||||
// b_color1(255, 255, 255, 140);
|
||||
pRenderer->PathCommandEnd();
|
||||
b_color1(255, 255, 255, 140);
|
||||
|
||||
// m_oContext.fillRect(0, 0, m_lWidthPix, m_lHeightPix);
|
||||
// m_oContext.beginPath();
|
||||
pRenderer->AddRect(0.0, 0.0, pRenderer->GetPixW(), pRenderer->GetPixH());
|
||||
pRenderer->Fill();
|
||||
pRenderer->PathCommandEnd();
|
||||
|
||||
if (!m_bIntegerGrid)
|
||||
{
|
||||
/*
|
||||
m_oContext.setTransform(m_oFullTransform.sx, m_oFullTransform.shy, m_oFullTransform.shx,
|
||||
m_oFullTransform.sy, m_oFullTransform.tx, m_oFullTransform.ty);
|
||||
*/
|
||||
}
|
||||
pRenderer->put_IntegerGrid(bIsInteger);
|
||||
}
|
||||
|
||||
void CGraphics::p_color(int r, int g, int b, int a)
|
||||
{
|
||||
/*
|
||||
var _c = m_oPen.Color;
|
||||
if (m_bPenColorInit && _c.R == r && _c.G == g && _c.B == b && _c.A == a)
|
||||
return;
|
||||
|
||||
m_bPenColorInit = true;
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
|
||||
m_oContext.strokeStyle = "rgba(" + std::to_string(_c.R) + "," + std::to_string(_c.G) + "," + std::to_string(_c.B) +
|
||||
"," + std::to_string(static_cast<int>(static_cast<double>(_c.A) / 255.0)) + ")";
|
||||
*/
|
||||
pRenderer->put_PenColor(r | (g << 8) | (b << 16));
|
||||
pRenderer->put_PenAlpha(a);
|
||||
}
|
||||
|
||||
void CGraphics::p_width(int w)
|
||||
void CGraphics::p_width(double w)
|
||||
{
|
||||
// m_oPen.LineWidth = static_cast<int>(static_cast<double>(w) / 1000.0);
|
||||
pRenderer->put_PenSize(w / 1000.0);
|
||||
}
|
||||
|
||||
if (!m_bIntegerGrid)
|
||||
void CGraphics::p_dash(size_t length, double* dash)
|
||||
{
|
||||
if(length > 0)
|
||||
{
|
||||
/*
|
||||
if (0 != m_oPen.LineWidth)
|
||||
{
|
||||
m_oContext.lineWidth = m_oPen.LineWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
double _x1 = m_oFullTransform.TransformPointX(0, 0);
|
||||
double _y1 = m_oFullTransform.TransformPointY(0, 0);
|
||||
double _x2 = m_oFullTransform.TransformPointX(1, 1);
|
||||
double _y2 = m_oFullTransform.TransformPointY(1, 1);
|
||||
for(size_t i = 0; i < length; i++)
|
||||
dash[i] = dash[i] * 72.0 / 25.4 * 2;
|
||||
|
||||
double _koef = sqrt(((_x2 - _x1) * (_x2 - _x1) + (_y2 - _y1) * (_y2 - _y1)) / 2);
|
||||
m_oContext.lineWidth = static_cast<int>(1.0 / _koef);
|
||||
}
|
||||
*/
|
||||
pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom);
|
||||
pRenderer->PenDashPattern(dash, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if (0 != m_oPen.LineWidth)
|
||||
{
|
||||
v8::Local<v8::Value> _m = m_oFullTransform;
|
||||
double x = _m.sx + _m.shx;
|
||||
double y = _m.sy + _m.shy;
|
||||
|
||||
double koef = sqrt((x * x + y * y) / 2);
|
||||
m_oContext.lineWidth = static_cast<int>(m_oPen.LineWidth * koef);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oContext.lineWidth = 1;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphics::p_dash(const v8::Local<v8::Value>& params)
|
||||
{
|
||||
/*
|
||||
if (!m_oContext.setLineDash)
|
||||
return;
|
||||
|
||||
dash_no_smart = params ? params.slice() : null;
|
||||
m_oContext.setLineDash(params ? params : []);
|
||||
*/
|
||||
pRenderer->put_PenDashStyle(Aggplus::DashStyleSolid);
|
||||
}
|
||||
|
||||
void CGraphics::b_color1(int r, int g, int b, int a)
|
||||
{
|
||||
/*
|
||||
var _c = m_oBrush.Color1;
|
||||
if (m_bBrushColorInit && _c.R == r && _c.G == g && _c.B == b && _c.A == a)
|
||||
return;
|
||||
|
||||
m_bBrushColorInit = true;
|
||||
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
|
||||
m_oContext.fillStyle = "rgba(" + std::to_string(_c.R) + "," + std::to_string(_c.G) + "," + std::to_string(_c.B) +
|
||||
"," + std::to_string(static_cast<int>(static_cast<double>(_c.A) / 255.0)) + ")";
|
||||
*/
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
pRenderer->put_BrushColor1(r | (g << 8) | (b << 16));
|
||||
pRenderer->put_BrushAlpha1(a);
|
||||
}
|
||||
|
||||
void CGraphics::b_color2(int r, int g, int b, int a)
|
||||
{
|
||||
/*
|
||||
var _c = m_oBrush.Color2;
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
*/
|
||||
pRenderer->put_BrushColor2(r | (g << 8) | (b << 16));
|
||||
pRenderer->put_BrushAlpha2(a);
|
||||
}
|
||||
|
||||
void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty)
|
||||
{
|
||||
/*
|
||||
v8::Local<v8::Value> _t = m_oTransform;
|
||||
_t.sx = sx;
|
||||
_t.shx = shx;
|
||||
_t.shy = shy;
|
||||
_t.sy = sy;
|
||||
_t.tx = tx;
|
||||
_t.ty = ty;
|
||||
|
||||
CalculateFullTransform();
|
||||
if (!m_bIntegerGrid)
|
||||
{
|
||||
v8::Local<v8::Value> _ft = m_oFullTransform;
|
||||
m_oContext.setTransform(_ft.sx, _ft.shy, _ft.shx, _ft.sy, _ft.tx, s_ft.ty);
|
||||
}
|
||||
|
||||
if (NULL != m_oFontManager)
|
||||
m_oFontManager.SetTextMatrix(_t.sx, _t.shy, _t.shx, _t.sy, _t.tx, _t.ty);
|
||||
*/
|
||||
}
|
||||
|
||||
void CGraphics::CalculateFullTransform(bool isInvertNeed)
|
||||
{
|
||||
/*
|
||||
v8::Local<v8::Value> _ft = m_oFullTransform;
|
||||
v8::Local<v8::Value> _t = m_oTransform;
|
||||
_ft.sx = _t.sx;
|
||||
_ft.shx = _t.shx;
|
||||
_ft.shy = _t.shy;
|
||||
_ft.sy = _t.sy;
|
||||
_ft.tx = _t.tx;
|
||||
_ft.ty = _t.ty;
|
||||
global_MatrixTransformer.MultiplyAppend(_ft, m_oCoordTransform);
|
||||
|
||||
v8::Local<v8::Value> _it = m_oInvertFullTransform;
|
||||
_it.sx = _ft.sx;
|
||||
_it.shx = _ft.shx;
|
||||
_it.shy = _ft.shy;
|
||||
_it.sy = _ft.sy;
|
||||
_it.tx = _ft.tx;
|
||||
_it.ty = _ft.ty;
|
||||
|
||||
if (!isInvertNeed)
|
||||
{
|
||||
global_MatrixTransformer.MultiplyAppendInvert(_it, _t);
|
||||
}
|
||||
*/
|
||||
pRenderer->SetTransform(sx, shy, shx, sy, tx, ty);
|
||||
}
|
||||
|
||||
void CGraphics::_s()
|
||||
{
|
||||
// m_oContext.beginPath();
|
||||
pRenderer->PathCommandEnd();
|
||||
}
|
||||
|
||||
void CGraphics::_e()
|
||||
{
|
||||
// m_oContext.beginPath();
|
||||
pRenderer->PathCommandEnd();
|
||||
}
|
||||
|
||||
void CGraphics::_z()
|
||||
{
|
||||
// m_oContext.closePath();
|
||||
pRenderer->PathCommandClose();
|
||||
}
|
||||
|
||||
void CGraphics::_m(double x, double y)
|
||||
{
|
||||
/*
|
||||
if (!m_bIntegerGrid)
|
||||
{
|
||||
m_oContext.moveTo(x, y);
|
||||
|
||||
if (ArrayPoints != NULL)
|
||||
ArrayPoints[ArrayPoints.length] = {x: x, y: y};
|
||||
}
|
||||
if (!pRenderer->get_IntegerGrid())
|
||||
pRenderer->PathCommandMoveTo(x, y);
|
||||
else
|
||||
{
|
||||
var _x = (m_oFullTransform.TransformPointX(x, y)) >> 0;
|
||||
var _y = (m_oFullTransform.TransformPointY(x, y)) >> 0;
|
||||
m_oContext.moveTo(_x + 0.5, _y + 0.5);
|
||||
pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
pRenderer->PathCommandMoveTo((int)x + 0.5, (int)y + 0.5);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CGraphics::_l(double x, double y)
|
||||
{
|
||||
/*
|
||||
if (!m_bIntegerGrid)
|
||||
{
|
||||
m_oContext.lineTo(x, y);
|
||||
|
||||
if (ArrayPoints != NULL)
|
||||
ArrayPoints[ArrayPoints.length] = {x: x, y: y};
|
||||
}
|
||||
if (!pRenderer->get_IntegerGrid())
|
||||
pRenderer->PathCommandLineTo(x, y);
|
||||
else
|
||||
{
|
||||
var _x = (m_oFullTransform.TransformPointX(x, y)) >> 0;
|
||||
var _y = (m_oFullTransform.TransformPointY(x, y)) >> 0;
|
||||
m_oContext.lineTo(_x + 0.5, _y + 0.5);
|
||||
pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
pRenderer->PathCommandLineTo((int)x + 0.5, (int)y + 0.5);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CGraphics::_c(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
|
||||
@ -6,10 +6,13 @@
|
||||
|
||||
#include "../common/Types.h"
|
||||
#include "../graphics/Graphics.h"
|
||||
#include "../graphics/GraphicsRenderer.h"
|
||||
#include "../raster/BgraFrame.h"
|
||||
|
||||
#include "v8.h"
|
||||
#include "libplatform/libplatform.h"
|
||||
|
||||
/*
|
||||
#define GRAPHICS_NATIVE_COMMAND_EndDraw 1
|
||||
#define GRAPHICS_NATIVE_COMMAND_put_GlobalAlpha 2
|
||||
#define GRAPHICS_NATIVE_COMMAND_Start_GlobalAlpha 3
|
||||
@ -100,6 +103,7 @@
|
||||
#define GRAPHICS_NATIVE_COMMAND_DrawPresentationComment 88
|
||||
#define GRAPHICS_NATIVE_COMMAND_DrawPolygon 89
|
||||
#define GRAPHICS_NATIVE_COMMAND_DrawFootnoteRect 90
|
||||
*/
|
||||
|
||||
struct CFont
|
||||
{
|
||||
@ -123,6 +127,9 @@ namespace NSGraphics
|
||||
{
|
||||
class CGraphics
|
||||
{
|
||||
private:
|
||||
CGraphicsRenderer* pRenderer;
|
||||
CBgraFrame* pFrame;
|
||||
private:
|
||||
v8::Local<v8::Value>* m_oContext;
|
||||
double m_dWidthMM;
|
||||
@ -133,18 +140,18 @@ namespace NSGraphics
|
||||
double m_dDpiY;
|
||||
bool m_bIsBreak;
|
||||
|
||||
NSStructures::CPen m_oPen;
|
||||
NSStructures::CPen* m_oPen;
|
||||
bool m_bPenColorInit;
|
||||
NSStructures::CBrush m_oBrush;
|
||||
NSStructures::CBrush* m_oBrush;
|
||||
bool m_bBrushColorInit;
|
||||
|
||||
v8::Local<v8::Value>* m_oFontManager;
|
||||
|
||||
Aggplus::CMatrix m_oCoordTransform;
|
||||
Aggplus::CMatrix m_oBaseTransform;
|
||||
Aggplus::CMatrix m_oTransform;
|
||||
Aggplus::CMatrix m_oFullTransform;
|
||||
Aggplus::CMatrix m_oInvertFullTransform;
|
||||
Aggplus::CMatrix* m_oCoordTransform;
|
||||
Aggplus::CMatrix* m_oBaseTransform;
|
||||
Aggplus::CMatrix* m_oTransform;
|
||||
Aggplus::CMatrix* m_oFullTransform;
|
||||
Aggplus::CMatrix* m_oInvertFullTransform;
|
||||
|
||||
std::vector<std::pair<double, double>> ArrayPoints;
|
||||
|
||||
@ -264,19 +271,20 @@ namespace NSGraphics
|
||||
if(dash_no_smart) delete dash_no_smart;
|
||||
}
|
||||
|
||||
void init(double width_px, double height_px, double width_mm, double height_mm);
|
||||
void EndDraw() {}
|
||||
void put_GlobalAlpha(bool enable, double globalAlpha);
|
||||
void Start_GlobalAlpha() {}
|
||||
void End_GlobalAlpha();
|
||||
// pen methods
|
||||
void p_color(int r, int g, int b, int a);
|
||||
void p_width(int w);
|
||||
void p_dash(const v8::Local<v8::Value>& params);
|
||||
void p_width(double w);
|
||||
void p_dash(size_t length, double* dash);
|
||||
// brush methods
|
||||
void b_color1(int r, int g, int b, int a);
|
||||
void b_color2(int r, int g, int b, int a);
|
||||
void transform(double sx, double shy, double shx, double sy, double tx, double ty);
|
||||
void CalculateFullTransform(bool isInvertNeed);
|
||||
void CalculateFullTransform(bool isInvertNeed) {}
|
||||
// path commands
|
||||
void _s();
|
||||
void _e();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
|
||||
/*
|
||||
function CNativeGraphicsSerializer()
|
||||
{
|
||||
this.Memory = [];
|
||||
@ -588,6 +589,7 @@ CNativeGraphicsSerializer.prototype =
|
||||
this.Memory.push(h);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
function CNativeGraphics(_writer)
|
||||
{
|
||||
@ -709,12 +711,10 @@ CNativeGraphics.prototype =
|
||||
if (false === enable)
|
||||
{
|
||||
this.globalAlpha = 1;
|
||||
this.m_oContext.globalAlpha = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.globalAlpha = alpha;
|
||||
this.m_oContext.globalAlpha = alpha;
|
||||
}
|
||||
|
||||
this.Native["put_GlobalAlpha"](enable, alpha);
|
||||
@ -725,162 +725,83 @@ CNativeGraphics.prototype =
|
||||
},
|
||||
End_GlobalAlpha : function()
|
||||
{
|
||||
if (false === this.m_bIntegerGrid)
|
||||
{
|
||||
this.m_oContext.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
||||
this.b_color1(255, 255, 255, 140);
|
||||
|
||||
this.m_oContext.fillRect(0, 0, this.m_lWidthPix, this.m_lHeightPix);
|
||||
this.m_oContext.beginPath();
|
||||
|
||||
if (false === this.m_bIntegerGrid)
|
||||
{
|
||||
this.m_oContext.setTransform(this.m_oFullTransform.sx,this.m_oFullTransform.shy,this.m_oFullTransform.shx,
|
||||
this.m_oFullTransform.sy,this.m_oFullTransform.tx,this.m_oFullTransform.ty);
|
||||
}
|
||||
|
||||
this.Native["End_GlobalAlpha"]();
|
||||
},
|
||||
// pen methods
|
||||
p_color : function(r, g, b, a)
|
||||
{
|
||||
var _c = this.m_oPen.Color;
|
||||
if (this.m_bPenColorInit && _c.R === r && _c.G === g && _c.B === b && _c.A === a)
|
||||
return;
|
||||
|
||||
this.m_bPenColorInit = true;
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
|
||||
this.m_oContext.strokeStyle = "rgba(" + _c.R + "," + _c.G + "," + _c.B + "," + (_c.A / 255) + ")";
|
||||
|
||||
this.Native["p_color"](r, g, b, a);
|
||||
},
|
||||
p_width : function(w)
|
||||
{
|
||||
this.m_oPen.LineWidth = w / 1000;
|
||||
|
||||
if (!this.m_bIntegerGrid)
|
||||
{
|
||||
if (0 != this.m_oPen.LineWidth)
|
||||
{
|
||||
this.m_oContext.lineWidth = this.m_oPen.LineWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
var _x1 = this.m_oFullTransform.TransformPointX(0, 0);
|
||||
var _y1 = this.m_oFullTransform.TransformPointY(0, 0);
|
||||
var _x2 = this.m_oFullTransform.TransformPointX(1, 1);
|
||||
var _y2 = this.m_oFullTransform.TransformPointY(1, 1);
|
||||
|
||||
var _koef = Math.sqrt(((_x2 - _x1)*(_x2 - _x1) + (_y2 - _y1)*(_y2 - _y1)) / 2);
|
||||
this.m_oContext.lineWidth = 1 / _koef;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != this.m_oPen.LineWidth)
|
||||
{
|
||||
var _m = this.m_oFullTransform;
|
||||
var x = _m.sx + _m.shx;
|
||||
var y = _m.sy + _m.shy;
|
||||
|
||||
var koef = Math.sqrt((x * x + y * y) / 2);
|
||||
this.m_oContext.lineWidth = this.m_oPen.LineWidth * koef;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_oContext.lineWidth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
this.Native["p_width"](w);
|
||||
},
|
||||
p_dash : function(params)
|
||||
{
|
||||
if (!this.m_oContext.setLineDash)
|
||||
return;
|
||||
|
||||
this.dash_no_smart = params ? params.slice() : null;
|
||||
this.m_oContext.setLineDash(params ? params : []);
|
||||
|
||||
this.Native["p_dash"](params);
|
||||
this.Native["p_dash"](params ? params : []);
|
||||
},
|
||||
// brush methods
|
||||
b_color1 : function(r, g, b, a)
|
||||
{
|
||||
var _c = this.m_oBrush.Color1;
|
||||
if (this.m_bBrushColorInit && _c.R === r && _c.G === g && _c.B === b && _c.A === a)
|
||||
return;
|
||||
|
||||
this.m_bBrushColorInit = true;
|
||||
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
|
||||
this.m_oContext.fillStyle = "rgba(" + _c.R + "," + _c.G + "," + _c.B + "," + (_c.A / 255) + ")";
|
||||
|
||||
this.Native["b_color1"](r, g, b, a);
|
||||
},
|
||||
b_color2 : function(r, g, b, a)
|
||||
{
|
||||
var _c = this.m_oBrush.Color2;
|
||||
_c.R = r;
|
||||
_c.G = g;
|
||||
_c.B = b;
|
||||
_c.A = a;
|
||||
|
||||
this.Native["b_color2"](r, g, b, a);
|
||||
},
|
||||
transform : function(sx, shy, shx, sy, tx, ty)
|
||||
{
|
||||
var _t = this.m_oTransform;
|
||||
_t.sx = sx;
|
||||
_t.shx = shx;
|
||||
_t.shy = shy;
|
||||
_t.sy = sy;
|
||||
_t.tx = tx;
|
||||
_t.ty = ty;
|
||||
_t.sx = sx;
|
||||
_t.shx = shx;
|
||||
_t.shy = shy;
|
||||
_t.sy = sy;
|
||||
_t.tx = tx;
|
||||
_t.ty = ty;
|
||||
|
||||
this.CalculateFullTransform();
|
||||
if (false === this.m_bIntegerGrid)
|
||||
{
|
||||
var _ft = this.m_oFullTransform;
|
||||
this.m_oContext.setTransform(_ft.sx,_ft.shy,_ft.shx,_ft.sy,_ft.tx,_ft.ty);
|
||||
this.Native["transform"](_ft.sx, _ft.shy, _ft.shx, _ft.sy, _ft.tx, _ft.ty);
|
||||
}
|
||||
|
||||
if (null != this.m_oFontManager)
|
||||
{
|
||||
this.m_oFontManager.SetTextMatrix(_t.sx,_t.shy,_t.shx,_t.sy,_t.tx,_t.ty);
|
||||
}
|
||||
|
||||
this.Native["transform"](sx, shy, shx, sy, tx, ty);
|
||||
//if (null != this.m_oFontManager)
|
||||
//{
|
||||
// this.m_oFontManager.SetTextMatrix(_t.sx, _t.shy, _t.shx, _t.sy, _t.tx, _t.ty);
|
||||
//}
|
||||
},
|
||||
CalculateFullTransform : function(isInvertNeed)
|
||||
{
|
||||
var _ft = this.m_oFullTransform;
|
||||
var _t = this.m_oTransform;
|
||||
_ft.sx = _t.sx;
|
||||
var _t = this.m_oTransform;
|
||||
_ft.sx = _t.sx;
|
||||
_ft.shx = _t.shx;
|
||||
_ft.shy = _t.shy;
|
||||
_ft.sy = _t.sy;
|
||||
_ft.tx = _t.tx;
|
||||
_ft.ty = _t.ty;
|
||||
_ft.sy = _t.sy;
|
||||
_ft.tx = _t.tx;
|
||||
_ft.ty = _t.ty;
|
||||
global_MatrixTransformer.MultiplyAppend(_ft, this.m_oCoordTransform);
|
||||
|
||||
var _it = this.m_oInvertFullTransform;
|
||||
_it.sx = _ft.sx;
|
||||
_it.sx = _ft.sx;
|
||||
_it.shx = _ft.shx;
|
||||
_it.shy = _ft.shy;
|
||||
_it.sy = _ft.sy;
|
||||
_it.tx = _ft.tx;
|
||||
_it.ty = _ft.ty;
|
||||
_it.sy = _ft.sy;
|
||||
_it.tx = _ft.tx;
|
||||
_it.ty = _ft.ty;
|
||||
|
||||
if (false !== isInvertNeed)
|
||||
{
|
||||
@ -892,57 +813,47 @@ CNativeGraphics.prototype =
|
||||
// path commands
|
||||
_s : function()
|
||||
{
|
||||
this.m_oContext.beginPath();
|
||||
|
||||
this.Native["_s"]();
|
||||
},
|
||||
_e : function()
|
||||
{
|
||||
this.m_oContext.beginPath();
|
||||
|
||||
this.Native["_e"]();
|
||||
},
|
||||
_z : function()
|
||||
{
|
||||
this.m_oContext.closePath();
|
||||
|
||||
this.Native["_z"]();
|
||||
},
|
||||
_m : function(x, y)
|
||||
{
|
||||
if (false === this.m_bIntegerGrid)
|
||||
{
|
||||
this.m_oContext.moveTo(x,y);
|
||||
this.Native["_m"](x, y);
|
||||
|
||||
if (this.ArrayPoints != null)
|
||||
this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y};
|
||||
}
|
||||
else
|
||||
{
|
||||
var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0;
|
||||
var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0;
|
||||
this.m_oContext.moveTo(_x + 0.5,_y + 0.5);
|
||||
var _x = (this.m_oFullTransform.TransformPointX(x, y)) >> 0;
|
||||
var _y = (this.m_oFullTransform.TransformPointY(x, y)) >> 0;
|
||||
this.Native["_m"](_x + 0.5, _y + 0.5);
|
||||
}
|
||||
|
||||
this.Native["_m"](x, y);
|
||||
},
|
||||
_l : function(x, y)
|
||||
{
|
||||
if (false === this.m_bIntegerGrid)
|
||||
{
|
||||
this.m_oContext.lineTo(x,y);
|
||||
this.Native["_l"](x, y);
|
||||
|
||||
if (this.ArrayPoints != null)
|
||||
this.ArrayPoints[this.ArrayPoints.length] = {x: x, y: y};
|
||||
}
|
||||
else
|
||||
{
|
||||
var _x = (this.m_oFullTransform.TransformPointX(x,y)) >> 0;
|
||||
var _y = (this.m_oFullTransform.TransformPointY(x,y)) >> 0;
|
||||
this.m_oContext.lineTo(_x + 0.5,_y + 0.5);
|
||||
var _x = (this.m_oFullTransform.TransformPointX(x, y)) >> 0;
|
||||
var _y = (this.m_oFullTransform.TransformPointY(x, y)) >> 0;
|
||||
this.Native["_l"](_x + 0.5, _y + 0.5);
|
||||
}
|
||||
|
||||
this.Native["_l"](x, y);
|
||||
},
|
||||
_c : function(x1, y1, x2, y2, x3, y3)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user