/* ============================== ============================== */ TwLimb::TwLimb(IKALimb* l, const char* name, const ivec2& pos, const ivec2& size, const vec4& color) : bar(0), limb(0) { limb = l; if(limb) { limb->AddRef(); } bar = TwNewBar(name); TwStructs* twStructs = TwStructs::GetInstance(); ASSERT(twStructs); // Ball TwAddVarCB(bar, "BallRestRotation", twStructs->GetType(TW_STRUCT_EULER), &TwLimb::SetBallRestRotation, &TwLimb::GetBallRestRotation, reinterpret_cast<void*>(limb->ball), "group='Ball & Socket' label='Rest Rotation'"); TwAddVarCB(bar, "BallRotation", twStructs->GetType(TW_STRUCT_EULER), &TwLimb::SetBallRotation, &TwLimb::GetBallRotation, reinterpret_cast<void*>(limb->ball), "group='Ball & Socket' label='Rotation'"); TwAddVarCB(bar, "BallPosition", twStructs->GetType(TW_STRUCT_POSITION), &TwLimb::SetJointPosition, &TwLimb::GetJointPosition, reinterpret_cast<void*>(limb->ball), "group='Ball & Socket' label='Position'"); // Hinge TwAddVarCB(bar, "HingeAxis", TW_TYPE_DIR3F, &TwLimb::SetHingeAxis, &TwLimb::GetHingeAxis, reinterpret_cast<void*>(limb->hinge), "group='Hinge' label='Axis'"); TwAddVarCB(bar, "HingeRestAngle", TW_TYPE_FLOAT, &TwLimb::SetHingeRestAngle, &TwLimb::GetHingeRestAngle, reinterpret_cast<void*>(limb->hinge), "group='Hinge' label='Rest Angle'"); TwAddVarCB(bar, "HingeAngle", TW_TYPE_FLOAT, &TwLimb::SetHingeAngle, &TwLimb::GetHingeAngle, reinterpret_cast<void*>(limb->hinge), "group='Hinge' label='Angle'"); TwAddVarCB(bar, "HingePosition", twStructs->GetType(TW_STRUCT_POSITION), &TwLimb::SetJointPosition, &TwLimb::GetJointPosition, reinterpret_cast<void*>(limb->hinge), "group='Hinge' label='Position'"); // Universal TwAddVarCB(bar, "UniversalAxis1", TW_TYPE_DIR3F, &TwLimb::SetUniversalAxis1, &TwLimb::GetUniversalAxis1, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Axis 1'"); TwAddVarCB(bar, "UniversalRestAngle1", TW_TYPE_FLOAT, &TwLimb::SetUniversalRestAngle1, &TwLimb::GetUniversalRestAngle1, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Rest Angle 1'"); TwAddVarCB(bar, "UniversalAngle1", TW_TYPE_FLOAT, &TwLimb::SetUniversalAngle1, &TwLimb::GetUniversalAngle1, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Angle 1'"); TwAddVarCB(bar, "UniversalAxis2", TW_TYPE_DIR3F, &TwLimb::SetUniversalAxis2, &TwLimb::GetUniversalAxis2, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Axis 2'"); TwAddVarCB(bar, "UniversalRestAngle2", TW_TYPE_FLOAT, &TwLimb::SetUniversalRestAngle2, &TwLimb::GetUniversalRestAngle2, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Rest Angle 2'"); TwAddVarCB(bar, "UniversalAngle2", TW_TYPE_FLOAT, &TwLimb::SetUniversalAngle2, &TwLimb::GetUniversalAngle2, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Angle 2'"); TwAddVarCB(bar, "UniversalPosition", twStructs->GetType(TW_STRUCT_POSITION), &TwLimb::SetJointPosition, &TwLimb::GetJointPosition, reinterpret_cast<void*>(limb->universal), "group='Universal' label='Position'"); SetPos(pos); SetSize(size); SetColor(color); }
void mitk::ColorProperty::SetValue(const mitk::Color & color ) { SetColor(color); }
/********************************************************************* * Function: void TouchCalibration() * * PreCondition: InitGraph() must be called before * * Input: none * * Output: none * * Side Effects: none * * Overview: calibrates touch screen * * Note: none * ********************************************************************/ void TouchCalibration(){ static const XCHAR scr1StrLn1[] = {'I','M','P','O','R','T','A','N','T','.',0}; static const XCHAR scr1StrLn2[] = {'N','o','w',' ','t','o','u','c','h',' ','s','c','r','e','e','n',' ','c','a','l','i','b','r','a','t','i','o','n',0}; static const XCHAR scr1StrLn3[] = {'w','i','l','l',' ','b','e',' ','p','e','r','f','o','m','e','d','.','T','o','u','c','h',' ','p','o','i','n','t','s',0}; static const XCHAR scr1StrLn4[] = {'E','X','A','C','T','L','Y',' ','a','t',' ','t','h','e',' ','p','o','s','i','t','i','o','n','s',0}; static const XCHAR scr1StrLn5[] = {'s','h','o','w','n',' ','b','y',' ','a','r','r','o','w','s','.',0}; static const XCHAR scr1StrLn6[] = {'T','o','u','c','h',' ','s','c','r','e','e','n',' ','t','o',' ','c','o','n','t','i','n','u','e','.',0}; static const XCHAR scr2StrLn1[] = {'H','o','l','d',' ','S','3',' ','b','u','t','t','o','n',' ','a','n','d',0}; static const XCHAR scr2StrLn2[] = {'p','r','e','s','s',' ','M','C','L','R',' ','r','e','s','e','t','(','S','1',')',0}; static const XCHAR scr2StrLn3[] = {'t','o',' ','R','E','P','E','A','T',' ','t','h','e',' ','c','a','l','i','b','r','a','t','i','o','n',0}; static const XCHAR scr2StrLn4[] = {'p','r','o','c','e','d','u','r','e','.',0}; SHORT x,y; SHORT textHeight; SetFont((void*)&GOLFontDefault); textHeight = GetTextHeight((void*)&GOLFontDefault); SetColor(WHITE); ClearDevice(); SetColor(BRIGHTRED); WAIT_UNTIL_FINISH(OutTextXY(0,0*textHeight, (XCHAR*)scr1StrLn1)); SetColor(BLACK); WAIT_UNTIL_FINISH(OutTextXY(0,1*textHeight, (XCHAR*)scr1StrLn2)); WAIT_UNTIL_FINISH(OutTextXY(0,2*textHeight, (XCHAR*)scr1StrLn3)); WAIT_UNTIL_FINISH(OutTextXY(0,3*textHeight, (XCHAR*)scr1StrLn4)); WAIT_UNTIL_FINISH(OutTextXY(0,4*textHeight, (XCHAR*)scr1StrLn5)); SetColor(BRIGHTRED); WAIT_UNTIL_FINISH(OutTextXY(0,6*textHeight, (XCHAR*)scr1StrLn6)); // Wait for touch do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); DelayMs(500); SetColor(WHITE); ClearDevice(); SetColor(BRIGHTRED); #ifdef SWAP_X_AND_Y WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-5,15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-4,5,GetMaxX()-4,15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-6,5,GetMaxX()-6,15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-15,5)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,4,GetMaxX()-15,4)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,6,GetMaxX()-15,6)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,6,GetMaxX()-15,16)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,4,GetMaxX()-15,14)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-15,15)); #else WAIT_UNTIL_FINISH(Line(5,5,5,15)); WAIT_UNTIL_FINISH(Line(4,5,4,15)); WAIT_UNTIL_FINISH(Line(6,5,6,15)); WAIT_UNTIL_FINISH(Line(5,5,15,5)); WAIT_UNTIL_FINISH(Line(5,4,15,4)); WAIT_UNTIL_FINISH(Line(5,6,15,6)); WAIT_UNTIL_FINISH(Line(5,6,15,16)); WAIT_UNTIL_FINISH(Line(5,4,15,14)); WAIT_UNTIL_FINISH(Line(5,5,15,15)); #endif _calXMin = 0xFFFF; _calXMax = 0; _calYMin = 0xFFFF; _calYMax = 0; TouchGetCalPoints(); SetColor(WHITE); ClearDevice(); SetColor(BRIGHTRED); #ifdef SWAP_X_AND_Y WAIT_UNTIL_FINISH(Line(5,5,5,15)); WAIT_UNTIL_FINISH(Line(4,5,4,15)); WAIT_UNTIL_FINISH(Line(6,5,6,15)); WAIT_UNTIL_FINISH(Line(5,5,15,5)); WAIT_UNTIL_FINISH(Line(5,4,15,4)); WAIT_UNTIL_FINISH(Line(5,6,15,6)); WAIT_UNTIL_FINISH(Line(5,6,15,16)); WAIT_UNTIL_FINISH(Line(5,4,15,14)); WAIT_UNTIL_FINISH(Line(5,5,15,15)); #else WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,5,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(4,GetMaxY()-5,4,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(6,GetMaxY()-5,6,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,15,GetMaxY()-5)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-4,15,GetMaxY()-4)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-6,15,GetMaxY()-6)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-6,15,GetMaxY()-16)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-4,15,GetMaxY()-14)); WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,15,GetMaxY()-15)); #endif TouchGetCalPoints(); SetColor(WHITE); ClearDevice(); SetColor(BRIGHTRED); #ifdef SWAP_X_AND_Y WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-5,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-4,GetMaxY()-5,GetMaxX()/2-4,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-6,GetMaxY()-5,GetMaxX()/2-6,GetMaxY()-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-15,GetMaxY()-5)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-4,GetMaxX()/2-15,GetMaxY()-4)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-6,GetMaxX()/2-15,GetMaxY()-6)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-6,GetMaxX()/2-15,GetMaxY()-16)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-4,GetMaxX()/2-15,GetMaxY()-14)); WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-15,GetMaxY()-15)); #else WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-5,GetMaxY()/2-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-4,GetMaxY()/2-5,GetMaxX()-4,GetMaxY()/2-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-6,GetMaxY()/2-5,GetMaxX()-6,GetMaxY()/2-15)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-15,GetMaxY()/2-5)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-4,GetMaxX()-15,GetMaxY()/2-4)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-6,GetMaxX()-15,GetMaxY()/2-6)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-6,GetMaxX()-15,GetMaxY()/2-16)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-4,GetMaxX()-15,GetMaxY()/2-14)); WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-15,GetMaxY()/2-15)); #endif TouchGetCalPoints(); SetColor(WHITE); ClearDevice(); SetColor(BLACK); WAIT_UNTIL_FINISH(OutTextXY(10,1*textHeight,(XCHAR*)scr2StrLn1)); WAIT_UNTIL_FINISH(OutTextXY(10,2*textHeight,(XCHAR*)scr2StrLn2)); WAIT_UNTIL_FINISH(OutTextXY(10,3*textHeight,(XCHAR*)scr2StrLn3)); WAIT_UNTIL_FINISH(OutTextXY(10,4*textHeight,(XCHAR*)scr2StrLn4)); SetColor(BRIGHTRED); WAIT_UNTIL_FINISH(OutTextXY(10,6*textHeight,(XCHAR*)scr1StrLn6)); // Wait for touch do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); DelayMs(500); SetColor(BLACK); ClearDevice(); }
void CGraphics_OpenGL::LinesBegin() { dbg_assert(m_Drawing == 0, "called begin twice"); m_Drawing = DRAWING_LINES; SetColor(1,1,1,1); }
void Log::outCommand(uint32 account, const char* str, ...) { if (!str) return; std::lock_guard<std::mutex> guard(m_worldLogMtx); if (m_logLevel >= LOG_LVL_DETAIL) { if (m_colored) SetColor(true, m_colors[LogDetails]); if (m_includeTime) outTime(); va_list ap; va_start(ap, str); vutf8printf(stdout, str, &ap); va_end(ap); if (m_colored) ResetColor(true); printf("\n"); } if (logfile && m_logFileLevel >= LOG_LVL_DETAIL) { va_list ap; outTimestamp(logfile); va_start(ap, str); vfprintf(logfile, str, ap); fprintf(logfile, "\n"); va_end(ap); fflush(logfile); } if (m_gmlog_per_account) { if (FILE* per_file = openGmlogPerAccount(account)) { va_list ap; outTimestamp(per_file); va_start(ap, str); vfprintf(per_file, str, ap); fprintf(per_file, "\n"); va_end(ap); fclose(per_file); } } else if (gmLogfile) { va_list ap; outTimestamp(gmLogfile); va_start(ap, str); vfprintf(gmLogfile, str, ap); fprintf(gmLogfile, "\n"); va_end(ap); fflush(gmLogfile); } fflush(stdout); }
void Log::outCommand(uint32 account, const char * str, ...) { if (!str) return; // TODO: support accountid if (m_enableLogDB && m_dbGM) { va_list ap2; va_start(ap2, str); char nnew_str[MAX_QUERY_LEN]; vsnprintf(nnew_str, MAX_QUERY_LEN, str, ap2); outDB(LOG_TYPE_GM, nnew_str); va_end(ap2); } if (m_logLevel > LOGL_NORMAL) { if (m_colored) SetColor(true, m_colors[LOGL_BASIC]); va_list ap; va_start(ap, str); vutf8printf(stdout, str, &ap); va_end(ap); if (m_colored) ResetColor(true); printf("\n"); if (logfile) { outTimestamp(logfile); va_list ap2; va_start(ap2, str); vfprintf(logfile, str, ap2); fprintf(logfile, "\n" ); va_end(ap2); fflush(logfile); } } if (m_gmlog_per_account) { if (FILE* per_file = openGmlogPerAccount (account)) { outTimestamp(per_file); va_list ap; va_start(ap, str); vfprintf(per_file, str, ap); fprintf(per_file, "\n" ); va_end(ap); fclose(per_file); } } else if (gmLogfile) { outTimestamp(gmLogfile); va_list ap; va_start(ap, str); vfprintf(gmLogfile, str, ap); fprintf(gmLogfile, "\n" ); va_end(ap); fflush(gmLogfile); } fflush(stdout); }
void Label::OnPaint() { SetColor(color->GetColor().r, color->GetColor().g, color->GetColor().b); DrawString(text, X, Y); }
void PS_PLOTTER::Text( const wxPoint& aPos, enum EDA_COLOR_T aColor, const wxString& aText, double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold ) { SetCurrentLineWidth( aWidth ); SetColor( aColor ); // Draw the native postscript text (if requested) if( m_textMode == PLOTTEXTMODE_NATIVE ) { const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique" : "/KicadFont-Oblique") : (aBold ? "/KicadFont-Bold" : "/KicadFont"); // Compute the copious tranformation parameters double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f; double wideningFactor, heightFactor; computeTextParameters( aPos, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor ); // The text must be escaped correctly, the others are the various // parameters. The CTM is formatted with %f since sin/cos tends // to make %g use exponential notation (which is not supported) fputsPostscriptString( outputFile, aText ); fprintf( outputFile, " %g [%f %f %f %f %f %f] %g %s textshow\n", wideningFactor, ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f, heightFactor, fontname ); /* The textshow operator retained the coordinate system, we use it * to plot the overbars. See the PDF sister function for more * details */ std::vector<int> pos_pairs; postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs ); int overbar_y = KiROUND( aSize.y * 1.1 ); for( unsigned i = 0; i < pos_pairs.size(); i += 2) { DPOINT dev_from = userToDeviceSize( wxSize( pos_pairs[i], overbar_y ) ); DPOINT dev_to = userToDeviceSize( wxSize( pos_pairs[i + 1], overbar_y ) ); fprintf( outputFile, "%g %g %g %g line ", dev_from.x, dev_from.y, dev_to.x, dev_to.y ); } // Restore the CTM fputs( "grestore\n", outputFile ); } // Draw the hidden postscript text (if requested) if( m_textMode == PLOTTEXTMODE_PHANTOM ) { fputsPostscriptString( outputFile, aText ); DPOINT pos_dev = userToDeviceCoordinates( aPos ); fprintf( outputFile, " %g %g phantomshow\n", pos_dev.x, pos_dev.y ); } // Draw the stroked text (if requested) if( m_textMode != PLOTTEXTMODE_NATIVE ) { PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold ); } }
void KeyBar::DisplayObject() { GotoXY(X1,Y1); AltState=CtrlState=ShiftState=0; #if 1 //Maximus: на таблетках лучше бы все кнопки показать, для пальцетыканья int KeyWidth=(X2-X1+2)/12; #else int KeyWidth=(X2-X1-1)/12; #endif #if 1 //Maximus: на таблетках лучше бы все кнопки показать, для пальцетыканья if (KeyWidth<3) KeyWidth=3; #else if (KeyWidth<8) KeyWidth=8; #endif int LabelWidth=KeyWidth-2; for (int i=0; i<KEY_COUNT; i++) { #if 1 //Maximus: на таблетках лучше бы все кнопки показать, для пальцетыканья if (WhereX()+2>X2) break; else if ((i+1)==KEY_COUNT) LabelWidth=X2-WhereX()-1; #else if (WhereX()+LabelWidth>=X2) break; #endif SetColor(COL_KEYBARNUM); FS<<i+1; SetColor(COL_KEYBARTEXT); const wchar_t *Label=L""; if (IntKeyState.ShiftPressed) { ShiftState=IntKeyState.ShiftPressed; if (IntKeyState.CtrlPressed) { CtrlState=IntKeyState.CtrlPressed; if (!IntKeyState.AltPressed) // Ctrl-Alt-Shift - это особый случай :-) { if (i<KeyCounts [KBL_CTRLSHIFT]) Label=KeyTitles [KBL_CTRLSHIFT][i]; } else if (!(Opt.CASRule&1) || !(Opt.CASRule&2)) { if (i<KeyCounts [KBL_CTRLALTSHIFT]) Label=KeyTitles [KBL_CTRLALTSHIFT][i]; } } else if (IntKeyState.AltPressed) { if (i<KeyCounts [KBL_ALTSHIFT]) Label=KeyTitles [KBL_ALTSHIFT][i]; AltState=IntKeyState.AltPressed; } else { if (i<KeyCounts [KBL_SHIFT]) Label=KeyTitles [KBL_SHIFT][i]; } } else if (IntKeyState.CtrlPressed) { CtrlState=IntKeyState.CtrlPressed; if (IntKeyState.AltPressed) { if (i<KeyCounts [KBL_CTRLALT]) Label=KeyTitles [KBL_CTRLALT][i]; AltState=IntKeyState.AltPressed; } else { if (i<KeyCounts [KBL_CTRL]) Label=KeyTitles [KBL_CTRL][i]; } } else if (IntKeyState.AltPressed) { AltState=IntKeyState.AltPressed; if (i<KeyCounts [KBL_ALT]) Label=KeyTitles [KBL_ALT][i]; } else if (i<KeyCounts [KBL_MAIN] && !(DisableMask & (1<<i))) Label=KeyTitles [KBL_MAIN][i]; if (!Label) Label=L""; string strLabel=Label; if (strLabel.Contains(L'|')) { UserDefinedList LabelList(ULF_NOTRIM|ULF_NOUNQUOTE, L"|"); if(LabelList.Set(Label) && !LabelList.IsEmpty()) { string strLabelTest, strLabel2; strLabel=LabelList.GetNext(); const wchar_t *Label2; while ((Label2=LabelList.GetNext()) != nullptr) { strLabelTest=strLabel; strLabelTest+=Label2; if (StrLength(strLabelTest) <= LabelWidth) if (StrLength(Label2) > StrLength(strLabel2)) strLabel2=Label2; } strLabel+=strLabel2; } } FS<<fmt::LeftAlign()<<fmt::ExactWidth(LabelWidth)<<strLabel; if (i<KEY_COUNT-1) { SetColor(COL_KEYBARBACKGROUND); Text(L" "); } } int Width=X2-WhereX()+1; if (Width>0) { SetColor(COL_KEYBARTEXT); FS<<fmt::MinWidth(Width)<<L""; } }
void AnimaMappedValues::SetColor(const AnimaString& propertyName, AFloat r, AFloat g, AFloat b, AFloat a) { AnimaColor4f color(r, g, b, a); SetColor(propertyName, color); }
int main(int args[]) { srand(time(0)); //auto window = Window::CreateSDLWindow(); auto application = new FWApplication(); if (!application->GetWindow()) { LOG("Couldn't create window..."); return EXIT_FAILURE; } application->SetTargetFPS(60); application->SetColor(Color(255, 10, 40, 255)); Game* game = new Game(application); //while (true){} while (application->IsRunning()) { application->StartTick(); SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: application->Quit(); break; case SDL_KEYDOWN: switch (event.key.keysym.scancode){ case SDL_SCANCODE_SPACE: game->Pause(); break; default: break; } } } application->UpdateGameObjects(); if (!game->IsPause()){ game->Update(application->GetDeltaTime()); } application->RenderGameObjects(); application->SetColor(Color(0, 0, 0, 255));// For the letter colour application->DrawTextWithWhiteBorder("[Round] " + std::to_string(game->GetRoundNumber()), SCREEN_WIDTH / 2, 20); application->DrawTextWithWhiteBorder("[Seconds Remaining] " + std::to_string(game->GetTimeRemaining()), SCREEN_WIDTH / 2, 40); if (game->IsPause()){ application->DrawTextWithWhiteBorder("[PAUSE]", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); application->SetColor(Color(238, 233, 233, 255));// For the background } else{ application->SetColor(Color(255, 255, 255, 255));// For the background } if (game->GameOver()){ application->Quit(); } application->EndTick(); } return EXIT_SUCCESS; }
void AnimaMappedValues::SetColor(const AnimaString& propertyName, AnimaColor3f value) { AnimaColor4f color(value, 1.0f); SetColor(propertyName, color); }
bool AnimaMappedValues::ReadObject(const ptree& objectTree, AnimaScene* scene, bool readName) { try { if(readName) SetName(objectTree.get<AnimaString>("AnimaMappedValues.Name")); for (auto& property : objectTree.get_child("AnimaMappedValues.Properties")) { if (property.first == "Property") { AnimaString name = property.second.get<AnimaString>("Name"); AnimaString type = property.second.get<AnimaString>("Type"); if(type == "bool") { bool value = property.second.get<bool>("Value"); SetBoolean(name, value); } else if(type == "float") { AFloat value = property.second.get<AFloat>("Value"); SetFloat(name, value); } else if(type == "integer") { AInt value = property.second.get<AInt>("Value"); SetInteger(name, value); } else if(type == "matrix") { AnimaMatrix value = property.second.get<AnimaMatrix>("Value"); SetMatrix(name, value); } else if(type == "vector") { for(auto& valueTree : property.second.get_child("Value")) { if(valueTree.first == "AnimaVectorGenerator") { ptree generatorTree; generatorTree.add_child("AnimaVectorGenerator", valueTree.second); AnimaString generatorName = _uniqueName + generatorTree.get<AnimaString>("AnimaVectorGenerator.Name"); AnimaVectorGenerator* generator = _dataGeneratorManager->GetDataGeneratorOfTypeFromName<AnimaVectorGenerator>(generatorName); if(generator == nullptr) generator = _dataGeneratorManager->CreateVectorGenerator(generatorName); if(generator) { if(!generator->ReadObject(generatorTree, scene, false)) return false; generator->SetGeneratedFromMappedValues(true); SetVector(name, generator); } } } } else if(type == "color") { for(auto& valueTree : property.second.get_child("Value")) { if(valueTree.first == "AnimaColorGenerator") { ptree generatorTree; generatorTree.add_child("AnimaColorGenerator", valueTree.second); AnimaString generatorName = _uniqueName + generatorTree.get<AnimaString>("AnimaColorGenerator.Name"); AnimaColorGenerator* generator = _dataGeneratorManager->GetDataGeneratorOfTypeFromName<AnimaColorGenerator>(generatorName); if(generator == nullptr) generator = _dataGeneratorManager->CreateColorGenerator(generatorName); if(generator) { if(!generator->ReadObject(generatorTree, scene, false)) return false; generator->SetGeneratedFromMappedValues(true); SetColor(name, generator); } } } } else if(type == "texture") { for(auto& valueTree : property.second.get_child("Value")) { if(valueTree.first == "AnimaTextureGenerator") { ptree generatorTree; generatorTree.add_child("AnimaTextureGenerator", valueTree.second); AnimaString generatorName = _uniqueName + generatorTree.get<AnimaString>("AnimaTextureGenerator.Name"); AnimaTextureGenerator* generator = _dataGeneratorManager->GetDataGeneratorOfTypeFromName<AnimaTextureGenerator>(generatorName); if(generator == nullptr) generator = _dataGeneratorManager->CreateTextureGenerator(generatorName); if(generator) { if(!generator->ReadObject(generatorTree, scene, false)) return false; generator->SetGeneratedFromMappedValues(true); SetTexture(name, generator); } } } } } } ptree namedObjectTree = objectTree.get_child("AnimaMappedValues.NamedObject"); return AnimaNamedObject::ReadObject(namedObjectTree, scene, false); } catch (boost::property_tree::ptree_bad_path& exception) { AnimaLogger::LogMessageFormat("ERROR - Error parsing mapped values: %s", exception.what()); return false; } catch (boost::property_tree::ptree_bad_data& exception) { AnimaLogger::LogMessageFormat("ERROR - Error parsing mapped values: %s", exception.what()); return false; } }
//<Script module="Base" filedefs="Lights.xscript"> void Light::native_SetColor(CallStruct &cs) { DWORD newColor = (DWORD)cs.GetInt(0); SetColor(newColor); }
void PerformBoardTest( void ) { static int elapsedSeconds = 0; static void *picture; RTCCProcessEvents(); if (previousSecond != _time_str[11]) { switch ( elapsedSeconds ) { case 0: // We will test to see if we are plugged into the PC as a // device (on the right side of the board) or if the debugger // side is plugged in (on the left side of the board). If // we are plugged in as a device, we will receive SOF tokens, // which sets the SOF interrupt. picture = &intro; // Turn on the USB module in device mode. First, disable all // USB interrupts, since we are just doing a local test. Then // enable the module in default device mode and turn on the // power. We will let the module take care of pulling up the // correct lines. Note that the interrupt flags in U1IR are // cleared by writing a "1" to each flag. U1IE = 0; U1IR = 0xFF; U1CONbits.USBEN = 1; U1PWRCbits.USBPWR = 1; // Fall through case 2: GOLFree(); SetColor( WHITE ); ClearDevice(); break; case 1: case 3: GOLFree(); SetColor( BLACK ); ClearDevice(); break; case 4: // See if we are plugged into the PC as a device. If so, we // will display a slightly different picture. if (U1IRbits.SOFIF) { // We are receiving SOF tokens, so we must be plugged // into a host. picture = &introDevice; } // Disable and power off the USB module. U1CONbits.USBEN = 1; U1PWRCbits.USBPWR = 0; // Display the selected graphic. PictCreate( ID_ICON, // ID 0,0,GetMaxX(),GetMaxY(), // dimension PICT_DRAW, // will be dislayed, has frame 1, // scale factor is x1 picture, // bitmap NULL ); // default GOL scheme break; case 5: RGBTurnOnLED( RGB_SATURATION_MINIMUM, RGB_SATURATION_MINIMUM, RGB_SATURATION_MINIMUM ); break; case 6: // Red RGBSetRed( RGB_SATURATION_MAXIMUM ); break; case 7: // Yellow RGBSetGreen( RGB_SATURATION_MAXIMUM ); break; case 8: // Green RGBSetRed( RGB_SATURATION_MINIMUM ); break; case 9: // Aqua RGBSetBlue( RGB_SATURATION_MAXIMUM ); break; case 10: // Blue RGBSetGreen( RGB_SATURATION_MINIMUM ); break; case 11: // Fuschia RGBSetRed( RGB_SATURATION_MAXIMUM ); break; case 12: // White RGBSetGreen( RGB_SATURATION_MAXIMUM ); break; case 13: // Pause break; case 14: RGBTurnOffLED(); screenState = SCREEN_DISPLAY_MAIN; previousSecond = ' '; elapsedSeconds = 0; return; break; } previousSecond = _time_str[11]; elapsedSeconds ++; } }
void ClearScreen(){ // Preenchemos a janela de branco al_clear_to_color(SetColor(255, 255, 255,1)); }
void P3DMaterialDef::Load (P3DInputStringFmtStream *SourceStream, const P3DFileVersion *Version) { float R1,G1,B1; char StrValue[255 + 1]; unsigned int Layer; SourceStream->ReadFmtStringTagged("BaseColor","fff",&R1,&G1,&B1); SetColor(R1,G1,B1); for (Layer = 0; Layer < P3D_MAX_TEX_LAYERS; Layer++) { if (TexNames[Layer] != NULL) { free(TexNames[Layer]); } } if ((Version->Major == 0) && (Version->Minor < 4)) { SourceStream->ReadFmtStringTagged("BaseTexture","s",StrValue,sizeof(StrValue)); if (strcmp(StrValue,"__None__") == 0) { } else { SetTexName(P3D_TEX_DIFFUSE,StrValue); } } else { for (Layer = 0; Layer < P3D_MAX_TEX_LAYERS; Layer++) { SourceStream->ReadFmtStringTagged(TexLayersNames[Layer],"s",StrValue,sizeof(StrValue)); if (strcmp(StrValue,"__None__") == 0) { } else { SetTexName(Layer,StrValue); } } } SourceStream->ReadFmtStringTagged("DoubleSided","b",&DoubleSided); SourceStream->ReadFmtStringTagged("Transparent","b",&Transparent); if ((Version->Major == 0) && (Version->Minor < 3)) { bool Billboard; SourceStream->ReadFmtStringTagged("Billboard","b",&Billboard); if (Billboard) { BillboardMode = P3D_BILLBOARD_MODE_SPHERICAL; } else { BillboardMode = P3D_BILLBOARD_MODE_NONE; } } else { SourceStream->ReadFmtStringTagged("BillboardMode","s",StrValue,sizeof(StrValue)); if (strcmp(StrValue,"spherical") == 0) { BillboardMode = P3D_BILLBOARD_MODE_SPHERICAL; } else if (strcmp(StrValue,"cylindrical") == 0) { BillboardMode = P3D_BILLBOARD_MODE_CYLINDRICAL; } else { BillboardMode = P3D_BILLBOARD_MODE_NONE; } } if ((Version->Major == 0) && (Version->Minor > 2)) { SourceStream->ReadFmtStringTagged("AlphaCtrlEnabled","b",&AlphaCtrlEnabled); SourceStream->ReadFmtStringTagged("AlphaFadeIn","f",&AlphaFadeIn); SourceStream->ReadFmtStringTagged("AlphaFadeOut","f",&AlphaFadeOut); AlphaFadeIn = P3DMath::Clampf(0.0f,1.0f,AlphaFadeIn); AlphaFadeOut = P3DMath::Clampf(0.0f,1.0f,AlphaFadeOut); } }
// RPG_InteractableComponent RPG_InteractableComponent::RPG_InteractableComponent() : RPG_HighlightableComponent() { SetColor(VColorRef(0, 127, 0)); }
/** * Setzt die Zeichenfarbe des Vektors in Ganzzahligen Werten. * Die Parameter werden nicht geprüft oder angepasst bevor sie gesetzt werden. */ void SGLVektor::SetColor(unsigned char R,unsigned char G,unsigned char B) {SetColor(GLdouble(R)/GLdouble(255),GLdouble(G)/GLdouble(255),GLdouble(B)/GLdouble(255));}
int _k_main(struct multiboot_info *bootinfo) { int i; uint32_t memSize; struct memory_region* region; uint32_t *p,*p2; /*Initialize hardware drivers*/ hw_initialize(); //! install our exception handlers setvect (0, divide_by_zero_fault); setvect (1, single_step_trap); setvect (2, nmi_trap); setvect (3, breakpoint_trap); setvect (4, overflow_trap); setvect (5, bounds_check_fault); setvect (6, invalid_opcode_fault); setvect (7, no_device_fault); setvect (8, double_fault_abort); setvect (10, invalid_tss_fault); setvect (11, no_segment_fault); setvect (12, stack_fault); setvect (13, general_protection_fault); setvect (14, page_fault); setvect (16, fpu_fault); setvect (17, alignment_check_fault); setvect (18, machine_check_abort); setvect (19, simd_fpu_fault); ClrScr (0x13); GotoXY (0,0); SetColor (0x12); Puts ("\n zygote OS v0.01\n"); SetColor (0x17); /* Puts ("Enabled A20!\n"); Puts ("Initialized GDT and IDT!\n"); Puts ("Installed PIC, PIT, and exception handlers!\n"); Printf ("Cpu vender: %s \n", get_cpu_vender ());*/ //! get memory size in KB memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64; //! initialize the physical memory manager //! we place the memory bit map used by the PMM at the end of the kernel in memory pmmngr_init (memSize, 0x100000); Printf("pmm initialized with %i KB physical memory; memLo: %i memHi: %i\n", memSize,bootinfo->m_memoryLo,bootinfo->m_memoryHi); SetColor (0x19); Printf ("Physical Memory Map:\n"); region = (struct memory_region*)0x1000; for (i=0; i<15; ++i) { //! sanity check; if type is > 4 mark it reserved if (region[i].type>4) region[i].type=1; //! if start address is 0, there is no more entries, break out if (i>0 && region[i].startLo==0) break; //! display entry Printf ("region %i: start: 0x%x%x length (bytes): 0x%x%x type: %i (%s)\n", i, region[i].startHi, region[i].startLo, region[i].sizeHi,region[i].sizeLo, region[i].type, strMemoryTypes[region[i].type-1]); //! if region is avilable memory, initialize the region for use if (region[i].type==1) pmmngr_init_region (region[i].startLo, region[i].sizeLo); } SetColor (0x17); Printf ("\npmm regions initialized: %i allocation blocks; used or reserved blocks: %i\nfree blocks: %i\n", pmmngr_get_block_count (), pmmngr_get_use_block_count (), pmmngr_get_free_block_count () ); //! allocating and deallocating memory examples... SetColor (0x12); p = (uint32_t*)pmmngr_alloc_block (); Printf ("\np allocated at 0x%x", p); p2 = (uint32_t*)pmmngr_alloc_blocks (2); Printf ("\nallocated 2 blocks for p2 at 0x%x", p2); pmmngr_free_block (p); p = (uint32_t*)pmmngr_alloc_block (); Printf ("\nUnallocated p to free block 1. p is reallocated to 0x%x", p); pmmngr_free_block (p); pmmngr_free_blocks (p2, 2); //To test divide by zero exception //i = 10/0; Puts ("\nHitting any key will fire the default handlers \n"); for(;;) { } };
void ScreenRecoveryUI::DrawHorizontalRule(int* y) { SetColor(MENU); *y += ROW_INTERVAL; gr_fill(0, *y, gr_fb_width(), *y + 2); *y += ROW_INTERVAL; }
/********************************************************************* * Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* image, BYTE stretch, PUTIMAGE_PARAM *pPartialImageData) * * PreCondition: none * * Input: left,top - left top image corner, * image - image pointer, * stretch - image stretch factor * pPartialImageData - (currently not implemented in this driver) * * Output: none * * Side Effects: none * * Overview: outputs monochrome image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *image, BYTE stretch, PUTIMAGE_PARAM *pPartialImageData) { register FLASH_BYTE *flashAddress; register FLASH_BYTE *tempFlashAddress; BYTE temp = 0; WORD sizeX, sizeY; WORD x, y, currentXLocation; BYTE stretchX, stretchY; WORD pallete[2]; BYTE mask; // Move pointer to size information flashAddress = image + 2; // Read image size sizeY = *((FLASH_WORD *)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD *)flashAddress); flashAddress += 2; pallete[0] = *((FLASH_WORD *)flashAddress); flashAddress += 2; pallete[1] = *((FLASH_WORD *)flashAddress); flashAddress += 2; DisplayEnable(); for(y = 0; y < sizeY; y++) { tempFlashAddress = flashAddress; for(stretchY = 0; stretchY < stretch; stretchY++) { flashAddress = tempFlashAddress; SetAddress((WORD) left, (WORD) top); mask = 0; for(x = 0, currentXLocation = 0; x < sizeX; x++) { // Read 8 pixels from flash if(mask == 0) { temp = *flashAddress; flashAddress++; mask = 0x01; } // Set color if(mask & temp) { SetColor(pallete[1]); } else { SetColor(pallete[0]); } // Write pixel to screen for(stretchX = 0; stretchX < stretch; stretchX++) { #ifdef USE_TRANSPARENT_COLOR if (((GetTransparentColor() == GetColor()) && (GetTransparentColorStatus() == TRANSPARENT_COLOR_ENABLE))) { currentXLocation++; SetAddress(left + currentXLocation , top); } else #endif { currentXLocation++; WritePixel(_color); } } // Shift to the next pixel mask <<= 1; } top++; } } DisplayDisable(); }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void ChTrackShoeSinglePin::AddVisualizationAssets(VisualizationType vis) { if (vis == VisualizationType::NONE) return; double pitch = GetPitch(); double front_cyl_loc = GetFrontCylinderLoc(); double rear_cyl_loc = GetRearCylinderLoc(); double cyl_radius = GetCylinderRadius(); const ChVector<>& pad_box_dims = GetPadBoxDimensions(); const ChVector<>& guide_box_dims = GetGuideBoxDimensions(); double p0y = 2.1 * (pad_box_dims.y() / 2); double p1y = 1.5 * (pad_box_dims.y() / 2); double p2y = 0.5 * (pad_box_dims.y() / 2); // Render the revolute pin auto rev_axis = std::make_shared<ChCylinderShape>(); rev_axis->GetCylinderGeometry().p1 = ChVector<>(pitch / 2, -p0y, 0); rev_axis->GetCylinderGeometry().p2 = ChVector<>(pitch / 2, p0y, 0); rev_axis->GetCylinderGeometry().rad = cyl_radius / 1.5; m_shoe->AddAsset(rev_axis); // Render boxes between pins auto box_L = std::make_shared<ChBoxShape>(); box_L->GetBoxGeometry().SetLengths(ChVector<>(pitch - 1.5 * cyl_radius, 0.95 * (p0y - p1y), pad_box_dims.z() / 3)); box_L->GetBoxGeometry().Pos = ChVector<>(0, +0.95 * (p0y + p1y) / 2, 0); m_shoe->AddAsset(box_L); auto box_R = std::make_shared<ChBoxShape>(); box_R->GetBoxGeometry().SetLengths(ChVector<>(pitch - 1.5 * cyl_radius, 0.95 * (p0y - p1y), pad_box_dims.z() / 3)); box_R->GetBoxGeometry().Pos = ChVector<>(0, -0.95 * (p0y + p1y) / 2, 0); m_shoe->AddAsset(box_R); // Render the contact cylinders (for contact with sprocket) auto cyl_FR = std::make_shared<ChCylinderShape>(); cyl_FR->GetCylinderGeometry().p1 = ChVector<>(front_cyl_loc, -p1y, 0); cyl_FR->GetCylinderGeometry().p2 = ChVector<>(front_cyl_loc, -p2y, 0); cyl_FR->GetCylinderGeometry().rad = cyl_radius; m_shoe->AddAsset(cyl_FR); auto cyl_RR = std::make_shared<ChCylinderShape>(); cyl_RR->GetCylinderGeometry().p1 = ChVector<>(rear_cyl_loc, -p1y, 0); cyl_RR->GetCylinderGeometry().p2 = ChVector<>(rear_cyl_loc, -p2y, 0); cyl_RR->GetCylinderGeometry().rad = cyl_radius; m_shoe->AddAsset(cyl_RR); auto cyl_FL = std::make_shared<ChCylinderShape>(); cyl_FL->GetCylinderGeometry().p1 = ChVector<>(front_cyl_loc, p1y, 0); cyl_FL->GetCylinderGeometry().p2 = ChVector<>(front_cyl_loc, p2y, 0); cyl_FL->GetCylinderGeometry().rad = cyl_radius; m_shoe->AddAsset(cyl_FL); auto cyl_RL = std::make_shared<ChCylinderShape>(); cyl_RL->GetCylinderGeometry().p1 = ChVector<>(rear_cyl_loc, p1y, 0); cyl_RL->GetCylinderGeometry().p2 = ChVector<>(rear_cyl_loc, p2y, 0); cyl_RL->GetCylinderGeometry().rad = cyl_radius; m_shoe->AddAsset(cyl_RL); // Render the pad contact box auto box_shoe = std::make_shared<ChBoxShape>(); box_shoe->GetBoxGeometry().SetLengths(pad_box_dims); box_shoe->GetBoxGeometry().Pos = GetPadBoxLocation(); m_shoe->AddAsset(box_shoe); // Render the guiding pin contact box auto box_pin = std::make_shared<ChBoxShape>(); box_pin->GetBoxGeometry().SetLengths(guide_box_dims); box_pin->GetBoxGeometry().Pos = GetGuideBoxLocation(); m_shoe->AddAsset(box_pin); // Assign color (based on track shoe index) auto col = std::make_shared<ChColorAsset>(); if (m_index == 0) col->SetColor(ChColor(0.6f, 0.3f, 0.3f)); else if (m_index % 2 == 0) col->SetColor(ChColor(0.3f, 0.6f, 0.3f)); else col->SetColor(ChColor(0.3f, 0.3f, 0.6f)); m_shoe->AddAsset(col); }
/********************************************************************* * Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* image, BYTE stretch, PUTIMAGE_PARAM *pPartialImageData) * * PreCondition: none * * Input: left,top - left top image corner, * image - image pointer, * stretch - image stretch factor * pPartialImageData - (currently not implemented in this driver) * * Output: none * * Side Effects: none * * Overview: outputs 16 color image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *image, BYTE stretch, PUTIMAGE_PARAM *pPartialImageData) { register FLASH_BYTE *flashAddress; register FLASH_BYTE *tempFlashAddress; WORD sizeX, sizeY; register WORD x, y, currentXLocation; BYTE temp = 0; register BYTE stretchX, stretchY; WORD pallete[16]; WORD counter; // Move pointer to size information flashAddress = image + 2; // Read image size sizeY = *((FLASH_WORD *)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD *)flashAddress); flashAddress += 2; // Read pallete for(counter = 0; counter < 16; counter++) { pallete[counter] = *((FLASH_WORD *)flashAddress); flashAddress += 2; } DisplayEnable(); for(y = 0; y < sizeY; y++) { tempFlashAddress = flashAddress; for(stretchY = 0; stretchY < stretch; stretchY++) { flashAddress = tempFlashAddress; SetAddress(left, top); for(x = 0, currentXLocation = 0; x < sizeX; x++) { // Read 2 pixels from flash if(x & 0x0001) { // second pixel in byte SetColor(pallete[temp >> 4]); } else { temp = *flashAddress; flashAddress++; // first pixel in byte SetColor(pallete[temp & 0x0f]); } // Write pixel to screen for(stretchX = 0; stretchX < stretch; stretchX++) { #ifdef USE_TRANSPARENT_COLOR if (((GetTransparentColor() == GetColor()) && (GetTransparentColorStatus() == TRANSPARENT_COLOR_ENABLE))) { currentXLocation++; SetAddress(left + currentXLocation, top); } else #endif { WritePixel(_color); currentXLocation++; } } } top++; }
void ScrollText::Tick(float pulse){ char *foo; float v; switch(state){ case SCROLL_TICK: foo = ConsoleStream::GetString(); // fixme: Follow the "creator destructs" roule offset+=pulse; Set(Rect(1-(offset*.05f),0,1,1)); if((offset*.05f)>((GetFont()->GetWidth(foo)/10.0f)+1.0f)) offset -= ((GetFont()->GetWidth(foo)/10.0f)+1.0f)/.05f; delete foo; if(urgent->GetCount()==0) break; // case SCROLL_TO_URGENT: t = 0; ustr = (char*)urgent->GetItem(0); urgent->Remove(0); state = SCROLL_TO_URGENT_TICK; uview->ConsoleStream::Clear(); //printf("ustr = %s",ustr); uview->ConsoleStream::Print(ustr); delete ustr; case SCROLL_TO_URGENT_TICK: foo = ConsoleStream::GetString(); // fixme: Follow the "creator destructs" roule offset+=pulse; Set(Rect(1-(offset*.05f),0,1,1)); if((offset*.05f)>((GetFont()->GetWidth(foo)/10.0f)+1.0f)) offset -= ((GetFont()->GetWidth(foo)/10.0f)+1.0f)/.05f; delete foo; t += pulse; v = t>1?1:t; // SetColor(ARGB(1-v,1-v,1-v)); // uview->SetColor(ARGB(v,v,v)); //255.0f/255.0f,212.0f/255.0f,95.0f/255.0f SetColor(ARGB((255.0f/255.0f)*(1-v),(212.0f/255.0f)*(1-v),(95.0f/255.0f)*(1-v))); uview->SetColor(ARGB(v*(255.0f/255.0f),v*(212.0f/255.0f),v*(95.0f/255.0f))); if(t<1) break; t = 0; state = URGENT_TICK; //sstr = new char[strlen(ConsoleStream::GetString())+1]; //sprintf(sstr,"%s",ConsoleStream::GetString()); //ConsoleStream::Clear(); //ConsoleStream::Print(ustr); case URGENT_TICK: t += pulse; v = sin(t*25)*.5f+.5f; uview->SetColor(ARGB(v*(255.0f/255.0f),v*(212.0f/255.0f),v*(95.0f/255.0f))); if(t<5) break; case URGENT_TO_SCROLL: t = 0; state = URGENT_TO_SCROLL_TICK; //ConsoleStream::Clear(); //ConsoleStream::Print(sstr); //delete sstr; case URGENT_TO_SCROLL_TICK: foo = ConsoleStream::GetString(); // fixme: Follow the "creator destructs" roule offset+=pulse; Set(Rect(1-(offset*.05f),0,1,1)); if((offset*.05f)>((GetFont()->GetWidth(foo)/10.0f)+1.0f)) offset -= ((GetFont()->GetWidth(foo)/10.0f)+1.0f)/.05f; delete foo; t += pulse; //SetTransparency(((4-t)/4)>0?0:((4-t)/4)); v = t>1?1:t; SetColor(ARGB(v*(255.0f/255.0f),v*(212.0f/255.0f),v*(95.0f/255.0f))); uview->SetColor(ARGB((255.0f/255.0f)*(1-v),(212.0f/255.0f)*(1-v),(95.0f/255.0f)*(1-v))); if(t<1) break; //delete ustr; state = SCROLL_TICK; } }
void DKObject::SetColor(float r, float g, float b, float a) { SetColor(DKColor(r,g,b,a)); }
void mitk::ColorProperty::SetColor( float red, float green, float blue ) { float tmp[3] = { red, green, blue }; SetColor(mitk::Color(tmp)); }
inline TextRenderer* ResetColor() { SetColor(1.0f, 1.0f, 1.0f); }
/********************************************************************* * Function: void TouchGetCalPoints(void) * * PreCondition: InitGraph() must be called before * * Input: none * * Output: none * * Side Effects: none * * Overview: gets values for 3 touches * * Note: none * ********************************************************************/ void TouchGetCalPoints(void){ static const XCHAR calStr[] = {'C','A','L','I','B','R','A','T','I','O','N',0}; XCHAR calTouchLeft[] = {'3',' ','t','o','u','c','h','e','s',' ','l','e','f','t',0}; SHORT counter; SHORT x,y; WORD ax[3],ay[3]; SetFont((void*)&GOLFontDefault); SetColor(BRIGHTRED); WAIT_UNTIL_FINISH(OutTextXY((GetMaxX()-GetTextWidth((XCHAR*)calStr,(void*)&GOLFontDefault))>>1, (GetMaxY()-GetTextHeight((void*)&GOLFontDefault))>>1, (XCHAR*)calStr)); for(counter=0; counter<3; counter++){ SetColor(BRIGHTRED); calTouchLeft[0] = '3' - counter; WAIT_UNTIL_FINISH(OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft)); // Wait for press do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); ax[counter] = x; ay[counter] = y; // Wait for release do{ x=ADCGetX(); y=ADCGetY(); }while((y!=-1)&&(x!=-1)); SetColor(WHITE); WAIT_UNTIL_FINISH(OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft)); DelayMs(500); } for(counter=0; counter<3; counter++){ if(_calXMax < ax[counter]) _calXMax = ax[counter]; if(_calYMin > ay[counter]) _calYMin = ay[counter]; if(_calYMax < ay[counter]) _calYMax = ay[counter]; if(_calXMin > ax[counter]) _calXMin = ax[counter]; } }
void DXF_PLOTTER::Text( const wxPoint& aPos, COLOR4D aColor, const wxString& aText, double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, void* aData ) { // Fix me: see how to use DXF text mode for multiline texts if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) aMultilineAllowed = false; // the text has only one line. if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed ) { // output text as graphics. // Perhaps multiline texts could be handled as DXF text entity // but I do not want spend time about this (JPC) PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold, aMultilineAllowed ); } else { /* Emit text as a text entity. This loses formatting and shape but it's more useful as a CAD object */ DPOINT origin_dev = userToDeviceCoordinates( aPos ); SetColor( aColor ); wxString cname = getDXFColorName( m_currentColor ); DPOINT size_dev = userToDeviceSize( aSize ); int h_code = 0, v_code = 0; switch( aH_justify ) { case GR_TEXT_HJUSTIFY_LEFT: h_code = 0; break; case GR_TEXT_HJUSTIFY_CENTER: h_code = 1; break; case GR_TEXT_HJUSTIFY_RIGHT: h_code = 2; break; } switch( aV_justify ) { case GR_TEXT_VJUSTIFY_TOP: v_code = 3; break; case GR_TEXT_VJUSTIFY_CENTER: v_code = 2; break; case GR_TEXT_VJUSTIFY_BOTTOM: v_code = 1; break; } // Position, size, rotation and alignment // The two alignment point usages is somewhat idiot (see the DXF ref) // Anyway since we don't use the fit/aligned options, they're the same fprintf( outputFile, " 0\n" "TEXT\n" " 7\n" "%s\n" // Text style " 8\n" "%s\n" // Layer name " 10\n" "%g\n" // First point X " 11\n" "%g\n" // Second point X " 20\n" "%g\n" // First point Y " 21\n" "%g\n" // Second point Y " 40\n" "%g\n" // Text height " 41\n" "%g\n" // Width factor " 50\n" "%g\n" // Rotation " 51\n" "%g\n" // Oblique angle " 71\n" "%d\n" // Mirror flags " 72\n" "%d\n" // H alignment " 73\n" "%d\n", // V alignment aBold ? (aItalic ? "KICADBI" : "KICADB") : (aItalic ? "KICADI" : "KICAD"), TO_UTF8( cname ), origin_dev.x, origin_dev.x, origin_dev.y, origin_dev.y, size_dev.y, fabs( size_dev.x / size_dev.y ), aOrient / 10.0, aItalic ? DXF_OBLIQUE_ANGLE : 0, size_dev.x < 0 ? 2 : 0, // X mirror flag h_code, v_code ); /* There are two issue in emitting the text: - Our overline character (~) must be converted to the appropriate control sequence %%O or %%o - Text encoding in DXF is more or less unspecified since depends on the DXF declared version, the acad version reading it *and* some system variables to be put in the header handled only by newer acads Also before R15 unicode simply is not supported (you need to use bigfonts which are a massive PITA). Common denominator solution: use Latin1 (and however someone could choke on it, anyway). Sorry for the extended latin people. If somewant want to try fixing this recent version seems to use UTF-8 (and not UCS2 like the rest of Windows) XXX Actually there is a *third* issue: older DXF formats are limited to 255 bytes records (it was later raised to 2048); since I'm lazy and text so long is not probable I just don't implement this rule. If someone is interested in fixing this, you have to emit the first partial lines with group code 3 (max 250 bytes each) and then finish with a group code 1 (less than 250 bytes). The DXF refs explains it in no more details... */ bool overlining = false; fputs( " 1\n", outputFile ); for( unsigned i = 0; i < aText.length(); i++ ) { /* Here I do a bad thing: writing the output one byte at a time! but today I'm lazy and I have no idea on how to coerce a Unicode wxString to spit out latin1 encoded text ... Atleast stdio is *supposed* to do output buffering, so there is hope is not too slow */ wchar_t ch = aText[i]; if( ch > 255 ) { // I can't encode this... putc( '?', outputFile ); } else { if( ch == '~' ) { // Handle the overline toggle fputs( overlining ? "%%o" : "%%O", outputFile ); overlining = !overlining; } else { putc( ch, outputFile ); } } } putc( '\n', outputFile ); } }