TdError HTMLFileOutput::setColor(TdColor textColor, bool textBold, TdColor backgroundColor, bool backgroundBold){ mCurrentColor = "color: " + convertColor(textColor, textBold) + ";" + "background-color: " + convertColor(backgroundColor, backgroundBold) + ";" ; if(textBold){ mCurrentColor += "font-weight: bold;"; } return eTD_NO_ERROR; }
void ColorOptionView::reset() { if (myColorSelection == 0) { return; } ZLColorOptionEntry &colorEntry = (ZLColorOptionEntry&)*myOption; GdkColor gdkColor; gtk_color_selection_get_current_color(myColorSelection, &gdkColor); colorEntry.onReset(convertColor(gdkColor)); GdkColor initialColor = convertColor(((ZLColorOptionEntry&)*myOption).initialColor()); GdkColor currentColor = convertColor(((ZLColorOptionEntry&)*myOption).color()); gtk_color_selection_set_current_color(myColorSelection, ¤tColor); gtk_color_selection_set_previous_color(myColorSelection, &initialColor); }
void FaceScanner::manualScan() { //----Image processing float t = ofMap(ofGetMouseX(), 0, ofGetWidth(), 0, 255, true); convertColor(m_grabber, m_thresh, CV_RGB2GRAY); //Grabber to CV color image m_threshCopy = m_thresh; //Make a copy threshold(m_threshCopy, t); //Threshold //invert(m_threshCopy); //Invert m_threshCopy.update(); //Update m_contourFinder.findContours(m_threshCopy); //Contour detection //----Drawing commands m_threshCopy.draw(10 + m_width/4, 10, m_width/4, m_height/4); m_contourFinder.draw(); ofPushStyle(); ofSetColor(ofColor::blue); for (auto line : m_contourFinder.getPolylines()) { ofPoint lCenter = line.getCentroid2D(); ofCircle(lCenter, 4); float dist = ofDist(lCenter.x, lCenter.y, m_faceCenter.x, m_faceCenter.y); if (dist < MIN_VERT_DISTANCE_TO_FACE && //Is the centroid of this line within a certain distance to the face's centroid? compareBoundingBox(line, MIN_HORZ_DISTANCE_TO_FACE)) //lCenter.x > m_faceBoundingBox.x && //Is the centroid of this line within the face's bounding box (along the x-axis)? //lCenter.x < (m_faceBoundingBox.x + m_faceBoundingBox.width)) { ofLine(lCenter.x, lCenter.y, m_faceCenter.x, m_faceCenter.y); } } ofPopStyle(); }
PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value) { if (value->isPrimitiveValue()) { ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); return PassRefPtr<ShadowList>(); } const CSSValueList* valueList = toCSSValueList(value); size_t shadowCount = valueList->length(); ShadowDataVector shadows; for (size_t i = 0; i < shadowCount; ++i) { const CSSShadowValue* item = toCSSShadowValue(valueList->item(i)); float x = item->x->computeLength<float>(state.cssToLengthConversionData()); float y = item->y->computeLength<float>(state.cssToLengthConversionData()); float blur = item->blur ? item->blur->computeLength<float>(state.cssToLengthConversionData()) : 0; float spread = item->spread ? item->spread->computeLength<float>(state.cssToLengthConversionData()) : 0; ShadowStyle shadowStyle = item->style && item->style->getValueID() == CSSValueInset ? Inset : Normal; Color color; if (item->color) color = convertColor(state, item->color.get()); else color = state.style()->color(); shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color)); } return ShadowList::adopt(shadows); }
void ColorOptionView::_createItem() { GdkColor initialColor = convertColor(((ZLColorOptionEntry&)*myOption).initialColor()); GdkColor currentColor = convertColor(((ZLColorOptionEntry&)*myOption).color()); myColorSelection = GTK_COLOR_SELECTION(gtk_color_selection_new()); gtk_color_selection_set_has_opacity_control(myColorSelection, false); gtk_color_selection_set_has_palette(myColorSelection, true); gtk_color_selection_set_current_color(myColorSelection, ¤tColor); gtk_color_selection_set_previous_color(myColorSelection, &initialColor); GtkContainer *container = GTK_CONTAINER(gtk_vbox_new(true, 0)); gtk_container_set_border_width(container, 5); gtk_container_add(container, GTK_WIDGET(myColorSelection)); myHolder.attachWidget(*this, GTK_WIDGET(container)); gtk_widget_show(GTK_WIDGET(container)); }
void FaceTracker::update(ofBaseVideoDraws& video) { if (!isThreadRunning()) { //videoMat = Mat(h, w, CV_8UC3); videoMat = toCv(video).clone(); convertColor(videoMat, grayMat, CV_RGB2GRAY); resize(grayMat, graySmallMat, graySmallMat.size()); startThread(true, false); } }
// *************************************************************************** bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { if(!CViewBase::parse(cur, parentGroup)) return false; CViewRenderer &rVR = *CViewRenderer::getInstance(); // link to the db CXMLAutoPtr ptr; ptr = xmlGetProp (cur, (xmlChar*)"value"); if ( ptr ) _Number.link ( ptr ); else { nlinfo ("no value in %s", _Id.c_str()); return false; } // read options ptr = xmlGetProp (cur, (xmlChar*)"numdigit"); if(ptr) fromString((const char*)ptr, _NumDigit); clamp(_NumDigit, 1, 10); ptr = xmlGetProp (cur, (xmlChar*)"wspace"); if(ptr) fromString((const char*)ptr, _WSpace); ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" ); _Color = CRGBA(255,255,255,255); if (ptr) _Color = convertColor (ptr); // compute window size. Remove one space. sint32 wDigit= rVR.getFigurTextureW(); sint32 hDigit= rVR.getFigurTextureH(); setW((wDigit+_WSpace)*_NumDigit - _WSpace); setH(hDigit); // some init // For _NumDigit=2; set the divBase to 100, etc... _DivBase= 1; for(uint i= 0;i<(uint)_NumDigit;i++) { _DivBase*= 10; } // init cache. _Cache= -1; return true; }
void WaveFrontObj_WriteMaterial(const char *texelName, const char *texelFilename, const Material * const mat) { char texelNameCopy[MAX_PATH]; strcpy_s(texelNameCopy, texelName); RemoveSpaces(texelNameCopy); fprintf_s(matFile, "newmtl %s\n", texelNameCopy); fprintf_s(matFile, "Ns 7.843137\n"); D3DXVECTOR4 color = convertColor(mat->m_cBase); fprintf_s(matFile, "Ka 0.000000 0.000000 0.000000\n"); fprintf_s(matFile, "Kd %f %f %f\n", color.x, color.y, color.z); color = convertColor(mat->m_cGlossy); fprintf_s(matFile, "Ks %f %f %f\n", color.x, color.y, color.z); fprintf_s(matFile, "Ni 1.500000\n"); fprintf_s(matFile, "d %f\n", mat->m_fOpacity); fprintf_s(matFile, "illum 5\n"); if (texelFilename != NULL) { strcpy_s(texelNameCopy, texelFilename); RemoveSpaces(texelNameCopy); fprintf_s(matFile, "map_kd %s\n", texelNameCopy); fprintf_s(matFile, "map_ka %s\n\n", texelNameCopy); } }
int main(void){ HeartBeat_Init(); DAC_Init(1024); // initialize with command: Vout = Vref Timer0A_Init(dt[0]); LCD_Init(); // Initialize RNG Random_Init(121213); // Initialize touchscreen GPIO Touch_Init(); //lenPush = 1; //for(i=0; i<50; i=i+1){ InitializeBars(); for(i=0; i<400; i=i+1){ MovingColorBars(); } for(i=0; i<400; i=i+1){ DestabilizeBars(); } for(i=0; i<350; i=i+1){ FinishBars(); } for(i=0; i<1000; i=i+1){ Random4BPPTestSprite(); } LCD_ColorFill(convertColor(0, 0, 0)); Buttons_Init(); play = 0; while(1){ if (instrument == 0){ Music_Play(Wave[0], 64, strobePtr, 35); } if (instrument == 1){ Music_Play(Trumpet[0], 32, strobePtr, 35); } if (instrument == 2){ Music_Play(Flute[0], 32, strobePtr, 35); } } }
bool warp(Image<T>& dst, const Image<T>& src, const Matrix<S, 3, 3>& homographyFromPatchToImg, const T& defaultFillColor = ColorTraits<T>::min(), bool stopIfOutOfRange = false) { typedef Matrix<S, 3, 3> Matrix3; typedef Matrix<S, 3, 1> Vector3; typename Image<T>::range_iterator dst_it = dst.begin_range(); typename Image<T>::range_iterator dst_end = dst.end_range(); const Matrix3& H = homographyFromPatchToImg; bool isInsideSourceImage = true; for ( ; dst_it != dst_end; ++dst_it) { // Get the corresponding coordinates in the source image. Vector3 H_p; H_p = H * (Vector3() << dst_it.coords().template cast<S>(), S(1)).finished(); H_p /= H_p(2); // Check if the position is not in the image domain [0,w[ x [0,h[. bool posNotInImageDomain = H_p.x() < S(0) || H_p.x() >= S(src.width()-1) || H_p.y() < S(0) || H_p.y() >= S(src.height()-1); if (posNotInImageDomain && stopIfOutOfRange) return false; if (posNotInImageDomain && isInsideSourceImage) isInsideSourceImage = false; // Fill with either the default value or the interpolated value. if (posNotInImageDomain) *dst_it = defaultFillColor; else convertColor(*dst_it, interpolate(src, H_p.template head<2>().eval())); } return isInsideSourceImage; }
void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) { #define RequireAttr( attr, name, a ) \ if( MissingAttr( attr, name, a ) ) return; if( rName == "Include" ) { RequireAttr( attr, rName, "file" ); OSFactory *pFactory = OSFactory::instance( getIntf() ); string fullPath = m_path + pFactory->getDirSeparator() + attr["file"]; msg_Dbg( getIntf(), "opening included XML file: %s", fullPath.c_str() ); SkinParser subParser( getIntf(), fullPath.c_str(), m_path, m_pData ); subParser.parse(); } else if( rName == "IniFile" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "file" ); const BuilderData::IniFile iniFile( uniqueId( attr["id"] ), attr["file"] ); m_pData->m_listIniFile.push_back( iniFile ); } else if( rName == "Anchor" ) { RequireAttr( attr, rName, "priority" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "points", "(0,0)" ); DefaultAttr( attr, "range", "10" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); const BuilderData::Anchor anchor( x + m_xOffset, y + m_yOffset, attr["lefttop"], atoi( attr["range"] ), atoi( attr["priority"] ), attr["points"], m_curLayoutId ); m_pData->m_listAnchor.push_back( anchor ); } else if( rName == "Bitmap" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "file" ); RequireAttr( attr, rName, "alphacolor" ); DefaultAttr( attr, "nbframes", "1" ); DefaultAttr( attr, "fps", "4" ); DefaultAttr( attr, "loop", "0" ); m_curBitmapId = uniqueId( attr["id"] ); const BuilderData::Bitmap bitmap( m_curBitmapId, attr["file"], convertColor( attr["alphacolor"] ), atoi( attr["nbframes"] ), atoi( attr["fps"] ), atoi( attr["loop"] ) ); m_pData->m_listBitmap.push_back( bitmap ); } else if( rName == "SubBitmap" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "x" ); RequireAttr( attr, rName, "y" ); RequireAttr( attr, rName, "width" ); RequireAttr( attr, rName, "height" ); DefaultAttr( attr, "nbframes", "1" ); DefaultAttr( attr, "fps", "4" ); DefaultAttr( attr, "loop", "0" ); const BuilderData::SubBitmap bitmap( uniqueId( attr["id"] ), m_curBitmapId, atoi( attr["x"] ), atoi( attr["y"] ), atoi( attr["width"] ), atoi( attr["height"] ), atoi( attr["nbframes"] ), atoi( attr["fps"] ), atoi( attr["loop"] ) ); m_pData->m_listSubBitmap.push_back( bitmap ); } else if( rName == "BitmapFont" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "file" ); DefaultAttr( attr, "type", "digits" ); const BuilderData::BitmapFont font( uniqueId( attr["id"] ), attr["file"], attr["type"] ); m_pData->m_listBitmapFont.push_back( font ); } else if( rName == "PopupMenu" ) { RequireAttr( attr, rName, "id" ); m_popupPosList.push_back(0); m_curPopupId = uniqueId( attr["id"] ); const BuilderData::PopupMenu popup( m_curPopupId ); m_pData->m_listPopupMenu.push_back( popup ); } else if( rName == "MenuItem" ) { RequireAttr( attr, rName, "label" ); DefaultAttr( attr, "action", "none" ); const BuilderData::MenuItem item( attr["label"], attr["action"], m_popupPosList.back(), m_curPopupId ); m_pData->m_listMenuItem.push_back( item ); m_popupPosList.back()++; } else if( rName == "MenuSeparator" ) { const BuilderData::MenuSeparator sep( m_popupPosList.back(), m_curPopupId ); m_pData->m_listMenuSeparator.push_back( sep ); m_popupPosList.back()++; } else if( rName == "Button" ) { RequireAttr( attr, rName, "up" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "down", "none" ); DefaultAttr( attr, "over", "none" ); DefaultAttr( attr, "action", "none" ); DefaultAttr( attr, "tooltiptext", "" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); const BuilderData::Button button( uniqueId( attr["id"] ), x + m_xOffset, y + m_yOffset, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["visible"], attr["up"], attr["down"], attr["over"], attr["action"], attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listButton.push_back( button ); } else if( rName == "Checkbox" ) { RequireAttr( attr, rName, "up1" ); RequireAttr( attr, rName, "up2" ); RequireAttr( attr, rName, "state" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "down1", "none" ); DefaultAttr( attr, "over1", "none" ); DefaultAttr( attr, "down2", "none" ); DefaultAttr( attr, "over2", "none" ); DefaultAttr( attr, "action1", "none" ); DefaultAttr( attr, "action2", "none" ); DefaultAttr( attr, "tooltiptext1", "" ); DefaultAttr( attr, "tooltiptext2", "" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ), x + m_xOffset, y + m_yOffset, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["visible"], attr["up1"], attr["down1"], attr["over1"], attr["up2"], attr["down2"], attr["over2"], attr["state"], attr["action1"], attr["action2"], attr["tooltiptext1"], attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listCheckbox.push_back( checkbox ); } else if( rName == "Font" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "file" ); DefaultAttr( attr, "size", "12" ); const BuilderData::Font fontData( uniqueId( attr["id"] ), attr["file"], atoi( attr["size"] ) ); m_pData->m_listFont.push_back( fontData ); } else if( rName == "Group" ) { DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); m_xOffset += atoi( attr["x"] ); m_yOffset += atoi( attr["y"] ); m_xOffsetList.push_back( atoi( attr["x"] ) ); m_yOffsetList.push_back( atoi( attr["y"] ) ); } else if( rName == "Image" ) { RequireAttr( attr, rName, "image" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "width", "-1" ); DefaultAttr( attr, "height", "-1" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "action", "none" ); DefaultAttr( attr, "action2", "none" ); DefaultAttr( attr, "resize", "mosaic" ); DefaultAttr( attr, "help", "" ); DefaultAttr( attr, "art", "false" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); const BuilderData::Image imageData( uniqueId( attr["id"] ), x + m_xOffset, y + m_yOffset, width, height, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["visible"], attr["image"], attr["action"], attr["action2"], attr["resize"], attr["help"], convertBoolean( attr["art"] ), m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listImage.push_back( imageData ); } else if( rName == "Layout" ) { RequireAttr( attr, rName, "width" ); RequireAttr( attr, rName, "height" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "minwidth", "-1" ); DefaultAttr( attr, "maxwidth", "-1" ); DefaultAttr( attr, "minheight", "-1" ); DefaultAttr( attr, "maxheight", "-1" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, true ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); m_curLayoutId = uniqueId( attr["id"] ); const BuilderData::Layout layout( m_curLayoutId, width, height, getDimension( attr["minwidth"], refWidth ), getDimension( attr["maxwidth"], refWidth ), getDimension( attr["minheight"], refHeight ), getDimension( attr["maxheight"], refHeight ), m_curWindowId ); updateWindowPos( width, height ); m_pData->m_listLayout.push_back( layout ); m_curLayer = 0; } else if( rName == "Panel" ) { DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); RequireAttr( attr, rName, "width" ); RequireAttr( attr, rName, "height" ); DefaultAttr( attr, "position", "-1" ); DefaultAttr( attr, "xoffset", "0" ); DefaultAttr( attr, "yoffset", "0" ); DefaultAttr( attr, "xmargin", "0" ); DefaultAttr( attr, "ymargin", "0" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); convertPosition( attr["position"], attr["xoffset"], attr["yoffset"], attr["xmargin"], attr["ymargin"], width, height, refWidth, refHeight, &x, &y ); string panelId = uniqueId( "none" ); const BuilderData::Panel panel( panelId, x + m_xOffset, y + m_yOffset, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), width, height, m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listPanel.push_back( panel ); // Add the panel to the stack m_panelStack.push_back( panelId ); } else if( rName == "Playlist" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "font" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "flat", "true" ); // Only difference here DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "width", "0" ); DefaultAttr( attr, "height", "0" ); DefaultAttr( attr, "position", "-1" ); DefaultAttr( attr, "xoffset", "0" ); DefaultAttr( attr, "yoffset", "0" ); DefaultAttr( attr, "xmargin", "0" ); DefaultAttr( attr, "ymargin", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "bgimage", "none" ); DefaultAttr( attr, "itemimage", "none" ); DefaultAttr( attr, "openimage", "none" ); DefaultAttr( attr, "closedimage", "none" ); DefaultAttr( attr, "fgcolor", "#000000" ); DefaultAttr( attr, "playcolor", "#FF0000" ); DefaultAttr( attr, "bgcolor1", "#FFFFFF" ); DefaultAttr( attr, "bgcolor2", "#FFFFFF" ); DefaultAttr( attr, "selcolor", "#0000FF" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); convertPosition( attr["position"], attr["xoffset"], attr["yoffset"], attr["xmargin"], attr["ymargin"], width, height, refWidth, refHeight, &x, &y ); m_curTreeId = uniqueId( attr["id"] ); const BuilderData::Tree treeData( m_curTreeId, x + m_xOffset, y + m_yOffset, attr["visible"], attr["flat"], width, height, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["font"], "playtree", attr["bgimage"], attr["itemimage"], attr["openimage"], attr["closedimage"], attr["fgcolor"], attr["playcolor"], attr["bgcolor1"], attr["bgcolor2"], attr["selcolor"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listTree.push_back( treeData ); } else if( rName == "Playtree" ) { RequireAttr( attr, rName, "id" ); RequireAttr( attr, rName, "font" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "flat", "false" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "width", "0" ); DefaultAttr( attr, "height", "0" ); DefaultAttr( attr, "position", "-1" ); DefaultAttr( attr, "xoffset", "0" ); DefaultAttr( attr, "yoffset", "0" ); DefaultAttr( attr, "xmargin", "0" ); DefaultAttr( attr, "ymargin", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "bgimage", "none" ); DefaultAttr( attr, "itemimage", "none" ); DefaultAttr( attr, "openimage", "none" ); DefaultAttr( attr, "closedimage", "none" ); DefaultAttr( attr, "fgcolor", "#000000" ); DefaultAttr( attr, "playcolor", "#FF0000" ); DefaultAttr( attr, "bgcolor1", "#FFFFFF" ); DefaultAttr( attr, "bgcolor2", "#FFFFFF" ); DefaultAttr( attr, "selcolor", "#0000FF" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); convertPosition( attr["position"], attr["xoffset"], attr["yoffset"], attr["xmargin"], attr["ymargin"], width, height, refWidth, refHeight, &x, &y ); m_curTreeId = uniqueId( attr["id"] ); const BuilderData::Tree treeData( m_curTreeId, x + m_xOffset, y + m_yOffset, attr["visible"], attr["flat"], width, height, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["font"], "playtree", attr["bgimage"], attr["itemimage"], attr["openimage"], attr["closedimage"], attr["fgcolor"], attr["playcolor"], attr["bgcolor1"], attr["bgcolor2"], attr["selcolor"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listTree.push_back( treeData ); } else if( rName == "RadialSlider" ) { RequireAttr( attr, rName, "sequence" ); RequireAttr( attr, rName, "nbimages" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "minangle", "0" ); DefaultAttr( attr, "maxangle", "360" ); DefaultAttr( attr, "value", "none" ); DefaultAttr( attr, "tooltiptext", "" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); const BuilderData::RadialSlider radial( uniqueId( attr["id"] ), attr["visible"], x + m_xOffset, y + m_yOffset, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["sequence"], atoi( attr["nbimages"] ), atof( attr["minangle"] ) * M_PI /180, atof( attr["maxangle"] ) * M_PI / 180, attr["value"], attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listRadialSlider.push_back( radial ); } else if( rName == "Slider" ) { RequireAttr( attr, rName, "up" ); RequireAttr( attr, rName, "points" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "width", "-1" ); DefaultAttr( attr, "height", "-1" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "down", "none" ); DefaultAttr( attr, "over", "none" ); DefaultAttr( attr, "thickness", "10" ); DefaultAttr( attr, "value", "none" ); DefaultAttr( attr, "tooltiptext", "" ); DefaultAttr( attr, "help", "" ); string newValue = attr["value"]; if( m_curTreeId != "" ) { // Slider associated to a tree newValue = "playtree.slider"; } int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); const BuilderData::Slider slider( uniqueId( attr["id"] ), attr["visible"], x + m_xOffset, y + m_yOffset, width, height, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"], attr["over"], attr["points"], atoi( attr["thickness"] ), newValue, "none", 0, 0, 0, 0, attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listSlider.push_back( slider ); } else if( rName == "SliderBackground" ) { RequireAttr( attr, rName, "image" ); DefaultAttr( attr, "nbhoriz", "1" ); DefaultAttr( attr, "nbvert", "1" ); DefaultAttr( attr, "padhoriz", "0" ); DefaultAttr( attr, "padvert", "0" ); // Retrieve the current slider data BuilderData::Slider &slider = m_pData->m_listSlider.back(); slider.m_imageId = attr["image"]; slider.m_nbHoriz = atoi( attr["nbhoriz"] ); slider.m_nbVert = atoi( attr["nbvert"] ); slider.m_padHoriz = atoi( attr["padhoriz"] ); slider.m_padVert = atoi( attr["padvert"] ); } else if( rName == "Text" ) { RequireAttr( attr, rName, "font" ); DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "text", "" ); DefaultAttr( attr, "color", "#000000" ); DefaultAttr( attr, "scrolling", "auto" ); DefaultAttr( attr, "alignment", "left" ); DefaultAttr( attr, "focus", "true" ); DefaultAttr( attr, "width", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); const BuilderData::Text textData( uniqueId( attr["id"] ), x + m_xOffset, y + m_yOffset, attr["visible"], attr["font"], attr["text"], width, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), convertColor( attr["color"] ), attr["scrolling"], attr["alignment"], attr["focus"], attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listText.push_back( textData ); } else if( rName == "Theme" ) { RequireAttr( attr, rName, "version" ); DefaultAttr( attr, "tooltipfont", "defaultfont" ); DefaultAttr( attr, "magnet", "15" ); DefaultAttr( attr, "alpha", "255" ); DefaultAttr( attr, "movealpha", "255" ); // Check the version if( strcmp( attr["version"], SKINS_DTD_VERSION ) ) { msg_Err( getIntf(), "bad theme version : %s (you need version %s)", attr["version"], SKINS_DTD_VERSION ); m_errors = true; return; } const BuilderData::Theme theme( attr["tooltipfont"], atoi( attr["magnet"] ), convertInRange( attr["alpha"], 1, 255, "alpha" ), convertInRange( attr["movealpha"], 1, 255, "movealpha" ) ); m_pData->m_listTheme.push_back( theme ); } else if( rName == "ThemeInfo" ) { DefaultAttr( attr, "name", "" ); DefaultAttr( attr, "author", "" ); DefaultAttr( attr, "email", "" ); DefaultAttr( attr, "website", "" ); msg_Info( getIntf(), "skin: %s author: %s", attr["name"], attr["author"] ); } else if( rName == "Video" ) { DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "width", "0" ); DefaultAttr( attr, "height", "0" ); DefaultAttr( attr, "position", "-1" ); DefaultAttr( attr, "xoffset", "0" ); DefaultAttr( attr, "yoffset", "0" ); DefaultAttr( attr, "xmargin", "0" ); DefaultAttr( attr, "ymargin", "0" ); DefaultAttr( attr, "lefttop", "lefttop" ); DefaultAttr( attr, "rightbottom", "lefttop" ); DefaultAttr( attr, "xkeepratio", "false" ); DefaultAttr( attr, "ykeepratio", "false" ); DefaultAttr( attr, "autoresize", "true" ); DefaultAttr( attr, "help", "" ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, false ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); int width = getDimension( attr["width"], refWidth ); int height = getDimension( attr["height"], refHeight ); convertPosition( attr["position"], attr["xoffset"], attr["yoffset"], attr["xmargin"], attr["ymargin"], width, height, refWidth, refHeight, &x, &y ); const BuilderData::Video videoData( uniqueId( attr["id"] ), x + m_xOffset, y + m_yOffset, width, height, attr["lefttop"], attr["rightbottom"], convertBoolean( attr["xkeepratio"] ), convertBoolean( attr["ykeepratio"] ), attr["visible"], convertBoolean( attr["autoresize"] ), attr["help"], m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() ); m_curLayer++; m_pData->m_listVideo.push_back( videoData ); } else if( rName == "Window" ) { DefaultAttr( attr, "id", "none" ); DefaultAttr( attr, "visible", "true" ); DefaultAttr( attr, "x", "0" ); DefaultAttr( attr, "y", "0" ); DefaultAttr( attr, "position", "-1" ); DefaultAttr( attr, "xoffset", "0" ); DefaultAttr( attr, "yoffset", "0" ); DefaultAttr( attr, "xmargin", "0" ); DefaultAttr( attr, "ymargin", "0" ); DefaultAttr( attr, "dragdrop", "true" ); DefaultAttr( attr, "playondrop", "true" ); m_curWindowId = uniqueId( attr["id"] ); int refWidth, refHeight; getRefDimensions( refWidth, refHeight, true ); int x = getDimension( attr["x"], refWidth ); int y = getDimension( attr["y"], refHeight ); const BuilderData::Window window( m_curWindowId, x + m_xOffset, y + m_yOffset, attr["position"], attr["xoffset"], attr["yoffset"], attr["xmargin"], attr["ymargin"], convertBoolean( attr["visible"] ), convertBoolean( attr["dragdrop"] ), convertBoolean( attr["playondrop"] ) ); m_pData->m_listWindow.push_back( window ); } #undef RequireAttr }
void mode5RenderLine(u16* lineMix) { if(DISPCNT & 0x0080) { for(int x = 0; x < 240; x++) { lineMix[x] = convertColor(0x7fff); } gfxLastVCOUNT = VCOUNT; return; } u16 *palette = (u16 *)paletteRAM; if(layerEnable & 0x0400) { int changed = gfxBG2Changed; if(gfxLastVCOUNT > VCOUNT) changed = 3; gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, changed, line2); } gfxDrawSprites(lineOBJ); u32 background = (READ16LE(&palette[0]) | 0x30000000); for(int x = 0; x < 240; x++) { u32 color = background; u8 top = 0x20; if(line2[x] < color) { color = line2[x]; top = 0x04; } if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) { color = lineOBJ[x]; top = 0x10; } if((top & 0x10) && (color & 0x00010000)) { // semi-transparent OBJ u32 back = background; u8 top2 = 0x20; if(line2[x] < back) { back = line2[x]; top2 = 0x04; } if(top2 & (BLDMOD>>8)) color = gfxAlphaBlend(color, back, coeff[COLEV & 0x1F], coeff[(COLEV >> 8) & 0x1F]); else { switch((BLDMOD >> 6) & 3) { case 2: if(BLDMOD & top) color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); break; case 3: if(BLDMOD & top) color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); break; } } }
coeff[(COLEV >> 8) & 0x1F]); else { switch((BLDMOD >> 6) & 3) { case 2: if(BLDMOD & top) color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); break; case 3: if(BLDMOD & top) color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); break; } } } lineMix[x] = convertColor(color); } gfxBG2Changed = 0; gfxLastVCOUNT = VCOUNT; } void mode5RenderLineNoWindow(u16* lineMix) { if(DISPCNT & 0x0080) { for(int x = 0; x < 240; x++) { lineMix[x] = convertColor(0x7fff); } gfxLastVCOUNT = VCOUNT; return; }
bool MoviePlayer::playVideo() { bool skipped = false; uint16 x = (g_system->getWidth() - _decoder->getWidth()) / 2; uint16 y = (g_system->getHeight() - _decoder->getHeight()) / 2; while (!_vm->shouldQuit() && !_decoder->endOfVideo() && !skipped) { if (_decoder->needsUpdate()) { const Graphics::Surface *frame = _decoder->decodeNextFrame(); if (frame) { if (_decoderType == kVideoDecoderPSX) drawFramePSX(frame); else _vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); } if (_decoder->hasDirtyPalette()) { _decoder->setSystemPalette(); if (!_movieTexts.empty()) { // Look for the best color indexes to use to display the subtitles uint32 minWeight = 0xFFFFFFFF; uint32 weight; float c1Weight = 1e+30f; float c2Weight = 1e+30f; float c3Weight = 1e+30f; float c4Weight = 1e+30f; byte r, g, b; float h, s, v, hd, hsvWeight; const byte *palette = _decoder->getPalette(); // Color comparaison for the subtitles colors is done in HSL // C1 color is used for George and is almost white (R = 248, G = 252, B = 248) const float h1 = 0.333333f, s1 = 0.02f, v1 = 0.99f; // C2 color is used for George as a narrator and is grey (R = 184, G = 188, B = 184) const float h2 = 0.333333f, s2 = 0.02f, v2 = 0.74f; // C3 color is used for Nicole and is rose (R = 200, G = 120, B = 184) const float h3 = 0.866667f, s3 = 0.4f, v3 = 0.78f; // C4 color is used for Maguire and is blue (R = 80, G = 152, B = 184) const float h4 = 0.55f, s4 = 0.57f, v4 = 0.72f; for (int i = 0; i < 256; i++) { r = *palette++; g = *palette++; b = *palette++; weight = 3 * r * r + 6 * g * g + 2 * b * b; if (weight <= minWeight) { minWeight = weight; _black = i; } convertColor(r, g, b, h, s, v); // C1 color // It is almost achromatic (very low saturation) so the hue as litle impact on the color. // Therefore use a low weight on hue and high weight on saturation. hd = h - h1; hd += hd < -0.5f ? 1.0f : hd > 0.5f ? -1.0f : 0.0f; hsvWeight = 1.0f * hd * hd + 4.0f * (s - s1) * (s - s1) + 3.0f * (v - v1) * (v - v1); if (hsvWeight <= c1Weight) { c1Weight = hsvWeight; _c1Color = i; } // C2 color // Also an almost achromatic color so use the same weights as for C1 color. hd = h - h2; hd += hd < -0.5f ? 1.0f : hd > 0.5f ? -1.0f : 0.0f; hsvWeight = 1.0f * hd * hd + 4.0f * (s - s2) * (s - s2) + 3.0f * (v - v2) * (v - v2); if (hsvWeight <= c2Weight) { c2Weight = hsvWeight; _c2Color = i; } // C3 color // A light rose. Use a high weight on the hue to get a rose. // The color is a bit gray and the saturation has not much impact so use a low weight. hd = h - h3; hd += hd < -0.5f ? 1.0f : hd > 0.5f ? -1.0f : 0.0f; hsvWeight = 4.0f * hd * hd + 1.0f * (s - s3) * (s - s3) + 2.0f * (v - v3) * (v - v3); if (hsvWeight <= c3Weight) { c3Weight = hsvWeight; _c3Color = i; } // C4 color // Blue. Use a hight weight on the hue to get a blue. // The color is darker and more saturated than C3 and the saturation has more impact. hd = h - h4; hd += hd < -0.5f ? 1.0f : hd > 0.5f ? -1.0f : 0.0f; hsvWeight = 5.0f * hd * hd + 3.0f * (s - s4) * (s - s4) + 2.0f * (v - v4) * (v - v4); if (hsvWeight <= c4Weight) { c4Weight = hsvWeight; _c4Color = i; } } } } Graphics::Surface *screen = _vm->_system->lockScreen(); performPostProcessing((byte *)screen->pixels); _vm->_system->unlockScreen(); _vm->_system->updateScreen(); } Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) skipped = true; _vm->_system->delayMillis(10); } if (_decoderType == kVideoDecoderPSX) { // Need to jump back to paletted color initGraphics(g_system->getWidth(), g_system->getHeight(), true); } return !_vm->shouldQuit() && !skipped; }
ofColor convertColor(ofColor color, int code) { Vec3b cvColor(color.r, color.g, color.b); Vec3b result = convertColor(cvColor, code); return ofColor(result[0], result[1], result[2], color.a); }
void FaceScanner::update() { m_grabber.update(); if(m_grabber.isFrameNew()) { if (m_shouldTrack) { m_tracker.update(toCv(m_grabber)); //----If we've found a face, we store its intrinsics and begin our scanning procedure if (m_tracker.getFound() && //Have we found a face? ofGetElapsedTimef() > 2.0f && //Has it been at least 2 seconds? m_tracker.getImageFeature(ofxFaceTracker::FACE_OUTLINE).getArea() > MIN_FACE_AREA) //If we've found a face, is it reasonably large? { ofLogNotice("Face Scanner") << "Found a face."; //----The FBOs are cleared IFF the last sequence drawn was the particle system (denoted by the boolean m_shouldClearAmbient) if (!m_shouldClearAmbient) m_inkRenderer->clear(); m_inkRenderer->setDrawMode(InkRenderer::FOLLOWERS); convertColor(m_grabber, m_thresh, CV_RGB2GRAY); m_faceOutline = m_tracker.getImageFeature(ofxFaceTracker::FACE_OUTLINE); m_faceCenter = m_faceOutline.getCentroid2D(); m_faceArea = m_faceOutline.getArea(); //This is a hack: something is wrong with the sign of the value returned by getArea() m_faceBoundingBox = m_faceOutline.getBoundingBox(); m_shouldTrack = false; m_drawFrameStart = ofGetElapsedTimef(); //When did this scan start? scan(200, 10); //Start at a threshold value of 200, and decrement by 5 for each iteration } else { //----If we don't see a face and it's been m_ambientTimeout seconds, enter ambient mode if ((ofGetElapsedTimef() - m_ambientFrameStart) >= m_ambientTimeout) { //----We only want to do these operations once, otherwise the FBOs will clear every frame, and the particle system will never be drawn if (m_shouldClearAmbient) { ofLogNotice("Face Scanner") << "Entering ambient mode."; //----We tell the InkRenderer to draw particles after clearing the FBOs and resetting the "draw counter" m_inkRenderer->setDrawMode(InkRenderer::PARTICLES); m_inkRenderer->clear(); m_shouldClearAmbient = false; } } } } else if ((ofGetElapsedTimef() - m_drawFrameStart) >= m_drawTimeout) { //----If we shouldn't be tracking, that means we've already found a face, so begin the countdown ofLogNotice("Face Scanner") << "Starting a new scan."; //----After this point, we might not see another face, so we record the current time and ready the InkRenderer for a particle simulation m_ambientFrameStart = ofGetElapsedTimef(); m_shouldClearAmbient = true; ofSaveScreen("screenshots/image_" + ofGetTimestampString() + ".png"); reset(); } } }
void YZPrinter::doPrint( ) { const double fontsize = 10.0; PSDoc *doc = PS_new(); if (!doc) return ; QByteArray p = m_path.toLatin1(); PS_open_file(doc, p.data()); PS_set_info(doc, "Creator", "Yzis"); PS_set_info(doc, "Author", ""); PS_set_info(doc, "Title", p.data()); // Set so it'll fit on both A4 and letter paper; // some of us live in the US, with archaic paper sizes. ;-) PS_set_info(doc, "BoundingBox", "0 0 596 792"); int font; font = PS_findfont(doc, "Fixed", "", 0); dbg() << "findfont returned " << font << endl; if ( !font ) return ; //no font => abort QPrinter lpr(QPrinter::PrinterResolution); QPainter p( &lpr ); QFont f( "fixed" ); f.setFixedPitch( true ); f.setStyleHint( QFont::TypeWriter ); p.setFont( f ); unsigned int height = lpr.height(); unsigned int width = lpr.width(); unsigned int linespace = p.fontMetrics().lineSpacing(); unsigned int maxwidth = p.fontMetrics().maxWidth(); p.end(); PS_set_value(doc, "leading", linespace); unsigned int clipw = width / maxwidth - 1; unsigned int cliph = height / linespace - 1; unsigned int oldLinesVis = mView->getLinesVisible( ); unsigned int oldColumnsVis = mView->getColumnsVisible( ); //should be current's view setting no ? XXX bool number = mView->getLocalBooleanOption( "number" ); unsigned int marginLeft = 0; double red, green, blue; if ( number ) { marginLeft = ( 2 + QString::number( mView->buffer()->lineCount() ).length() ); } YOptionValue* ov_wrap = mView->getLocalOption( "wrap" ); bool oldWrap = ov_wrap->boolean(); ov_wrap->setBoolean( true ); mView->setVisibleArea( clipw - marginLeft, cliph, false ); unsigned int totalHeight = mView->drawTotalHeight(); mView->setVisibleArea( clipw - marginLeft, totalHeight, false ); mView->initDraw( 0, 0, 0, 0 ); unsigned int lastLineNumber = 0; unsigned int pageNumber = 0; QRect titleRect( 0, 0, width, linespace + linespace / 2 ); unsigned int topY = titleRect.height() + linespace; unsigned int curY = topY; unsigned int curX; cliph = ( height - topY ) / linespace; int nbPages = totalHeight / cliph + ( totalHeight % cliph ? 1 : 0 ); PS_begin_page(doc, 596, 792); PS_setfont(doc, font, fontsize); PS_set_parameter(doc, "hyphenation", "false"); PS_set_parameter(doc, "linebreak", "true"); PS_set_parameter(doc, "parbreak", "false"); PS_set_value(doc, "parindent", 0.0); PS_set_value(doc, "numindentlines", 0.0); while ( mView->drawNextLine( ) ) { if ( curY == topY ) { if ( pageNumber ) { PS_end_page(doc); PS_begin_page(doc, 596, 792); PS_setfont(doc, font, fontsize); PS_set_value(doc, "leading", linespace); } ++pageNumber; convertColor(Qt::black, red, green, blue); PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0); QByteArray n = ( ' ' + mView->buffer()->fileName() ).toLatin1(); PS_show_boxed(doc, n.data(), titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(), "left", ""); QByteArray nb = ( QString::number( pageNumber ) + '/' + QString::number( nbPages ) + ' ' ).toLatin1(); PS_show_boxed(doc, nb.data(), titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(), "right", ""); } if ( number ) { unsigned int lineNumber = mView->drawLineNumber(); if ( lineNumber != lastLineNumber ) { //p.setPen( Qt::gray ); convertColor(Qt::gray, red, green, blue); PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0); PS_moveto(doc, 0, curY); QByteArray m = QString::number( lineNumber ).rightJustified( marginLeft - 1, ' ' ).toLatin1(); PS_show(doc, m.data()); lastLineNumber = lineNumber; } } curX = marginLeft * maxwidth; while ( mView->drawNextCol( ) ) { QColor c = mView->drawColor( ); if ( c.isValid() && c != Qt::white ) convertColor(mView->drawColor(), red, green, blue); else convertColor(Qt::black, red, green, blue); PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0); char buf[2] = { 0, 0 }; buf[0] = mView->drawChar().toLatin1(); PS_show_xy(doc, buf, curX, curY); curX += mView->drawLength( ) * maxwidth; } curY += linespace * mView->drawHeight(); if ( curY >= cliph * linespace + topY ) { // draw Rect convertColor(Qt::black, red, green, blue); PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0); PS_rect(doc, 0, 0, width, curY); if ( number ) { PS_moveto(doc, marginLeft*maxwidth - maxwidth / 2, titleRect.height()); PS_lineto(doc, marginLeft*maxwidth - maxwidth / 2, curY); } PS_moveto(doc, titleRect.x(), titleRect.height()); PS_lineto(doc, titleRect.width(), titleRect.height()); curY = topY; } } if ( curY != topY ) { // draw Rect convertColor(Qt::black, red, green, blue); PS_setcolor(doc, "fillstroke", "rgb", red, green, blue, 0.0); PS_rect(doc, 0, 0, width, curY); if ( number ) { PS_moveto(doc, marginLeft*maxwidth - maxwidth / 2, titleRect.height()); PS_lineto(doc, marginLeft*maxwidth - maxwidth / 2, curY); } PS_moveto(doc, titleRect.x(), titleRect.height()); PS_lineto(doc, titleRect.width(), titleRect.height()); } PS_end_page(doc); PS_deletefont(doc, font); PS_close(doc); PS_delete(doc); PS_shutdown(); ov_wrap->setBoolean( oldWrap ); mView->setVisibleArea( oldColumnsVis, oldLinesVis, false ); }
// ------------------------------------------------------------------------------------------------ void CCtrlColPick::setColorOver (const string &col) { _ColorOver = convertColor (col.c_str()); }
void DispReel::PostRenderStatic(RenderDevice* pd3dDevice) { TRACE_FUNCTION(); if (!m_d.m_fVisible || !GetPTable()->GetEMReelsEnabled()) return; // get a pointer to the image specified in the object Texture * const pin = m_ptable->GetImage(m_d.m_szImage); // pointer to image information from the image manager if (!pin) return; if (g_pplayer->m_ptable->m_tblMirrorEnabled^g_pplayer->m_ptable->m_fReflectionEnabled) pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_NONE); else pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_CCW); pd3dDevice->SetRenderState(RenderDevice::DEPTHBIAS, 0); pd3dDevice->SetRenderState(RenderDevice::ZWRITEENABLE, TRUE); g_pplayer->m_pin3d.EnableAlphaTestReference(0xE0); //!! pd3dDevice->SetRenderState(RenderDevice::ALPHAFUNC, D3DCMP_GREATER); //!! still necessary? g_pplayer->m_pin3d.EnableAlphaBlend(false); pd3dDevice->DMDShader->SetTechnique("basic_noDMD"); const D3DXVECTOR4 c = convertColor(0xFFFFFFFF, 1.f); pd3dDevice->DMDShader->SetVector("vColor_Intensity", &c); pd3dDevice->DMDShader->SetTexture("Texture0", pin); pd3dDevice->DMDShader->Begin(0); for (int r = 0; r < m_d.m_reelcount; ++r) //!! optimize by doing all in one { const float posx = ReelInfo[r].position.left; const float posy = ReelInfo[r].position.top; const float width = ReelInfo[r].position.right; const float height = ReelInfo[r].position.bottom; const float u0 = m_digitTexCoords[ReelInfo[r].currentValue].u_min; const float v0 = m_digitTexCoords[ReelInfo[r].currentValue].v_min; const float u1 = m_digitTexCoords[ReelInfo[r].currentValue].u_max; const float v1 = m_digitTexCoords[ReelInfo[r].currentValue].v_max; float Verts[4 * 5] = { 1.0f, 1.0f, 0.0f, u1, v1, 0.0f, 1.0f, 0.0f, u0, v1, 1.0f, 0.0f, 0.0f, u1, v0, 0.0f, 0.0f, 0.0f, u0, v0 }; for (unsigned int i = 0; i < 4; ++i) { Verts[i * 5] = (Verts[i * 5] * width + posx)*2.0f - 1.0f; Verts[i * 5 + 1] = 1.0f - (Verts[i * 5 + 1] * height + posy)*2.0f; } pd3dDevice->DrawTexturedQuad((Vertex3D_TexelOnly*)Verts); } pd3dDevice->DMDShader->End(); //g_pplayer->m_pin3d.DisableAlphaBlend(); //!! not necessary anymore pd3dDevice->SetRenderState(RenderDevice::ALPHATESTENABLE, FALSE); //if(g_pplayer->m_ptable->m_tblMirrorEnabled^g_pplayer->m_ptable->m_fReflectionEnabled) // pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_CCW); }
void mode0RenderLine(u16* lineMix) { u16 *palette = (u16 *)paletteRAM; if(DISPCNT & 0x80) { for(int x = 0; x < 240; x++) { lineMix[x] = convertColor(0x7fff); } return; } if(layerEnable & 0x0100) { gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); } if(layerEnable & 0x0200) { gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); } if(layerEnable & 0x0400) { gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); } if(layerEnable & 0x0800) { gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3); } gfxDrawSprites(lineOBJ); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); for(int x = 0; x < 240; x++) { u32 color = backdrop; u8 top = 0x20; if(line0[x] < color) { color = line0[x]; top = 0x01; } if((u8)(line1[x]>>24) < (u8)(color >> 24)) { color = line1[x]; top = 0x02; } if((u8)(line2[x]>>24) < (u8)(color >> 24)) { color = line2[x]; top = 0x04; } if((u8)(line3[x]>>24) < (u8)(color >> 24)) { color = line3[x]; top = 0x08; } if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { color = lineOBJ[x]; top = 0x10; } if((top & 0x10) && (color & 0x00010000)) { // semi-transparent OBJ u32 back = backdrop; u8 top2 = 0x20; if((u8)(line0[x]>>24) < (u8)(back >> 24)) { back = line0[x]; top2 = 0x01; } if((u8)(line1[x]>>24) < (u8)(back >> 24)) { back = line1[x]; top2 = 0x02; } if((u8)(line2[x]>>24) < (u8)(back >> 24)) { back = line2[x]; top2 = 0x04; } if((u8)(line3[x]>>24) < (u8)(back >> 24)) { back = line3[x]; top2 = 0x08; } if(top2 & (BLDMOD>>8)) color = gfxAlphaBlend(color, back, coeff[COLEV & 0x1F], coeff[(COLEV >> 8) & 0x1F]); else { switch((BLDMOD >> 6) & 3) { case 2: if(BLDMOD & top) color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); break; case 3: if(BLDMOD & top) color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); break; } } }
void ColorOptionView::_onAccept() const { GdkColor gdkColor; gtk_color_selection_get_current_color(myColorSelection, &gdkColor); ((ZLColorOptionEntry&)*myOption).onAccept(convertColor(gdkColor)); }
void ColorScheme::processColorSchemeXml(QXmlStreamReader &xml, QHash<QString, ColorScheme *> &colorSchemes) { // The color scheme ColorScheme *colorScheme = new ColorScheme; // The styles defined QHash<QString, StyleInfo> definedStyles; QString langId; while (!xml.atEnd() && !xml.hasError()) { QXmlStreamReader::TokenType token = xml.readNext(); if (token == QXmlStreamReader::StartElement) { if (xml.name() == "colorscheme") { QString name = xml.attributes().value("name").toString(); colorSchemes[name] = colorScheme; } else if (xml.name() == "color") { QString type = xml.attributes().value("type").toString(); QString text = xml.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement); if (type == "foreground") { colorScheme->m_foreground = convertColor(text); } else if (type == "background") { colorScheme->m_background = convertColor(text); } else if (type == "caret") { colorScheme->m_caret = convertColor(text); } else if (type == "caretLine") { colorScheme->m_caretLine = convertColor(text); } else if (type == "selection") { colorScheme->m_selection = convertColor(text); } else if (type == "whitespace") { colorScheme->m_whitespaceForeground = convertColor(text); } } else if (xml.name() == "style") { StyleInfo styleInfo; QXmlStreamAttributes attrs = xml.attributes(); QString name = attrs.value("name").toString(); if (attrs.hasAttribute("foreground")) { styleInfo.setForegroundColor( convertColor(attrs.value("foreground").toString())); } if (attrs.hasAttribute("background")) { styleInfo.setBackgroundColor( convertColor(attrs.value("background").toString())); } if (attrs.hasAttribute("bold")) { styleInfo.setBold(attrs.value("bold").toString() == "true"); } if (attrs.hasAttribute("italic")) { styleInfo.setItalic( attrs.value("italic").toString() == "true"); } if (attrs.hasAttribute("underline")) { styleInfo.setUnderline( attrs.value("underline").toString() == "true"); } if (attrs.hasAttribute("eolFilled")) { styleInfo.setEolFilled( attrs.value("eolFilled").toString() == "true"); } definedStyles[name] = styleInfo; } else if (xml.name() == "language") { langId = xml.attributes().value("id").toString(); colorScheme->m_languagesStyles[langId] = QHash<int, StyleInfo>(); } else if (xml.name() == "styleInfo") { QString idStr = xml.attributes().value("id").toString(); bool ok; int id = idStr.toInt(&ok); if (ok) { QXmlStreamAttributes attrs = xml.attributes(); if (attrs.hasAttribute("styleRef")) { QString styleRef = attrs.value("styleRef").toString(); colorScheme->m_languagesStyles[langId][id] = definedStyles[styleRef]; } } } } } }