void FMovieSceneColorTrackInstance::Update(EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance) { for (auto ObjectPtr : RuntimeObjects) { UObject* Object = ObjectPtr.Get(); if ( Object != nullptr ) { if ( ColorType == EColorType::Slate ) { FSlateColor ColorValue = PropertyBindings->GetCurrentValue<FSlateColor>( Object ); FLinearColor LinearColor = ColorValue.GetSpecifiedColor(); if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, LinearColor ) ) { FSlateColor NewColor( LinearColor ); PropertyBindings->CallFunction<FSlateColor>( Object, &NewColor ); } } else if ( ColorType == EColorType::Color ) { // We assume the color we get back is in sRGB, assigning it to a linear color will implicitly // convert it to a linear color instead of using ReinterpretAsLinear which will just change the // bytes into floats using divide by 255. FColor SrgbColor = PropertyBindings->GetCurrentValue<FColor>( Object ); FLinearColor LinearColorValue = SrgbColor; bool bConvertBackToSRgb = true; if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, LinearColorValue ) ) { // Light components have to be handled specially here because their set function takes two values, the linear color // and whether or not the linear color needs to be converted back to sRGB. All other other set function cases should // follow the sequencer convention of having a single parameter of the correct type, which in this case is an FColor // already in sRGB format. ULightComponent* LightComponent = Cast<ULightComponent>( Object ); if ( LightComponent != nullptr ) { LightComponent->SetLightColor( LinearColorValue, bConvertBackToSRgb ); } else { FColor SRgbColorValue = LinearColorValue.ToFColor( bConvertBackToSRgb ); PropertyBindings->CallFunction<FColor>( Object, &SRgbColorValue ); } } } else { FLinearColor ColorValue = PropertyBindings->GetCurrentValue<FLinearColor>( Object ); if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, ColorValue ) ) { PropertyBindings->CallFunction<FLinearColor>( Object, &ColorValue ); } } } } }
/* * LoadImages * * Load up the images so that we can display them in the * game and configure the colors. */ void LoadImages (GtkWidget *window) { /* --- Load up the images --- */ LoadPixmaps (window, sprite_man); LoadPixmaps (window, sprite_ship1); LoadPixmaps (window, sprite_ship2); LoadPixmaps (window, sprite_lander); LoadPixmaps (window, sprite_mutant); LoadPixmaps (window, sprite_missile); /* --- Get the colors defined --- */ penRed = GetPen (NewColor (0xffff, 0x8888, 0x8888)); penGreen = GetPen (NewColor (0, 0xffff, 0)); penPurple = GetPen (NewColor (0xffff, 0, 0xffff)); penWhite = GetPen (NewColor (0xffff, 0xffff, 0xffff)); }
int Mesh::NewPoint(int a, int b, Scalar c) { Point P; P.vertex = NewVertex(a, b, c); P.texCoord = NewTexCoord(a, b, c); P.normal = NewNormal(a, b, c); P.color = NewColor(a, b, c); return AddPoint(P); }
static SDL_Color DefaultAxisColor(SDL_GameControllerAxis axis) { // Default colors for Xbox 360 controller switch (axis) { case SDL_CONTROLLER_AXIS_LEFTX: return NewColor(96, 128, 128); case SDL_CONTROLLER_AXIS_LEFTY: return NewColor(96, 128, 128); case SDL_CONTROLLER_AXIS_RIGHTX: return NewColor(96, 128, 128); case SDL_CONTROLLER_AXIS_RIGHTY: return NewColor(96, 128, 128); case SDL_CONTROLLER_AXIS_TRIGGERLEFT: return NewColor(224, 224, 224); case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: return NewColor(224, 224, 224); default: return NewColor(0, 0, 0); } }
/** Set color of the light */ void ULightComponent::SetLightColor(FLinearColor NewLightColor) { FColor NewColor(NewLightColor); // Can't set color on a static light if (AreDynamicDataChangesAllowed() && LightColor != NewColor) { LightColor = NewColor; // Use lightweight color and brightness update if( World && World->Scene ) { //@todo - remove from scene if brightness or color becomes 0 World->Scene->UpdateLightColorAndBrightness( this ); } } }
static struct colorname* LoadXColorPrologue(void) { struct colorname *list=NULL,*tmp=NULL; char *filepath,*pos,*max; const char *prefix=""; char *name,*values,*model; int nprefix=0,nname,nvalues,nmodel; struct filemmap fmmap; boolean mmapfailed; filepath=kpse_find_file(xcpname,kpse_program_text_format,false); if (filepath == NULL) return NULL; DEBUG_PRINT(DEBUG_COLOR,("\n OPEN XCOLOR PROLOGUE:\t'%s'", filepath)); mmapfailed = MmapFile(filepath,&fmmap); free(filepath); if (mmapfailed) return NULL; pos=fmmap.data; max=fmmap.data+fmmap.size; while(pos<max) { while (pos<max && *pos!='/') pos++; if (*pos=='/') { nname=nmodel=nvalues=0; name=++pos; /* first argument: color name */ FINDPSNAMEEND(pos,nname); values=++pos; /* second argument: color values */ FINDVALEND(pos,nvalues); model=pos+3; /* third argument: color model, prefixed by 'XC' */ while(pos<max && *pos!=' ' && *pos!='\r' && *pos!='\n') pos++; nmodel=pos-model; tmp=NewColor(prefix,nprefix,name,nname,model,nmodel,values,nvalues); tmp->next=list; list=tmp; } } UnMmapFile(&fmmap); return(list); }
void FMovieSceneColorTrackInstance::Update( float Position, float LastPosition, const TArray<UObject*>& RuntimeObjects, class IMovieScenePlayer& Player ) { for(UObject* Object : RuntimeObjects) { if( ColorTrack->IsSlateColor() ) { FSlateColor ColorValue = PropertyBindings->GetCurrentValue<FSlateColor>(Object); FLinearColor LinearColor = ColorValue.GetSpecifiedColor(); if(ColorTrack->Eval(Position, LastPosition, LinearColor)) { FSlateColor NewColor(LinearColor); PropertyBindings->CallFunction(Object, &NewColor); } } else { FLinearColor ColorValue = PropertyBindings->GetCurrentValue<FLinearColor>(Object); if(ColorTrack->Eval(Position, LastPosition, ColorValue)) { PropertyBindings->CallFunction(Object, &ColorValue); } } } }
// handle the menu commands here void HandleSnakeCommand( HWND hWnd, WPARAM wParam ) { switch ( wParam ) { case ID_FILE_NEWSNAKE: _chdir( TSRSystem()->m_strCurrentWorkingDirectory ); SAFE_DELETE( pTheSnake ); pTheSnake = new cRubikSnake( 24 ); break; case ID_OPTIONS_ADDPIECE: pTheSnake->AddPiece(); break; case ID_OPTIONS_REMOVEPIECE: pTheSnake->RemovePiece(); break; case ID_FILE_SAVESNAKE: _chdir( TSRSystem()->m_strCurrentWorkingDirectory ); pTheSnake->Save(); break; case ID_FILE_LOADSNAKE: _chdir( TSRSystem()->m_strCurrentWorkingDirectory ); pTheSnake->Load(); break; case ID_OPTIONS_CHANGEEVENPIECESCOLOR: { TSRColor4 NewColor( 0.0f, 0.0f, 0.0f, 1.0f ); if ( TSRPopUps::PickColor( NewColor ) ) pTheSnake->SetEvenColor( NewColor ); } break; case ID_OPTIONS_CHANGEODDPIECESCOLOR: { TSRColor4 NewColor( 0.0f, 0.0f, 0.0f, 1.0f ); if ( TSRPopUps::PickColor( NewColor ) ) { pTheSnake->SetOddColor( NewColor ); } } break; case ID_OPTIONS_CHANGEBACKGROUNDCOLOR: { if ( TSRPopUps::PickColor( g_BackGroundColor ) ) { Graphics()->SetClearColor( g_BackGroundColor.r, g_BackGroundColor.g, g_BackGroundColor.b, 1.0f ); } } break; case ID_HELP_ABOUT: // DialogBox( GetModuleHandle( NULL ), MAKEINTRESOURCE( IDD_DIALOG2 ), NULL, AboutDlgCallBack ); break; case ID_OPTIONS_ZOOMIN: g_pSnakeWorld->m_pCameraController->m_FocusRadius -= 3.0f; break; case ID_OPTIONS_ZOOMOUT: g_pSnakeWorld->m_pCameraController->m_FocusRadius += 3.0f; break; case ID_HELP_VISITWEBSITE: ShellExecute( 0, "open", "iexplore", "www.fluteys.com", 0, SW_SHOW ); break; case ID_FILE_EXIT: TSRSystem()->s_bIsAlive = false; break; case ID_OPTIONS_DISPLAYHELP: g_DisplayHelp = !g_DisplayHelp; CheckMenuItem( GetMenu( hWnd ), ID_OPTIONS_DISPLAYHELP, g_DisplayHelp ? MF_CHECKED : MF_UNCHECKED ); break; case ID_OPTIONS_SOUND: // pTheSnake->m_bUseSound = !pTheSnake->m_bUseSound; // CheckMenuItem( GetMenu( hWnd ), ID_OPTIONS_SOUND, pTheSnake->m_bUseSound ? MF_CHECKED : MF_UNCHECKED ); break; default: break; } }
static SDL_Color DefaultButtonColor(SDL_GameControllerButton button) { // Default colors for Xbox 360 controller switch (button) { case SDL_CONTROLLER_BUTTON_A: return NewColor(96, 160, 0); case SDL_CONTROLLER_BUTTON_B: return NewColor(240, 0, 0); case SDL_CONTROLLER_BUTTON_X: return NewColor(0, 96, 208); case SDL_CONTROLLER_BUTTON_Y: return NewColor(255, 160, 0); case SDL_CONTROLLER_BUTTON_BACK: return NewColor(224, 224, 224); case SDL_CONTROLLER_BUTTON_GUIDE: return NewColor(128, 176, 0); case SDL_CONTROLLER_BUTTON_START: return NewColor(224, 224, 224); case SDL_CONTROLLER_BUTTON_LEFTSTICK: return NewColor(96, 128, 128); case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return NewColor(96, 128, 128); case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return NewColor(224, 224, 224); case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return NewColor(224, 224, 224); case SDL_CONTROLLER_BUTTON_DPAD_UP: return NewColor(96, 128, 128); case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return NewColor(96, 128, 128); case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return NewColor(96, 128, 128); case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return NewColor(96, 128, 128); default: return NewColor(0, 0, 0); } }
static struct colorname* LoadColornameFile(const char* filename) { struct colorname *list=NULL,*tmp=NULL; char *filepath,*pos,*max; const char *prefix=""; char *name,*values,*model; int nprefix=0,nname,nvalues,nmodel; struct filemmap fmmap; boolean mmapfailed; filepath=kpse_find_file(filename,kpse_tex_format,false); if (filepath == NULL) return NULL; DEBUG_PRINT(DEBUG_COLOR,("\n OPEN COLOR NAMES:\t'%s'", filepath)); mmapfailed=MmapFile(filepath,&fmmap); free(filepath); if (mmapfailed) return NULL; pos=fmmap.data; max=fmmap.data+fmmap.size; while (pos<max && *pos!='\\') pos++; while(pos+9<max && strncmp(pos,"\\endinput",9)!=0) { if ((pos+20<max && strncmp(pos,"\\def\\colornameprefix",20)==0) || (pos+32<max && strncmp(pos,"\\providecommand*\\colornameprefix",32)==0)) { DEBUG_PRINT(DEBUG_COLOR,("\n \t'%.20s'", pos)); FINDARG(pos); prefix=pos; FINDNAMEEND(pos,nprefix); DEBUG_PRINT(DEBUG_COLOR,("\n \tCOLOR PREFIX '%.*s'",nprefix,prefix)); } else if (pos+17<max && strncmp(pos,"\\DefineNamedColor",17)==0) { DEBUG_PRINT(DEBUG_COLOR,("\n \t'%.17s'", pos)); model=NULL; nname=nmodel=nvalues=0; FINDARG(pos); /* skip first argument */ FINDARG(pos); /* find second argument: color name */ name=pos; FINDNAMEEND(pos,nname); FINDARG(pos); /* find third argument: color model */ model=pos; FINDMODELEND(pos,nmodel); FINDARG(pos); /* find fourth argument: color values */ values=pos; FINDVALEND(pos,nvalues); tmp=NewColor(prefix,nprefix,name,nname,model,nmodel,values,nvalues); tmp->next=list; list=tmp; } else if ((pos+15<max && strncmp(pos,"\\definecolorset",15)==0) || (pos+16<max && strncmp(pos,"\\preparecolorset",16)==0)) { char *model; DEBUG_PRINT(DEBUG_COLOR,("\n \t'%.15s'", pos)); FINDARG(pos); /* find first argument: color model */ model=pos; FINDMODELEND(pos,nmodel); FINDARG(pos); /* skip second argument */ FINDARG(pos); /* skip third argument */ FINDARG(pos); /* find fourth argument: names, values */ while(pos<max && *pos!='}'){ name=pos; FINDNAMEEND(pos,nname); pos++; values=pos; FINDVALEND(pos,nvalues); FINDLASTVALEND(pos); tmp=NewColor(prefix,nprefix,name,nname,model,nmodel,values,nvalues); tmp->next=list; list=tmp; FINDWORD(pos); } } else { pos++; while (pos<max && *pos!='\\') pos++; } } UnMmapFile(&fmmap); return(list); }
COMPONENT * AddComponent(ARCHETYPE *pArchetype, COMPONENTTYPE DesiredType) { COMPONENT * pNewComponent = calloc(1, sizeof(COMPONENT)); pNewComponent->pArchetype = pArchetype; pNewComponent->nextComponent = pArchetype->nextComponent; pArchetype->nextComponent = pNewComponent; if (DesiredType == Sprite) { SPRITE * pNewSprite = calloc(1, sizeof(SPRITE)); IMAGE * pImage = calloc(1, sizeof(IMAGE)); pNewSprite->Visible = True; pImage->pNextImage = NULL; pNewComponent->Type = Sprite; *pNewSprite = *(pArchetype->pGame->pGameStats->pDefaultSprite); pNewSprite->pImage = pImage; pNewSprite->CurrentAnimation = "Blank.png"; pNewComponent->pStruct = pNewSprite; pNewSprite->pImage->TextureFile = NULL; pNewSprite->pComponent = pNewComponent; pNewSprite->pArchetype = pArchetype; } if (DesiredType == Mesh) { MESH * pNewMesh = calloc(1, sizeof(MESH)); pNewComponent->Type = Mesh; *pNewMesh = *(pArchetype->pGame->pGameStats->pDefaultMesh); pNewMesh->Color = NewColor(1, 1, 1, 1); pNewMesh->Opacity = 1.0; pNewComponent->pStruct = pNewMesh; pNewMesh->pComponent = pNewComponent; pNewMesh->pArchetype = pArchetype; } if (DesiredType == Behavior) { BEHAVIOR * pNewBehavior = calloc(1, sizeof(BEHAVIOR)); pNewComponent->Type = Behavior; pNewComponent->pStruct = pNewBehavior; pNewBehavior->BehaviorScript = DefaultBehavior; pNewBehavior->pComponent = pNewComponent; pNewBehavior->pArchetype = pArchetype; } if (DesiredType == Physics) { PHYSICS * pNewPhysics = calloc(1, sizeof(PHYSICS)); pNewComponent->Type = Physics; pNewComponent->pStruct = pNewPhysics; pNewPhysics->Velocity = NewVector(0, 0); pNewPhysics->Acceleration = NewVector(0, 0); pNewPhysics->Gravity = 0.5; pNewPhysics->Friction = 0.1f; pNewPhysics->MaxSpeed = 0.5; pNewPhysics->pComponent = pNewComponent; pNewPhysics->pArchetype = pArchetype; } if (DesiredType == Collider) { COLLIDER * pNewCollider = calloc(1, sizeof(COLLIDER)); pNewComponent->Type = Collider; pNewComponent->pStruct = pNewCollider; pNewCollider->Enabled = True; pNewCollider->Offset = NewVector(0, 0); pNewCollider->Height = 1; pNewCollider->Width = 1; pNewCollider->pComponent = pNewComponent; pNewCollider->pArchetype = pArchetype; } if (DesiredType == KSound) { KSOUND * pNewSound = calloc(1, sizeof(KSOUND)); KSOUND_Init(pNewSound); pNewComponent->Type = KSound; pNewComponent->pStruct = pNewSound; // Generic component stuff. pNewSound->pComponent = pNewComponent; pNewSound->pArchetype = pArchetype; } return pNewComponent; }