Skip to content

Commit

Permalink
Added ArcView
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bojko committed Oct 6, 2017
1 parent 5048fdf commit 22ae72f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/bluecadet/views/ArcView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ ArcView::ArcView() : BaseView() {
ArcView::~ArcView() {
}

void ArcView::setup(float innerRadius, float outerRadius, float startAngle, float endAngle, ci::ColorA backgroundColor) {
setInnerRadius(innerRadius);
setOuterRadius(outerRadius);
setStartAngle(startAngle);
setEndAngle(endAngle);
setBackgroundColor(backgroundColor);
}

void ArcView::cancelAnimations() {
BaseView::cancelAnimations();
mSmoothness.stop();
Expand Down Expand Up @@ -91,7 +99,8 @@ ci::gl::GlslProgRef ArcView::getSharedProg() {
vPosition = vec4(ciPosition.xy * uSize, 0.0, 1.0);
vColor = ciColor * uBackgroundColor;
}
)).fragment(CI_GLSL(150,
))
.fragment(CI_GLSL(150,
in vec4 vPosition;
in vec4 vColor;
uniform vec2 uSize;
Expand Down Expand Up @@ -129,10 +138,9 @@ ci::gl::GlslProgRef ArcView::getSharedProg() {
oFragColor = vec4(vColor.rgb, alpha);
}

)).defineDirectives({
"M_PI " + to_string(glm::pi<float>()),
"M_TWO_PI " + to_string(glm::two_pi<float>())
})
))
.define("M_PI", to_string(glm::pi<float>()))
.define("M_TWO_PI", to_string(glm::two_pi<float>()))
);
}
return prog;
Expand Down
3 changes: 3 additions & 0 deletions src/bluecadet/views/ArcView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ArcView : public BaseView {
ArcView();
virtual ~ArcView();

//! Shortcut to configuring all required parameters
void setup(float innerRadius, float outerRadius, float startAngle = 0, float endAngle = glm::two_pi<float>(), ci::ColorA backgroundColor = ci::ColorA());

//! The outer radius of the arc (in px). Calls setSize() internally to change the size.
inline void setOuterRadius(float radius) { mOuterRadius = radius; setSize(ci::vec2(2.0f * radius)); }
inline ci::Anim<float> & getOuterRadius() { return mOuterRadius; invalidate(false, true); };
Expand Down

0 comments on commit 22ae72f

Please sign in to comment.