#include "../graphics.h" #include #include "../../../Common/Network/FileTransporter/include/FileTransporter.h" // APPLICATION INFO class CGraphicsAppImage_private { public: NSFonts::IApplicationFonts* m_pFonts; std::wstring m_sFontsDirectory; std::wstring m_sImagesDirectory; std::wstring m_sThemesDirectory; bool m_bIsRgba; std::map m_mapDownloads; CGraphicsAppImage_private() { m_pFonts = NULL; m_sFontsDirectory = L""; m_sImagesDirectory = L""; m_sThemesDirectory = L""; m_bIsRgba = false; } ~CGraphicsAppImage_private() { RELEASEINTERFACE(m_pFonts); for (std::map::iterator i = m_mapDownloads.begin(); i != m_mapDownloads.end(); i++) { std::wstring sTmp = i->second; if (NSFile::CFileBinary::Exists(sTmp)) NSFile::CFileBinary::Remove(sTmp); } } bool IsNeedDownload(const std::wstring& sUrl) { if ((0 == sUrl.find(L"www.")) || (0 == sUrl.find(L"http://")) || (0 == sUrl.find(L"https://"))) return true; return false; } std::wstring GetImagePath(const std::wstring& sUrl) { std::map::iterator find = m_mapDownloads.find(sUrl); if (find != m_mapDownloads.end()) return find->second; NSNetwork::NSFileTransport::CFileDownloader oDownloader(sUrl, false); std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG"); if (NSFile::CFileBinary::Exists(sTmpFile)) NSFile::CFileBinary::Remove(sTmpFile); sTmpFile = sTmpFile + L".png"; oDownloader.SetFilePath(sTmpFile); oDownloader.Start(0); while ( oDownloader.IsRunned() ) { NSThreads::Sleep( 10 ); } bool bIsDownloaded = oDownloader.IsFileDownloaded(); if (bIsDownloaded) { m_mapDownloads.insert(std::pair(sUrl, sTmpFile)); return sTmpFile; } return sUrl; } }; CGraphicsAppImage::CGraphicsAppImage() { m_internal = new CGraphicsAppImage_private(); } CGraphicsAppImage::~CGraphicsAppImage() { delete m_internal; } void CGraphicsAppImage::SetFontsDirectory(const std::wstring& dir) { m_internal->m_sFontsDirectory = dir; } std::wstring CGraphicsAppImage::GetFontsDirectory() { return m_internal->m_sFontsDirectory; } void CGraphicsAppImage::SetImagesDirectory(const std::wstring& dir) { m_internal->m_sImagesDirectory = dir; } std::wstring CGraphicsAppImage::GetImagesDirectory() { return m_internal->m_sImagesDirectory; } void CGraphicsAppImage::SetThemesDirectory(const std::wstring& dir) { m_internal->m_sThemesDirectory = dir; } std::wstring CGraphicsAppImage::GetThemesDirectory() { return m_internal->m_sThemesDirectory; } void CGraphicsAppImage::SetFonts(NSFonts::IApplicationFonts* fonts) { m_internal->m_pFonts = fonts; ADDREFINTERFACE(fonts); } NSFonts::IApplicationFonts* CGraphicsAppImage::GetFonts() { return m_internal->m_pFonts; } void CGraphicsAppImage::SetRgba(const bool& isRgba) { m_internal->m_bIsRgba = isRgba; } bool CGraphicsAppImage::GetRgba() { return m_internal->m_bIsRgba; } unsigned char* CGraphicsAppImage::GetBits(int& w, int& h) { return NULL; } unsigned char* CGraphicsAppImage::AllocBits(const int& w, const int& h) { return new unsigned char[4 * w * h]; } // APPLICATION INFO END CGraphicsEmbed::CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) { } CGraphicsEmbed::~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); } CGraphicsAppImage* CGraphicsEmbed::GetAppImage() { return m_pInternal->m_pAppImage; } void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage) { m_pInternal->m_pAppImage = appImage; } JSSmart CGraphicsEmbed::create(JSSmart Native, JSSmart width_px, JSSmart height_px, JSSmart width_mm, JSSmart height_mm) { if (!Native->isNull()) { JSSmart pNativeObject = Native->toObject(); CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative(); if (m_pInternal->m_pAppImage && pNativeEmbedObject) { delete m_pInternal->m_pAppImage; m_pInternal->m_pAppImage = NULL; } if (NULL == m_pInternal->m_pAppImage) m_pInternal->m_pAppImage = new CGraphicsAppImage(); if (pNativeEmbedObject) { NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject(); m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory); m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory); } else { JSSmart checkResources = pNativeObject->get("isResourcesObject"); if (checkResources->isBool() && true == checkResources->toBool()) { m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW()); m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW()); } } } m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble()); return NULL; } JSSmart CGraphicsEmbed::Destroy() { // For save image bits, if needed. m_pInternal->Destroy(); RELEASEOBJECT(m_pInternal); return NULL; } JSSmart CGraphicsEmbed::EndDraw() { m_pInternal->EndDraw(); return NULL; } JSSmart CGraphicsEmbed::put_GlobalAlpha(JSSmart enable, JSSmart globalAlpha) { m_pInternal->put_GlobalAlpha(enable->toBool(), globalAlpha->toDouble()); return NULL; } JSSmart CGraphicsEmbed::Start_GlobalAlpha() { m_pInternal->Start_GlobalAlpha(); return NULL; } JSSmart CGraphicsEmbed::End_GlobalAlpha() { m_pInternal->End_GlobalAlpha(); return NULL; } JSSmart CGraphicsEmbed::p_color(JSSmart r, JSSmart g, JSSmart b, JSSmart a) { m_pInternal->p_color(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); return NULL; } JSSmart CGraphicsEmbed::p_width(JSSmart w) { m_pInternal->p_width(w->toDouble()); return NULL; } JSSmart CGraphicsEmbed::p_dash(JSSmart params) { JSSmart 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 CGraphicsEmbed::b_color1(JSSmart r, JSSmart g, JSSmart b, JSSmart a) { m_pInternal->b_color1(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); return NULL; } JSSmart CGraphicsEmbed::b_color2(JSSmart r, JSSmart g, JSSmart b, JSSmart a) { m_pInternal->b_color2(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); return NULL; } JSSmart CGraphicsEmbed::transform(JSSmart sx, JSSmart shy, JSSmart shx, JSSmart sy, JSSmart tx, JSSmart ty) { m_pInternal->transform(sx->toDouble(), shy->toDouble(), shx->toDouble(), sy->toDouble(), tx->toDouble(), ty->toDouble()); return NULL; } JSSmart CGraphicsEmbed::CalculateFullTransform(JSSmart isInvertNeed) { m_pInternal->CalculateFullTransform(); return NULL; } JSSmart CGraphicsEmbed::_s() { m_pInternal->_s(); return NULL; } JSSmart CGraphicsEmbed::_e() { m_pInternal->_e(); return NULL; } JSSmart CGraphicsEmbed::_z() { m_pInternal->_z(); return NULL; } JSSmart CGraphicsEmbed::_m (JSSmart x, JSSmart y) { m_pInternal->_m(x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::_l (JSSmart x, JSSmart y) { m_pInternal->_l(x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::_c (JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2, JSSmart x3, JSSmart y3) { m_pInternal->_c(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble(), x3->toDouble(), y3->toDouble()); return NULL; } JSSmart CGraphicsEmbed::_c2(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2) { m_pInternal->_c2(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble()); return NULL; } JSSmart CGraphicsEmbed::ds() { m_pInternal->ds(); return NULL; } JSSmart CGraphicsEmbed::df() { m_pInternal->df(); return NULL; } JSSmart CGraphicsEmbed::save() { m_pInternal->save(); return NULL; } JSSmart CGraphicsEmbed::restore() { m_pInternal->restore(); return NULL; } JSSmart CGraphicsEmbed::clip() { m_pInternal->clip(); return NULL; } JSSmart CGraphicsEmbed::reset() { m_pInternal->reset(); return NULL; } JSSmart CGraphicsEmbed::FreeFont() { m_pInternal->FreeFont(); return NULL; } JSSmart CGraphicsEmbed::ClearLastFont() { m_pInternal->ClearLastFont(); return NULL; } JSSmart CGraphicsEmbed::drawImage2(JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect) { std::wstring sUrl = img->toStringW(); if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl)) sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl); m_pInternal->drawImage(sUrl, x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32()); return NULL; } JSSmart CGraphicsEmbed::drawImage (JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect, JSSmart nativeImage) { std::wstring sUrl = img->toStringW(); if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl)) sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl); m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32()); return NULL; } JSSmart CGraphicsEmbed::GetFont() { return CJSContext::createString(m_pInternal->GetFont()); } JSSmart CGraphicsEmbed::font(JSSmart font_id, JSSmart font_size) { m_pInternal->font(); return NULL; } JSSmart CGraphicsEmbed::SetFont(JSSmart path, JSSmart face, JSSmart size, JSSmart style) { m_pInternal->SetFont(path->toStringW(), face->toInt32(), size->toDouble(), style->toInt32()); return NULL; } JSSmart CGraphicsEmbed::GetTextPr() { m_pInternal->GetTextPr(); return NULL; } JSSmart CGraphicsEmbed::FillText(JSSmart x, JSSmart y, JSSmart text) { m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32()); return NULL; } JSSmart CGraphicsEmbed::t(JSSmart x, JSSmart y, JSSmart _arr) { m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW()); return NULL; } JSSmart CGraphicsEmbed::FillText2(JSSmart x, JSSmart y, JSSmart text, JSSmart cropX, JSSmart cropW) { m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32()); return NULL; } JSSmart CGraphicsEmbed::t2(JSSmart x, JSSmart y, JSSmart _arr, JSSmart cropX, JSSmart cropW) { m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW()); return NULL; } JSSmart CGraphicsEmbed::FillTextCode(JSSmart x, JSSmart y, JSSmart lUnicode) { m_pInternal->FillText(x->toDouble(), y->toDouble(), lUnicode->toInt32()); return NULL; } JSSmart CGraphicsEmbed::tg(JSSmart text, JSSmart x, JSSmart y) { m_pInternal->tg(text->toInt32(), x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::charspace(JSSmart space) { m_pInternal->charspace(); return NULL; } JSSmart CGraphicsEmbed::private_FillGlyph (JSSmart pGlyph, JSSmart _bounds) { m_pInternal->private_FillGlyph(); return NULL; } JSSmart CGraphicsEmbed::private_FillGlyphC(JSSmart pGlyph, JSSmart cropX, JSSmart cropW) { m_pInternal->private_FillGlyphC(); return NULL; } JSSmart CGraphicsEmbed::private_FillGlyph2(JSSmart pGlyph) { m_pInternal->private_FillGlyph2(); return NULL; } JSSmart CGraphicsEmbed::SetIntegerGrid(JSSmart param) { m_pInternal->SetIntegerGrid(param->toBool()); return NULL; } JSSmart CGraphicsEmbed::GetIntegerGrid() { return CJSContext::createBool(m_pInternal->GetIntegerGrid()); } JSSmart CGraphicsEmbed::DrawStringASCII (JSSmart text, JSSmart x, JSSmart y) { m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawStringASCII2(JSSmart text, JSSmart x, JSSmart y) { m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawHeaderEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type) { m_pInternal->DrawHeaderEdit(yPos->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawFooterEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type) { m_pInternal->DrawFooterEdit(yPos->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawLockParagraph (JSSmart x, JSSmart y1, JSSmart y2) { m_pInternal->DrawLockParagraph(x->toDouble(), y1->toDouble(), y2->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawLockObjectRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->DrawLockObjectRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawEmptyTableLine(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2) { m_pInternal->DrawEmptyTableLine(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawSpellingLine (JSSmart y0, JSSmart x0, JSSmart x1, JSSmart w) { m_pInternal->DrawSpellingLine(y0->toDouble(), x0->toDouble(), x1->toDouble(), w->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawHorLine (JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW) { m_pInternal->drawHorLine(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawHorLine2(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW) { m_pInternal->drawHorLine2(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawVerLine (JSSmart align, JSSmart x, JSSmart y, JSSmart b, JSSmart penW) { m_pInternal->drawVerLine(align->toInt32(), x->toDouble(), y->toDouble(), b->toDouble(), penW->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawHorLineExt(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW, JSSmart leftMW, JSSmart rightMW) { m_pInternal->drawHorLineExt(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble(), leftMW->toDouble(), rightMW->toDouble()); return NULL; } JSSmart CGraphicsEmbed::rect (JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::TableRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->TableRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::AddClipRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->AddClipRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::RemoveClipRect() { m_pInternal->RemoveClipRect(); return NULL; } JSSmart CGraphicsEmbed::SetClip(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->SetClip(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::RemoveClip() { m_pInternal->restore(); return NULL; } JSSmart CGraphicsEmbed::drawMailMergeField(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->drawMailMergeField(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawSearchResult (JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->drawSearchResult(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::drawFlowAnchor (JSSmart x, JSSmart y) { return NULL; } JSSmart CGraphicsEmbed::SavePen() { m_pInternal->SavePen(); return NULL; } JSSmart CGraphicsEmbed::RestorePen() { m_pInternal->RestorePen(); return NULL; } JSSmart CGraphicsEmbed::SaveBrush() { m_pInternal->SaveBrush(); return NULL; } JSSmart CGraphicsEmbed::RestoreBrush() { m_pInternal->RestoreBrush(); return NULL; } JSSmart CGraphicsEmbed::SavePenBrush() { m_pInternal->SavePenBrush(); return NULL; } JSSmart CGraphicsEmbed::RestorePenBrush() { m_pInternal->RestorePenBrush(); return NULL; } JSSmart CGraphicsEmbed::SaveGrState() { m_pInternal->SaveGrState(); return NULL; } JSSmart CGraphicsEmbed::RestoreGrState() { m_pInternal->RestoreGrState(); return NULL; } JSSmart CGraphicsEmbed::StartClipPath() { m_pInternal->StartClipPath(); return NULL; } JSSmart CGraphicsEmbed::EndClipPath() { m_pInternal->EndClipPath(); return NULL; } JSSmart CGraphicsEmbed::StartCheckTableDraw() { return CJSContext::createBool(m_pInternal->StartCheckTableDraw()); } JSSmart CGraphicsEmbed::SetTextClipRect(JSSmart _l, JSSmart _t, JSSmart _r, JSSmart _b) { m_pInternal->SetTextClipRect(_l->toDouble(), _t->toDouble(), _r->toDouble(), _b->toDouble()); return NULL; } JSSmart CGraphicsEmbed::AddSmartRect (JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart pen_w) { m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::CheckUseFonts2 (JSSmart _transform) { return NULL; } JSSmart CGraphicsEmbed::UncheckUseFonts2() { return NULL; } JSSmart CGraphicsEmbed::Drawing_StartCheckBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { return NULL; } JSSmart CGraphicsEmbed::Drawing_EndCheckBounds() { return NULL; } JSSmart CGraphicsEmbed::DrawPresentationComment(JSSmart type, JSSmart x, JSSmart y, JSSmart w, JSSmart h) { return NULL; } JSSmart CGraphicsEmbed::DrawPolygon(JSSmart oPath, JSSmart lineWidth, JSSmart shift) { return NULL; } JSSmart CGraphicsEmbed::DrawFootnoteRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->DrawFootnoteRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::toDataURL(JSSmart type) { return CJSContext::createString(m_pInternal->toDataURL(type->toStringW())); } JSSmart CGraphicsEmbed::GetPenColor() { JSSmart e = CJSContext::createObject(); NSGraphics::CColor res = m_pInternal->GetPenColor(); e->set("R", res.r); e->set("G", res.g); e->set("B", res.b); e->set("A", res.a); return e->toValue(); } JSSmart CGraphicsEmbed::GetBrushColor() { JSSmart e = CJSContext::createObject(); NSGraphics::CColor res = m_pInternal->GetBrushColor(); e->set("R", res.r); e->set("G", res.g); e->set("B", res.b); e->set("A", res.a); return e->toValue(); } JSSmart CGraphicsEmbed::put_brushTexture(JSSmart src, JSSmart type) { std::wstring sUrl = src->toStringW(); if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl)) sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl); m_pInternal->put_brushTexture(sUrl, type->toInt32()); return NULL; } JSSmart CGraphicsEmbed::put_brushTextureMode(JSSmart mode) { m_pInternal->put_brushTextureMode(mode->toInt32()); return NULL; } JSSmart CGraphicsEmbed::put_BrushTextureAlpha(JSSmart a) { m_pInternal->put_BrushTextureAlpha(a->toInt32()); return NULL; } JSSmart CGraphicsEmbed::put_BrushGradient(JSSmart colors, JSSmart transparent, JSSmart x0, JSSmart y0, JSSmart x1, JSSmart y1, JSSmart r0, JSSmart r1) { JSSmart items = colors->toArray(); size_t length = items->getCount() / 5; LONG* color = NULL; double* pos = NULL; if (length > 0) { color = new LONG[length]; pos = new double[length]; } LONG R, G, B, A; for (size_t i = 0; i < 5 * length; i++) { JSSmart item = items->get(i); size_t nDel = i % 5; switch (nDel) { case 0: pos[i / 5] = item->toDouble() / 100000.0; break; case 1: R = item->toInt32(); break; case 2: G = item->toInt32(); break; case 3: B = item->toInt32(); break; case 4: A = item->toInt32(); if (!transparent->isNull()) A = transparent->toInt32(); color[i / 5] = R | (G << 8) | (B << 16) | (A << 24); break; } } double _x0 = x0->toDouble() / 100000.0; double _y0 = y0->toDouble() / 100000.0; double _x1 = x1->toDouble() / 100000.0; double _y1 = y1->toDouble() / 100000.0; double _r0 = r0->toDouble() / 100000.0; double _r1 = r1->toDouble() / 100000.0; m_pInternal->put_BrushGradient(color, pos, length, _x0, _y0, _x1, _y1, _r0, _r1); RELEASEARRAYOBJECTS(color); RELEASEARRAYOBJECTS(pos); return NULL; } JSSmart CGraphicsEmbed::TransformPointX(JSSmart x, JSSmart y) { return CJSContext::createDouble(m_pInternal->TransformPointX(x->toDouble(), y->toDouble())); } JSSmart CGraphicsEmbed::TransformPointY(JSSmart x, JSSmart y) { return CJSContext::createDouble(m_pInternal->TransformPointY(x->toDouble(), y->toDouble())); } JSSmart CGraphicsEmbed::put_LineJoin(JSSmart join) { m_pInternal->put_LineJoin(join->toInt32()); return NULL; } JSSmart CGraphicsEmbed::get_LineJoin() { return CJSContext::createInt(m_pInternal->GetLineJoin()); } JSSmart CGraphicsEmbed::put_TextureBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { m_pInternal->put_TextureBounds(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::GetlineWidth() { return CJSContext::createDouble(m_pInternal->GetlineWidth()); } JSSmart CGraphicsEmbed::DrawPath(JSSmart path) { m_pInternal->DrawPath(path->toInt32()); return NULL; } JSSmart CGraphicsEmbed::CoordTransformOffset(JSSmart tx, JSSmart ty) { m_pInternal->CoordTransformOffset(tx->toDouble(), ty->toDouble()); return NULL; } JSSmart CGraphicsEmbed::GetTransform() { JSSmart e = CJSContext::createObject(); NSGraphics::CTransform res = m_pInternal->GetTransform(); e->set("sx", res.sx); e->set("shx", res.shx); e->set("shy", res.shy); e->set("sy", res.sy); e->set("tx", res.tx); e->set("ty", res.ty); return e->toValue(); } JSSmart CGraphicsEmbed::CreateLayer(JSSmart opacity) { m_pInternal->CreateLayer(opacity->toDouble()); return NULL; } JSSmart CGraphicsEmbed::BlendLayer() { m_pInternal->BlendLayer(); return NULL; }