Advertisement
xeromino

draw1

Jun 14th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. #include "ofApp.h"
  2.  
  3. //--------------------------------------------------------------
  4. void ofApp::setup(){
  5.     ofBackground(255,255,255);
  6. }
  7.  
  8. //--------------------------------------------------------------
  9. void ofApp::update(){
  10.     //MyString = "Number of lines: " + lines.size().str();
  11. }
  12.  
  13. //--------------------------------------------------------------
  14. void ofApp::draw(){
  15.     ofEnableAlphaBlending();
  16.     ofSetColor(30,30,30,30);
  17.    
  18.     for (auto line : lines) {
  19.         ofDrawLine(line.a, line.b);
  20.     }
  21.     ofSetColor(0);
  22.     //ofDrawBitmapString(MyString, 20, 20);
  23. }
  24.  
  25. //--------------------------------------------------------------
  26. void ofApp::keyPressed(int key){
  27.  
  28. }
  29.  
  30. //--------------------------------------------------------------
  31. void ofApp::keyReleased(int key){
  32.  
  33. }
  34.  
  35. //--------------------------------------------------------------
  36. void ofApp::mouseMoved(int x, int y ){
  37.  
  38. }
  39.  
  40. //--------------------------------------------------------------
  41. void ofApp::mouseDragged(int x, int y, int button){
  42.     for (auto point : drawnPoints){
  43.         ofPoint mouse;
  44.         mouse.set(x,y);
  45.         float dist = (mouse - point).length();
  46.         if (dist < 50){
  47.             Line lineTemp;
  48.             lineTemp.a = mouse;
  49.             lineTemp.b = point;
  50.             lines.push_back(lineTemp);
  51.         }
  52.     }
  53.     drawnPoints.push_back(ofPoint(x,y));
  54. }
  55.  
  56. //--------------------------------------------------------------
  57. void ofApp::mousePressed(int x, int y, int button){
  58.  
  59. }
  60.  
  61. //--------------------------------------------------------------
  62. void ofApp::mouseReleased(int x, int y, int button){
  63.  
  64. }
  65.  
  66. //--------------------------------------------------------------
  67. void ofApp::mouseEntered(int x, int y){
  68.  
  69. }
  70.  
  71. //--------------------------------------------------------------
  72. void ofApp::mouseExited(int x, int y){
  73.  
  74. }
  75.  
  76. //--------------------------------------------------------------
  77. void ofApp::windowResized(int w, int h){
  78.  
  79. }
  80.  
  81. //--------------------------------------------------------------
  82. void ofApp::gotMessage(ofMessage msg){
  83.  
  84. }
  85.  
  86. //--------------------------------------------------------------
  87. void ofApp::dragEvent(ofDragInfo dragInfo){
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement