├── .gitignore
├── README.md
├── typeLoader
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader Debug.xcscheme
│ └── typeLoader Release.xcscheme
├── typeLoader_3d
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_3d.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_3d Debug.xcscheme
│ └── typeLoader_3d Release.xcscheme
├── typeLoader_connectionBetweenLetters
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_connectionBetweenLetters.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_connectionBetweenLetters Debug.xcscheme
│ └── typeLoader_connectionBetweenLetters Release.xcscheme
├── typeLoader_image
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_image.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_image Debug.xcscheme
│ └── typeLoader_image Release.xcscheme
├── typeLoader_image_random
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_image_random.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_image_random Debug.xcscheme
│ └── typeLoader_image_random Release.xcscheme
├── typeLoader_resamplePoints
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_resamplePoints.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_resamplePoints Debug.xcscheme
│ └── typeLoader_resamplePoints Release.xcscheme
├── typeLoader_resamplePoints2
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_resamplePoints2.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_resamplePoints2 Debug.xcscheme
│ └── typeLoader_resamplePoints2 Release.xcscheme
├── typeLoader_resamplePoints3
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
│ ├── abzHelper.cpp
│ ├── abzHelper.h
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
└── typeLoader_resamplePoints3.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── typeLoader_resamplePoints3 Debug.xcscheme
│ └── typeLoader_resamplePoints3 Release.xcscheme
└── typeLoader_tracer
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
└── data
│ ├── .gitkeep
│ └── HelveticaNeueMed.ttf
├── config.make
├── openFrameworks-Info.plist
├── src
├── abzHelper.cpp
├── abzHelper.h
├── main.cpp
├── ofApp.cpp
└── ofApp.h
└── typeLoader_tracer.xcodeproj
├── project.pbxproj
└── xcshareddata
└── xcschemes
├── typeLoader_tracer Debug.xcscheme
└── typeLoader_tracer Release.xcscheme
/.gitignore:
--------------------------------------------------------------------------------
1 | # Some general ignore patterns
2 | build/
3 | obj/
4 | *.o
5 | Debug*/
6 | Release*/
7 | *.mode*
8 | *.app/
9 | *.pyc
10 | .svn/
11 |
12 |
13 | #XCode
14 | *.pbxuser
15 | *.perspective
16 | *.perspectivev3
17 | *.mode1v3
18 | *.mode2v3
19 | #XCode 4
20 | xcuserdata
21 | *.xcworkspace
22 |
23 | #Code::Blocks
24 | *.depend
25 | *.layout
26 |
27 | #Visual Studio
28 | *.sdf
29 | *.opensdf
30 | *.suo
31 | ipch/
32 |
33 | #Eclipse
34 | .metadata
35 | local.properties
36 | .externalToolBuilders
37 |
38 |
39 | # OS-specific ignore patterns
40 |
41 | #Linux
42 | *~
43 | # KDE
44 | .directory
45 |
46 | #OSX
47 | .DS_Store
48 | *.swp
49 | *~.nib
50 | # Thumbnails
51 | ._*
52 |
53 | #Windows
54 | # Windows image file caches
55 | Thumbs.db
56 | # Folder config file
57 | Desktop.ini
58 |
59 | #Android
60 | .csettings
61 | /libs/openFrameworksCompiled/project/android/paths.make
62 |
63 | # Miscellaneous
64 | .mailmap
65 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # a-b-z
2 | code examples from ABZ txt workshop in toronto
3 |
--------------------------------------------------------------------------------
/typeLoader/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader/addons.make
--------------------------------------------------------------------------------
/typeLoader/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | img.allocate(200, 200, OF_IMAGE_COLOR);
10 | ABZ.drawCharacterIntoImage(img, 'Z');
11 | }
12 |
13 | //--------------------------------------------------------------
14 | void ofApp::update(){
15 |
16 | }
17 |
18 | //--------------------------------------------------------------
19 | void ofApp::draw(){
20 |
21 |
22 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
23 | screen.scaleFromCenter(0.8);
24 | vector < ofPolyline > lines = ABZ.getCharacterLines('z', screen);
25 |
26 | for (int i = 0; i < lines.size(); i++){
27 |
28 | lines[i].draw();
29 |
30 | for (int j = 0; j < lines[i].size(); j++){
31 | ofCircle(lines[i][j], 10);
32 | }
33 |
34 | }
35 |
36 | img.draw(0,0);
37 | }
38 |
39 | //--------------------------------------------------------------
40 | void ofApp::keyPressed(int key){
41 |
42 | }
43 |
44 | //--------------------------------------------------------------
45 | void ofApp::keyReleased(int key){
46 |
47 | }
48 |
49 | //--------------------------------------------------------------
50 | void ofApp::mouseMoved(int x, int y ){
51 |
52 | }
53 |
54 | //--------------------------------------------------------------
55 | void ofApp::mouseDragged(int x, int y, int button){
56 |
57 | }
58 |
59 | //--------------------------------------------------------------
60 | void ofApp::mousePressed(int x, int y, int button){
61 |
62 | }
63 |
64 | //--------------------------------------------------------------
65 | void ofApp::mouseReleased(int x, int y, int button){
66 |
67 | }
68 |
69 | //--------------------------------------------------------------
70 | void ofApp::mouseEntered(int x, int y){
71 |
72 | }
73 |
74 | //--------------------------------------------------------------
75 | void ofApp::mouseExited(int x, int y){
76 |
77 | }
78 |
79 | //--------------------------------------------------------------
80 | void ofApp::windowResized(int w, int h){
81 |
82 | }
83 |
84 | //--------------------------------------------------------------
85 | void ofApp::gotMessage(ofMessage msg){
86 |
87 | }
88 |
89 | //--------------------------------------------------------------
90 | void ofApp::dragEvent(ofDragInfo dragInfo){
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/typeLoader/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 |
29 | ofImage img;
30 |
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/typeLoader/typeLoader.xcodeproj/xcshareddata/xcschemes/typeLoader Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader/typeLoader.xcodeproj/xcshareddata/xcschemes/typeLoader Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_3d/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_3d/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_3d/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_3d/addons.make
--------------------------------------------------------------------------------
/typeLoader_3d/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_3d/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_3d/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_3d/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_3d/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_3d/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_3d/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 |
13 |
14 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
15 |
16 |
17 | ofPath p = font.getCharacterAsPoints(c);
18 | vector < ofPolyline > lines = p.getOutline();
19 |
20 | ofRectangle temp;
21 | bool bSetYet = false;
22 | for (auto line : lines){
23 | for (auto pt : line){
24 |
25 | if (bSetYet == false){
26 | temp.setPosition(pt.x, pt.y);
27 | } else {
28 | temp.growToInclude(pt.x, pt.y);
29 | }
30 | bSetYet = true;
31 | }
32 | }
33 |
34 | ofRectangle target = temp;
35 |
36 | target.scaleTo(fitInside);
37 |
38 | for (auto & line : lines){
39 | for (auto & pt : line){
40 |
41 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
42 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
43 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
44 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
45 |
46 | }
47 | }
48 |
49 |
50 | return lines;
51 | }
52 |
53 |
54 |
55 | ofPolyline abzHelper::getCharacterLargestLine( char c, ofRectangle fitInside){
56 |
57 |
58 | ofPath p = font.getCharacterAsPoints(c);
59 | vector < ofPolyline > lines = p.getOutline();
60 |
61 | int largest = -1;
62 | float maxLength = 0;
63 |
64 | for (int i = 0; i < lines.size(); i++){
65 | float length = lines[i].getPerimeter();
66 | if (length > maxLength){
67 | maxLength = length;
68 | largest = i;
69 | }
70 | }
71 |
72 |
73 | ofPolyline lineWeWant = lines[largest];
74 |
75 | ofRectangle temp;
76 | temp = lineWeWant.getBoundingBox();
77 | // bool bSetYet = false;
78 | // for (auto line : lines){
79 | // for (auto pt : line){
80 | //
81 | // if (bSetYet == false){
82 | // temp.setPosition(pt.x, pt.y);
83 | // } else {
84 | // temp.growToInclude(pt.x, pt.y);
85 | // }
86 | // bSetYet = true;
87 | // }
88 | // }
89 |
90 | ofRectangle target = temp;
91 |
92 | target.scaleTo(fitInside);
93 |
94 | //for (auto & line : lines){
95 | for (auto & pt : lineWeWant){
96 |
97 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
98 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
99 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
100 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
101 |
102 | }
103 | //}
104 |
105 |
106 | return lineWeWant;
107 | }
108 |
109 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
110 |
111 |
112 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
113 |
114 | ofPath p = font.getCharacterAsPoints(c);
115 | vector < ofPolyline > lines = p.getOutline();
116 |
117 | ofRectangle temp;
118 | bool bSetYet = false;
119 | for (auto line : lines){
120 | if (!bSetYet){
121 | temp = line.getBoundingBox();
122 | bSetYet = true;
123 | } else {
124 | temp.growToInclude(line.getBoundingBox());
125 |
126 | }
127 | // for (auto pt : line){
128 | //
129 | // if (bSetYet == false){
130 | // temp.setPosition(pt.x, pt.y);
131 | // } else {
132 | // temp.growToInclude(pt.x, pt.y);
133 | // }
134 | // bSetYet = true;
135 | // }
136 | }
137 |
138 | ofRectangle target = temp;
139 | target.scaleTo(bounds);
140 | target.scaleFromCenter(0.9);
141 | ofPoint offset = target.getPosition() - temp.getPosition();
142 | float scalef = target.height / temp.height;
143 | ofFbo fbo;
144 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
145 |
146 |
147 | fbo.begin();
148 | ofClear(0,0,0);
149 | ofPushMatrix();
150 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
151 | ofScale( scalef, scalef);
152 | ofSetColor(255,255,255);
153 | p.setFillColor(ofColor::white);
154 | p.setFilled(true);
155 | p.draw();
156 | p.getOutline()[0].draw();
157 | ofPopMatrix();
158 | fbo.end();
159 |
160 | fbo.readToPixels(img.getPixels());
161 | img.update();
162 |
163 | }
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/typeLoader_3d/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | ofPolyline getCharacterLargestLine( char c, ofRectangle fitInside );
19 |
20 | };
--------------------------------------------------------------------------------
/typeLoader_3d/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_3d/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 |
10 |
11 | }
12 |
13 | //--------------------------------------------------------------
14 | void ofApp::update(){
15 |
16 | }
17 |
18 | //--------------------------------------------------------------
19 | void ofApp::draw(){
20 |
21 | ofBackground(0);
22 |
23 |
24 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
25 | screen.scaleFromCenter(0.5);
26 | ofPolyline linesPreSample = ABZ.getCharacterLargestLine('a' + mouseX % 26, screen);
27 |
28 | linesPreSample = linesPreSample.getResampledByCount(300);
29 |
30 | vector < ofPolyline > rotatedPaths;
31 |
32 |
33 | ofRectangle bounds = linesPreSample.getBoundingBox();
34 |
35 |
36 | for (int i = 0; i < linesPreSample.size(); i++){
37 |
38 | ofPolyline temp;
39 | for (int j = 0; j < 360; j++){
40 | ofPoint pt = linesPreSample[i];
41 | pt -= ofPoint(bounds.x, ofGetHeight()/2);
42 | //pt.x += j;
43 | pt.rotate(j, ofPoint(0,1,0));
44 |
45 | // since we are using a camera,
46 | // we don't translate back to
47 | // mid point
48 | //pt += ofPoint(ofGetWidth()/2, ofGetHeight()/2);
49 |
50 | temp.addVertex(pt);
51 | }
52 | rotatedPaths.push_back(temp);
53 | }
54 |
55 | cam.enableOrtho();
56 | cam.begin();
57 | ofRotateX(180);
58 | for (int i = 0; i < rotatedPaths.size(); i++){
59 | rotatedPaths[i].draw();
60 | }
61 | cam.end();
62 |
63 |
64 | }
65 |
66 | //--------------------------------------------------------------
67 | void ofApp::keyPressed(int key){
68 |
69 | }
70 |
71 | //--------------------------------------------------------------
72 | void ofApp::keyReleased(int key){
73 |
74 | }
75 |
76 | //--------------------------------------------------------------
77 | void ofApp::mouseMoved(int x, int y ){
78 |
79 | }
80 |
81 | //--------------------------------------------------------------
82 | void ofApp::mouseDragged(int x, int y, int button){
83 |
84 | }
85 |
86 | //--------------------------------------------------------------
87 | void ofApp::mousePressed(int x, int y, int button){
88 |
89 | }
90 |
91 | //--------------------------------------------------------------
92 | void ofApp::mouseReleased(int x, int y, int button){
93 |
94 | }
95 |
96 | //--------------------------------------------------------------
97 | void ofApp::mouseEntered(int x, int y){
98 |
99 | }
100 |
101 | //--------------------------------------------------------------
102 | void ofApp::mouseExited(int x, int y){
103 |
104 | }
105 |
106 | //--------------------------------------------------------------
107 | void ofApp::windowResized(int w, int h){
108 |
109 | }
110 |
111 | //--------------------------------------------------------------
112 | void ofApp::gotMessage(ofMessage msg){
113 |
114 | }
115 |
116 | //--------------------------------------------------------------
117 | void ofApp::dragEvent(ofDragInfo dragInfo){
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/typeLoader_3d/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 | vector < ofPolyline > lines;
29 | ofEasyCam cam;
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/typeLoader_3d/typeLoader_3d.xcodeproj/xcshareddata/xcschemes/typeLoader_3d Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_3d/typeLoader_3d.xcodeproj/xcshareddata/xcschemes/typeLoader_3d Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_connectionBetweenLetters/addons.make
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_connectionBetweenLetters/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_connectionBetweenLetters/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 |
13 |
14 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
15 |
16 |
17 | ofPath p = font.getCharacterAsPoints(c);
18 | vector < ofPolyline > lines = p.getOutline();
19 |
20 | ofRectangle temp;
21 | bool bSetYet = false;
22 | for (auto line : lines){
23 | for (auto pt : line){
24 |
25 | if (bSetYet == false){
26 | temp.setPosition(pt.x, pt.y);
27 | } else {
28 | temp.growToInclude(pt.x, pt.y);
29 | }
30 | bSetYet = true;
31 | }
32 | }
33 |
34 | ofRectangle target = temp;
35 |
36 | target.scaleTo(fitInside);
37 |
38 | for (auto & line : lines){
39 | for (auto & pt : line){
40 |
41 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
42 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
43 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
44 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
45 |
46 | }
47 | }
48 |
49 |
50 | return lines;
51 | }
52 |
53 |
54 |
55 | ofPolyline abzHelper::getCharacterLargestLine( char c, ofRectangle fitInside){
56 |
57 |
58 | ofPath p = font.getCharacterAsPoints(c);
59 | vector < ofPolyline > lines = p.getOutline();
60 |
61 | int largest = -1;
62 | float maxLength = 0;
63 |
64 | for (int i = 0; i < lines.size(); i++){
65 | float length = lines[i].getPerimeter();
66 | if (length > maxLength){
67 | maxLength = length;
68 | largest = i;
69 | }
70 | }
71 |
72 |
73 | ofPolyline lineWeWant = lines[largest];
74 |
75 | ofRectangle temp;
76 | temp = lineWeWant.getBoundingBox();
77 | // bool bSetYet = false;
78 | // for (auto line : lines){
79 | // for (auto pt : line){
80 | //
81 | // if (bSetYet == false){
82 | // temp.setPosition(pt.x, pt.y);
83 | // } else {
84 | // temp.growToInclude(pt.x, pt.y);
85 | // }
86 | // bSetYet = true;
87 | // }
88 | // }
89 |
90 | ofRectangle target = temp;
91 |
92 | target.scaleTo(fitInside);
93 |
94 | //for (auto & line : lines){
95 | for (auto & pt : lineWeWant){
96 |
97 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
98 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
99 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
100 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
101 |
102 | }
103 | //}
104 |
105 |
106 | return lineWeWant;
107 | }
108 |
109 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
110 |
111 |
112 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
113 |
114 | ofPath p = font.getCharacterAsPoints(c);
115 | vector < ofPolyline > lines = p.getOutline();
116 |
117 | ofRectangle temp;
118 | bool bSetYet = false;
119 | for (auto line : lines){
120 | if (!bSetYet){
121 | temp = line.getBoundingBox();
122 | bSetYet = true;
123 | } else {
124 | temp.growToInclude(line.getBoundingBox());
125 |
126 | }
127 | // for (auto pt : line){
128 | //
129 | // if (bSetYet == false){
130 | // temp.setPosition(pt.x, pt.y);
131 | // } else {
132 | // temp.growToInclude(pt.x, pt.y);
133 | // }
134 | // bSetYet = true;
135 | // }
136 | }
137 |
138 | ofRectangle target = temp;
139 | target.scaleTo(bounds);
140 | target.scaleFromCenter(0.9);
141 | ofPoint offset = target.getPosition() - temp.getPosition();
142 | float scalef = target.height / temp.height;
143 | ofFbo fbo;
144 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
145 |
146 |
147 | fbo.begin();
148 | ofClear(0,0,0);
149 | ofPushMatrix();
150 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
151 | ofScale( scalef, scalef);
152 | ofSetColor(255,255,255);
153 | p.setFillColor(ofColor::white);
154 | p.setFilled(true);
155 | p.draw();
156 | p.getOutline()[0].draw();
157 | ofPopMatrix();
158 | fbo.end();
159 |
160 | fbo.readToPixels(img.getPixels());
161 | img.update();
162 |
163 | }
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | ofPolyline getCharacterLargestLine( char c, ofRectangle fitInside );
19 |
20 | };
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 |
10 |
11 | }
12 |
13 | //--------------------------------------------------------------
14 | void ofApp::update(){
15 |
16 | }
17 |
18 | //--------------------------------------------------------------
19 | void ofApp::draw(){
20 |
21 | ofBackground(0);
22 |
23 |
24 | ofRectangle screenA = ofRectangle(0,0,ofGetWidth()/2, ofGetHeight());
25 |
26 | ofRectangle screenB = ofRectangle(ofGetWidth()/2,0,ofGetWidth()/2, ofGetHeight());
27 |
28 | screenA.scaleFromCenter(0.8);
29 | screenB.scaleFromCenter(0.8);
30 |
31 | ofPolyline letterA = ABZ.getCharacterLargestLine('a', screenA);
32 |
33 | ofPolyline letterB = ABZ.getCharacterLargestLine('z', screenB);
34 |
35 | letterA = letterA.getResampledByCount(100);
36 | letterB = letterB.getResampledByCount(100);
37 |
38 | int count = MIN(letterA.size(), letterB.size());
39 |
40 | for (int i = 0; i < count; i++){
41 | ofLine(letterA[(i + mouseX) % letterA.size() ], letterB[i]);
42 | }
43 | }
44 |
45 | //--------------------------------------------------------------
46 | void ofApp::keyPressed(int key){
47 |
48 | }
49 |
50 | //--------------------------------------------------------------
51 | void ofApp::keyReleased(int key){
52 |
53 | }
54 |
55 | //--------------------------------------------------------------
56 | void ofApp::mouseMoved(int x, int y ){
57 |
58 | }
59 |
60 | //--------------------------------------------------------------
61 | void ofApp::mouseDragged(int x, int y, int button){
62 |
63 | }
64 |
65 | //--------------------------------------------------------------
66 | void ofApp::mousePressed(int x, int y, int button){
67 |
68 | }
69 |
70 | //--------------------------------------------------------------
71 | void ofApp::mouseReleased(int x, int y, int button){
72 |
73 | }
74 |
75 | //--------------------------------------------------------------
76 | void ofApp::mouseEntered(int x, int y){
77 |
78 | }
79 |
80 | //--------------------------------------------------------------
81 | void ofApp::mouseExited(int x, int y){
82 |
83 | }
84 |
85 | //--------------------------------------------------------------
86 | void ofApp::windowResized(int w, int h){
87 |
88 | }
89 |
90 | //--------------------------------------------------------------
91 | void ofApp::gotMessage(ofMessage msg){
92 |
93 | }
94 |
95 | //--------------------------------------------------------------
96 | void ofApp::dragEvent(ofDragInfo dragInfo){
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 | abzHelper ABZ;
26 |
27 |
28 | };
29 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/typeLoader_connectionBetweenLetters.xcodeproj/xcshareddata/xcschemes/typeLoader_connectionBetweenLetters Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_connectionBetweenLetters/typeLoader_connectionBetweenLetters.xcodeproj/xcshareddata/xcschemes/typeLoader_connectionBetweenLetters Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_image/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_image/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_image/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image/addons.make
--------------------------------------------------------------------------------
/typeLoader_image/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_image/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_image/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_image/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_image/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader_image/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader_image/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_image/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | img.allocate(200, 200, OF_IMAGE_COLOR);
10 | ABZ.drawCharacterIntoImage(img, 'Z');
11 |
12 | grabber.setup(640, 480);
13 |
14 | }
15 |
16 | //--------------------------------------------------------------
17 | void ofApp::update(){
18 |
19 | grabber.update();
20 | }
21 |
22 | //--------------------------------------------------------------
23 | void ofApp::draw(){
24 |
25 | ofBackground(0);
26 |
27 | //grabber.draw(0,0);
28 |
29 |
30 | // for (int i = 0; i < grabber.getWidth(); i+=10){
31 | // for (int j = 0; j < grabber.getHeight(); j+=10){
32 | // ofColor pixel = grabber.getPixels().getColor(i, j);
33 | // float brightness = pixel.getBrightness();
34 | // ofCircle( i, j, ofMap(brightness, 0, 255, 1,5));
35 | // }
36 | // }
37 |
38 | ofSetLineWidth(5);
39 |
40 | for (int i = 0; i < grabber.getWidth(); i+=10){
41 | for (int j = 0; j < grabber.getHeight(); j+=10){
42 | ofColor pixel = grabber.getPixels().getColor(i, j);
43 | float brightness = pixel.getBrightness();
44 |
45 | ofPushMatrix();
46 | ofTranslate(i, j);
47 | ofRotateZ(ofMap(brightness, 0, 255, 0, 90));
48 | ofLine(0,0,10,0);
49 | ofPopMatrix();
50 | //ofCircle( i, j, ofMap(brightness, 0, 255, 1,5));
51 | }
52 | }
53 |
54 |
55 |
56 | //img.draw(0,0);
57 |
58 | // draw as grid
59 | // for (int i = 0; i < img.getWidth(); i+=5){
60 | // for (int j = 0; j< img.getHeight(); j+=5){
61 | // ofColor pixel = img.getColor(i, j);
62 | // float brightness = pixel.getBrightness();
63 | //
64 | // ofCircle( i * 4, j * 4, ofMap(brightness, 0, 255, 1,2));
65 | // //cout << brightness << endl;
66 | // }
67 | // }
68 |
69 |
70 | }
71 |
72 | //--------------------------------------------------------------
73 | void ofApp::keyPressed(int key){
74 |
75 | }
76 |
77 | //--------------------------------------------------------------
78 | void ofApp::keyReleased(int key){
79 |
80 | }
81 |
82 | //--------------------------------------------------------------
83 | void ofApp::mouseMoved(int x, int y ){
84 |
85 | }
86 |
87 | //--------------------------------------------------------------
88 | void ofApp::mouseDragged(int x, int y, int button){
89 |
90 | }
91 |
92 | //--------------------------------------------------------------
93 | void ofApp::mousePressed(int x, int y, int button){
94 |
95 | }
96 |
97 | //--------------------------------------------------------------
98 | void ofApp::mouseReleased(int x, int y, int button){
99 |
100 | }
101 |
102 | //--------------------------------------------------------------
103 | void ofApp::mouseEntered(int x, int y){
104 |
105 | }
106 |
107 | //--------------------------------------------------------------
108 | void ofApp::mouseExited(int x, int y){
109 |
110 | }
111 |
112 | //--------------------------------------------------------------
113 | void ofApp::windowResized(int w, int h){
114 |
115 | }
116 |
117 | //--------------------------------------------------------------
118 | void ofApp::gotMessage(ofMessage msg){
119 |
120 | }
121 |
122 | //--------------------------------------------------------------
123 | void ofApp::dragEvent(ofDragInfo dragInfo){
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/typeLoader_image/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 |
29 | ofImage img;
30 |
31 | ofVideoGrabber grabber;
32 |
33 | };
34 |
--------------------------------------------------------------------------------
/typeLoader_image/typeLoader_image.xcodeproj/xcshareddata/xcschemes/typeLoader_image Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_image/typeLoader_image.xcodeproj/xcshareddata/xcschemes/typeLoader_image Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_image_random/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_image_random/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_image_random/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image_random/addons.make
--------------------------------------------------------------------------------
/typeLoader_image_random/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image_random/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_image_random/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_image_random/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_image_random/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_image_random/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_image_random/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader_image_random/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader_image_random/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_image_random/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | img.allocate(200, 200, OF_IMAGE_COLOR);
10 | ABZ.drawCharacterIntoImage(img, 'Z');
11 |
12 |
13 |
14 | }
15 |
16 | //--------------------------------------------------------------
17 | void ofApp::update(){
18 |
19 | }
20 |
21 | //--------------------------------------------------------------
22 | void ofApp::draw(){
23 |
24 | ofBackground(0);
25 |
26 | //img.draw(0,0);
27 |
28 | ofSeedRandom(mouseX);
29 | for (int i = 0; i < 1000; i++){
30 | ofPoint pt( ofRandom(0,200), ofRandom(0,200));
31 | ofColor pixel = img.getColor(pt.x, pt.y);
32 | float brightness = pixel.getBrightness();
33 | float radius = ofRandom(3, 35);
34 | if (brightness > 0){
35 | ofFill();
36 | ofSetColor(0);
37 | ofCircle(pt.x * 3, pt.y * 3, radius);
38 | ofNoFill();
39 | ofSetColor(255);
40 | ofCircle(pt.x * 3, pt.y * 3, radius);
41 |
42 | }
43 | }
44 |
45 | }
46 |
47 | //--------------------------------------------------------------
48 | void ofApp::keyPressed(int key){
49 |
50 | }
51 |
52 | //--------------------------------------------------------------
53 | void ofApp::keyReleased(int key){
54 |
55 | }
56 |
57 | //--------------------------------------------------------------
58 | void ofApp::mouseMoved(int x, int y ){
59 |
60 | }
61 |
62 | //--------------------------------------------------------------
63 | void ofApp::mouseDragged(int x, int y, int button){
64 |
65 | }
66 |
67 | //--------------------------------------------------------------
68 | void ofApp::mousePressed(int x, int y, int button){
69 |
70 | }
71 |
72 | //--------------------------------------------------------------
73 | void ofApp::mouseReleased(int x, int y, int button){
74 |
75 | }
76 |
77 | //--------------------------------------------------------------
78 | void ofApp::mouseEntered(int x, int y){
79 |
80 | }
81 |
82 | //--------------------------------------------------------------
83 | void ofApp::mouseExited(int x, int y){
84 |
85 | }
86 |
87 | //--------------------------------------------------------------
88 | void ofApp::windowResized(int w, int h){
89 |
90 | }
91 |
92 | //--------------------------------------------------------------
93 | void ofApp::gotMessage(ofMessage msg){
94 |
95 | }
96 |
97 | //--------------------------------------------------------------
98 | void ofApp::dragEvent(ofDragInfo dragInfo){
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/typeLoader_image_random/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 |
29 | ofImage img;
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/typeLoader_image_random/typeLoader_image_random.xcodeproj/xcshareddata/xcschemes/typeLoader_image_random Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_image_random/typeLoader_image_random.xcodeproj/xcshareddata/xcschemes/typeLoader_image_random Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints/addons.make
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | }
10 |
11 | //--------------------------------------------------------------
12 | void ofApp::update(){
13 |
14 | }
15 |
16 | //--------------------------------------------------------------
17 | void ofApp::draw(){
18 |
19 | ofBackground(0);
20 |
21 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
22 | screen.scaleFromCenter(0.8);
23 | vector < ofPolyline > lines = ABZ.getCharacterLines('R', screen);
24 |
25 | for (int i = 0; i < lines.size(); i++){
26 |
27 | ofPolyline line = lines[i].getResampledBySpacing(10);
28 |
29 | line = line.getSmoothed(MAX(mouseX, 1));
30 |
31 | line.draw();
32 | for (int j = 0; j < line.size(); j++){
33 | ofCircle(line[j].x, line[j].y, 3);
34 | }
35 | // lines[i].draw();
36 | //
37 | // for (int j = 0; j < lines[i].size(); j++){
38 | // ofCircle(lines[i][j], 10);
39 | // }
40 |
41 | }
42 |
43 |
44 | }
45 |
46 | //--------------------------------------------------------------
47 | void ofApp::keyPressed(int key){
48 |
49 | }
50 |
51 | //--------------------------------------------------------------
52 | void ofApp::keyReleased(int key){
53 |
54 | }
55 |
56 | //--------------------------------------------------------------
57 | void ofApp::mouseMoved(int x, int y ){
58 |
59 | }
60 |
61 | //--------------------------------------------------------------
62 | void ofApp::mouseDragged(int x, int y, int button){
63 |
64 | }
65 |
66 | //--------------------------------------------------------------
67 | void ofApp::mousePressed(int x, int y, int button){
68 |
69 | }
70 |
71 | //--------------------------------------------------------------
72 | void ofApp::mouseReleased(int x, int y, int button){
73 |
74 | }
75 |
76 | //--------------------------------------------------------------
77 | void ofApp::mouseEntered(int x, int y){
78 |
79 | }
80 |
81 | //--------------------------------------------------------------
82 | void ofApp::mouseExited(int x, int y){
83 |
84 | }
85 |
86 | //--------------------------------------------------------------
87 | void ofApp::windowResized(int w, int h){
88 |
89 | }
90 |
91 | //--------------------------------------------------------------
92 | void ofApp::gotMessage(ofMessage msg){
93 |
94 | }
95 |
96 | //--------------------------------------------------------------
97 | void ofApp::dragEvent(ofDragInfo dragInfo){
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 |
29 | };
30 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/typeLoader_resamplePoints.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints/typeLoader_resamplePoints.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints2/addons.make
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints2/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints2/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | }
10 |
11 | //--------------------------------------------------------------
12 | void ofApp::update(){
13 |
14 | }
15 |
16 | //--------------------------------------------------------------
17 | void ofApp::draw(){
18 |
19 | ofBackground(0);
20 |
21 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
22 | screen.scaleFromCenter(0.8);
23 | vector < ofPolyline > lines = ABZ.getCharacterLines('R', screen);
24 |
25 | ofSeedRandom(mouseX);
26 |
27 | for (int i = 0; i < lines.size(); i++){
28 |
29 | ofPolyline line = lines[i].getResampledBySpacing(20);
30 |
31 | // connect every point to the mouse:
32 | for (int j = 0; j < line.size(); j++){
33 | ofPoint pt = line[j];
34 | ofPoint mouse(mouseX, mouseY);
35 | ofDrawLine(pt, mouse);
36 | }
37 |
38 |
39 | // shoot lines off away from the mouse with constant length
40 | // for (int j = 0; j < line.size(); j++){
41 | // ofPoint pt = line[j];
42 | // ofPoint mouse(mouseX, mouseY);
43 | // ofPoint diff = pt - mouse;
44 | // diff.normalize();
45 | // ofLine(pt, pt + diff * 100);
46 | // }
47 |
48 | // using random:
49 | // for (int j = 0; j < line.size(); j++){
50 | //
51 | // if (ofRandom(0,1) > 0.5){
52 | // int j_p_1 = (j + (int)ofRandom(10, 40)) % line.size();
53 | // ofDrawLine( line[j] , line[j_p_1]);
54 | // }
55 | //
56 | // }
57 |
58 |
59 |
60 | }
61 |
62 |
63 | }
64 |
65 | //--------------------------------------------------------------
66 | void ofApp::keyPressed(int key){
67 |
68 | }
69 |
70 | //--------------------------------------------------------------
71 | void ofApp::keyReleased(int key){
72 |
73 | }
74 |
75 | //--------------------------------------------------------------
76 | void ofApp::mouseMoved(int x, int y ){
77 |
78 | }
79 |
80 | //--------------------------------------------------------------
81 | void ofApp::mouseDragged(int x, int y, int button){
82 |
83 | }
84 |
85 | //--------------------------------------------------------------
86 | void ofApp::mousePressed(int x, int y, int button){
87 |
88 | }
89 |
90 | //--------------------------------------------------------------
91 | void ofApp::mouseReleased(int x, int y, int button){
92 |
93 | }
94 |
95 | //--------------------------------------------------------------
96 | void ofApp::mouseEntered(int x, int y){
97 |
98 | }
99 |
100 | //--------------------------------------------------------------
101 | void ofApp::mouseExited(int x, int y){
102 |
103 | }
104 |
105 | //--------------------------------------------------------------
106 | void ofApp::windowResized(int w, int h){
107 |
108 | }
109 |
110 | //--------------------------------------------------------------
111 | void ofApp::gotMessage(ofMessage msg){
112 |
113 | }
114 |
115 | //--------------------------------------------------------------
116 | void ofApp::dragEvent(ofDragInfo dragInfo){
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 |
29 | };
30 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/typeLoader_resamplePoints2.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints2 Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints2/typeLoader_resamplePoints2.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints2 Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints3/addons.make
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints3/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_resamplePoints3/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
13 |
14 |
15 | ofPath p = font.getCharacterAsPoints(c);
16 | vector < ofPolyline > lines = p.getOutline();
17 |
18 | ofRectangle temp;
19 | bool bSetYet = false;
20 | for (auto line : lines){
21 | for (auto pt : line){
22 |
23 | if (bSetYet == false){
24 | temp.setPosition(pt.x, pt.y);
25 | } else {
26 | temp.growToInclude(pt.x, pt.y);
27 | }
28 | bSetYet = true;
29 | }
30 | }
31 |
32 | ofRectangle target = temp;
33 |
34 | target.scaleTo(fitInside);
35 |
36 | for (auto & line : lines){
37 | for (auto & pt : line){
38 |
39 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
40 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
41 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
42 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
43 |
44 | }
45 | }
46 |
47 |
48 | return lines;
49 | }
50 |
51 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
52 |
53 |
54 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
55 |
56 | ofPath p = font.getCharacterAsPoints(c);
57 | vector < ofPolyline > lines = p.getOutline();
58 |
59 | ofRectangle temp;
60 | bool bSetYet = false;
61 | for (auto line : lines){
62 | if (!bSetYet){
63 | temp = line.getBoundingBox();
64 | bSetYet = true;
65 | } else {
66 | temp.growToInclude(line.getBoundingBox());
67 |
68 | }
69 | // for (auto pt : line){
70 | //
71 | // if (bSetYet == false){
72 | // temp.setPosition(pt.x, pt.y);
73 | // } else {
74 | // temp.growToInclude(pt.x, pt.y);
75 | // }
76 | // bSetYet = true;
77 | // }
78 | }
79 |
80 | ofRectangle target = temp;
81 | target.scaleTo(bounds);
82 | target.scaleFromCenter(0.9);
83 | ofPoint offset = target.getPosition() - temp.getPosition();
84 | float scalef = target.height / temp.height;
85 | ofFbo fbo;
86 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
87 |
88 |
89 | fbo.begin();
90 | ofClear(0,0,0);
91 | ofPushMatrix();
92 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
93 | ofScale( scalef, scalef);
94 | ofSetColor(255,255,255);
95 | p.setFillColor(ofColor::white);
96 | p.setFilled(true);
97 | p.draw();
98 | p.getOutline()[0].draw();
99 | ofPopMatrix();
100 | fbo.end();
101 |
102 | fbo.readToPixels(img.getPixels());
103 | img.update();
104 |
105 | }
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | };
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
10 | screen.scaleFromCenter(0.8);
11 | vector < ofPolyline > linesPreSample = ABZ.getCharacterLines('R', screen);
12 |
13 | for (int i = 0; i < linesPreSample.size(); i++){
14 | ofPolyline line = linesPreSample[i];
15 | line = line.getResampledBySpacing(10);
16 | lines.push_back(line);
17 |
18 | }
19 | }
20 |
21 | //--------------------------------------------------------------
22 | void ofApp::update(){
23 |
24 | }
25 |
26 | //--------------------------------------------------------------
27 | void ofApp::draw(){
28 |
29 | ofBackground(0);
30 |
31 | for (int i = 0; i < lines.size(); i++){
32 |
33 | // impressionistic style
34 | // for (int j = 0; j < lines[i].size(); j++){
35 | // lines[i][j].x += ofRandom(-1,1);
36 | // lines[i][j].y += ofRandom(-1,1);
37 | //
38 | // }
39 | //
40 | // ofPolyline lineSmoothed = lines[i];
41 | // lineSmoothed = lineSmoothed.getResampledBySpacing(3);
42 | // lineSmoothed = lineSmoothed.getSmoothed(11);
43 | // lineSmoothed.draw();
44 |
45 |
46 | // that time you were on mushrooms look at type
47 | // for (int j = 0; j < lines[i].size(); j++){
48 | // lines[i][j].x += sin(ofGetElapsedTimef() + j*0.1);
49 | // lines[i][j].y += sin(ofGetElapsedTimef() + j*0.2);
50 | // }
51 | //
52 | // lines[i].draw();
53 |
54 | // simple random:
55 | for (int j = 0; j < lines[i].size(); j++){
56 | lines[i][j].x += ofRandom(-1,1);
57 | lines[i][j].y += ofRandom(-1,1);
58 | }
59 | lines[i].draw();
60 |
61 |
62 | }
63 |
64 |
65 | //ofSeedRandom(mouseX);
66 |
67 | // for (int i = 0; i < lines.size(); i++){
68 | //
69 | //
70 | // for (int j = 0; j < line.size(); j++){
71 | // line[j].x += ofRandom(-100,100);
72 | // line[j].y += ofRandom(-100,100);
73 | //
74 | // }
75 | //
76 | // line.draw();
77 | //
78 | //
79 | //
80 | //
81 | // }
82 |
83 |
84 | }
85 |
86 | //--------------------------------------------------------------
87 | void ofApp::keyPressed(int key){
88 |
89 | }
90 |
91 | //--------------------------------------------------------------
92 | void ofApp::keyReleased(int key){
93 |
94 | }
95 |
96 | //--------------------------------------------------------------
97 | void ofApp::mouseMoved(int x, int y ){
98 |
99 | }
100 |
101 | //--------------------------------------------------------------
102 | void ofApp::mouseDragged(int x, int y, int button){
103 |
104 | }
105 |
106 | //--------------------------------------------------------------
107 | void ofApp::mousePressed(int x, int y, int button){
108 |
109 | }
110 |
111 | //--------------------------------------------------------------
112 | void ofApp::mouseReleased(int x, int y, int button){
113 |
114 | }
115 |
116 | //--------------------------------------------------------------
117 | void ofApp::mouseEntered(int x, int y){
118 |
119 | }
120 |
121 | //--------------------------------------------------------------
122 | void ofApp::mouseExited(int x, int y){
123 |
124 | }
125 |
126 | //--------------------------------------------------------------
127 | void ofApp::windowResized(int w, int h){
128 |
129 | }
130 |
131 | //--------------------------------------------------------------
132 | void ofApp::gotMessage(ofMessage msg){
133 |
134 | }
135 |
136 | //--------------------------------------------------------------
137 | void ofApp::dragEvent(ofDragInfo dragInfo){
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 |
26 |
27 | abzHelper ABZ;
28 | vector < ofPolyline > lines;
29 |
30 | };
31 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/typeLoader_resamplePoints3.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints3 Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_resamplePoints3/typeLoader_resamplePoints3.xcodeproj/xcshareddata/xcschemes/typeLoader_resamplePoints3 Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_tracer/Makefile:
--------------------------------------------------------------------------------
1 | # Attempt to load a config.make file.
2 | # If none is found, project defaults in config.project.make will be used.
3 | ifneq ($(wildcard config.make),)
4 | include config.make
5 | endif
6 |
7 | # make sure the the OF_ROOT location is defined
8 | ifndef OF_ROOT
9 | OF_ROOT=$(realpath ../../..)
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/typeLoader_tracer/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | //ICONS - NEW IN 0072
9 | ICON_NAME_DEBUG = icon-debug.icns
10 | ICON_NAME_RELEASE = icon.icns
11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
12 |
13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
14 | //ICON_FILE_PATH = bin/data/
15 |
16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/typeLoader_tracer/addons.make:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_tracer/addons.make
--------------------------------------------------------------------------------
/typeLoader_tracer/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_tracer/bin/data/.gitkeep
--------------------------------------------------------------------------------
/typeLoader_tracer/bin/data/HelveticaNeueMed.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ofZach/a-b-z/067f7280906f42dd87408a3f9cff83bd50929a86/typeLoader_tracer/bin/data/HelveticaNeueMed.ttf
--------------------------------------------------------------------------------
/typeLoader_tracer/config.make:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # CONFIGURE PROJECT MAKEFILE (optional)
3 | # This file is where we make project specific configurations.
4 | ################################################################################
5 |
6 | ################################################################################
7 | # OF ROOT
8 | # The location of your root openFrameworks installation
9 | # (default) OF_ROOT = ../../..
10 | ################################################################################
11 | # OF_ROOT = ../../..
12 |
13 | ################################################################################
14 | # PROJECT ROOT
15 | # The location of the project - a starting place for searching for files
16 | # (default) PROJECT_ROOT = . (this directory)
17 | #
18 | ################################################################################
19 | # PROJECT_ROOT = .
20 |
21 | ################################################################################
22 | # PROJECT SPECIFIC CHECKS
23 | # This is a project defined section to create internal makefile flags to
24 | # conditionally enable or disable the addition of various features within
25 | # this makefile. For instance, if you want to make changes based on whether
26 | # GTK is installed, one might test that here and create a variable to check.
27 | ################################################################################
28 | # None
29 |
30 | ################################################################################
31 | # PROJECT EXTERNAL SOURCE PATHS
32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder.
33 | # Like source folders in the PROJECT_ROOT, these paths are subject to
34 | # exlclusion via the PROJECT_EXLCUSIONS list.
35 | #
36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
37 | #
38 | # Note: Leave a leading space when adding list items with the += operator
39 | ################################################################################
40 | # PROJECT_EXTERNAL_SOURCE_PATHS =
41 |
42 | ################################################################################
43 | # PROJECT EXCLUSIONS
44 | # These makefiles assume that all folders in your current project directory
45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
46 | # to look for source code. The any folders or files that match any of the
47 | # items in the PROJECT_EXCLUSIONS list below will be ignored.
48 | #
49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
50 | # string unless teh user adds a wildcard (%) operator to match subdirectories.
51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is
52 | # treated literally.
53 | #
54 | # (default) PROJECT_EXCLUSIONS = (blank)
55 | #
56 | # Will automatically exclude the following:
57 | #
58 | # $(PROJECT_ROOT)/bin%
59 | # $(PROJECT_ROOT)/obj%
60 | # $(PROJECT_ROOT)/%.xcodeproj
61 | #
62 | # Note: Leave a leading space when adding list items with the += operator
63 | ################################################################################
64 | # PROJECT_EXCLUSIONS =
65 |
66 | ################################################################################
67 | # PROJECT LINKER FLAGS
68 | # These flags will be sent to the linker when compiling the executable.
69 | #
70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
71 | #
72 | # Note: Leave a leading space when adding list items with the += operator
73 | ################################################################################
74 |
75 | # Currently, shared libraries that are needed are copied to the
76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
77 | # add a runtime path to search for those shared libraries, since they aren't
78 | # incorporated directly into the final executable application binary.
79 | # TODO: should this be a default setting?
80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs
81 |
82 | ################################################################################
83 | # PROJECT DEFINES
84 | # Create a space-delimited list of DEFINES. The list will be converted into
85 | # CFLAGS with the "-D" flag later in the makefile.
86 | #
87 | # (default) PROJECT_DEFINES = (blank)
88 | #
89 | # Note: Leave a leading space when adding list items with the += operator
90 | ################################################################################
91 | # PROJECT_DEFINES =
92 |
93 | ################################################################################
94 | # PROJECT CFLAGS
95 | # This is a list of fully qualified CFLAGS required when compiling for this
96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
97 | # defined in your platform specific core configuration files. These flags are
98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
99 | #
100 | # (default) PROJECT_CFLAGS = (blank)
101 | #
102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
103 | # your platform specific configuration file will be applied by default and
104 | # further flags here may not be needed.
105 | #
106 | # Note: Leave a leading space when adding list items with the += operator
107 | ################################################################################
108 | # PROJECT_CFLAGS =
109 |
110 | ################################################################################
111 | # PROJECT OPTIMIZATION CFLAGS
112 | # These are lists of CFLAGS that are target-specific. While any flags could
113 | # be conditionally added, they are usually limited to optimization flags.
114 | # These flags are added BEFORE the PROJECT_CFLAGS.
115 | #
116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
117 | #
118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
119 | #
120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
121 | #
122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
123 | #
124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
126 | # file will be applied by default and further optimization flags here may not
127 | # be needed.
128 | #
129 | # Note: Leave a leading space when adding list items with the += operator
130 | ################################################################################
131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
133 |
134 | ################################################################################
135 | # PROJECT COMPILERS
136 | # Custom compilers can be set for CC and CXX
137 | # (default) PROJECT_CXX = (blank)
138 | # (default) PROJECT_CC = (blank)
139 | # Note: Leave a leading space when adding list items with the += operator
140 | ################################################################################
141 | # PROJECT_CXX =
142 | # PROJECT_CC =
143 |
--------------------------------------------------------------------------------
/typeLoader_tracer/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | cc.openFrameworks.ofapp
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 | CFBundleIconFile
20 | ${ICON}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/typeLoader_tracer/src/abzHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "abzHelper.h"
4 |
5 | //---------------------------------------------------------------
6 | void abzHelper::loadFont(string name){
7 | font.load(name, 200, true, true, true);
8 | }
9 |
10 |
11 |
12 |
13 |
14 | vector < ofPolyline > abzHelper::getCharacterLines( char c, ofRectangle fitInside){
15 |
16 |
17 | ofPath p = font.getCharacterAsPoints(c);
18 | vector < ofPolyline > lines = p.getOutline();
19 |
20 | ofRectangle temp;
21 | bool bSetYet = false;
22 | for (auto line : lines){
23 | for (auto pt : line){
24 |
25 | if (bSetYet == false){
26 | temp.setPosition(pt.x, pt.y);
27 | } else {
28 | temp.growToInclude(pt.x, pt.y);
29 | }
30 | bSetYet = true;
31 | }
32 | }
33 |
34 | ofRectangle target = temp;
35 |
36 | target.scaleTo(fitInside);
37 |
38 | for (auto & line : lines){
39 | for (auto & pt : line){
40 |
41 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
42 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
43 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
44 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
45 |
46 | }
47 | }
48 |
49 |
50 | return lines;
51 | }
52 |
53 |
54 |
55 | ofPolyline abzHelper::getCharacterLargestLine( char c, ofRectangle fitInside){
56 |
57 |
58 | ofPath p = font.getCharacterAsPoints(c);
59 | vector < ofPolyline > lines = p.getOutline();
60 |
61 | int largest = -1;
62 | float maxLength = 0;
63 |
64 | for (int i = 0; i < lines.size(); i++){
65 | float length = lines[i].getPerimeter();
66 | if (length > maxLength){
67 | maxLength = length;
68 | largest = i;
69 | }
70 | }
71 |
72 |
73 | ofPolyline lineWeWant = lines[largest];
74 |
75 | ofRectangle temp;
76 | temp = lineWeWant.getBoundingBox();
77 | // bool bSetYet = false;
78 | // for (auto line : lines){
79 | // for (auto pt : line){
80 | //
81 | // if (bSetYet == false){
82 | // temp.setPosition(pt.x, pt.y);
83 | // } else {
84 | // temp.growToInclude(pt.x, pt.y);
85 | // }
86 | // bSetYet = true;
87 | // }
88 | // }
89 |
90 | ofRectangle target = temp;
91 |
92 | target.scaleTo(fitInside);
93 |
94 | //for (auto & line : lines){
95 | for (auto & pt : lineWeWant){
96 |
97 | float pctx = ofMap(pt.x, temp.x, temp.x + temp.width, 0, 1);
98 | float pcty = ofMap(pt.y, temp.y, temp.y + temp.height, 0, 1);
99 | pt.x = ofMap(pctx, 0, 1, target.x, target.x + target.width);
100 | pt.y = ofMap(pcty, 0, 1, target.y, target.y + target.height);
101 |
102 | }
103 | //}
104 |
105 |
106 | return lineWeWant;
107 | }
108 |
109 | void abzHelper::drawCharacterIntoImage(ofImage & img, char c){
110 |
111 |
112 | ofRectangle bounds = ofRectangle(0,0, img.getWidth(), img.getHeight());
113 |
114 | ofPath p = font.getCharacterAsPoints(c);
115 | vector < ofPolyline > lines = p.getOutline();
116 |
117 | ofRectangle temp;
118 | bool bSetYet = false;
119 | for (auto line : lines){
120 | if (!bSetYet){
121 | temp = line.getBoundingBox();
122 | bSetYet = true;
123 | } else {
124 | temp.growToInclude(line.getBoundingBox());
125 |
126 | }
127 | // for (auto pt : line){
128 | //
129 | // if (bSetYet == false){
130 | // temp.setPosition(pt.x, pt.y);
131 | // } else {
132 | // temp.growToInclude(pt.x, pt.y);
133 | // }
134 | // bSetYet = true;
135 | // }
136 | }
137 |
138 | ofRectangle target = temp;
139 | target.scaleTo(bounds);
140 | target.scaleFromCenter(0.9);
141 | ofPoint offset = target.getPosition() - temp.getPosition();
142 | float scalef = target.height / temp.height;
143 | ofFbo fbo;
144 | fbo.allocate(bounds.width, bounds.height, GL_RGB);
145 |
146 |
147 | fbo.begin();
148 | ofClear(0,0,0);
149 | ofPushMatrix();
150 | ofTranslate(offset.x, img.getHeight()*0.5 + target.getHeight()*0.5);
151 | ofScale( scalef, scalef);
152 | ofSetColor(255,255,255);
153 | p.setFillColor(ofColor::white);
154 | p.setFilled(true);
155 | p.draw();
156 | p.getOutline()[0].draw();
157 | ofPopMatrix();
158 | fbo.end();
159 |
160 | fbo.readToPixels(img.getPixels());
161 | img.update();
162 |
163 | }
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/typeLoader_tracer/src/abzHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | class abzHelper {
6 |
7 | public:
8 |
9 |
10 | ofTrueTypeFont font;
11 |
12 | void loadFont(string name);
13 |
14 | vector < ofPolyline > getCharacterLines( char c, ofRectangle fitInside );
15 | void drawCharacterIntoImage( ofImage & img, char c);
16 |
17 |
18 | ofPolyline getCharacterLargestLine( char c, ofRectangle fitInside );
19 |
20 | };
--------------------------------------------------------------------------------
/typeLoader_tracer/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main( ){
6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
7 |
8 | // this kicks off the running of my app
9 | // can be OF_WINDOW or OF_FULLSCREEN
10 | // pass in width and height too:
11 | ofRunApp(new ofApp());
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/typeLoader_tracer/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 |
6 |
7 | ABZ.loadFont("HelveticaNeueMed.ttf");
8 |
9 |
10 |
11 | }
12 |
13 | //--------------------------------------------------------------
14 | void ofApp::update(){
15 |
16 | }
17 |
18 | //--------------------------------------------------------------
19 | void ofApp::draw(){
20 |
21 | ofBackground(0);
22 |
23 |
24 | ofRectangle screen = ofRectangle(0,0,ofGetWidth(), ofGetHeight());
25 |
26 |
27 | screen.scaleFromCenter(0.8);
28 |
29 | ofPolyline letterA = ABZ.getCharacterLargestLine('a', screen);
30 |
31 | letterA.draw();
32 |
33 | float pct = ofMap( sin(ofGetElapsedTimef()), -1, 1, 0, 1);
34 | ofPoint pt = letterA.getPointAtPercent(pct);
35 | ofCircle(pt, 10);
36 |
37 |
38 | // float pct = fmod(ofGetElapsedTimef(), 1.0);
39 | // ofPoint pt = letterA.getPointAtPercent(pct);
40 | // ofCircle(pt, 10);
41 |
42 | // float startPt = fmod(ofGetElapsedTimef()*0.4, 1.0);
43 | // float range = 0.2;
44 | // ofPolyline temp;
45 | // for (int i = 0; i< 100; i++){
46 | // float pct = ofMap(i, 0, 100,startPt, startPt + range);
47 | // pct = fmod(pct, 1.0);
48 | // temp.addVertex( letterA.getPointAtPercent(pct));
49 | // }
50 | // temp.draw();
51 |
52 | }
53 |
54 | //--------------------------------------------------------------
55 | void ofApp::keyPressed(int key){
56 |
57 | }
58 |
59 | //--------------------------------------------------------------
60 | void ofApp::keyReleased(int key){
61 |
62 | }
63 |
64 | //--------------------------------------------------------------
65 | void ofApp::mouseMoved(int x, int y ){
66 |
67 | }
68 |
69 | //--------------------------------------------------------------
70 | void ofApp::mouseDragged(int x, int y, int button){
71 |
72 | }
73 |
74 | //--------------------------------------------------------------
75 | void ofApp::mousePressed(int x, int y, int button){
76 |
77 | }
78 |
79 | //--------------------------------------------------------------
80 | void ofApp::mouseReleased(int x, int y, int button){
81 |
82 | }
83 |
84 | //--------------------------------------------------------------
85 | void ofApp::mouseEntered(int x, int y){
86 |
87 | }
88 |
89 | //--------------------------------------------------------------
90 | void ofApp::mouseExited(int x, int y){
91 |
92 | }
93 |
94 | //--------------------------------------------------------------
95 | void ofApp::windowResized(int w, int h){
96 |
97 | }
98 |
99 | //--------------------------------------------------------------
100 | void ofApp::gotMessage(ofMessage msg){
101 |
102 | }
103 |
104 | //--------------------------------------------------------------
105 | void ofApp::dragEvent(ofDragInfo dragInfo){
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/typeLoader_tracer/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "abzHelper.h"
5 |
6 | class ofApp : public ofBaseApp{
7 |
8 | public:
9 | void setup();
10 | void update();
11 | void draw();
12 |
13 | void keyPressed(int key);
14 | void keyReleased(int key);
15 | void mouseMoved(int x, int y );
16 | void mouseDragged(int x, int y, int button);
17 | void mousePressed(int x, int y, int button);
18 | void mouseReleased(int x, int y, int button);
19 | void mouseEntered(int x, int y);
20 | void mouseExited(int x, int y);
21 | void windowResized(int w, int h);
22 | void dragEvent(ofDragInfo dragInfo);
23 | void gotMessage(ofMessage msg);
24 |
25 | abzHelper ABZ;
26 |
27 |
28 | };
29 |
--------------------------------------------------------------------------------
/typeLoader_tracer/typeLoader_tracer.xcodeproj/xcshareddata/xcschemes/typeLoader_tracer Debug.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/typeLoader_tracer/typeLoader_tracer.xcodeproj/xcshareddata/xcschemes/typeLoader_tracer Release.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------