HOG2
ScreenTransition.cpp
Go to the documentation of this file.
1 //
2 // ScreenTransition.cpp
3 // puzzleSample
4 //
5 // Created by Nathan Sturtevant on 5/22/19.
6 // Copyright © 2019 University of Denver. All rights reserved.
7 //
8 
9 #include "ScreenTransition.h"
10 
12 {
13  numSegments = seg;
14  linesPerSegment = lps;
15  color = clr;
16 }
17 
19 {
20  color = c;
21 }
22 
23 void LineTransition::Reset(float t)
24 {
25  mTime = t;
26 }
27 
28 bool LineTransition::Step(float delta)
29 {
30  mTime += delta;
31  if (mTime > 1)
32  mTime = 1;
33  if (mTime < 0)
34  mTime = 0;
35  if (mTime >= 1 || mTime <= 0)
36  return true;
37  return false;
38 }
40 {
41 // numSegments = seg;
42 // linesPerSegment = lps;
43  float segmentHeight = 2.0/numSegments;
44  for (int x = -2; x < numSegments+2; x++)
45  {
46  Graphics::rect r(-2, -1+x*segmentHeight, 2, -1+x*segmentHeight+mTime*segmentHeight);
47  d.FillRect(r, color);
48  }
49 }
50 
52 :dim(dimension){}
53 
55 {
56  mTime = t;
57 }
58 bool FallingBoxTransition::Step(float delta)
59 {
60  mTime += delta;
61  if (mTime > 1)
62  mTime = 1;
63  if (mTime < 0)
64  mTime = 0;
65  if (mTime >= 1 || mTime <= 0)
66  return true;
67  return false;
68 }
69 
71 {
72  float s = 1.0f/dim;
73  for (float x = -2; x < 2; x += 2*s)
74  {
75  for (float y = -2; y < 2; y += 2*s)
76  {
77  d.FillSquare({x+s, y+s}, s*mTime, Colors::black);
78  }
79  }
80 }
FallingBoxTransition::Reset
virtual void Reset(float t)
Definition: ScreenTransition.cpp:54
rgbColor
A color; r/g/b are between 0...1.
Definition: Colors.h:17
FallingBoxTransition::dim
int dim
Definition: ScreenTransition.h:46
LineTransition::Step
virtual bool Step(float delta)
Definition: ScreenTransition.cpp:28
FallingBoxTransition::mTime
float mTime
Definition: ScreenTransition.h:45
LineTransition::numSegments
int numSegments
Definition: ScreenTransition.h:34
d
mcData d[]
Definition: MotionCaptureMovement.cpp:21
Graphics::rect
Definition: Graphics.h:94
FallingBoxTransition::Draw
virtual void Draw(Graphics::Display &d)
Definition: ScreenTransition.cpp:70
LineTransition::LineTransition
LineTransition(int numSegments, int linesPerSegment, rgbColor color=Colors::black)
Definition: ScreenTransition.cpp:11
LineTransition::linesPerSegment
int linesPerSegment
Definition: ScreenTransition.h:34
FallingBoxTransition::Step
virtual bool Step(float delta)
Definition: ScreenTransition.cpp:58
Colors::black
const rgbColor black
Definition: Colors.h:119
LineTransition::mTime
float mTime
Definition: ScreenTransition.h:33
LineTransition::color
rgbColor color
Definition: ScreenTransition.h:35
Graphics::Display
Definition: Graphics.h:146
LineTransition::Draw
virtual void Draw(Graphics::Display &d)
Definition: ScreenTransition.cpp:39
LineTransition::Reset
virtual void Reset(float t)
Definition: ScreenTransition.cpp:23
FallingBoxTransition::FallingBoxTransition
FallingBoxTransition(int dimension)
Definition: ScreenTransition.cpp:51
LineTransition::SetColor
void SetColor(rgbColor c)
Definition: ScreenTransition.cpp:18
ScreenTransition.h