SlideShare a Scribd company logo
1 of 85
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //        (       )
    void bark(); //            (       )
}; //Dog               (       ";"         )


int main (int argc, char * const argv[]) { //


}
software systems.



Interface and Implementation

     To invent programs, you need to be able to capture abstractions and express them in t
     design. It’s the job of a programming language to help you do this. The language shoul
     process of invention and design by letting you encode abstractions that reveal the way
     It should let you make your ideas concrete in the code you write. Surface details shou
     the architecture of your program.

     All programming languages provide devices that help express abstractions. In essence
     are ways of grouping implementation details, hiding them, and giving them, at least t
     a common interface—much as a mechanical object separates its interface from its impl
     illustrated in “Interface and Implementation” .

     Figure 2-1            Inte rfa ce a nd Im ple m e nta tion

     interface                         implementation




                       11
                  10
                 9
                  8
                       7
                               6


     Looking at such a unit from the inside, as the implementor, you’d be concerned with w
     composed of and how it works. Looking at it from the outside, as the user, you’re conc
     with what it is and what it does. You can look past the details and think solely in term
::   (   ){
    //
}
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //         (           )
    void bark(); //             (           )
}; //Dog                (       ";"                      )


void Dog::bark() { //Dog                        bark()
    //
    cout << name << "               !       " << endl;
}

int main (int argc, char * const argv[]) { //
}
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //         (           )
    void bark(); //             (           )
}; //Dog                (       ";"                      )


void Dog::bark() { //Dog                        bark()
    //
    cout << name << "               !       " << endl;
}

int main (int argc, char * const argv[]) { //
    Dog hachi; //Dog                                     hachi
}
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //          (           )
    void bark(); //              (           )
}; //Dog                (        ";"                       )


void Dog::bark() { //Dog                         bark()
    //
    cout << name << "                !       " << endl;
}

int main (int argc, char * const argv[]) { //
    Dog hachi; //Dog                                       hachi
    hachi.name = "      "; //hachi                        name   "   "
}
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //          (           )
    void bark(); //              (           )
}; //Dog                (        ";"                       )
void Dog::bark() { //Dog                         bark()
    //
    cout << name << "                !       " << endl;
}
int main (int argc, char * const argv[]) { //
    Dog hachi; //Dog                                       hachi
    hachi.name = "      "; //hachi                        name   "   "
    hachi.bark(); //hachi                        bark()
}
run
[Switching to process xxxx]
            !
    ...


Debugger stopped.
Program exited with status value:0.
#include "Dog.h"

int main (int argc, char * const argv[]) { //
    Dog hachi; //Dog                          hachi
    hachi.name = "     "; //hachi            name   "   "
    hachi.bark(); //hachi           bark()
}
#include <iostream>
using namespace std;

class Dog { // Dog
public:
    string name; //        (       )
    void bark(); //            (       )
}; //Dog               (       ";"         )
#include "Dog.h"

void Dog::bark() { //Dog         bark()
    //
    cout << name << "      !   " << endl;
}
#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"

class testApp : public ofBaseApp {
public:
    void setup();
    void update();
    void draw();
    void keyPressed (int key);
    void keyReleased(int key);
    void mouseMoved(int x, int y );
    void mouseDragged(int x, int y, int button);
    void mousePressed(int x, int y, int button);
    void mouseReleased(int x, int y, int button);
    void windowResized(int w, int h);
};

#endif
#include "testApp.h"

void   testApp::setup(){
}
void   testApp::update(){
}
void   testApp::draw(){
}
void   testApp::keyPressed(int key){
}
void   testApp::keyReleased(int key){
}
void   testApp::mouseMoved(int x, int y){
}
void   testApp::mouseDragged(int x, int y, int button){
}
void   testApp::mousePressed(int x, int y, int button){
}
void   testApp::mouseReleased(int x, int y, int button){
}
void   testApp::windowResized(int w, int h){
}
#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"
#include "ofBlob.h"

class testApp : public ofBaseApp {
public:
    void setup();
    void update();
    void draw();
    void keyPressed (int key);
    void keyReleased(int key);
    void mouseMoved(int x, int y );
    void mouseDragged(int x, int y, int button);
    void mousePressed(int x, int y, int button);
    void mouseReleased(int x, int y, int button);
    void windowResized(int w, int h);
    ofBlob blob; //ofBlob
};

#endif
#include "testApp.h"

void testApp::setup(){
    //
    ofBackground(0, 0, 0);
    ofSetCircleResolution(64);
    ofEnableAlphaBlending();
    ofSetFrameRate(30);
}

void testApp::update(){
}

void testApp::draw(){
    blob.draw(); //blob      draw()
}

...(   )
#ifndef _OF_BLOB
#define _OF_BLOB

#include "ofMain.h"

class ofBlob {
public:
    // method
    void draw();
};

#endif
#include "ofBlob.h"

void ofBlob::draw()
{
    ofSetColor(31, 63, 255);
    ofCircle(ofGetWidth()/2, ofGetHeight()/2, 100);
}
#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"
#include "ofBlob.h"

class testApp : public ofBaseApp {

public:
  void    setup();
  void    update();
  void    draw();
  void    keyPressed (int key);
  void    keyReleased(int key);
  void    mouseMoved(int x, int y );
  void    mouseDragged(int x, int y, int button);
  void    mousePressed(int x, int y, int button);
  void    mouseReleased(int x, int y, int button);
  void    windowResized(int w, int h);

     ofBlob blob; //ofBlob
};

#endif
#include "testApp.h"

void testApp::setup(){
  //
    ofBackground(0, 0, 0);
    ofSetCircleResolution(32);
    ofEnableAlphaBlending();
    ofSetFrameRate(30);
    blob.setPos(ofPoint(300, 400)); //blob
    blob.setDim(80); //blob
}

void testApp::update(){
}

void testApp::draw(){
  blob.draw(); //blob          draw()
}

...(    )
#ifndef _OF_BLOB
#define _OF_BLOB

#include "ofMain.h"

class ofBlob {

private:
   float dim; //
     ofPoint pos; //

public:
  void setDim(float dim); //dim
     float getDim(); //dim
     void setPos(ofPoint pos); //pos
     ofPoint getPos(); //pos
     void draw(); //
};

#endif
#include "ofBlob.h"

void ofBlob::setDim(float _dim)
{
  dim = _dim;
}

float ofBlob::getDim()
{
   return dim;
}

void ofBlob::setPos(ofPoint _pos)
{
  pos = _pos;
}

ofPoint ofBlob::getPos()
{
   return pos;
}

void ofBlob::draw()
{
  ofSetColor(31, 63, 255);
  ofCircle(pos.x, pos.y, dim);
#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"
#include "ofBlob.h"

class testApp : public ofBaseApp {

public:
  void setup();
  void update();
  void draw();

     void   keyPressed (int key);
     void   keyReleased(int key);
     void   mouseMoved(int x, int y );
     void   mouseDragged(int x, int y, int button);
     void   mousePressed(int x, int y, int button);
     void   mouseReleased(int x, int y, int button);
     void   windowResized(int w, int h);

     ofBlob blob; //ofBlob
};
#include "testApp.h"

void testApp::setup(){
  //
    ofBackground(0, 0, 0);
    ofSetCircleResolution(32);
    ofEnableAlphaBlending();
    ofSetFrameRate(30);
    blob.setPos(ofPoint(300, 400)); //blob
    blob.setDim(80); //blob
    blob.setSpeed(ofPoint(8,5)); //
}

void testApp::update(){
  blob.update();
}

void testApp::draw(){
  blob.draw(); //blob          draw()
}

...(    )
#ifndef _OF_BLOB
#define _OF_BLOB
#include "ofMain.h"

class ofBlob {

private:
   float dim; //
     ofPoint pos; //
     ofPoint speed; //


public:
  void setDim(float dim); //dim
     float getDim(); //dim
     void setPos(ofPoint pos); //pos
     ofPoint getPos(); //pos
     void setSpeed(ofPoint speed); //speed
     ofPoint getSpeed(); //speed
     void update(); //
     void draw(); //
};
#include "ofBlob.h"

void ofBlob::setDim(float _dim)
{
  dim = _dim;
}

float ofBlob::getDim()
{
   return dim;
}

void ofBlob::setPos(ofPoint _pos)
{
  pos = _pos;
}

ofPoint ofBlob::getPos()
{
   return pos;
}

void ofBlob::setSpeed(ofPoint _speed)
{
ofPoint ofBlob::getSpeed()
{
   return speed;
}

void ofBlob::update()
{
  pos.x += speed.x;
  pos.y += speed.y;
  if(pos.x < dim || pos.x > ofGetWidth()-dim){
     speed.x *= -1;
  }
  if(pos.y < dim || pos.y > ofGetHeight()-dim){
     speed.y *= -1;
  }
}

void ofBlob::draw()
{
  ofSetColor(31, 63, 255);
  ofCircle(pos.x, pos.y, dim);
}
#ifndef _OF_BLOB
#define _OF_BLOB

#include "ofMain.h"

class ofBlob {

private:
   float dim; //
  ofPoint pos; //
  ofPoint speed; //
  float moveDim; //
  float phase; //
  float phaseSpeed; //


public:
  ofBlob(); //
  void setDim(float dim); //dim
  float getDim(); //dim
  void setPos(ofPoint pos); //pos
  ofPoint getPos(); //pos
ofPoint getSpeed(); //speed
     void update(); //
     void draw(); //
};

#endif
#include "ofBlob.h"

ofBlob::ofBlob()
{
  phaseSpeed = ofRandom(0.1, 0.2);
  phase = 0;
}

void ofBlob::setDim(float _dim)
{
  dim = _dim;
}

float ofBlob::getDim()
{
   return dim;
}

void ofBlob::setPos(ofPoint _pos)
{
  pos = _pos;
}
ofPoint ofBlob::getPos()
{
   return pos;
}

void ofBlob::setSpeed(ofPoint _speed)
{
  speed = _speed;
}

ofPoint ofBlob::getSpeed()
{
   return speed;
}

void ofBlob::update()
{
  moveDim = dim + sin(phase)*dim/4;
  phase += phaseSpeed;
  if(phase > TWO_PI){
     phase -= TWO_PI;
  }
  pos.x += speed.x;
  pos.y += speed.y;
if(pos.x < dim || pos.x > ofGetWidth()-dim){
       speed.x *= -1;
    }
    if(pos.y < dim || pos.y > ofGetHeight()-dim){
       speed.y *= -1;
    }
}

void ofBlob::draw()
{
  ofSetColor(31, 63, 255, 200);
  ofCircle(pos.x, pos.y, moveDim);
}
#ifndef _TEST_APP
#define _TEST_APP


#include "ofMain.h"
#include "ofBlob.h"

class testApp : public ofBaseApp {

public:
  void setup();
  void update();
  void draw();

     void   keyPressed (int key);
     void   keyReleased(int key);
     void   mouseMoved(int x, int y );
     void   mouseDragged(int x, int y, int button);
     void   mousePressed(int x, int y, int button);
     void   mouseReleased(int x, int y, int button);
     void   windowResized(int w, int h);

     vector <ofBlob> blobs; //ofBlob              Vector
};
#include "testApp.h"

void testApp::setup(){
  ofBackground(0, 0, 0);
  ofSetCircleResolution(64);
  ofEnableAlphaBlending();
  ofSetFrameRate(30);
}

void testApp::update(){
  for (int i = 0; i < blobs.size(); i++) {
     blobs[i].update();
  }
}

void testApp::draw(){
  for (int i = 0; i < blobs.size(); i++) {
     blobs[i].draw();
  }
}

...(   )...
void testApp::mouseReleased(int x, int y, int button){
  ofBlob b = ofBlob(); //    ofBlob
    b.setPos(ofPoint(mouseX, mouseY)); //
    b.setDim(ofRandom(10,40)); //
    b.setSpeed(ofPoint(ofRandom(-5, 5), ofRandom(-5, 5))); //
    blobs.push_back(b);
}

...(    )
#ifndef _OF_BLOB
#define _OF_BLOB

#include "ofMain.h"

class ofBlob {

private:
   float dim; //
  ofPoint pos; //
  ofPoint speed; //
  float moveDim; //
  float phase; //
  float phaseSpeed; //


public:
  ofBlob(); //
  void setDim(float dim); //dim
  float getDim(); //dim
  void setPos(ofPoint pos); //pos
  ofPoint getPos(); //pos
ofPoint getSpeed(); //speed
     void update(); //
     void draw(); //
};

#endif
#include "ofBlob.h"

ofBlob::ofBlob()
{
  phaseSpeed = ofRandom(0.1, 0.2);
  phase = 0;
}

void ofBlob::setDim(float _dim)
{
  dim = _dim;
}

float ofBlob::getDim()
{
   return dim;
}

void ofBlob::setPos(ofPoint _pos)
{
  pos = _pos;
}

ofPoint ofBlob::getPos()
{
   return pos;
void ofBlob::setSpeed(ofPoint _speed)
{
  speed = _speed;
}

ofPoint ofBlob::getSpeed()
{
   return speed;
}

void ofBlob::update()
{
  moveDim = dim + sin(phase)*dim/4;
  phase += phaseSpeed;
  if(phase > TWO_PI){
     phase -= TWO_PI;
  }
  pos.x += speed.x;
  pos.y += speed.y;
  if(pos.x < dim || pos.x > ofGetWidth()-dim){
     speed.x *= -1;
  }
  if(pos.y < dim || pos.y > ofGetHeight()-dim){
     speed.y *= -1;
  }
}
void ofBlob::draw()
{
  ofSetColor(31, 63, 255, 80);
  ofCircle(pos.x, pos.y, moveDim);
  ofSetColor(255, 63, 31);
  ofCircle(pos.x, pos.y, dim/10);
}
#ifndef _TEST_APP
#define _TEST_APP


#include "ofMain.h"
#include "ofBlob.h"

class testApp : public ofBaseApp {

public:
  void setup();
  void update();
  void draw();

     void   keyPressed (int key);
     void   keyReleased(int key);
     void   mouseMoved(int x, int y );
     void   mouseDragged(int x, int y, int button);
     void   mousePressed(int x, int y, int button);
     void   mouseReleased(int x, int y, int button);
     void   windowResized(int w, int h);

     vector <ofBlob> blobs; //ofBlob              Vector
};
#include "testApp.h"

void testApp::setup(){
  ofBackground(0, 0, 0);
  ofSetCircleResolution(64);
  ofEnableAlphaBlending();
  ofSetFrameRate(30);

    ofBlob b = ofBlob();
    b.setPos(ofPoint(ofGetWidth()/2, ofGetHeight()/2));
    b.setDim(ofGetHeight()/3);
    blobs.push_back(b);
}

void testApp::update(){
  for (int i = 0; i < blobs.size(); i++) {
     blobs[i].update();
  }
}

void testApp::draw(){
  for (int i = 0; i < blobs.size(); i++) {
     blobs[i].draw();
  }
void testApp::keyPressed(int key){
  switch (key) {
     case 'f':
        ofSetFullscreen(true);
        break;
  }
}

void testApp::keyReleased(int key){
}

void testApp::mouseMoved(int x, int y){
}

void testApp::mouseDragged(int x, int y, int button){
}

void testApp::mousePressed(int x, int y, int button){
  int bSize = blobs.size();
  for (int i = 0; i < bSize; i++) {
     ofPoint p = blobs[i].getPos();
     float dist = ofDist(p.x, p.y, mouseX, mouseY);
     float dim = blobs[i].getDim();
     ofPoint pos = blobs[i].getPos();
if(dist < dim){
        //
          blobs[i].setDim(dim*0.6);
          blobs[i].setPos(ofPoint(pos.x-dim/2,pos.y-dim/2));
          blobs[i].setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/
150)));

          //   1
          ofBlob b1 = ofBlob();
          b1.setDim(dim*0.6);
          b1.setPos(ofPoint(pos.x+dim/2,pos.y+dim/2));
          b1.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/
150)));
          blobs.push_back(b1);

          //   2
          ofBlob b2 = ofBlob();
          b2.setDim(dim*0.6);
          b2.setPos(ofPoint(pos.x-dim/2,pos.y+dim/2));
          b2.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/
150)));
          blobs.push_back(b2);
//   3
            ofBlob b3 = ofBlob();
            b3.setDim(dim*0.6);
            b3.setPos(ofPoint(pos.x+dim/2,pos.y-dim/2));
            b3.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/
150)));
            blobs.push_back(b3);
        }
    }
}

void testApp::mouseReleased(int x, int y, int button){
  //ofBlob b = ofBlob(ofPoint(mouseX, mouseY));
  //blobs.push_back(b);
}

void testApp::windowResized(int w, int h){
}
#ifndef _OF_BLOB
#define _OF_BLOB

#include "ofMain.h"

class ofBlob {

private:
   float dim; //
  ofPoint pos; //
  ofPoint speed; //
  float moveDim; //
  float phase; //
  float phaseSpeed; //


public:
  ofBlob(); //
  void setDim(float dim); //dim
  float getDim(); //dim
  void setPos(ofPoint pos); //pos
  ofPoint getPos(); //pos
ofPoint getSpeed(); //speed
     void update(); //
     void draw(); //
};

#endif
#include "ofBlob.h"

ofBlob::ofBlob()
{
  phaseSpeed = ofRandom(0.1, 0.2);
  phase = 0;
}

void ofBlob::setDim(float _dim)
{
  dim = _dim;
}

float ofBlob::getDim()
{
   return dim;
}

void ofBlob::setPos(ofPoint _pos)
{
  pos = _pos;
}

ofPoint ofBlob::getPos()
{
   return pos;
void ofBlob::setSpeed(ofPoint _speed)
{
  speed = _speed;
}

ofPoint ofBlob::getSpeed()
{
   return speed;
}

void ofBlob::update()
{
  moveDim = dim + sin(phase)*dim/4;
  phase += phaseSpeed;
  if(phase > TWO_PI){
     phase -= TWO_PI;
  }
  pos.x += speed.x;
  pos.y += speed.y;
  if(pos.x < dim || pos.x > ofGetWidth()-dim){
     speed.x *= -1;
  }
  if(pos.y < dim || pos.y > ofGetHeight()-dim){
     speed.y *= -1;
  }
}
void ofBlob::draw()
{
  ofSetColor(31, 63, 255, 80);
  ofCircle(pos.x, pos.y, moveDim);
  ofSetColor(255, 63, 31);
  ofCircle(pos.x, pos.y, dim/10);
}
Sbaw091006

More Related Content

What's hot

Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
Lin Yo-An
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2
drewz lin
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 

What's hot (20)

Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
Creating own language made easy
Creating own language made easyCreating own language made easy
Creating own language made easy
 
Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Swift 2
Swift 2Swift 2
Swift 2
 

Similar to Sbaw091006

Write a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdfWrite a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdf
jillisacebi75827
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
ssuser454af01
 
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
AdrianEBJKingr
 

Similar to Sbaw091006 (20)

Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler support
 
C++ programs
C++ programsC++ programs
C++ programs
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
Write a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdfWrite a C++ program 1. Study the function process_text() in file.pdf
Write a C++ program 1. Study the function process_text() in file.pdf
 
Usp
UspUsp
Usp
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptx
 
File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
ios,objective tutorial
ios,objective tutorial ios,objective tutorial
ios,objective tutorial
 
Txjs
TxjsTxjs
Txjs
 
Opp compile
Opp compileOpp compile
Opp compile
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
-- This is the shell-c Test- --shell -test sub #include -ctype-h- -- C.pdf
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 

More from Atsushi Tadokoro

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
Atsushi Tadokoro
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
Atsushi Tadokoro
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
Atsushi Tadokoro
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
Atsushi Tadokoro
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Atsushi Tadokoro
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Atsushi Tadokoro
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
Atsushi Tadokoro
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
Atsushi Tadokoro
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Atsushi Tadokoro
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
Atsushi Tadokoro
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Atsushi Tadokoro
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
Atsushi Tadokoro
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
Atsushi Tadokoro
 

More from Atsushi Tadokoro (20)

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
 
Tamabi media131118
Tamabi media131118Tamabi media131118
Tamabi media131118
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
 

Sbaw091006

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" ) int main (int argc, char * const argv[]) { // }
  • 14. software systems. Interface and Implementation To invent programs, you need to be able to capture abstractions and express them in t design. It’s the job of a programming language to help you do this. The language shoul process of invention and design by letting you encode abstractions that reveal the way It should let you make your ideas concrete in the code you write. Surface details shou the architecture of your program. All programming languages provide devices that help express abstractions. In essence are ways of grouping implementation details, hiding them, and giving them, at least t a common interface—much as a mechanical object separates its interface from its impl illustrated in “Interface and Implementation” . Figure 2-1 Inte rfa ce a nd Im ple m e nta tion interface implementation 11 10 9 8 7 6 Looking at such a unit from the inside, as the implementor, you’d be concerned with w composed of and how it works. Looking at it from the outside, as the user, you’re conc with what it is and what it does. You can look past the details and think solely in term
  • 15. :: ( ){ // }
  • 16. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" ) void Dog::bark() { //Dog bark() // cout << name << " ! " << endl; } int main (int argc, char * const argv[]) { // }
  • 17. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" ) void Dog::bark() { //Dog bark() // cout << name << " ! " << endl; } int main (int argc, char * const argv[]) { // Dog hachi; //Dog hachi }
  • 18. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" ) void Dog::bark() { //Dog bark() // cout << name << " ! " << endl; } int main (int argc, char * const argv[]) { // Dog hachi; //Dog hachi hachi.name = " "; //hachi name " " }
  • 19. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" ) void Dog::bark() { //Dog bark() // cout << name << " ! " << endl; } int main (int argc, char * const argv[]) { // Dog hachi; //Dog hachi hachi.name = " "; //hachi name " " hachi.bark(); //hachi bark() }
  • 20. run [Switching to process xxxx] ! ... Debugger stopped. Program exited with status value:0.
  • 21.
  • 22. #include "Dog.h" int main (int argc, char * const argv[]) { // Dog hachi; //Dog hachi hachi.name = " "; //hachi name " " hachi.bark(); //hachi bark() }
  • 23. #include <iostream> using namespace std; class Dog { // Dog public: string name; // ( ) void bark(); // ( ) }; //Dog ( ";" )
  • 24. #include "Dog.h" void Dog::bark() { //Dog bark() // cout << name << " ! " << endl; }
  • 25.
  • 26. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); }; #endif
  • 27. #include "testApp.h" void testApp::setup(){ } void testApp::update(){ } void testApp::draw(){ } void testApp::keyPressed(int key){ } void testApp::keyReleased(int key){ } void testApp::mouseMoved(int x, int y){ } void testApp::mouseDragged(int x, int y, int button){ } void testApp::mousePressed(int x, int y, int button){ } void testApp::mouseReleased(int x, int y, int button){ } void testApp::windowResized(int w, int h){ }
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofBlob.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); ofBlob blob; //ofBlob }; #endif
  • 37. #include "testApp.h" void testApp::setup(){ // ofBackground(0, 0, 0); ofSetCircleResolution(64); ofEnableAlphaBlending(); ofSetFrameRate(30); } void testApp::update(){ } void testApp::draw(){ blob.draw(); //blob draw() } ...( )
  • 38. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { public: // method void draw(); }; #endif
  • 39. #include "ofBlob.h" void ofBlob::draw() { ofSetColor(31, 63, 255); ofCircle(ofGetWidth()/2, ofGetHeight()/2, 100); }
  • 40.
  • 41.
  • 42.
  • 43. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofBlob.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); ofBlob blob; //ofBlob }; #endif
  • 44. #include "testApp.h" void testApp::setup(){ // ofBackground(0, 0, 0); ofSetCircleResolution(32); ofEnableAlphaBlending(); ofSetFrameRate(30); blob.setPos(ofPoint(300, 400)); //blob blob.setDim(80); //blob } void testApp::update(){ } void testApp::draw(){ blob.draw(); //blob draw() } ...( )
  • 45. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { private: float dim; // ofPoint pos; // public: void setDim(float dim); //dim float getDim(); //dim void setPos(ofPoint pos); //pos ofPoint getPos(); //pos void draw(); // }; #endif
  • 46. #include "ofBlob.h" void ofBlob::setDim(float _dim) { dim = _dim; } float ofBlob::getDim() { return dim; } void ofBlob::setPos(ofPoint _pos) { pos = _pos; } ofPoint ofBlob::getPos() { return pos; } void ofBlob::draw() { ofSetColor(31, 63, 255); ofCircle(pos.x, pos.y, dim);
  • 47.
  • 48.
  • 49.
  • 50. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofBlob.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); ofBlob blob; //ofBlob };
  • 51. #include "testApp.h" void testApp::setup(){ // ofBackground(0, 0, 0); ofSetCircleResolution(32); ofEnableAlphaBlending(); ofSetFrameRate(30); blob.setPos(ofPoint(300, 400)); //blob blob.setDim(80); //blob blob.setSpeed(ofPoint(8,5)); // } void testApp::update(){ blob.update(); } void testApp::draw(){ blob.draw(); //blob draw() } ...( )
  • 52. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { private: float dim; // ofPoint pos; // ofPoint speed; // public: void setDim(float dim); //dim float getDim(); //dim void setPos(ofPoint pos); //pos ofPoint getPos(); //pos void setSpeed(ofPoint speed); //speed ofPoint getSpeed(); //speed void update(); // void draw(); // };
  • 53. #include "ofBlob.h" void ofBlob::setDim(float _dim) { dim = _dim; } float ofBlob::getDim() { return dim; } void ofBlob::setPos(ofPoint _pos) { pos = _pos; } ofPoint ofBlob::getPos() { return pos; } void ofBlob::setSpeed(ofPoint _speed) {
  • 54. ofPoint ofBlob::getSpeed() { return speed; } void ofBlob::update() { pos.x += speed.x; pos.y += speed.y; if(pos.x < dim || pos.x > ofGetWidth()-dim){ speed.x *= -1; } if(pos.y < dim || pos.y > ofGetHeight()-dim){ speed.y *= -1; } } void ofBlob::draw() { ofSetColor(31, 63, 255); ofCircle(pos.x, pos.y, dim); }
  • 55.
  • 56.
  • 57.
  • 58. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { private: float dim; // ofPoint pos; // ofPoint speed; // float moveDim; // float phase; // float phaseSpeed; // public: ofBlob(); // void setDim(float dim); //dim float getDim(); //dim void setPos(ofPoint pos); //pos ofPoint getPos(); //pos
  • 59. ofPoint getSpeed(); //speed void update(); // void draw(); // }; #endif
  • 60. #include "ofBlob.h" ofBlob::ofBlob() { phaseSpeed = ofRandom(0.1, 0.2); phase = 0; } void ofBlob::setDim(float _dim) { dim = _dim; } float ofBlob::getDim() { return dim; } void ofBlob::setPos(ofPoint _pos) { pos = _pos; }
  • 61. ofPoint ofBlob::getPos() { return pos; } void ofBlob::setSpeed(ofPoint _speed) { speed = _speed; } ofPoint ofBlob::getSpeed() { return speed; } void ofBlob::update() { moveDim = dim + sin(phase)*dim/4; phase += phaseSpeed; if(phase > TWO_PI){ phase -= TWO_PI; } pos.x += speed.x; pos.y += speed.y;
  • 62. if(pos.x < dim || pos.x > ofGetWidth()-dim){ speed.x *= -1; } if(pos.y < dim || pos.y > ofGetHeight()-dim){ speed.y *= -1; } } void ofBlob::draw() { ofSetColor(31, 63, 255, 200); ofCircle(pos.x, pos.y, moveDim); }
  • 63.
  • 64.
  • 65. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofBlob.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); vector <ofBlob> blobs; //ofBlob Vector };
  • 66. #include "testApp.h" void testApp::setup(){ ofBackground(0, 0, 0); ofSetCircleResolution(64); ofEnableAlphaBlending(); ofSetFrameRate(30); } void testApp::update(){ for (int i = 0; i < blobs.size(); i++) { blobs[i].update(); } } void testApp::draw(){ for (int i = 0; i < blobs.size(); i++) { blobs[i].draw(); } } ...( )...
  • 67. void testApp::mouseReleased(int x, int y, int button){ ofBlob b = ofBlob(); // ofBlob b.setPos(ofPoint(mouseX, mouseY)); // b.setDim(ofRandom(10,40)); // b.setSpeed(ofPoint(ofRandom(-5, 5), ofRandom(-5, 5))); // blobs.push_back(b); } ...( )
  • 68. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { private: float dim; // ofPoint pos; // ofPoint speed; // float moveDim; // float phase; // float phaseSpeed; // public: ofBlob(); // void setDim(float dim); //dim float getDim(); //dim void setPos(ofPoint pos); //pos ofPoint getPos(); //pos
  • 69. ofPoint getSpeed(); //speed void update(); // void draw(); // }; #endif
  • 70. #include "ofBlob.h" ofBlob::ofBlob() { phaseSpeed = ofRandom(0.1, 0.2); phase = 0; } void ofBlob::setDim(float _dim) { dim = _dim; } float ofBlob::getDim() { return dim; } void ofBlob::setPos(ofPoint _pos) { pos = _pos; } ofPoint ofBlob::getPos() { return pos;
  • 71. void ofBlob::setSpeed(ofPoint _speed) { speed = _speed; } ofPoint ofBlob::getSpeed() { return speed; } void ofBlob::update() { moveDim = dim + sin(phase)*dim/4; phase += phaseSpeed; if(phase > TWO_PI){ phase -= TWO_PI; } pos.x += speed.x; pos.y += speed.y; if(pos.x < dim || pos.x > ofGetWidth()-dim){ speed.x *= -1; } if(pos.y < dim || pos.y > ofGetHeight()-dim){ speed.y *= -1; } }
  • 72. void ofBlob::draw() { ofSetColor(31, 63, 255, 80); ofCircle(pos.x, pos.y, moveDim); ofSetColor(255, 63, 31); ofCircle(pos.x, pos.y, dim/10); }
  • 73.
  • 74.
  • 75. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofBlob.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); vector <ofBlob> blobs; //ofBlob Vector };
  • 76. #include "testApp.h" void testApp::setup(){ ofBackground(0, 0, 0); ofSetCircleResolution(64); ofEnableAlphaBlending(); ofSetFrameRate(30); ofBlob b = ofBlob(); b.setPos(ofPoint(ofGetWidth()/2, ofGetHeight()/2)); b.setDim(ofGetHeight()/3); blobs.push_back(b); } void testApp::update(){ for (int i = 0; i < blobs.size(); i++) { blobs[i].update(); } } void testApp::draw(){ for (int i = 0; i < blobs.size(); i++) { blobs[i].draw(); }
  • 77. void testApp::keyPressed(int key){ switch (key) { case 'f': ofSetFullscreen(true); break; } } void testApp::keyReleased(int key){ } void testApp::mouseMoved(int x, int y){ } void testApp::mouseDragged(int x, int y, int button){ } void testApp::mousePressed(int x, int y, int button){ int bSize = blobs.size(); for (int i = 0; i < bSize; i++) { ofPoint p = blobs[i].getPos(); float dist = ofDist(p.x, p.y, mouseX, mouseY); float dim = blobs[i].getDim(); ofPoint pos = blobs[i].getPos();
  • 78. if(dist < dim){ // blobs[i].setDim(dim*0.6); blobs[i].setPos(ofPoint(pos.x-dim/2,pos.y-dim/2)); blobs[i].setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/ 150))); // 1 ofBlob b1 = ofBlob(); b1.setDim(dim*0.6); b1.setPos(ofPoint(pos.x+dim/2,pos.y+dim/2)); b1.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/ 150))); blobs.push_back(b1); // 2 ofBlob b2 = ofBlob(); b2.setDim(dim*0.6); b2.setPos(ofPoint(pos.x-dim/2,pos.y+dim/2)); b2.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/ 150))); blobs.push_back(b2);
  • 79. // 3 ofBlob b3 = ofBlob(); b3.setDim(dim*0.6); b3.setPos(ofPoint(pos.x+dim/2,pos.y-dim/2)); b3.setSpeed(ofPoint(ofRandom(-dim/150,dim/150),ofRandom(-dim/150,dim/ 150))); blobs.push_back(b3); } } } void testApp::mouseReleased(int x, int y, int button){ //ofBlob b = ofBlob(ofPoint(mouseX, mouseY)); //blobs.push_back(b); } void testApp::windowResized(int w, int h){ }
  • 80. #ifndef _OF_BLOB #define _OF_BLOB #include "ofMain.h" class ofBlob { private: float dim; // ofPoint pos; // ofPoint speed; // float moveDim; // float phase; // float phaseSpeed; // public: ofBlob(); // void setDim(float dim); //dim float getDim(); //dim void setPos(ofPoint pos); //pos ofPoint getPos(); //pos
  • 81. ofPoint getSpeed(); //speed void update(); // void draw(); // }; #endif
  • 82. #include "ofBlob.h" ofBlob::ofBlob() { phaseSpeed = ofRandom(0.1, 0.2); phase = 0; } void ofBlob::setDim(float _dim) { dim = _dim; } float ofBlob::getDim() { return dim; } void ofBlob::setPos(ofPoint _pos) { pos = _pos; } ofPoint ofBlob::getPos() { return pos;
  • 83. void ofBlob::setSpeed(ofPoint _speed) { speed = _speed; } ofPoint ofBlob::getSpeed() { return speed; } void ofBlob::update() { moveDim = dim + sin(phase)*dim/4; phase += phaseSpeed; if(phase > TWO_PI){ phase -= TWO_PI; } pos.x += speed.x; pos.y += speed.y; if(pos.x < dim || pos.x > ofGetWidth()-dim){ speed.x *= -1; } if(pos.y < dim || pos.y > ofGetHeight()-dim){ speed.y *= -1; } }
  • 84. void ofBlob::draw() { ofSetColor(31, 63, 255, 80); ofCircle(pos.x, pos.y, moveDim); ofSetColor(255, 63, 31); ofCircle(pos.x, pos.y, dim/10); }