#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder/Vector.h"
#include "cinder/Rand.h"
#include "cinder/qtime/MovieWriter.h"
#include "cinder/ip/Fill.h"
#include "Resources.h"
#include
#define _USE_MATH_DEFINES
#include
using std::list;

using namespace ci;
using namespace ci::app;
using namespace std;

class SpiralApp : public AppNative {
public:
void setup();
void mouseDown( MouseEvent event );
void mouseMove( MouseEvent event );
void update();
void draw();
void setUpMovie( bool isRecord);
qtime::MovieWriterRef mMovieWriter;
bool isRecord = true;
Vec2f center;
list vecList;
float radius = 10;
int numAround = 4;
float randomRadius = 0;
};

void SpiralApp::setup()
{
if(isRecord){
fs::path path = getSaveFilePath();
if( path.empty() )
return; // user cancelled save

// The preview image below is entitled "Lava" by "Z T Jackson"
// flickr.com/photos/ztjackson/3241111818/

qtime::MovieWriter::Format format;
if( qtime::MovieWriter::getUserCompressionSettings( &format, loadImage( loadResource( RES_MY_RES ) ) ) ) {
mMovieWriter = qtime::MovieWriter::create( path, getWindowWidth(), getWindowHeight(), format );
}
}


}

void SpiralApp::mouseDown( MouseEvent event )
{

}

void SpiralApp::mouseMove( MouseEvent event)
{
randomRadius = event.getPos().x / 3;
}

void SpiralApp::update()
{
float angle = 0;
center = Vec2f(getWindowWidth()/2,getWindowHeight()/2);
vecList.clear();
radius = 10 + randomRadius;
float radian;
float limitAngle = numAround * 360;
for (angle = 0; angle < limitAngle; angle+=5) {
radius += 0.5;
radian = angle * M_PI / 180;
//ラジアンに変換をし忘れている。
vecList.push_back(Vec2f(center.x + radius*cos(radian), center.y + radius*sin(radian)));
}
}

void SpiralApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
gl::begin(GL_LINE_STRIP);
for(list::iterator partIt = vecList.begin(); partIt != vecList.end();++partIt){
gl::color(1.0, 1.0, 1.0);
gl::vertex(partIt->x,partIt->y);
}
gl::end();
if(isRecord){
if( mMovieWriter ){
mMovieWriter->addFrame( copyWindowSurface() );
}

}

}

CINDER_APP_NATIVE( SpiralApp, RendererGl )

Loading more stuff…

Hmm…it looks like things are taking a while to load. Try again?

Loading videos…