├── .gitignore
├── CyrilTouchOSC.touchosc
├── DroidSansMono.ttf
├── LICENSE.md
├── Makefile
├── Project.xcconfig
├── README.md
├── addons.make
├── bin
└── data
│ ├── code
│ ├── 0.cy
│ ├── 1.cy
│ ├── 2.cy
│ ├── 3.cy
│ ├── 4.cy
│ ├── 5.cy
│ ├── 6.cy
│ ├── 7.cy
│ ├── 8.cy
│ └── 9.cy
│ └── sprites
│ ├── 1.png
│ └── 6.png
├── config.make
├── cyril-logo.icns
├── cyril.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── darren.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
├── xcshareddata
│ └── xcschemes
│ │ ├── cyril Debug.xcscheme
│ │ └── cyril Release.xcscheme
└── xcuserdata
│ └── darren.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── cyril
└── Images.xcassets
│ └── AppIcon.appiconset
│ ├── Contents.json
│ ├── cyril-logo128x128.png
│ ├── cyril-logo16x16.png
│ ├── cyril-logo256x256.png
│ └── cyril-logo32x32.png
├── openFrameworks-Info.plist
└── src
├── Cyril
├── Cyril.cpp
├── Cyril.h
├── CyrilBloom.cpp
├── CyrilBloom.h
├── CyrilOp.cpp
├── CyrilOp.h
├── CyrilParser.cpp
├── CyrilParser.h
├── CyrilPixelate.cpp
├── CyrilPixelate.h
├── CyrilState.cpp
├── CyrilState.h
├── Funs
│ ├── CyrilCosFun.cpp
│ ├── CyrilCosFun.h
│ ├── CyrilFftFun.cpp
│ ├── CyrilFftFun.h
│ ├── CyrilFun.cpp
│ ├── CyrilFun.h
│ ├── CyrilHsbFun.cpp
│ ├── CyrilHsbFun.h
│ ├── CyrilLerpFun.cpp
│ ├── CyrilLerpFun.h
│ ├── CyrilMapFun.cpp
│ ├── CyrilMapFun.h
│ ├── CyrilNoiseFun.cpp
│ ├── CyrilNoiseFun.h
│ ├── CyrilPaletteFun.cpp
│ ├── CyrilPaletteFun.h
│ ├── CyrilRandFun.cpp
│ ├── CyrilRandFun.h
│ ├── CyrilSinFun.cpp
│ ├── CyrilSinFun.h
│ ├── CyrilTanFun.cpp
│ ├── CyrilTanFun.h
│ ├── CyrilWaveFun.cpp
│ └── CyrilWaveFun.h
├── Lang
│ ├── CyrilAssign.h
│ ├── CyrilColorLoad.cpp
│ ├── CyrilColorLoad.h
│ ├── CyrilDebugOp.cpp
│ ├── CyrilDebugOp.h
│ ├── CyrilDo.h
│ ├── CyrilFor.h
│ ├── CyrilHexColor.h
│ ├── CyrilIf.h
│ ├── CyrilList.h
│ ├── CyrilLoad.h
│ ├── CyrilNamedColor.h
│ ├── CyrilPush.h
│ ├── CyrilUnaryOp.h
│ └── CyrilWhile.h
├── Ops
│ ├── CyrilAnimStep.cpp
│ ├── CyrilAnimStep.h
│ ├── CyrilAnimation.cpp
│ ├── CyrilAnimation.h
│ ├── CyrilBackgroundOp.cpp
│ ├── CyrilBackgroundOp.h
│ ├── CyrilBallDetailOp.cpp
│ ├── CyrilBallDetailOp.h
│ ├── CyrilBallOp.cpp
│ ├── CyrilBallOp.h
│ ├── CyrilBinaryOp.h
│ ├── CyrilBlink.cpp
│ ├── CyrilBlink.h
│ ├── CyrilBoxOp.cpp
│ ├── CyrilBoxOp.h
│ ├── CyrilColorOp.cpp
│ ├── CyrilColorOp.h
│ ├── CyrilConeOp.cpp
│ ├── CyrilConeOp.h
│ ├── CyrilDie.h
│ ├── CyrilFillOp.cpp
│ ├── CyrilFillOp.h
│ ├── CyrilGridOp.cpp
│ ├── CyrilGridOp.h
│ ├── CyrilImgOp.cpp
│ ├── CyrilImgOp.h
│ ├── CyrilInitOp.cpp
│ ├── CyrilInitOp.h
│ ├── CyrilKaleidoscope.cpp
│ ├── CyrilKaleidoscope.h
│ ├── CyrilLightOp.cpp
│ ├── CyrilLightOp.h
│ ├── CyrilLineOp.cpp
│ ├── CyrilLineOp.h
│ ├── CyrilMoveOp.cpp
│ ├── CyrilMoveOp.h
│ ├── CyrilNoFillOp.cpp
│ ├── CyrilNoFillOp.h
│ ├── CyrilNoiseWarp.cpp
│ ├── CyrilNoiseWarp.h
│ ├── CyrilPalette.cpp
│ ├── CyrilPalette.h
│ ├── CyrilPaletteItem.cpp
│ ├── CyrilPaletteItem.h
│ ├── CyrilParticle.cpp
│ ├── CyrilParticle.h
│ ├── CyrilPegOp.cpp
│ ├── CyrilPegOp.h
│ ├── CyrilPopMatrixOp.cpp
│ ├── CyrilPopMatrixOp.h
│ ├── CyrilPushMatrixOp.cpp
│ ├── CyrilPushMatrixOp.h
│ ├── CyrilRectOp.cpp
│ ├── CyrilRectOp.h
│ ├── CyrilRotateOp.cpp
│ ├── CyrilRotateOp.h
│ ├── CyrilScaleOp.cpp
│ ├── CyrilScaleOp.h
│ ├── CyrilShape.cpp
│ ├── CyrilShape.h
│ ├── CyrilShapeList.cpp
│ ├── CyrilShapeList.h
│ ├── CyrilSphereDetailOp.cpp
│ ├── CyrilSphereDetailOp.h
│ ├── CyrilSphereOp.cpp
│ ├── CyrilSphereOp.h
│ ├── CyrilTile.cpp
│ └── CyrilTile.h
├── cyril.lpp
└── cyril.ypp
├── Engine
├── Palette.cpp
├── Palette.h
├── Particle.cpp
└── Particle.h
├── cmds.h
├── cyrilApp.cpp
├── cyrilApp.h
└── main.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/*.app
2 | cyril.xcodeproj/project.xcworkspace/xcshareddata*
3 | cyril.xcodeproj/project.xcworkspace/xcuserdata/*
4 | cyril.xcodeproj/project.xcworkspace/xcuserdata/darren.xcuserdatad/UserInterfaceState.xcuserstate
5 | *darren.xcuserdatad*
6 |
7 | /.idea
8 | /of_*
9 |
10 | # OS generated files #
11 | ######################
12 | .DS_Store
13 | .DS_Store?
14 | ._*
15 | .Spotlight-V100
16 | .Trashes
17 | ehthumbs.db
18 | Thumbs.db
19 |
20 |
21 |
--------------------------------------------------------------------------------
/CyrilTouchOSC.touchosc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/CyrilTouchOSC.touchosc
--------------------------------------------------------------------------------
/DroidSansMono.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/DroidSansMono.ttf
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | **openFrameworks** is distributed under the [MIT License](https://en.wikipedia.org/wiki/MIT_License). This gives everyone the freedoms to use openFrameworks in any context: commercial or non-commercial, public or private, open or closed source.
2 |
3 | ---
4 |
5 | Copyright (c) 2004 - openFrameworks Community
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 |
13 | ---
14 |
15 | openFrameworks also ships with a mix of the following [libraries](docs/libraries.md), depending on your platform, which may have different licenses.
16 |
17 | * [OpenGL](http://www.opengl.org/), [GLEW](http://glew.sourceforge.net/), [GLUT](http://www.opengl.org/resources/libraries/glut/), [libtess2](https://code.google.com/p/libtess2/) and [cairo](http://cairographics.org/) for graphics
18 | * [rtAudio](http://www.music.mcgill.ca/~gary/rtaudio/), [PortAudio](http://www.portaudio.com/) or [FMOD](http://www.fmod.org/) and [Kiss FFT](http://kissfft.sourceforge.net/) for audio input, output and analysis
19 | * [FreeType](http://freetype.sourceforge.net/index2.html) for fonts
20 | * [FreeImage](http://freeimage.sourceforge.net/) for image saving and loading
21 | * [Quicktime](http://developer.apple.com/quicktime/), [Unicap](http://unicap-imaging.org/), [GStreamer](http://gstreamer.freedesktop.org/) and [videoInput](https://github.com/ofTheo/videoInput) for video playback and grabbing
22 | * [Poco](http://pocoproject.org/) for a variety of utilities
--------------------------------------------------------------------------------
/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=../../..
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/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)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cyril - Live Coding
2 |
3 | **New? [Check the getting started guide](https://medium.com/cyril-live-coding/getting-started-with-beta-6-c74e93463c3d)**
4 |
5 | **NEW BRANCH:** Dev is continuing on the [CMake Branch](https://github.com/cyrilcode/cyril/tree/cmake)
6 |
7 | The Cyril programming language is designed for fast prototyping of visualisations and live coding visuals.
8 |
9 | Full information on the website:
10 |
11 | * http://cyrilcode.com
12 |
13 | ## Getting Started
14 |
15 | The language reference on the website is slightly out-of-date. There's a website by Cyril user Dan Hett called [Cyril Patterns](http://cyrilpatterns.tumblr.com/) that has loads of examples, and is a good way to learn the syntax.
16 |
17 | If you use a recent beta, then Post Processing effects are turned on by default, and can be toggled by pressing `cmd` + `z`. If you are not using post processing effects you probably want to toggle them off as the output quality improves.
18 |
19 | See here for more [keyboard controls](http://cyrilcode.com/controls.html)
20 |
21 | External editor support has been added in recent beta versions so you can project one screen and edit code in another using any text editor. Edit the files in the `data/code` folder and Cyril will refresh each time a file is saved.
22 |
23 | ## Requirements
24 |
25 | Cyril is built against version 0.8.4 of openFrameworks
26 |
27 | * http://www.openframeworks.cc/download/
28 |
29 | It also depends on various ofx Addons:
30 |
31 | * https://github.com/darrenmothersele/ofxBeat
32 | * https://github.com/darrenmothersele/ofxEditor
33 | * https://github.com/bakercp/ofxIO
34 | * ofxPostProcessing use my fork for extra getters/setters of params: https://github.com/darrenmothersele/ofxPostProcessing originally by Neil Mendoza https://github.com/neilmendoza/ofxPostProcessing
35 |
36 | These addons may be required or will be dependencies soon as they are being used in new features:
37 |
38 | * ofxSyphon
39 | * ofxGUI
40 | * ofxOSC
41 | * ofxXmlSettings
42 |
--------------------------------------------------------------------------------
/addons.make:
--------------------------------------------------------------------------------
1 | ofxGui
2 | ofxOsc
3 | ofxXmlSettings
4 | ofxBeat
5 | ofxEditor
6 |
--------------------------------------------------------------------------------
/bin/data/code/0.cy:
--------------------------------------------------------------------------------
1 |
2 |
3 | rotate
4 |
5 | a: a + 0.01
6 | b: b + 0.01
7 | c: c + 0.01
8 |
9 | i: noise(a) * 0.1
10 | j: noise(1,b) * 0.05
11 | k: noise(1,1,c) * 0.05
12 |
13 | do 2 times
14 | do 4 times
15 | rotate 90
16 | particle 0, i,j,k
17 | color white,(1 - HEALTH) * 255
18 | if HEALTH < 0.7 box HEALTH
19 | end
20 | end
21 | i: 0 - i
22 | j: 0 - j
23 | k: 0 - k
24 | end
25 |
26 | //fxK 1
27 | //fxNW
28 |
--------------------------------------------------------------------------------
/bin/data/code/1.cy:
--------------------------------------------------------------------------------
1 | light 0,-10,10
2 |
3 | //rotate
4 | //stroke
5 | fill
6 | DECAY: 0.1
7 | ballDetail 0.1
8 | color hotPink,255
9 | i: i + 0.01
10 | for x: -20 to 25 step 4
11 | for y: -10 to 14 step 4
12 | push
13 | move x,y,-1
14 | rotate 270,0,1,0
15 | rotate (1 - noise(i)) * 360
16 | particle 0,noise(x,y,i) * 0.5,noise(y,x,i) * 0.3,0
17 | // color hsb(100,255,255),HEALTH
18 | rotate
19 | box 0.2, 1, 2
20 | end
21 | pop
22 | end
23 | end
24 |
25 |
26 | //fxB 2
27 |
--------------------------------------------------------------------------------
/bin/data/code/2.cy:
--------------------------------------------------------------------------------
1 |
2 |
3 | rotate TIME / 4
4 |
5 | do 8 times
6 | rotate FRAME
7 | particle 0.01,wave(1000) * 0.05,wave(500) * 0.05,0
8 | rotate HEALTH * 360,0,-1,0
9 | color lerp(#ff0000,#ff00ff,HEALTH),175
10 | do 2 times
11 | rotate
12 | shape
13 | vert 0,0
14 | vert 0.45,0.75
15 | vert -0.45,0.75
16 | vert 0,0
17 | end
18 | end
19 | end
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/bin/data/code/3.cy:
--------------------------------------------------------------------------------
1 |
2 |
3 | particle 0.1
4 | i: i + 0.1
5 | box i
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/bin/data/code/4.cy:
--------------------------------------------------------------------------------
1 |
2 |
3 | do 25 times
4 | rotate FRAME / 25
5 | push
6 | move 1
7 | box 0.01,0.02,10
8 | pop
9 | end
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/bin/data/code/5.cy:
--------------------------------------------------------------------------------
1 | move 0,0,4
2 | rotate 45,1,0,0
3 | scale 2
4 | color red,200
5 | push
6 | do 4 times
7 | rotate FRAME / 8, 0,1,0
8 | push
9 | rotate FRAME / 10,0,1,0
10 | tile 4,4,4
11 | box 0.25,0.025,0.01
12 | end
13 | pop
14 | end
15 | pop
16 | color lightBlue,50
17 | push
18 | move 0,0,-1
19 | do 1 times
20 | rotate 0 - FRAME / 20,0,1,0
21 | push
22 | rotate FRAME / 6,0,1,0
23 | tile 4,4,4
24 | ball 0.1,0.2,0.15
25 | end
26 | pop
27 |
28 | end
29 | pop
30 |
31 | fxNW
32 | //fxNW wave(12300)*20,fft(10)/10,wave(12200)
33 | //fxK KICK
34 |
--------------------------------------------------------------------------------
/bin/data/code/6.cy:
--------------------------------------------------------------------------------
1 |
2 | noFill
3 | color hotPink
4 | do 4 times
5 | rotate FRAME / 4
6 | box 4
7 | end
8 |
--------------------------------------------------------------------------------
/bin/data/code/7.cy:
--------------------------------------------------------------------------------
1 | //rotate FRAME / 2,0,1,0
2 | //scale 0.2
3 | //move -16
4 | // for i: 0 to 32 step 1
5 | // box 1,fft(i)*10,1
6 | // move 1,0
7 | //end
8 | DECAY: 0.01
9 | rotate wave(1000) * 36,0,0,1
10 | do 8 times
11 | rotate 45
12 | f: 3
13 | blink 1,10
14 | particle 0.05 * fft(f),0,0,0
15 | color hotPink, HEALTH * 255
16 | box 1, HEALTH * 10, 1
17 | end
18 | end
19 | end
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/bin/data/code/8.cy:
--------------------------------------------------------------------------------
1 | fill
2 | palette $p
3 | // 10 red
4 | 10 yellow
5 | 10 orange
6 | end
7 | scale 10
8 | rotate 90,1,0,0
9 | stroke 2
10 | i: 0
11 | do 10 times
12 | i: i + 0.1
13 | color lerp($p, i)
14 | color pink
15 | rotate FRAME / 100, 0,1,0
16 | cone
17 | end
18 |
--------------------------------------------------------------------------------
/bin/data/code/9.cy:
--------------------------------------------------------------------------------
1 |
2 | palette $f
3 | 50 red
4 | 25 orange
5 | 25 yellow
6 | end
7 | sphereDetail 2
8 | DECAY: 0.01
9 | do 10 times
10 | rotate FRAME / 10
11 |
12 | push
13 | i: i + 0.1
14 | x: noise(i)
15 | y: noise(i,0.1)
16 |
17 | move 1 + x * 0.5,1 + y * 0.5
18 | rotate 90,0,-1,0
19 | particle 0.04,-0.0001,0.0005,0
20 | color lerp($f, HEALTH - 0.001), (HEALTH * 100) + 100
21 | sphere 0.1
22 | end
23 | pop
24 | end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/bin/data/sprites/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/bin/data/sprites/1.png
--------------------------------------------------------------------------------
/bin/data/sprites/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/bin/data/sprites/6.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/cyril-logo.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril-logo.icns
--------------------------------------------------------------------------------
/cyril.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cyril.xcodeproj/project.xcworkspace/xcuserdata/darren.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril.xcodeproj/project.xcworkspace/xcuserdata/darren.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/cyril.xcodeproj/xcshareddata/xcschemes/cyril 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 |
--------------------------------------------------------------------------------
/cyril.xcodeproj/xcshareddata/xcschemes/cyril 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 |
--------------------------------------------------------------------------------
/cyril.xcodeproj/xcuserdata/darren.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | cyril Debug.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | cyril Release.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 1
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | E4B69B5A0A3A1756003C02F2
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/cyril/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "scale" : "2x",
6 | "size" : "16x16"
7 | },
8 | {
9 | "size" : "16x16",
10 | "idiom" : "mac",
11 | "filename" : "cyril-logo16x16.png",
12 | "scale" : "1x"
13 | },
14 | {
15 | "size" : "32x32",
16 | "idiom" : "mac",
17 | "filename" : "cyril-logo32x32.png",
18 | "scale" : "1x"
19 | },
20 | {
21 | "idiom" : "mac",
22 | "scale" : "2x",
23 | "size" : "32x32"
24 | },
25 | {
26 | "size" : "128x128",
27 | "idiom" : "mac",
28 | "filename" : "cyril-logo128x128.png",
29 | "scale" : "1x"
30 | },
31 | {
32 | "idiom" : "mac",
33 | "scale" : "2x",
34 | "size" : "128x128"
35 | },
36 | {
37 | "size" : "256x256",
38 | "idiom" : "mac",
39 | "filename" : "cyril-logo256x256.png",
40 | "scale" : "1x"
41 | },
42 | {
43 | "idiom" : "mac",
44 | "scale" : "2x",
45 | "size" : "256x256"
46 | },
47 | {
48 | "idiom" : "mac",
49 | "scale" : "1x",
50 | "size" : "512x512"
51 | },
52 | {
53 | "idiom" : "mac",
54 | "scale" : "2x",
55 | "size" : "512x512"
56 | }
57 | ],
58 | "info" : {
59 | "version" : 1,
60 | "author" : "xcode"
61 | }
62 | }
--------------------------------------------------------------------------------
/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo128x128.png
--------------------------------------------------------------------------------
/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo16x16.png
--------------------------------------------------------------------------------
/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo256x256.png
--------------------------------------------------------------------------------
/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyrilcode/cyril/40ad7082d34cbe41fba04c59829403150c56e9fd/cyril/Images.xcassets/AppIcon.appiconset/cyril-logo32x32.png
--------------------------------------------------------------------------------
/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 | cyril-logo
11 | CFBundleIdentifier
12 | com.cyrilcode.cyril
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | beta
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Cyril/Cyril.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Cyril.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "Cyril.h"
10 |
11 | Cyril* Cyril::clone () {
12 | return new Cyril (*this);
13 | }
14 |
15 | Cyril::Cyril (const Cyril &other) {
16 | valid = other.valid;
17 | }
18 |
19 | // How many items are left on the stack after eval?
20 | int Cyril::size() {
21 | return 0;
22 | }
23 |
24 | void Cyril::eval(CyrilState &) {
25 | // Do nothing!
26 | }
27 |
28 | void Cyril::update(CyrilState &) {
29 | // Do nothing!
30 | }
--------------------------------------------------------------------------------
/src/Cyril/Cyril.h:
--------------------------------------------------------------------------------
1 | //
2 | // Cyril.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_Cyril_h
10 | #define cyril2_Cyril_h
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "CyrilState.h"
15 |
16 | class Particle;
17 |
18 | void yyerror(const char *);
19 |
20 | class Cyril {
21 | public:
22 | bool valid;
23 | Cyril() { valid = true; }
24 | virtual ~Cyril () {}
25 | Cyril (const Cyril &other);
26 | virtual Cyril *clone ();
27 | virtual void print() { };
28 | virtual int size();
29 | virtual void update(CyrilState &);
30 | virtual void eval(CyrilState &);
31 | virtual int matchPushPop() { return 0; }
32 | };
33 |
34 | #endif
35 |
36 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilBloom.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBloom.cpp
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 15/09/2014.
6 | //
7 | //
8 |
9 | #include "CyrilBloom.h"
10 |
11 | CyrilBloom::CyrilBloom (Cyril* _e) : e(_e) {
12 | s = e->size();
13 | if (!(s == 1 || s == 0)) {
14 | // Width, Height - or single argument for same w and h
15 | yyerror("Bloom FX command takes 0 or 1 arguments");
16 | valid = false;
17 | }
18 | prevBloom = 0.001953125;
19 | }
20 |
21 | CyrilBloom::CyrilBloom (const CyrilBloom &other) {
22 | e = other.e->clone ();
23 | }
24 | CyrilBloom::~CyrilBloom ()
25 | {
26 | }
27 | void CyrilBloom::print() {
28 | cout << "CyrilBloom" << endl;
29 | }
30 | Cyril * CyrilBloom::clone () {
31 | return new CyrilBloom (*this);
32 | }
33 | int CyrilBloom::size() {
34 | return 0;
35 | }
36 | void CyrilBloom::update(CyrilState &_s) {
37 | // FX_BLOOM = 3
38 | _s.post[3]->enable();
39 | }
40 | void CyrilBloom::eval(CyrilState &_s) {
41 | float bloom;
42 | if (s == 1) {
43 | e->eval(_s);
44 | bloom = (_s.stk->top()) / 1000.0f;
45 | _s.stk->pop();
46 | }
47 | else {
48 | // same defaults as ofxPostProcessing:
49 | bloom = 0.001953125;
50 | }
51 | if (bloom != prevBloom) {
52 | prevBloom = bloom;
53 | _s.bloom->setIncrements(bloom, 0, 0, bloom);
54 | }
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilBloom.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBloom.h
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 15/09/2014.
6 | //
7 | //
8 |
9 | #ifndef __cyril__CyrilBloom__
10 | #define __cyril__CyrilBloom__
11 |
12 | #include "Cyril.h"
13 |
14 | class CyrilBloom : public Cyril {
15 | protected:
16 | Cyril* e;
17 | int s;
18 | float prevBloom;
19 | public:
20 | CyrilBloom(Cyril* _e);
21 | CyrilBloom (const CyrilBloom &other);
22 | virtual ~CyrilBloom ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | virtual void update(CyrilState &);
28 | };
29 |
30 |
31 | #endif /* defined(__cyril__CyrilBloom__) */
32 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilOp.h"
10 |
11 | CyrilOp::CyrilOp (Cyril* _c) : c(_c) {
12 |
13 | }
14 |
15 | CyrilOp::CyrilOp (const CyrilOp &other) {
16 | c = other.c->clone ();
17 | }
18 | CyrilOp::~CyrilOp ()
19 | {
20 | delete c;
21 | }
22 | void CyrilOp::print() {
23 | c->print();
24 | cout << "No Op" << endl;
25 | }
26 | Cyril * CyrilOp::clone () { return new CyrilOp (*this); }
27 | int CyrilOp::size() { return 0; }
28 | void CyrilOp::eval(CyrilState &_s) {
29 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilOp_h
10 | #define cyril2_CyrilOp_h
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 |
16 | class CyrilOp : public Cyril {
17 | protected:
18 | Cyril* c;
19 | public:
20 |
21 | CyrilOp(Cyril* _c = NULL);
22 | CyrilOp(const CyrilOp &other);
23 | virtual ~CyrilOp ();
24 | virtual void print();
25 | virtual Cyril *clone ();
26 | virtual int size();
27 | virtual void eval(CyrilState &);
28 | };
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilParser.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilParser.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilParser.h"
10 | #include "y.tab.h"
11 | extern void scannerRestart();
12 |
13 | Cyril* CyrilParser::parseString(string progStr) {
14 | //const char *str = progStr.c_str();
15 | int res = 0;
16 | progStr.append(1, '\n');
17 | res = yycyrilParseString(progStr.c_str());
18 | if (res == 0) {
19 | #ifdef DEBUG_PRINT
20 | cout << "Compile OK" << endl;
21 | #endif
22 | if (pRoot->matchPushPop() != 0) {
23 | cout << "Unmatched push and pop matrix" << endl;
24 | pRoot->valid = false;
25 | }
26 | }
27 | else {
28 | pRoot = new Cyril();
29 | pRoot->valid = false;
30 | }
31 | return pRoot;
32 | return new Cyril();
33 | }
34 |
35 | Cyril* CyrilParser::parseFile(string fileName) {
36 | //Cyril * pAST;
37 | int res = 0;
38 | FILE *fp=fopen(ofToDataPath(fileName).c_str(),"r");
39 | if(!fp) {
40 | #ifdef DEBUG_PRINT
41 | cout << "Error opening file" << fileName << endl;
42 | #endif
43 | }
44 | else {
45 | #ifdef DEBUG_PRINT
46 | cout << "parsing file " << fileName << endl;
47 | #endif
48 | scannerRestart();
49 | line_no = 0;
50 | yyin = fp;
51 | res = yyparse();
52 | fclose(fp);
53 | if (res == 0) {
54 | #ifdef DEBUG_PRINT
55 | cout << "Compile OK" << endl;
56 | #endif
57 | }
58 | }
59 | return pRoot;
60 | }
--------------------------------------------------------------------------------
/src/Cyril/CyrilParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilParser.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilParser_h
10 | #define cyril2_CyrilParser_h
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 | #include "CyrilList.h"
15 | #include "CyrilOp.h"
16 | #include "CyrilAssign.h"
17 | #include "CyrilPush.h"
18 | #include "CyrilDo.h"
19 | #include "CyrilFor.h"
20 | #include "CyrilIf.h"
21 | #include "CyrilWhile.h"
22 | #include "CyrilHexColor.h"
23 | #include "CyrilFun.h"
24 | #include "CyrilBinaryOp.h"
25 | #include "CyrilLoad.h"
26 | #include "CyrilUnaryOp.h"
27 | #include "CyrilParticle.h"
28 |
29 | extern "C" int yyparse();
30 | extern FILE *yyin;
31 | extern "C" int line_no;
32 | extern Cyril * pRoot;
33 | extern int yycyrilParseString(const char *str);
34 |
35 | class CyrilParser {
36 | public:
37 | static Cyril* parseString(string progStr);
38 | static Cyril* parseFile(string fileName);
39 | };
40 |
41 | #endif
42 |
43 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilPixelate.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPixelate.cpp
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 15/09/2014.
6 | //
7 | //
8 |
9 | #include "CyrilPixelate.h"
10 |
11 | CyrilPixelate::CyrilPixelate (Cyril* _e) : e(_e) {
12 | s = e->size();
13 | if (!(s == 2 || s == 1 || s == 0)) {
14 | // Width, Height - or single argument for same w and h
15 | yyerror("Pixelate FX command takes 0, 1 or 2 arguments");
16 | valid = false;
17 | }
18 | }
19 |
20 | CyrilPixelate::CyrilPixelate (const CyrilPixelate &other) {
21 | e = other.e->clone ();
22 | }
23 | CyrilPixelate::~CyrilPixelate ()
24 | {
25 | }
26 | void CyrilPixelate::print() {
27 | cout << "CyrilPixelate" << endl;
28 | }
29 | Cyril * CyrilPixelate::clone () {
30 | return new CyrilPixelate (*this);
31 | }
32 | int CyrilPixelate::size() {
33 | return 0;
34 | }
35 | void CyrilPixelate::update(CyrilState &_s) {
36 | // FX_PIXELATE = 2
37 | _s.post[2]->enable();
38 | }
39 | void CyrilPixelate::eval(CyrilState &_s) {
40 | float width, height;
41 | if (s == 2) {
42 | e->eval(_s);
43 | height = _s.stk->top();
44 | _s.stk->pop();
45 | width = _s.stk->top();
46 | _s.stk->pop();
47 | }
48 | else if (s == 1) {
49 | e->eval(_s);
50 | height = _s.stk->top();
51 | width = height;
52 | _s.stk->pop();
53 | }
54 | else {
55 | // same defaults as ofxPostProcessing:
56 | width = 100;
57 | height = 100;
58 | }
59 | _s.pixelate->setResolution(width, height);
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilPixelate.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPixelate.h
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 15/09/2014.
6 | //
7 | //
8 |
9 | #ifndef __cyril__CyrilPixelate__
10 | #define __cyril__CyrilPixelate__
11 |
12 | #include "Cyril.h"
13 |
14 |
15 | class CyrilPixelate : public Cyril {
16 | protected:
17 | Cyril* e;
18 | int s;
19 | public:
20 | CyrilPixelate(Cyril* _e);
21 | CyrilPixelate (const CyrilPixelate &other);
22 | virtual ~CyrilPixelate ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | virtual void update(CyrilState &);
28 | };
29 |
30 | #endif /* defined(__cyril__CyrilPixelate__) */
31 |
--------------------------------------------------------------------------------
/src/Cyril/CyrilState.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilState.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilState.h"
10 |
11 | CyrilState::CyrilState(map * _t,
12 | stack * _s, ofMatrixStack * _m, vector * _p, map * _c,
13 | map * _i, CyrilState * _pr)
14 | : sym(_t), stk(_s), ms(_m), ps(_p), cs(_c), img(_i), parent(_pr)
15 | {
16 |
17 | }
18 |
19 | CyrilState::CyrilState() {
20 |
21 | }
22 |
23 | CyrilState::~CyrilState () {
24 | delete sym;
25 | delete stk;
26 | delete ms;
27 | while(!ps->empty()) delete ps->back(), ps->pop_back();
28 | delete ps;
29 | for(map::iterator it = cs->begin(); it != cs->end(); ++it){
30 | delete (*it).second;
31 | }
32 | delete cs;
33 | for(map::iterator it = img->begin(); it != img->end(); ++it){
34 | delete (*it).second;
35 | }
36 | delete img;
37 | /*
38 | if (light != NULL)
39 | delete light;
40 | */
41 | }
42 | /*
43 | CyrilState::CyrilState (const CyrilState &other) {
44 |
45 | }
46 | CyrilState::CyrilState *clone () {
47 |
48 | }
49 | */
--------------------------------------------------------------------------------
/src/Cyril/CyrilState.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilState.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilState__
10 | #define __cyril2__CyrilState__
11 |
12 | #include "ofMain.h"
13 | #include "ofxPostProcessing.h"
14 |
15 | class Particle;
16 | class Palette;
17 |
18 | class CyrilState {
19 | public:
20 | map * sym;
21 | stack * stk;
22 | ofMatrixStack * ms;
23 | vector * ps;
24 | map * cs;
25 | map * img;
26 | CyrilState * parent;
27 | ofLight * light;
28 | ofxPostProcessing post;
29 | KaleidoscopePass::Ptr kaleido;
30 | NoiseWarpPass::Ptr noisewarp;
31 | PixelatePass::Ptr pixelate;
32 | BloomPass::Ptr bloom;
33 | float kaleidosegments;
34 |
35 | CyrilState(map * _t,
36 | stack * _s, ofMatrixStack * _m, vector * _p,
37 | map * _c, map * _i, CyrilState *);
38 | CyrilState();
39 | ~CyrilState ();
40 | //CyrilState (const CyrilState &other);
41 | //CyrilState *clone ();
42 |
43 | };
44 |
45 | #endif /* defined(__cyril2__CyrilState__) */
46 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilCosFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilCosFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilCosFun.h"
10 |
11 | CyrilCosFun::CyrilCosFun(Cyril* _c) : CyrilFun(_c) {
12 | int s = c->size();
13 | if (!(s == 1)) {
14 | yyerror("Cos function 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilCosFun::CyrilCosFun(const CyrilCosFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilCosFun::~CyrilCosFun () {
23 | delete c;
24 | }
25 | void CyrilCosFun::print() {
26 | c->print();
27 | cout << "Cos" << endl;
28 | }
29 | Cyril * CyrilCosFun::clone () {
30 | return new CyrilCosFun (*this);
31 | }
32 | int CyrilCosFun::size() {
33 | return 1;
34 | }
35 | void CyrilCosFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float result = cos(_s.stk->top());
38 | _s.stk->pop();
39 | _s.stk->push(result);
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilCosFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilCosFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilCosFun__
10 | #define __cyril2__CyrilCosFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilCosFun : public CyrilFun {
16 | public:
17 | CyrilCosFun(Cyril* _c);
18 | CyrilCosFun(const CyrilCosFun &other);
19 | virtual ~CyrilCosFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilCosFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilFftFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFftFun.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 15/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilFftFun.h"
10 |
11 | CyrilFftFun::CyrilFftFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 1)) {
14 | yyerror("FFT function has 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilFftFun::CyrilFftFun(const CyrilFftFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilFftFun::~CyrilFftFun () {
23 | delete c;
24 | }
25 | void CyrilFftFun::print() {
26 | c->print();
27 | cout << "Palette" << endl;
28 | }
29 | Cyril * CyrilFftFun::clone () {
30 | return new CyrilFftFun (*this);
31 | }
32 | int CyrilFftFun::size() {
33 | return 1;
34 | }
35 | void CyrilFftFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | int d = _s.stk->top(); _s.stk->pop();
38 | //cout << "FFT of " << (d % 32) << endl;
39 | //float f = fftSubbands[d % 32];
40 |
41 | _s.stk->push((*_s.sym)[REG_BEAT_FFT_START + (d % 32)]);
42 | }
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilFftFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFftFun.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 15/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilFftFun__
10 | #define __Cyril__CyrilFftFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 | #include "Palette.h"
15 |
16 | extern float fftSubbands[32];
17 |
18 | class CyrilFftFun : public CyrilFun {
19 | public:
20 | CyrilFftFun(Cyril* _c);
21 | CyrilFftFun(const CyrilFftFun &other);
22 | virtual ~CyrilFftFun ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | };
28 |
29 |
30 | #endif /* defined(__Cyril__CyrilFftFun__) */
31 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilFun.h"
10 |
11 | CyrilFun::CyrilFun(Cyril* _c) : c(_c) {
12 | }
13 |
14 | CyrilFun::CyrilFun (const CyrilFun &other) {
15 | c = other.c->clone ();
16 | }
17 | CyrilFun::~CyrilFun () {
18 | delete c;
19 | }
20 | void CyrilFun::print() {
21 | c->print();
22 | cout << "No Fun" << endl;
23 | }
24 | Cyril * CyrilFun::clone () {
25 | return new CyrilFun (*this);
26 | }
27 | int CyrilFun::size() {
28 | return 1;
29 | }
30 | void CyrilFun::eval(CyrilState &_state) {
31 | _state.stk->push(0);
32 | }
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilFun_h
10 | #define cyril2_CyrilFun_h
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 | #include "cmds.h"
15 |
16 | class CyrilFun : public Cyril {
17 | protected:
18 | Cyril* c;
19 | public:
20 | CyrilFun(Cyril* _c = NULL);
21 | CyrilFun(const CyrilFun &other);
22 | virtual ~CyrilFun ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | };
28 |
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilHsbFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilHsbFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilHsbFun.h"
10 |
11 | CyrilHsbFun::CyrilHsbFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 1 || s == 2 || s == 3)) {
14 | yyerror("HSB function has 1, 2 or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilHsbFun::CyrilHsbFun(const CyrilHsbFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilHsbFun::~CyrilHsbFun () {
23 | delete c;
24 | }
25 | void CyrilHsbFun::print() {
26 | c->print();
27 | cout << "HSB" << endl;
28 | }
29 | Cyril * CyrilHsbFun::clone () {
30 | return new CyrilHsbFun (*this);
31 | }
32 | int CyrilHsbFun::size() {
33 | return 3;
34 | }
35 | void CyrilHsbFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float h, s, b;
38 | switch (c->size()) {
39 | case 1:
40 | b = 255;
41 | s = 255;
42 | h = _s.stk->top(); _s.stk->pop();
43 | break;
44 | case 2:
45 | b = _s.stk->top(); _s.stk->pop();
46 | s = 255;
47 | h = _s.stk->top(); _s.stk->pop();
48 | break;
49 | case 3:
50 | b = _s.stk->top(); _s.stk->pop();
51 | s = _s.stk->top(); _s.stk->pop();
52 | h = _s.stk->top(); _s.stk->pop();
53 | break;
54 | }
55 | ofColor col;
56 | col.setHsb(h, s, b);
57 | //col = ofColor(col.r, col.g, col.b);
58 | _s.stk->push(float(col.r));
59 | _s.stk->push(float(col.g));
60 | _s.stk->push(float(col.b));
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilHsbFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilHsbFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilHsbFun__
10 | #define __cyril2__CyrilHsbFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilHsbFun : public CyrilFun {
16 | public:
17 | CyrilHsbFun(Cyril* _c);
18 | CyrilHsbFun(const CyrilHsbFun &other);
19 | virtual ~CyrilHsbFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilHsbFun__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilLerpFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLerpFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilLerpFun.h"
10 |
11 | CyrilLerpFun::CyrilLerpFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 2 || s == 3 || s == 7)) {
14 | yyerror("Lerp function has 2 or 3 arguments (or 7 with colors)");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilLerpFun::CyrilLerpFun(const CyrilLerpFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilLerpFun::~CyrilLerpFun () {
23 | delete c;
24 | }
25 | void CyrilLerpFun::print() {
26 | c->print();
27 | cout << "Lerp" << endl;
28 | }
29 | Cyril * CyrilLerpFun::clone () {
30 | return new CyrilLerpFun (*this);
31 | }
32 | int CyrilLerpFun::size() {
33 | int sz = c->size();
34 | if (sz == 2 || sz == 7) {
35 | return 3;
36 | }
37 | return 1;
38 | }
39 | void CyrilLerpFun::eval(CyrilState &_s) {
40 | c->eval(_s);
41 | float i, v1, v2, v3;
42 | ofColor _c;
43 | switch (c->size()) {
44 | case 2:
45 | i = _s.stk->top(); _s.stk->pop();
46 | v1 = _s.stk->top(); _s.stk->pop();
47 | if (_s.cs->count(v1)) {
48 | _c = (*_s.cs)[v1]->lerp(i);
49 | }
50 | else if (_s.parent->cs->count(v1)) {
51 | _c = (*_s.parent->cs)[v1]->lerp(i);
52 | }
53 | else {
54 | //cout << "Error: can't find palette!" << endl;
55 | _s.stk->push(255);
56 | _s.stk->push(255);
57 | _s.stk->push(255);
58 | break;
59 | }
60 | _s.stk->push(_c.r);
61 | _s.stk->push(_c.g);
62 | _s.stk->push(_c.b);
63 | break;
64 | case 3:
65 | i = _s.stk->top(); _s.stk->pop();
66 | v2 = _s.stk->top(); _s.stk->pop();
67 | v1 = _s.stk->top(); _s.stk->pop();
68 | _s.stk->push(ofLerp(v1, v2, i));
69 | break;
70 | case 7:
71 | i = _s.stk->top(); _s.stk->pop();
72 | v3 = _s.stk->top(); _s.stk->pop();
73 | v2 = _s.stk->top(); _s.stk->pop();
74 | v1 = _s.stk->top(); _s.stk->pop();
75 | ofColor source(v1, v2, v3);
76 | v3 = _s.stk->top(); _s.stk->pop();
77 | v2 = _s.stk->top(); _s.stk->pop();
78 | v1 = _s.stk->top(); _s.stk->pop();
79 | ofColor result = ofColor(v1, v2, v3).lerp(source, i);
80 | _s.stk->push(result.r);
81 | _s.stk->push(result.g);
82 | _s.stk->push(result.b);
83 | }
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilLerpFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLerpFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilLerpFun__
10 | #define __cyril2__CyrilLerpFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 | #include "Palette.h"
15 |
16 | class CyrilLerpFun : public CyrilFun {
17 | public:
18 | CyrilLerpFun(Cyril* _c);
19 | CyrilLerpFun(const CyrilLerpFun &other);
20 | virtual ~CyrilLerpFun ();
21 | virtual void print();
22 | virtual Cyril *clone ();
23 | virtual int size();
24 | virtual void eval(CyrilState &);
25 | };
26 |
27 |
28 | #endif /* defined(__cyril2__CyrilLerpFun__) */
29 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilMapFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilMapFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilMapFun.h"
10 |
11 | CyrilMapFun::CyrilMapFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 5)) {
14 | yyerror("Map function has 5 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilMapFun::CyrilMapFun(const CyrilMapFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilMapFun::~CyrilMapFun () {
23 | delete c;
24 | }
25 | void CyrilMapFun::print() {
26 | c->print();
27 | cout << "MAP" << endl;
28 | }
29 | Cyril * CyrilMapFun::clone () {
30 | return new CyrilMapFun (*this);
31 | }
32 | int CyrilMapFun::size() {
33 | return 1;
34 | }
35 | void CyrilMapFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float v, min1, max1, min2, max2;
38 | max2 = _s.stk->top(); _s.stk->pop();
39 | min2 = _s.stk->top(); _s.stk->pop();
40 | max1 = _s.stk->top(); _s.stk->pop();
41 | min1 = _s.stk->top(); _s.stk->pop();
42 | v = _s.stk->top(); _s.stk->pop();
43 | _s.stk->push(ofMap(v, min1, max1, min2, max2));
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilMapFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilMapFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilMapFun__
10 | #define __cyril2__CyrilMapFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilMapFun : public CyrilFun {
16 | public:
17 | CyrilMapFun(Cyril* _c);
18 | CyrilMapFun(const CyrilMapFun &other);
19 | virtual ~CyrilMapFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilMapFun__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilNoiseFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoiseFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilNoiseFun.h"
10 |
11 | CyrilNoiseFun::CyrilNoiseFun(Cyril* _c) : CyrilFun(_c) {
12 | int s = c->size();
13 | if (!(s == 1 || s == 2 || s == 3)) {
14 | yyerror("Noise function has 1, 2 or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilNoiseFun::CyrilNoiseFun(const CyrilNoiseFun &other) {
20 | c = other.c->clone ();
21 | }
22 |
23 | CyrilNoiseFun::~CyrilNoiseFun () {
24 | delete c;
25 | }
26 |
27 | void CyrilNoiseFun::print() {
28 | c->print();
29 | cout << "Noise" << endl;
30 | }
31 | Cyril * CyrilNoiseFun::clone () {
32 | return new CyrilNoiseFun (*this);
33 | }
34 | int CyrilNoiseFun::size() {
35 | return 1;
36 | }
37 | void CyrilNoiseFun::eval(CyrilState &_s) {
38 | c->eval(_s);
39 | float r, x, y, z;
40 | switch (c->size()) {
41 | case 1:
42 | x = _s.stk->top(); _s.stk->pop();
43 | r = ofNoise(x);
44 | break;
45 | case 2:
46 | x = _s.stk->top(); _s.stk->pop();
47 | y = _s.stk->top(); _s.stk->pop();
48 | r = ofNoise(x, y);
49 | break;
50 | case 3:
51 | x = _s.stk->top(); _s.stk->pop();
52 | y = _s.stk->top(); _s.stk->pop();
53 | z = _s.stk->top(); _s.stk->pop();
54 | r = ofNoise(x, y, z);
55 | break;
56 | }
57 | _s.stk->push(r);
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilNoiseFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoiseFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilNoiseFun__
10 | #define __cyril2__CyrilNoiseFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilNoiseFun : public CyrilFun {
16 | public:
17 | CyrilNoiseFun(Cyril* _c);
18 | CyrilNoiseFun(const CyrilNoiseFun &other);
19 | virtual ~CyrilNoiseFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilNoiseFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilPaletteFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPaletteFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPaletteFun.h"
10 |
11 | CyrilPaletteFun::CyrilPaletteFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 1 || s == 2)) {
14 | yyerror("Palette function has 1 or 2 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilPaletteFun::CyrilPaletteFun(const CyrilPaletteFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilPaletteFun::~CyrilPaletteFun () {
23 | delete c;
24 | }
25 | void CyrilPaletteFun::print() {
26 | c->print();
27 | cout << "Palette" << endl;
28 | }
29 | Cyril * CyrilPaletteFun::clone () {
30 | return new CyrilPaletteFun (*this);
31 | }
32 | int CyrilPaletteFun::size() {
33 | return 3;
34 | }
35 | void CyrilPaletteFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float p, d;
38 | if (c->size() == 2) {
39 | d = _s.stk->top(); _s.stk->pop();
40 | }
41 | else {
42 | d = ofRandomuf();
43 | }
44 | p = _s.stk->top(); _s.stk->pop();
45 | ofColor _c = (*_s.cs)[p]->getColorAt(d);
46 | _s.stk->push(_c.r);
47 | _s.stk->push(_c.g);
48 | _s.stk->push(_c.b);
49 | }
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilPaletteFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPaletteFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPaletteFun__
10 | #define __cyril2__CyrilPaletteFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 | #include "Palette.h"
15 |
16 | class CyrilPaletteFun : public CyrilFun {
17 | public:
18 | CyrilPaletteFun(Cyril* _c);
19 | CyrilPaletteFun(const CyrilPaletteFun &other);
20 | virtual ~CyrilPaletteFun ();
21 | virtual void print();
22 | virtual Cyril *clone ();
23 | virtual int size();
24 | virtual void eval(CyrilState &);
25 | };
26 |
27 | #endif /* defined(__cyril2__CyrilPaletteFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilRandFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRandFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilRandFun.h"
10 |
11 | CyrilRandFun::CyrilRandFun(Cyril * _c) : CyrilFun(_c) {
12 | int s = _c->size();
13 | if (!(s == 0 || s == 1 || s == 2)) {
14 | yyerror("Rand function has 0, 1 or 2 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilRandFun::CyrilRandFun(const CyrilRandFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilRandFun::~CyrilRandFun () {
23 | delete c;
24 | }
25 | void CyrilRandFun::print() {
26 | c->print();
27 | cout << "Rand" << endl;
28 | }
29 | Cyril * CyrilRandFun::clone () {
30 | return new CyrilRandFun (*this);
31 | }
32 | int CyrilRandFun::size() {
33 | return 1;
34 | }
35 | void CyrilRandFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float r, x, y;
38 | switch (c->size()) {
39 | case 0:
40 | r = ofRandomf();
41 | break;
42 | case 1:
43 | x = _s.stk->top(); _s.stk->pop();
44 | r = ofRandom(x);
45 | break;
46 | case 2:
47 | x = _s.stk->top(); _s.stk->pop();
48 | y = _s.stk->top(); _s.stk->pop();
49 | r = ofRandom(x, y);
50 | break;
51 | }
52 | _s.stk->push(r);
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilRandFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRandFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilRandFun__
10 | #define __cyril2__CyrilRandFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilRandFun : public CyrilFun {
16 | public:
17 | CyrilRandFun(Cyril* _c);
18 | CyrilRandFun(const CyrilRandFun &other);
19 | virtual ~CyrilRandFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilRandFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilSinFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSinFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilSinFun.h"
10 |
11 | CyrilSinFun::CyrilSinFun(Cyril* _c) : CyrilFun(_c) {
12 | int s = c->size();
13 | if (!(s == 1)) {
14 | yyerror("Sin function 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilSinFun::CyrilSinFun(const CyrilSinFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilSinFun::~CyrilSinFun () {
23 | delete c;
24 | }
25 | void CyrilSinFun::print() {
26 | c->print();
27 | cout << "Sin" << endl;
28 | }
29 | Cyril * CyrilSinFun::clone () {
30 | return new CyrilSinFun (*this);
31 | }
32 | int CyrilSinFun::size() {
33 | return 1;
34 | }
35 | void CyrilSinFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float result = sin(_s.stk->top());
38 | _s.stk->pop();
39 | _s.stk->push(result);
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilSinFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSinFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilSinFun__
10 | #define __cyril2__CyrilSinFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilSinFun : public CyrilFun {
16 | public:
17 | CyrilSinFun(Cyril* _c);
18 | CyrilSinFun(const CyrilSinFun &other);
19 | virtual ~CyrilSinFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 |
28 | #endif /* defined(__cyril2__CyrilSinFun__) */
29 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilTanFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilTanFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilTanFun.h"
10 |
11 | CyrilTanFun::CyrilTanFun(Cyril* _c) : CyrilFun(_c) {
12 | int s = c->size();
13 | if (!(s == 1)) {
14 | yyerror("Tan function 1 argument");
15 | valid = false;
16 | }
17 | }
18 | CyrilTanFun::CyrilTanFun (const CyrilTanFun &other) {
19 | c = other.c->clone ();
20 | }
21 | CyrilTanFun::~CyrilTanFun () {
22 | delete c;
23 | }
24 | void CyrilTanFun::print() {
25 | c->print();
26 | cout << "Tan" << endl;
27 | }
28 | Cyril * CyrilTanFun::clone () {
29 | return new CyrilTanFun (*this);
30 | }
31 | int CyrilTanFun::size() {
32 | return 1;
33 | }
34 | void CyrilTanFun::eval(CyrilState &_s) {
35 | c->eval(_s);
36 | float result = tan(_s.stk->top());
37 | _s.stk->pop();
38 | _s.stk->push(result);
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilTanFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilTanFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilTanFun__
10 | #define __cyril2__CyrilTanFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilTanFun : public CyrilFun {
16 | public:
17 | CyrilTanFun(Cyril* _c);
18 | CyrilTanFun(const CyrilTanFun &other);
19 | virtual ~CyrilTanFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilTanFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilWaveFun.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilWaveFun.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilWaveFun.h"
10 |
11 | CyrilWaveFun::CyrilWaveFun(Cyril* _c) : CyrilFun(_c) {
12 | int s = c->size();
13 | if (!(s == 1)) {
14 | yyerror("Wave function 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilWaveFun::CyrilWaveFun(const CyrilWaveFun &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilWaveFun::~CyrilWaveFun () {
23 | delete c;
24 | }
25 | void CyrilWaveFun::print() {
26 | c->print();
27 | cout << "Wave" << endl;
28 | }
29 | Cyril * CyrilWaveFun::clone () {
30 | return new CyrilWaveFun (*this);
31 | }
32 | int CyrilWaveFun::size() {
33 | return 1;
34 | }
35 | void CyrilWaveFun::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float result = (sin(((*_s.sym)[REG_TIME] / _s.stk->top())) * 0.5) + 0.5;
38 | _s.stk->pop();
39 | _s.stk->push(result);
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/src/Cyril/Funs/CyrilWaveFun.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilWaveFun.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilWaveFun__
10 | #define __cyril2__CyrilWaveFun__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilFun.h"
14 |
15 | class CyrilWaveFun : public CyrilFun {
16 | public:
17 | CyrilWaveFun(Cyril* _c);
18 | CyrilWaveFun (const CyrilWaveFun &other);
19 | virtual ~CyrilWaveFun ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilWaveFun__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilAssign.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilAssign.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilAssign_h
10 | #define cyril2_CyrilAssign_h
11 |
12 | #include "cmds.h"
13 |
14 | class CyrilAssign : public Cyril {
15 | int loc;
16 | Cyril* c;
17 | public:
18 | CyrilAssign(int _i, Cyril* _c) : loc(_i), c(_c) {
19 | valid = c->valid;
20 | int sz = _c->size();
21 | if (!(sz == 1 || sz == 3)) {
22 | yyerror("Assignment requires 1 argument (or 3 for color)");
23 | valid = false;
24 | }
25 | }
26 | CyrilAssign (const CyrilAssign &other) {
27 | loc = other.loc;
28 | c = other.c->clone ();
29 | }
30 | virtual ~CyrilAssign ()
31 | {
32 | delete c;
33 | }
34 | void print() {
35 | c->print();
36 | cout << "Assign: " << loc << endl;
37 | }
38 | virtual Cyril *clone () { return new CyrilAssign (*this); }
39 | virtual int size() { return 0; }
40 | virtual void eval(CyrilState &_s) {
41 | c->eval(_s);
42 | switch (c->size()) {
43 | case 1:
44 | (*_s.sym)[loc] = _s.stk->top();
45 | _s.stk->pop();
46 | break;
47 | case 3:
48 | float b = _s.stk->top(); _s.stk->pop();
49 | float g = _s.stk->top(); _s.stk->pop();
50 | float r = _s.stk->top(); _s.stk->pop();
51 | (*_s.sym)[loc] = ofColor(r, g, b).getHex();
52 | break;
53 | }
54 | }
55 | virtual int matchPushPop() { return c->matchPushPop(); }
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilColorLoad.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilColorLoad.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilColorLoad.h"
10 |
11 |
12 | CyrilColorLoad::CyrilColorLoad(int _i) : loc(_i) {
13 | valid = true;
14 | }
15 | CyrilColorLoad::CyrilColorLoad (const CyrilColorLoad &other) {
16 | loc = other.loc;
17 | }
18 | CyrilColorLoad::~CyrilColorLoad ()
19 | {
20 | }
21 | void CyrilColorLoad::print() {
22 | cout << "Color Load: " << loc << endl;
23 | }
24 | Cyril * CyrilColorLoad::clone () { return new CyrilColorLoad (*this); }
25 | int CyrilColorLoad::size() {
26 | return 3;
27 | }
28 | void CyrilColorLoad::eval(CyrilState &_s) {
29 | ofColor c = ofColor::fromHex((*_s.sym)[loc]);
30 | //cout << "Load color: " << c << endl;
31 | _s.stk->push(float(c.r));
32 | _s.stk->push(float(c.g));
33 | _s.stk->push(float(c.b));
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilColorLoad.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilColorLoad.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilColorLoad__
10 | #define __cyril2__CyrilColorLoad__
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 |
16 | class CyrilColorLoad : public Cyril {
17 | int loc;
18 | public:
19 | CyrilColorLoad(int _i);
20 | CyrilColorLoad (const CyrilColorLoad &other) ;
21 | virtual ~CyrilColorLoad ();
22 | void print();
23 | virtual Cyril *clone ();
24 | virtual int size();
25 | virtual void eval(CyrilState &);
26 | };
27 |
28 |
29 | #endif /* defined(__cyril2__CyrilColorLoad__) */
30 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilDebugOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilDebugOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilDebugOp.h"
10 |
11 | CyrilDebugOp::CyrilDebugOp (Cyril* _c) : CyrilOp(_c) {
12 |
13 | }
14 |
15 | CyrilDebugOp::CyrilDebugOp (const CyrilDebugOp &other) {
16 | c = other.c->clone ();
17 | }
18 | CyrilDebugOp::~CyrilDebugOp ()
19 | {
20 | delete c;
21 | }
22 | void CyrilDebugOp::print() {
23 | c->print();
24 | cout << "Debug" << endl;
25 | }
26 | Cyril * CyrilDebugOp::clone () {
27 | return new CyrilDebugOp (*this);
28 | }
29 | int CyrilDebugOp::size() {
30 | return 0;
31 | }
32 | void CyrilDebugOp::eval(CyrilState &_s) {
33 | c->eval(_s);
34 | cout << "DEBUG:";
35 | int sz = c->size();
36 | for (int i = 0; i < sz; i++) {
37 | cout << " " << _s.stk->top();
38 | _s.stk->pop();
39 | }
40 | cout << endl;
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilDebugOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilDebugOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilDebugOp__
10 | #define __cyril2__CyrilDebugOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilDebugOp : public CyrilOp {
16 | public:
17 | CyrilDebugOp(Cyril* _c);
18 | CyrilDebugOp (const CyrilDebugOp &other);
19 | virtual ~CyrilDebugOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 | #endif /* defined(__cyril2__CyrilDebugOp__) */
26 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilDo.h:
--------------------------------------------------------------------------------
1 | //
2 | // CurilDo.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CurilDo_h
10 | #define cyril2_CurilDo_h
11 |
12 | #include "cmds.h"
13 |
14 | class CyrilDo : public Cyril {
15 | Cyril* e;
16 | Cyril* c;
17 | public:
18 | CyrilDo(Cyril* _e, Cyril* _c) : e(_e), c(_c) {
19 | valid = c->valid;
20 | if (_e->size() != 1) {
21 | yyerror("Incorrect size of expression in do loop");
22 | valid = false;
23 | }
24 | }
25 | CyrilDo (const CyrilDo &other) {
26 | e = other.e->clone ();
27 | c = other.c->clone ();
28 | }
29 | virtual ~CyrilDo ()
30 | {
31 | delete e;
32 | delete c;
33 | }
34 | void print() {
35 | c->print();
36 | e->print();
37 | cout << "Do: " << endl;
38 | }
39 | virtual Cyril *clone () { return new CyrilDo (*this); }
40 | virtual int size() { return 0; }
41 | virtual void eval(CyrilState &_s) {
42 | e->eval(_s);
43 | float val = _s.stk->top();
44 | _s.stk->pop();
45 | while (val > 0) {
46 | c->eval(_s);
47 | val--;
48 | }
49 | }
50 | virtual int matchPushPop() { return c->matchPushPop(); }
51 | };
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilFor.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFor.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilFor_h
10 | #define cyril2_CyrilFor_h
11 |
12 | #include "cmds.h"
13 |
14 | class CyrilFor : public Cyril {
15 | int loc;
16 | Cyril* e1;
17 | Cyril* e2;
18 | Cyril* e3;
19 | float step;
20 | Cyril* c;
21 | public:
22 | CyrilFor(int _i, Cyril* _e1, Cyril* _e2, Cyril* _e3, Cyril* _c)
23 | : loc(_i), e1(_e1), e2(_e2), e3(_e3), c(_c) {
24 | valid = e1->valid && e2->valid && e3->valid && c->valid;
25 | if (_e1->size() != 1 || _e2->size() != 1 || _e3->size() != 1) {
26 | yyerror("Incorrect size of expression in for loop");
27 | valid = false;
28 | }
29 | CyrilPush *sC = dynamic_cast(e3);
30 | if (sC == NULL) {
31 | yyerror("Step of FOR loop must be a number");
32 | valid = false;
33 | }
34 | else {
35 | step = sC->getValue();
36 | }
37 | }
38 | CyrilFor (const CyrilFor &other) {
39 | loc = other.loc;
40 | e1 = other.e1->clone ();
41 | e2 = other.e2->clone ();
42 | e3 = other.e3->clone ();
43 | c = other.c->clone ();
44 | }
45 | virtual ~CyrilFor ()
46 | {
47 | delete e1;
48 | delete e2;
49 | delete e3;
50 | delete c;
51 | }
52 | void print() {
53 | e1->print();
54 | e2->print();
55 | e3->print();
56 | c->print();
57 | cout << "For: " << loc << endl;
58 | }
59 | virtual Cyril *clone () { return new CyrilFor (*this); }
60 | virtual int size() { return 0; }
61 | virtual void eval(CyrilState &_s) { e1->eval(_s);
62 | (*_s.sym)[loc] = _s.stk->top();
63 | _s.stk->pop();
64 | float limit;
65 | e2->eval(_s);
66 | limit = _s.stk->top();
67 | _s.stk->pop();
68 | while ((*_s.sym)[loc] < limit) {
69 | c->eval(_s);
70 | (*_s.sym)[loc] += step;
71 | }
72 | }
73 | virtual int matchPushPop() { return c->matchPushPop(); }
74 | };
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilHexColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilHexColor.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilHexColor_h
10 | #define cyril2_CyrilHexColor_h
11 |
12 |
13 | #include "cmds.h"
14 |
15 |
16 | class CyrilHexColor : public Cyril {
17 | string s;
18 | float r,g,b;
19 | public:
20 | CyrilHexColor(const char * _s) : s(_s) {
21 | string converter(s);
22 | stringstream sr(converter.substr(0,2));
23 | stringstream sg(converter.substr(2,2));
24 | stringstream sb(converter.substr(4,2));
25 | int ir, ig, ib;
26 | sr >> hex >> ir;
27 | sg >> hex >> ig;
28 | sb >> hex >> ib;
29 | r = ir; g = ig; b = ib;
30 | //cout << "Debug color: " << r << "," << g << "," << b << endl;
31 | valid = true;
32 | }
33 | CyrilHexColor (const CyrilHexColor &other) {
34 | s = other.s;
35 | }
36 | virtual ~CyrilHexColor ()
37 | {
38 | }
39 | void print() {
40 | cout << "Hex: " << s << endl;
41 | }
42 | virtual Cyril *clone () { return new CyrilHexColor (*this); }
43 | virtual int size() { return 3; }
44 | virtual void eval(CyrilState &_s) {
45 | _s.stk->push(r);
46 | _s.stk->push(g);
47 | _s.stk->push(b);
48 | }
49 | };
50 |
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilIf.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilIf.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilIf_h
10 | #define cyril2_CyrilIf_h
11 |
12 | #include "cmds.h"
13 |
14 |
15 | class CyrilIf : public Cyril {
16 | Cyril* e;
17 | Cyril* c;
18 | public:
19 | CyrilIf(Cyril* _e, Cyril* _c) : e(_e), c(_c) {
20 | valid = e->valid && c->valid;
21 | if (_e->size() != 1) {
22 | yyerror("Incorrect size of expression in if condition");
23 | valid = false;
24 | }
25 | }
26 | CyrilIf (const CyrilIf &other) {
27 | e = other.e->clone ();
28 | c = other.c->clone ();
29 | }
30 | virtual ~CyrilIf ()
31 | {
32 | delete e;
33 | delete c;
34 | }
35 | void print() {
36 | c->print();
37 | e->print();
38 | cout << "If: " << endl;
39 | }
40 | virtual Cyril *clone () { return new CyrilIf (*this); }
41 | virtual int size() { return 0; }
42 | virtual void eval(CyrilState &_s) {
43 | e->eval(_s);
44 | float b = _s.stk->top();
45 | _s.stk->pop();
46 | if (b > 0) {
47 | c->eval(_s);
48 | }
49 | }
50 | virtual int matchPushPop() { return c->matchPushPop(); }
51 | };
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilList.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilList.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilList_h
10 | #define cyril2_CyrilList_h
11 |
12 | #include "cmds.h"
13 |
14 | class CyrilList : public Cyril {
15 | Cyril* c1;
16 | Cyril* c2;
17 | public:
18 | CyrilList(Cyril* _c1, Cyril* _c2) : c1(_c1), c2(_c2) {
19 | valid = c1->valid && c2->valid;
20 | }
21 | CyrilList (const CyrilList &other) {
22 | c1 = other.c1->clone ();
23 | c2 = other.c2->clone ();
24 | }
25 | virtual ~CyrilList ()
26 | {
27 | delete c1;
28 | delete c2;
29 | }
30 | void print() {
31 | c1->print();
32 | c2->print();
33 | }
34 | virtual Cyril *clone () { return new CyrilList (*this); }
35 | virtual int size() { return c1->size() + c2->size(); }
36 | virtual void update(CyrilState &_s) {
37 | c1->update(_s);
38 | c2->update(_s);
39 | }
40 | virtual void eval(CyrilState &_s) {
41 | c1->eval(_s);
42 | c2->eval(_s);
43 | }
44 | virtual int matchPushPop() {
45 | return c1->matchPushPop() + c2->matchPushPop();
46 | }
47 | };
48 |
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilLoad.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLoad.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilLoad_h
10 | #define cyril2_CyrilLoad_h
11 |
12 | #include "cmds.h"
13 |
14 |
15 | class CyrilLoad : public Cyril {
16 | int loc;
17 | public:
18 | CyrilLoad(int _i) : loc(_i) {
19 | valid = true;
20 | }
21 | CyrilLoad (const CyrilLoad &other) {
22 | loc = other.loc;
23 | }
24 | virtual ~CyrilLoad ()
25 | {
26 | }
27 | void print() {
28 | cout << "Load: " << loc << endl;
29 | }
30 | virtual Cyril *clone () { return new CyrilLoad (*this); }
31 | virtual int size() { return 1; }
32 | virtual void eval(CyrilState &_s) {
33 | //cout << "Load " << loc << ": " << (*_s.sym)[loc] << endl;
34 | //cout << _s.sym->count(loc) << endl;
35 | if ((*_s.sym)[loc] == 0 && (*_s.parent->sym)[loc] != 0) {
36 | _s.stk->push((*_s.parent->sym)[loc]);
37 | }
38 | else {
39 | _s.stk->push((*_s.sym)[loc]);
40 | }
41 | }
42 | };
43 |
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilNamedColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNamedColor.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 18/11/2013.
6 | //
7 | //
8 |
9 | #ifndef Cyril_CyrilNamedColor_h
10 | #define Cyril_CyrilNamedColor_h
11 |
12 |
13 | #include "cmds.h"
14 |
15 | extern map < string, ofColor > colorNameMap;
16 |
17 |
18 | class CyrilNamedColor : public Cyril {
19 | string s;
20 | float r,g,b;
21 | public:
22 |
23 | CyrilNamedColor(const char * _s) : s(_s) {
24 |
25 | ofColor c = colorNameMap[s];
26 |
27 | r = c.r;
28 | g = c.g;
29 | b = c.b;
30 | //cout << "Debug color: " << r << "," << g << "," << b << endl;
31 | valid = true;
32 | }
33 | CyrilNamedColor (const CyrilNamedColor &other) {
34 | s = other.s;
35 | }
36 | virtual ~CyrilNamedColor ()
37 | {
38 | }
39 | void print() {
40 | cout << "Named color: " << s << endl;
41 | }
42 | virtual Cyril *clone () { return new CyrilNamedColor (*this); }
43 | virtual int size() { return 3; }
44 | virtual void eval(CyrilState &_s) {
45 | _s.stk->push(r);
46 | _s.stk->push(g);
47 | _s.stk->push(b);
48 | }
49 | };
50 |
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilPush.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPush.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilPush_h
10 | #define cyril2_CyrilPush_h
11 |
12 |
13 | #include "cmds.h"
14 |
15 | class CyrilPush : public Cyril {
16 | float f;
17 | public:
18 | CyrilPush(float _f) : f(_f) {
19 | valid = true;
20 | }
21 | CyrilPush (const CyrilPush &other) {
22 | f = other.f;
23 | }
24 | virtual ~CyrilPush ()
25 | {
26 | }
27 | void print() {
28 | cout << "Push: " << f << endl;
29 | }
30 | virtual Cyril *clone () { return new CyrilPush (*this); }
31 | int size() { return 1; }
32 | float getValue() { return f; }
33 | virtual void eval(CyrilState &_s) {
34 | _s.stk->push(f);
35 | }
36 | };
37 |
38 |
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilUnaryOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilUnaryOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilUnaryOp_h
10 | #define cyril2_CyrilUnaryOp_h
11 |
12 | #include "cmds.h"
13 |
14 |
15 | class CyrilUnaryOp : public Cyril {
16 | string o;
17 | int op;
18 | Cyril* e;
19 | public:
20 | CyrilUnaryOp(string _o, Cyril* _e) : o(_o), e(_e) {
21 | valid = e->valid;
22 | if ("!" == o) {
23 | op = OP_NOT;
24 | if (e->size() != 1) {
25 | yyerror("Operand to ! should be 1 value");
26 | valid = false;
27 | }
28 | }
29 | else {
30 | yyerror("Unknown operation");
31 | valid = false;
32 | }
33 | }
34 | CyrilUnaryOp (const CyrilUnaryOp &other) {
35 | o = other.o;
36 | e = other.e->clone ();
37 | }
38 | virtual ~CyrilUnaryOp ()
39 | {
40 | delete e;
41 | }
42 | void print() {
43 | e->print();
44 | cout << "Unary: " << o << endl;
45 | }
46 | virtual Cyril *clone () { return new CyrilUnaryOp (*this); }
47 | virtual int size() { return 1; }
48 | virtual void eval(CyrilState &_s) {
49 | e->eval(_s);
50 | float v1 = _s.stk->top();
51 | _s.stk->pop();
52 | switch (op) {
53 | case OP_NOT:
54 | if (v1 > 0) {
55 | _s.stk->push(0);
56 | }
57 | else {
58 | _s.stk->push(1);
59 | }
60 | break;
61 | default:
62 | _s.stk->push(0);
63 | cout << "Warning unknown unary operator " << op << endl;
64 | }
65 | }
66 | };
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/src/Cyril/Lang/CyrilWhile.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilWhile.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilWhile_h
10 | #define cyril2_CyrilWhile_h
11 |
12 | #include "cmds.h"
13 |
14 | class CyrilWhile : public Cyril {
15 | Cyril* e;
16 | Cyril* c;
17 | public:
18 | CyrilWhile(Cyril* _e, Cyril* _c) : e(_e), c(_c) {
19 | valid = e->valid && c->valid;
20 | if (_e->size() != 1) {
21 | yyerror("Incorrect size of expression in while loop");
22 | valid = false;
23 | }
24 | }
25 | CyrilWhile (const CyrilWhile &other) {
26 | e = other.e->clone ();
27 | c = other.c->clone ();
28 | }
29 | virtual ~CyrilWhile ()
30 | {
31 | delete e;
32 | delete c;
33 | }
34 | void print() {
35 | c->print();
36 | e->print();
37 | cout << "While: " << endl;
38 | }
39 | virtual Cyril *clone () { return new CyrilWhile (*this); }
40 | virtual int size() { return 0; }
41 | virtual void eval(CyrilState &_s) {
42 | float test;
43 | e->eval(_s);
44 | test = _s.stk->top();
45 | _s.stk->pop();
46 | while (test > 0) {
47 | c->eval(_s);
48 | e->eval(_s);
49 | test = _s.stk->top();
50 | _s.stk->pop();
51 | }
52 | }
53 | virtual int matchPushPop() { return c->matchPushPop(); }
54 | };
55 |
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilAnimStep.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilAnimStep.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilAnimStep.h"
10 |
11 | CyrilAnimStep::CyrilAnimStep (float _n, Cyril* _e1, Cyril* _e2) : n(_n), e1(_e1), e2(_e2) {
12 |
13 | }
14 |
15 | CyrilAnimStep::CyrilAnimStep (const CyrilAnimStep &other) {
16 | n = other.n;
17 | e1 = other.e1->clone ();
18 | e2 = other.e2->clone ();
19 | }
20 | CyrilAnimStep::~CyrilAnimStep ()
21 | {
22 | delete e1;
23 | delete e2;
24 | }
25 | void CyrilAnimStep::print() {
26 | e1->print();
27 | e2->print();
28 | cout << "AnimStep " << n << endl;
29 | }
30 | Cyril * CyrilAnimStep::clone () {
31 | return new CyrilAnimStep (*this);
32 | }
33 | int CyrilAnimStep::size() {
34 | if (!dynamic_cast(e2)) {
35 | //cout << " " << n << " " << endl;
36 | // we're last so just report to stack and we're done
37 | return n;
38 | }
39 | //cout << " " << n + e2->size();
40 | return n + e2->size();
41 | }
42 | void CyrilAnimStep::eval(CyrilState &_s) {
43 | int step = _s.stk->top(); _s.stk->pop();
44 | int total = _s.stk->top(); _s.stk->pop();
45 | //cout << total << ":" << step << endl;
46 | if ((total - n) < step) {
47 | e1->eval(_s);
48 | }
49 | else {
50 | _s.stk->push(total - n);
51 | _s.stk->push(step);
52 | e2->eval(_s);
53 | }
54 | }
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilAnimStep.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilAnimStep.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilAnimStep__
10 | #define __cyril2__CyrilAnimStep__
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 |
15 | class CyrilAnimStep : public Cyril {
16 | float n;
17 | Cyril* e1;
18 | Cyril* e2;
19 | public:
20 | CyrilAnimStep(float _n, Cyril* _e1, Cyril* _e2);
21 | CyrilAnimStep (const CyrilAnimStep &other);
22 | virtual ~CyrilAnimStep ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | };
28 |
29 |
30 | #endif /* defined(__cyril2__CyrilAnimStep__) */
31 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilAnimation.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilAnimation.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilAnimation.h"
10 |
11 | CyrilAnimation::CyrilAnimation (Cyril* _e) : e(_e) {
12 |
13 | }
14 |
15 | CyrilAnimation::CyrilAnimation (const CyrilAnimation &other) {
16 | e = other.e->clone ();
17 | }
18 | CyrilAnimation::~CyrilAnimation ()
19 | {
20 | delete e;
21 | }
22 | void CyrilAnimation::print() {
23 | e->print();
24 | cout << "Animation" << endl;
25 | }
26 | Cyril * CyrilAnimation::clone () {
27 | return new CyrilAnimation (*this);
28 | }
29 | int CyrilAnimation::size() {
30 | return 0;
31 | }
32 | void CyrilAnimation::eval(CyrilState &_s) {
33 | //cout << endl << "Anim start" << endl;
34 | int total = e->size();
35 | // Push the total step size and current step time
36 | _s.stk->push(total);
37 | _s.stk->push((ofGetElapsedTimeMillis() % total));
38 | e->eval(_s);
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilAnimation.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilAnimation.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilAnimation__
10 | #define __cyril2__CyrilAnimation__
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 |
15 | class CyrilAnimation : public Cyril {
16 | Cyril* e;
17 | public:
18 | CyrilAnimation(Cyril* _e);
19 | CyrilAnimation (const CyrilAnimation &other);
20 | virtual ~CyrilAnimation ();
21 | virtual void print();
22 | virtual Cyril *clone ();
23 | virtual int size();
24 | virtual void eval(CyrilState &);
25 | };
26 |
27 |
28 | #endif /* defined(__cyril2__CyrilAnimation__) */
29 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBackgroundOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBackgroundOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilBackgroundOp.h"
10 |
11 | CyrilBackgroundOp::CyrilBackgroundOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 4 || s == 3 || s == 1)) {
14 | yyerror("background command requires 1 (palette) or 3 arguments (r,g,b) or a hex color");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilBackgroundOp::CyrilBackgroundOp (const CyrilBackgroundOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilBackgroundOp::~CyrilBackgroundOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilBackgroundOp::print() {
27 | c->print();
28 | cout << "Background" << endl;
29 | }
30 | Cyril * CyrilBackgroundOp::clone () {
31 | return new CyrilBackgroundOp (*this);
32 | }
33 | int CyrilBackgroundOp::size() {
34 | return 0;
35 | }
36 | void CyrilBackgroundOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r, g, b;
39 | float a = 255.0;
40 | if (c->size() == 4) {
41 | a = _s.stk->top(); _s.stk->pop();
42 | b = _s.stk->top(); _s.stk->pop();
43 | g = _s.stk->top(); _s.stk->pop();
44 | r = _s.stk->top(); _s.stk->pop();
45 | //ofBackground(r, g, b, a);
46 | ofClear(r, g, b, a);
47 | return;
48 | }
49 | if (c->size() == 3) {
50 | b = _s.stk->top(); _s.stk->pop();
51 | g = _s.stk->top(); _s.stk->pop();
52 | r = _s.stk->top(); _s.stk->pop();
53 | //ofBackground(r, g, b);
54 | ofClear(r, g, b, a);
55 | return;
56 | }
57 | else {
58 | b = _s.stk->top(); _s.stk->pop();
59 | // load palette from b
60 | (*_s.cs)[b]->drawBackground();
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBackgroundOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBackgroundOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilBackgroundOp__
10 | #define __cyril2__CyrilBackgroundOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 | #include "Palette.h"
15 |
16 | class CyrilBackgroundOp : public CyrilOp {
17 | public:
18 | CyrilBackgroundOp(Cyril* _c);
19 | CyrilBackgroundOp (const CyrilBackgroundOp &other);
20 | virtual ~CyrilBackgroundOp ();
21 | virtual void print();
22 | virtual Cyril *clone ();
23 | virtual int size();
24 | virtual void eval(CyrilState &);
25 | };
26 |
27 |
28 | #endif /* defined(__cyril2__CyrilBackgroundOp__) */
29 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBallDetailOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBallDetailOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilBallDetailOp.h"
10 |
11 | CyrilBallDetailOp::CyrilBallDetailOp (Cyril* _c) : CyrilOp(_c) {
12 | if (_c->size() != 1) {
13 | yyerror("BallDetail command requires 1 argument");
14 | valid = false;
15 | }
16 | }
17 |
18 | CyrilBallDetailOp::CyrilBallDetailOp (const CyrilBallDetailOp &other) {
19 | c = other.c->clone ();
20 | }
21 | CyrilBallDetailOp::~CyrilBallDetailOp ()
22 | {
23 | delete c;
24 | }
25 | void CyrilBallDetailOp::print() {
26 | c->print();
27 | cout << "BallDetail" << endl;
28 | }
29 | Cyril * CyrilBallDetailOp::clone () {
30 | return new CyrilBallDetailOp (*this);
31 | }
32 | int CyrilBallDetailOp::size() {
33 | return 0;
34 | }
35 | void CyrilBallDetailOp::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float d = _s.stk->top();
38 | _s.stk->pop();
39 | if (d > 5) d = 5;
40 | ofSetIcoSphereResolution(d);
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBallDetailOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBallDetailOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilBallDetailOp__
10 | #define __cyril2__CyrilBallDetailOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilBallDetailOp : public CyrilOp {
16 | public:
17 | CyrilBallDetailOp(Cyril* _c);
18 | CyrilBallDetailOp (const CyrilBallDetailOp &other);
19 | virtual ~CyrilBallDetailOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilBallDetailOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBallOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBallOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilBallOp.h"
10 |
11 | CyrilBallOp::CyrilBallOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1)) {
14 | yyerror("Ball command requires 0 or 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilBallOp::CyrilBallOp (const CyrilBallOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilBallOp::~CyrilBallOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilBallOp::print() {
27 | c->print();
28 | cout << "Ball" << endl;
29 | }
30 | Cyril * CyrilBallOp::clone () {
31 | return new CyrilBallOp (*this);
32 | }
33 | int CyrilBallOp::size() {
34 | return 0;
35 | }
36 | void CyrilBallOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r;
39 | if (c->size() == 1) {
40 | r = _s.stk->top();
41 | _s.stk->pop();
42 | }
43 | else {
44 | r = 1;
45 | }
46 | ofDrawIcoSphere(r);
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBallOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBallOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilBallOp__
10 | #define __cyril2__CyrilBallOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilBallOp : public CyrilOp {
16 | public:
17 | CyrilBallOp(Cyril* _c);
18 | CyrilBallOp (const CyrilBallOp &other);
19 | virtual ~CyrilBallOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 | #endif /* defined(__cyril2__CyrilBallOp__) */
26 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBinaryOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBinaryOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilBinaryOp_h
10 | #define cyril2_CyrilBinaryOp_h
11 |
12 | #include "cmds.h"
13 |
14 |
15 | class CyrilBinaryOp : public Cyril {
16 | string o;
17 | int op;
18 | Cyril* e1;
19 | Cyril* e2;
20 | public:
21 | CyrilBinaryOp(string _o, Cyril* _e1, Cyril* _e2) : o(_o), e1(_e1), e2(_e2) {
22 | valid = e1->valid && e2->valid;
23 | if ("+" == o) {
24 | op = OP_PLUS;
25 | if (e1->size() != 1) {
26 | yyerror("Left operand to + should be 1 value");
27 | valid = false;
28 | }
29 | if (e2->size() != 1) {
30 | yyerror("Right operand to + should be 1 value");
31 | valid = false;
32 | }
33 | }
34 | else if ("-" == o) {
35 | op = OP_MINUS;
36 | if (e1->size() != 1) {
37 | yyerror("Left operand to - should be 1 value");
38 | valid = false;
39 | }
40 | if (e2->size() != 1) {
41 | yyerror("Right operand to - should be 1 value");
42 | valid = false;
43 | }
44 | }
45 | else if ("/" == o) {
46 | op = OP_DIV;
47 | if (e1->size() != 1) {
48 | yyerror("Left operand to / should be 1 value");
49 | valid = false;
50 | }
51 | if (e2->size() != 1) {
52 | yyerror("Right operand to / should be 1 value");
53 | valid = false;
54 | }
55 | }
56 | else if ("*" == o) {
57 | op = OP_MULT;
58 | if (e1->size() != 1) {
59 | yyerror("Left operand to * should be 1 value");
60 | valid = false;
61 | }
62 | if (e2->size() != 1) {
63 | yyerror("Right operand to * should be 1 value");
64 | valid = false;
65 | }
66 | }
67 | else if ("%" == o) {
68 | op = OP_MOD;
69 | if (e1->size() != 1) {
70 | yyerror("Left operand to % should be 1 value");
71 | valid = false;
72 | }
73 | if (e2->size() != 1) {
74 | yyerror("Right operand to % should be 1 value");
75 | valid = false;
76 | }
77 | }
78 | else if ("==" == o) {
79 | op = OP_EQ;
80 | if (e1->size() != 1) {
81 | yyerror("Left operand to == should be 1 value");
82 | valid = false;
83 | }
84 | if (e2->size() != 1) {
85 | yyerror("Right operand to == should be 1 value");
86 | valid = false;
87 | }
88 | }
89 | else if ("!=" == o) {
90 | op = OP_NOTEQ;
91 | if (e1->size() != 1) {
92 | yyerror("Left operand to != should be 1 value");
93 | valid = false;
94 | }
95 | if (e2->size() != 1) {
96 | yyerror("Right operand to != should be 1 value");
97 | valid = false;
98 | }
99 | }
100 | else if ("<" == o) {
101 | op = OP_LESS;
102 | if (e1->size() != 1) {
103 | yyerror("Left operand to < should be 1 value");
104 | valid = false;
105 | }
106 | if (e2->size() != 1) {
107 | yyerror("Right operand to < should be 1 value");
108 | valid = false;
109 | }
110 | }
111 | else if ("<=" == o) {
112 | op = OP_LESSEQ;
113 | if (e1->size() != 1) {
114 | yyerror("Left operand to <= should be 1 value");
115 | valid = false;
116 | }
117 | if (e2->size() != 1) {
118 | yyerror("Right operand to <= should be 1 value");
119 | valid = false;
120 | }
121 | }
122 | else if (">" == o) {
123 | op = OP_GR;
124 | if (e1->size() != 1) {
125 | yyerror("Left operand to > should be 1 value");
126 | valid = false;
127 | }
128 | if (e2->size() != 1) {
129 | yyerror("Right operand to > should be 1 value");
130 | valid = false;
131 | }
132 | }
133 | else if (">=" == o) {
134 | op = OP_GREQ;
135 | if (e1->size() != 1) {
136 | yyerror("Left operand to >= should be 1 value");
137 | valid = false;
138 | }
139 | if (e2->size() != 1) {
140 | yyerror("Right operand to >= should be 1 value");
141 | valid = false;
142 | }
143 | }
144 | else if ("&" == o) {
145 | op = OP_AND;
146 | if (e1->size() != 1) {
147 | yyerror("Left operand to AND should be 1 value");
148 | valid = false;
149 | }
150 | if (e2->size() != 1) {
151 | yyerror("Right operand to AND should be 1 value");
152 | valid = false;
153 | }
154 | }
155 | else if ("|" == o) {
156 | op = OP_OR;
157 | if (e1->size() != 1) {
158 | yyerror("Left operand to OR should be 1 value");
159 | valid = false;
160 | }
161 | if (e2->size() != 1) {
162 | yyerror("Right operand to OR should be 1 value");
163 | valid = false;
164 | }
165 | }
166 | else {
167 | yyerror("Unknown operation");
168 | valid = false;
169 | }
170 | }
171 | CyrilBinaryOp (const CyrilBinaryOp &other) {
172 | o = other.o;
173 | e1 = other.e1->clone ();
174 | e2 = other.e2->clone ();
175 | }
176 | virtual ~CyrilBinaryOp ()
177 | {
178 | delete e1;
179 | delete e2;
180 | }
181 | void print() {
182 | e1->print();
183 | e2->print();
184 | cout << "Binary: " << o << endl;
185 | }
186 | virtual Cyril *clone () { return new CyrilBinaryOp (*this); }
187 | virtual int size() { return 1; }
188 | virtual void eval(CyrilState &_s) {
189 | e1->eval(_s);
190 | float v1 = _s.stk->top();
191 | _s.stk->pop();
192 | e2->eval(_s);
193 | float v2 = _s.stk->top();
194 | _s.stk->pop();
195 | switch (op) {
196 | case OP_MINUS:
197 | _s.stk->push(v1 - v2);
198 | break;
199 | case OP_PLUS:
200 | _s.stk->push(v1 + v2);
201 | break;
202 | case OP_MULT:
203 | _s.stk->push(v1 * v2);
204 | break;
205 | case OP_DIV:
206 | if (v2 == 0) {
207 | cout << "Warning: divide by 0" << endl;
208 | _s.stk->push(0);
209 | }
210 | else {
211 | _s.stk->push(v1 / v2);
212 | }
213 | break;
214 | case OP_MOD:
215 | if (v2 == 0) {
216 | cout << "Warning: divide(mod) by 0" << endl;
217 | _s.stk->push(0);
218 | }
219 | else {
220 | _s.stk->push(int(v1) % int(v2));
221 | }
222 | break;
223 | case OP_EQ:
224 | if (v1 == v2) {
225 | _s.stk->push(1);
226 | }
227 | else {
228 | _s.stk->push(0);
229 | }
230 | break;
231 | case OP_NOTEQ:
232 | if (v1 != v2) {
233 | _s.stk->push(1);
234 | }
235 | else {
236 | _s.stk->push(0);
237 | }
238 | break;
239 | case OP_LESS:
240 | if (v1 < v2) {
241 | _s.stk->push(1);
242 | }
243 | else {
244 | _s.stk->push(0);
245 | }
246 | break;
247 | case OP_LESSEQ:
248 | if (v1 <= v2) {
249 | _s.stk->push(1);
250 | }
251 | else {
252 | _s.stk->push(0);
253 | }
254 | break;
255 | case OP_GR:
256 | if (v1 > v2) {
257 | _s.stk->push(1);
258 | }
259 | else {
260 | _s.stk->push(0);
261 | }
262 | break;
263 | case OP_GREQ:
264 | if (v1 >= v2) {
265 | _s.stk->push(1);
266 | }
267 | else {
268 | _s.stk->push(0);
269 | }
270 | break;
271 | case OP_AND:
272 | if (v1 > 0 && v2 > 0) {
273 | _s.stk->push(1);
274 | }
275 | else {
276 | _s.stk->push(0);
277 | }
278 | break;
279 | case OP_OR:
280 | if (v1 > 0 || v2 > 0) {
281 | _s.stk->push(1);
282 | }
283 | else {
284 | _s.stk->push(0);
285 | }
286 | break;
287 | default:
288 | _s.stk->push(0);
289 | cout << "Warning unknown operator " << op << endl;
290 | }
291 | }
292 | };
293 |
294 |
295 | #endif
296 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBlink.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBlink.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilBlink.h"
10 |
11 | CyrilBlink::CyrilBlink (Cyril* _e, Cyril* _c) : e(_e), c(_c) {
12 | if (_e->size() != 2) {
13 | yyerror("Blink command requires on and off times");
14 | valid = false;
15 | }
16 | }
17 |
18 | CyrilBlink::CyrilBlink (const CyrilBlink &other) {
19 | e = other.e->clone ();
20 | c = other.c->clone ();
21 | }
22 | CyrilBlink::~CyrilBlink ()
23 | {
24 | delete e;
25 | delete c;
26 | }
27 | void CyrilBlink::print() {
28 | e->print();
29 | c->print();
30 | cout << "Blink" << endl;
31 | }
32 | Cyril * CyrilBlink::clone () {
33 | return new CyrilBlink (*this);
34 | }
35 | int CyrilBlink::size() {
36 | return 0;
37 | }
38 | void CyrilBlink::eval(CyrilState &_s) {
39 | e->eval(_s);
40 | float v2 = _s.stk->top();
41 | _s.stk->pop();
42 | float v1 = _s.stk->top();
43 | _s.stk->pop();
44 | //float t = (ofGetElapsedTimeMillis() / 1000.0);
45 | if ((v1 + v2) == 0) {
46 | cout << "Mod by 0 error in blink" << endl;
47 | return;
48 | }
49 | if ((ofGetElapsedTimeMillis() % int(v1 + v2)) < v1) {
50 | c->eval(_s);
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBlink.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBlink.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 07/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilBlink__
10 | #define __cyril2__CyrilBlink__
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 |
15 | class CyrilBlink : public Cyril {
16 | Cyril* e;
17 | Cyril* c;
18 | public:
19 | CyrilBlink(Cyril* _e, Cyril* _c);
20 | CyrilBlink (const CyrilBlink &other);
21 | virtual ~CyrilBlink ();
22 | virtual void print();
23 | virtual Cyril *clone ();
24 | virtual int size();
25 | virtual void eval(CyrilState &);
26 | virtual int matchPushPop() { return c->matchPushPop(); }
27 | };
28 |
29 | #endif /* defined(__cyril2__CyrilBlink__) */
30 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBoxOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBoxOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilBoxOp.h"
10 |
11 | CyrilBoxOp::CyrilBoxOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 3)) {
14 | yyerror("Box command requires 0, 1, or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilBoxOp::CyrilBoxOp (const CyrilBoxOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilBoxOp::~CyrilBoxOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilBoxOp::print() {
27 | c->print();
28 | cout << "Box" << endl;
29 | }
30 | Cyril * CyrilBoxOp::clone () {
31 | return new CyrilBoxOp (*this);
32 | }
33 | int CyrilBoxOp::size() {
34 | return 0;
35 | }
36 | void CyrilBoxOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float x, y, z, w, h, d;
39 | switch (c->size()) {
40 | case 3:
41 | d = _s.stk->top(); _s.stk->pop();
42 | h = _s.stk->top(); _s.stk->pop();
43 | w = _s.stk->top(); _s.stk->pop();
44 | break;
45 | case 1:
46 | d = _s.stk->top(); _s.stk->pop();
47 | h = d;
48 | w = d;
49 | break;
50 | default:
51 | d = 1;
52 | h = 1;
53 | w = 1;
54 | }
55 | ofDrawBox(w, h, d);
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilBoxOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilBoxOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilBoxOp__
10 | #define __cyril2__CyrilBoxOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilBoxOp : public CyrilOp {
16 | public:
17 | CyrilBoxOp(Cyril* _c);
18 | CyrilBoxOp (const CyrilBoxOp &other);
19 | virtual ~CyrilBoxOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilBoxOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilColorOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilColorOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilColorOp.h"
10 |
11 | CyrilColorOp::CyrilColorOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 1 || s == 2 || s == 3 || s == 4)) {
14 | yyerror("Color command needs 1, 2, 3 or 4 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilColorOp::CyrilColorOp (const CyrilColorOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilColorOp::~CyrilColorOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilColorOp::print() {
27 | c->print();
28 | cout << "Color" << endl;
29 | }
30 | Cyril * CyrilColorOp::clone () {
31 | return new CyrilColorOp (*this);
32 | }
33 | int CyrilColorOp::size() {
34 | return 0;
35 | }
36 | void CyrilColorOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r, g, b, a;
39 | switch (c->size()) {
40 | case 4:
41 | a = _s.stk->top(); _s.stk->pop();
42 | b = _s.stk->top(); _s.stk->pop();
43 | g = _s.stk->top(); _s.stk->pop();
44 | r = _s.stk->top(); _s.stk->pop();
45 | break;
46 | case 3:
47 | a = 255;
48 | b = _s.stk->top(); _s.stk->pop();
49 | g = _s.stk->top(); _s.stk->pop();
50 | r = _s.stk->top(); _s.stk->pop();
51 | break;
52 | case 2:
53 | a = _s.stk->top(); _s.stk->pop();
54 | b = _s.stk->top(); _s.stk->pop();
55 | g = b;
56 | r = b;
57 | break;
58 | case 1:
59 | a = 255;
60 | b = _s.stk->top(); _s.stk->pop();
61 | g = b;
62 | r = b;
63 | break;
64 | }
65 | ofSetColor(r, g, b, a);
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilColorOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilColorOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilColorOp__
10 | #define __cyril2__CyrilColorOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilColorOp : public CyrilOp {
16 | public:
17 | CyrilColorOp(Cyril* _c);
18 | CyrilColorOp (const CyrilColorOp &other);
19 | virtual ~CyrilColorOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilColorOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilConeOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilConeOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilConeOp.h"
10 |
11 | CyrilConeOp::CyrilConeOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 2)) {
14 | yyerror("Cone command requires 0, 1 or 2 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilConeOp::CyrilConeOp (const CyrilConeOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilConeOp::~CyrilConeOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilConeOp::print() {
27 | c->print();
28 | cout << "Cone" << endl;
29 | }
30 | Cyril * CyrilConeOp::clone () {
31 | return new CyrilConeOp (*this);
32 | }
33 | int CyrilConeOp::size() {
34 | return 0;
35 | }
36 | void CyrilConeOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r, h;
39 | switch (c->size()) {
40 | case 2:
41 | h = _s.stk->top(); _s.stk->pop();
42 | r = _s.stk->top(); _s.stk->pop();
43 | break;
44 | case 1:
45 | h = _s.stk->top(); _s.stk->pop();
46 | r = h;
47 | break;
48 | case 0:
49 | h = 1;
50 | r = 1;
51 | break;
52 | }
53 | ofDrawCone(r, h);
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilConeOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilConeOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilConeOp__
10 | #define __cyril2__CyrilConeOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilConeOp : public CyrilOp {
16 | public:
17 | CyrilConeOp(Cyril* _c);
18 | CyrilConeOp (const CyrilConeOp &other);
19 | virtual ~CyrilConeOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilConeOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilDie.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilDie.h
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 13/04/2015.
6 | //
7 | //
8 |
9 | #ifndef cyril_CyrilDie_h
10 | #define cyril_CyrilDie_h
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilDie : public CyrilOp {
16 | public:
17 | CyrilDie(Cyril* _c);
18 | CyrilDie (const CyrilDie &other);
19 | virtual ~CyrilDie ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | CyrilDie::CyrilDie (Cyril* _c) : CyrilOp(_c) {
28 | int s = c->size();
29 | if (!(s == 0)) {
30 | yyerror("Die command requires no arguments");
31 | valid = false;
32 | }
33 | }
34 |
35 | CyrilDie::CyrilDie (const CyrilDie &other) {
36 | c = other.c->clone ();
37 | }
38 | CyrilDie::~CyrilDie ()
39 | {
40 | delete c;
41 | }
42 | void CyrilDie::print() {
43 | c->print();
44 | cout << "Die" << endl;
45 | }
46 | Cyril * CyrilDie::clone () {
47 | return new CyrilDie (*this);
48 | }
49 | int CyrilDie::size() {
50 | return 0;
51 | }
52 | void CyrilDie::eval(CyrilState &_s) {
53 | //c->eval(_s);
54 | valid = false;
55 | }
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilFillOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFillOp.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 14/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilFillOp.h"
10 |
11 | CyrilFillOp::CyrilFillOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 2 || s == 3 || s == 4)) {
14 | yyerror("Fill command takes 0 (standard) or 1, 2, 3, or 4 arguments (color)");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilFillOp::CyrilFillOp (const CyrilFillOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilFillOp::~CyrilFillOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilFillOp::print() {
27 | c->print();
28 | cout << "Fill" << endl;
29 | }
30 | Cyril * CyrilFillOp::clone () {
31 | return new CyrilFillOp (*this);
32 | }
33 | int CyrilFillOp::size() {
34 | return 0;
35 | }
36 | void CyrilFillOp::eval(CyrilState &_s) {
37 | int _size = c->size();
38 | if (_size == 0) {
39 | ofFill();
40 | return;
41 | }
42 | c->eval(_s);
43 | float r, g, b, a;
44 | switch (_size) {
45 | case 4:
46 | a = _s.stk->top(); _s.stk->pop();
47 | b = _s.stk->top(); _s.stk->pop();
48 | g = _s.stk->top(); _s.stk->pop();
49 | r = _s.stk->top(); _s.stk->pop();
50 | break;
51 | case 3:
52 | a = 255;
53 | b = _s.stk->top(); _s.stk->pop();
54 | g = _s.stk->top(); _s.stk->pop();
55 | r = _s.stk->top(); _s.stk->pop();
56 | break;
57 | case 2:
58 | a = _s.stk->top(); _s.stk->pop();
59 | b = _s.stk->top(); _s.stk->pop();
60 | g = b;
61 | r = b;
62 | break;
63 | case 1:
64 | a = 255;
65 | b = _s.stk->top(); _s.stk->pop();
66 | g = b;
67 | r = b;
68 | break;
69 | }
70 | ofSetColor(r, g, b, a);
71 | ofFill();
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilFillOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilFillOp.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 14/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilFillOp__
10 | #define __Cyril__CyrilFillOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilFillOp : public CyrilOp {
16 | public:
17 | CyrilFillOp(Cyril* _c);
18 | CyrilFillOp (const CyrilFillOp &other);
19 | virtual ~CyrilFillOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__Cyril__CyrilFillOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilGridOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilGridOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilGridOp.h"
10 |
11 | CyrilGridOp::CyrilGridOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1)) {
14 | yyerror("Grid command requires 0 or 1 argument");
15 | cout << _c->size() << endl;
16 | valid = false;
17 | }
18 | }
19 |
20 | CyrilGridOp::CyrilGridOp (const CyrilGridOp &other) {
21 | c = other.c->clone ();
22 | }
23 | CyrilGridOp::~CyrilGridOp ()
24 | {
25 | delete c;
26 | }
27 | void CyrilGridOp::print() {
28 | c->print();
29 | cout << "Grid" << endl;
30 | }
31 | Cyril * CyrilGridOp::clone () {
32 | return new CyrilGridOp (*this);
33 | }
34 | int CyrilGridOp::size() {
35 | return 0;
36 | }
37 | void CyrilGridOp::eval(CyrilState &_s) {
38 | c->eval(_s);
39 | float s;
40 | if (c->size() == 1) {
41 | s = _s.stk->top(); _s.stk->pop();
42 | }
43 | else {
44 | s = 1;
45 | }
46 | if (s > 0) {
47 | ofDrawGridPlane(s);
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilGridOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilGridOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilGridOp__
10 | #define __cyril2__CyrilGridOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilGridOp : public CyrilOp {
16 | public:
17 | CyrilGridOp(Cyril* _c);
18 | CyrilGridOp (const CyrilGridOp &other);
19 | virtual ~CyrilGridOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilGridOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilImgOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilImgOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilImgOp.h"
10 |
11 | CyrilImgOp::CyrilImgOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 1)) {
14 | yyerror("Image command requires 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilImgOp::CyrilImgOp (const CyrilImgOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilImgOp::~CyrilImgOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilImgOp::print() {
27 | c->print();
28 | cout << "Image" << endl;
29 | }
30 | Cyril * CyrilImgOp::clone () {
31 | return new CyrilImgOp (*this);
32 | }
33 | int CyrilImgOp::size() {
34 | return 0;
35 | }
36 | void CyrilImgOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float i;
39 | i = _s.stk->top(); _s.stk->pop();
40 | ofScale(0.01, 0.01, 0.01);
41 | if (_s.img->count(i)) {
42 | //cout << "Draw image " << _s.img->at(i) << endl;
43 | _s.img->at(i)->draw(0, 0, 0);
44 | }
45 | // TODO: recurse up the parent tree
46 | else if (_s.parent) {
47 | if (_s.parent->img->count(i)) {
48 | _s.parent->img->at(i)->draw(0, 0, 0);
49 | }
50 | }
51 | ofScale(100, 100, 100);
52 | }
53 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilImgOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilImgOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilImgOp__
10 | #define __cyril2__CyrilImgOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilImgOp : public CyrilOp {
16 | public:
17 | CyrilImgOp(Cyril* _c);
18 | CyrilImgOp (const CyrilImgOp &other);
19 | virtual ~CyrilImgOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__cyril2__CyrilImgOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilInitOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilInitOp.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilInitOp.h"
10 |
11 | CyrilInitOp::CyrilInitOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0)) {
14 | yyerror("Init command takes 0 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilInitOp::CyrilInitOp (const CyrilInitOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilInitOp::~CyrilInitOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilInitOp::print() {
27 | c->print();
28 | cout << "Init" << endl;
29 | }
30 | Cyril * CyrilInitOp::clone () {
31 | return new CyrilInitOp (*this);
32 | }
33 | int CyrilInitOp::size() {
34 | return 0;
35 | }
36 | void CyrilInitOp::eval(CyrilState &_s) {
37 | if ((*_s.sym)[REG_FRAME] == 0) {
38 | c->eval(_s);
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilInitOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilInitOp.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilInitOp__
10 | #define __Cyril__CyrilInitOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilInitOp : public CyrilOp {
16 | public:
17 | CyrilInitOp(Cyril* _c);
18 | CyrilInitOp (const CyrilInitOp &other);
19 | virtual ~CyrilInitOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 | #endif /* defined(__Cyril__CyrilInitOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilKaleidoscope.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilKaleidoscope.cpp
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 12/09/2014.
6 | //
7 | //
8 |
9 | #include "CyrilKaleidoscope.h"
10 |
11 | CyrilKaleidoscope::CyrilKaleidoscope (Cyril* _e) : e(_e) {
12 | s = e->size();
13 | if (!(s == 1 || s == 0)) {
14 | yyerror("Kaleidoscope command takes 0 or 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilKaleidoscope::CyrilKaleidoscope (const CyrilKaleidoscope &other) {
20 | e = other.e->clone ();
21 | }
22 | CyrilKaleidoscope::~CyrilKaleidoscope ()
23 | {
24 | }
25 | void CyrilKaleidoscope::print() {
26 | cout << "Kaleidoscope" << endl;
27 | }
28 | Cyril * CyrilKaleidoscope::clone () {
29 | return new CyrilKaleidoscope (*this);
30 | }
31 | int CyrilKaleidoscope::size() {
32 | return 0;
33 | }
34 | void CyrilKaleidoscope::update(CyrilState &_s) {
35 | // FX_KALEIDOSCOPE = 0
36 | _s.post[0]->enable();
37 | }
38 | void CyrilKaleidoscope::eval(CyrilState &_s) {
39 | float d;
40 | if (s == 0) {
41 | d = 2.0;
42 | }
43 | else {
44 | e->eval(_s);
45 | d = _s.stk->top();
46 | _s.stk->pop();
47 | }
48 | _s.kaleido->setSegments(d);
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilKaleidoscope.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilKaleidoscope.h
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 12/09/2014.
6 | //
7 | //
8 |
9 | #ifndef __cyril__CyrilKaleidoscope__
10 | #define __cyril__CyrilKaleidoscope__
11 |
12 | #include "Cyril.h"
13 |
14 |
15 | class CyrilKaleidoscope : public Cyril {
16 | protected:
17 | Cyril* e;
18 | int s;
19 | public:
20 | CyrilKaleidoscope(Cyril* _e);
21 | CyrilKaleidoscope (const CyrilKaleidoscope &other);
22 | virtual ~CyrilKaleidoscope ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | virtual void update(CyrilState &);
28 | };
29 |
30 |
31 | #endif /* defined(__cyril__CyrilKaleidoscope__) */
32 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilLightOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLightOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilLightOp.h"
10 |
11 | CyrilLightOp::CyrilLightOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 3 || s == 6)) {
14 | yyerror("Light command requires 3 or 6 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilLightOp::CyrilLightOp (const CyrilLightOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilLightOp::~CyrilLightOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilLightOp::print() {
27 | c->print();
28 | cout << "Light" << endl;
29 | }
30 | Cyril * CyrilLightOp::clone () {
31 | return new CyrilLightOp (*this);
32 | }
33 | int CyrilLightOp::size() {
34 | return 0;
35 | }
36 | void CyrilLightOp::eval(CyrilState &_s) {
37 | if (_s.light != NULL) {
38 | c->eval(_s);
39 | float x, y, z, a;
40 | switch (c->size()) {
41 | case 3:
42 | z = _s.stk->top(); _s.stk->pop();
43 | y = _s.stk->top(); _s.stk->pop();
44 | x = _s.stk->top(); _s.stk->pop();
45 | _s.light->setPosition(x, y, z);
46 | break;
47 | case 6:
48 | z = _s.stk->top(); _s.stk->pop();
49 | y = _s.stk->top(); _s.stk->pop();
50 | x = _s.stk->top(); _s.stk->pop();
51 | //_s.light->setAmbientColor(ofColor(x, y, z));
52 | _s.light->setDiffuseColor(ofColor(x, y, z));
53 | //_s.light->setAmbientColor(ofColor(x, y, z));
54 | z = _s.stk->top(); _s.stk->pop();
55 | y = _s.stk->top(); _s.stk->pop();
56 | x = _s.stk->top(); _s.stk->pop();
57 | //_s.light->setSpecularColor(ofColor(x, y, z));
58 | _s.light->setAmbientColor(ofColor(x, y, z));
59 | break;
60 | }
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilLightOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLightOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilLightOp__
10 | #define __cyril2__CyrilLightOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilLightOp : public CyrilOp {
16 | public:
17 | CyrilLightOp(Cyril* _c);
18 | CyrilLightOp (const CyrilLightOp &other);
19 | virtual ~CyrilLightOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilLightOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilLineOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLineOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilLineOp.h"
10 |
11 | CyrilLineOp::CyrilLineOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 2 || s == 4)) {
14 | yyerror("Line command requires 2 or 4 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilLineOp::CyrilLineOp (const CyrilLineOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilLineOp::~CyrilLineOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilLineOp::print() {
27 | c->print();
28 | cout << "Line" << endl;
29 | }
30 | Cyril * CyrilLineOp::clone () {
31 | return new CyrilLineOp (*this);
32 | }
33 | int CyrilLineOp::size() {
34 | return 0;
35 | }
36 | void CyrilLineOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float x1, x2, y1, y2;
39 | switch (c->size()) {
40 | case 4:
41 | y2 = _s.stk->top(); _s.stk->pop();
42 | x2 = _s.stk->top(); _s.stk->pop();
43 | y1 = _s.stk->top(); _s.stk->pop();
44 | x1 = _s.stk->top(); _s.stk->pop();
45 | break;
46 | case 2:
47 | y2 = _s.stk->top(); _s.stk->pop();
48 | x2 = _s.stk->top(); _s.stk->pop();
49 | y1 = 0;
50 | x1 = 0;
51 | break;
52 | }
53 | ofLine(x1, y1, x2, y2);
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilLineOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilLineOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilLineOp__
10 | #define __cyril2__CyrilLineOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilLineOp : public CyrilOp {
16 | public:
17 | CyrilLineOp(Cyril* _c);
18 | CyrilLineOp (const CyrilLineOp &other);
19 | virtual ~CyrilLineOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilLineOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilMoveOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilMoveOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilMoveOp.h"
10 |
11 | CyrilMoveOp::CyrilMoveOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 2 || s == 3)) {
14 | yyerror("Move command requires 1, 2 or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilMoveOp::CyrilMoveOp (const CyrilMoveOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilMoveOp::~CyrilMoveOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilMoveOp::print() {
27 | c->print();
28 | cout << "Move" << endl;
29 | }
30 | Cyril * CyrilMoveOp::clone () {
31 | return new CyrilMoveOp (*this);
32 | }
33 | int CyrilMoveOp::size() {
34 | return 0;
35 | }
36 | void CyrilMoveOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | int s = c->size();
39 | float x,y,z;
40 | switch (c->size()) {
41 | case 3:
42 | z = _s.stk->top(); _s.stk->pop();
43 | y = _s.stk->top(); _s.stk->pop();
44 | x = _s.stk->top(); _s.stk->pop();
45 | break;
46 | case 2:
47 | z = 0;
48 | y = _s.stk->top(); _s.stk->pop();
49 | x = _s.stk->top(); _s.stk->pop();
50 | break;
51 | case 1:
52 | z = 0;
53 | y = 0;
54 | x = _s.stk->top(); _s.stk->pop();
55 | break;
56 | default:
57 | z = 0;
58 | y = 0;
59 | x = sin((*_s.sym)[REG_TIME] / 1000);
60 | }
61 | ofTranslate(x, y, z);
62 | _s.ms->translate(x, y, z);
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilMoveOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilMoveOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilMoveOp__
10 | #define __cyril2__CyrilMoveOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilMoveOp : public CyrilOp {
16 | public:
17 | CyrilMoveOp(Cyril* _c);
18 | CyrilMoveOp (const CyrilMoveOp &other);
19 | virtual ~CyrilMoveOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 |
27 |
28 | #endif /* defined(__cyril2__CyrilMoveOp__) */
29 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilNoFillOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoNoFillOp.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 14/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilNoFillOp.h"
10 |
11 | CyrilNoFillOp::CyrilNoFillOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1)) {
14 | yyerror("noFill command takes 0 or 1 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilNoFillOp::CyrilNoFillOp (const CyrilNoFillOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilNoFillOp::~CyrilNoFillOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilNoFillOp::print() {
27 | c->print();
28 | cout << "Fill" << endl;
29 | }
30 | Cyril * CyrilNoFillOp::clone () {
31 | return new CyrilNoFillOp (*this);
32 | }
33 | int CyrilNoFillOp::size() {
34 | return 0;
35 | }
36 | void CyrilNoFillOp::eval(CyrilState &_s) {
37 | int _size = c->size();
38 | if (_size == 1) {
39 | c->eval(_s);
40 | ofSetLineWidth(_s.stk->top());
41 | _s.stk->pop();
42 | ofFill();
43 | }
44 | ofNoFill();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilNoFillOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoNoFillOp.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 14/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilNoNoFillOp__
10 | #define __Cyril__CyrilNoNoFillOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilNoFillOp : public CyrilOp {
16 | public:
17 | CyrilNoFillOp(Cyril* _c);
18 | CyrilNoFillOp (const CyrilNoFillOp &other);
19 | virtual ~CyrilNoFillOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__Cyril__CyrilNoNoFillOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilNoiseWarp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoiseWarp.cpp
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 12/09/2014.
6 | //
7 | //
8 |
9 | #include "CyrilNoiseWarp.h"
10 |
11 | CyrilNoiseWarp::CyrilNoiseWarp (Cyril* _e) : e(_e) {
12 | s = e->size();
13 | if (!(s == 3 || s == 0)) {
14 | // FREQ, AMP, SPEED
15 | yyerror("NoiseWarp FX command takes 0 or 3 arguments");
16 | valid = false;
17 | }
18 | }
19 |
20 | CyrilNoiseWarp::CyrilNoiseWarp (const CyrilNoiseWarp &other) {
21 | e = other.e->clone ();
22 | }
23 | CyrilNoiseWarp::~CyrilNoiseWarp ()
24 | {
25 | }
26 | void CyrilNoiseWarp::print() {
27 | cout << "NoiseWarp" << endl;
28 | }
29 | Cyril * CyrilNoiseWarp::clone () {
30 | return new CyrilNoiseWarp (*this);
31 | }
32 | int CyrilNoiseWarp::size() {
33 | return 0;
34 | }
35 | void CyrilNoiseWarp::update(CyrilState &_s) {
36 | // FX_NOISE_WARP = 1
37 | _s.post[1]->enable();
38 | }
39 | void CyrilNoiseWarp::eval(CyrilState &_s) {
40 | float frequency, amplitude, speed;
41 | if (s == 3) {
42 | e->eval(_s);
43 | frequency = _s.stk->top();
44 | _s.stk->pop();
45 | amplitude = _s.stk->top();
46 | _s.stk->pop();
47 | speed = _s.stk->top();
48 | _s.stk->pop();
49 | }
50 | else {
51 | // same defaults as ofxPostProcessing:
52 | frequency = 4.0;
53 | amplitude = 0.1;
54 | speed = 0.1;
55 | }
56 | _s.noisewarp->setFrequency(frequency);
57 | _s.noisewarp->setAmplitude(amplitude);
58 | _s.noisewarp->setSpeed(speed);
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilNoiseWarp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilNoiseWarp.h
3 | // cyril
4 | //
5 | // Created by Darren Mothersele on 12/09/2014.
6 | //
7 | //
8 |
9 | #ifndef __cyril__CyrilNoiseWarp__
10 | #define __cyril__CyrilNoiseWarp__
11 |
12 | #include "Cyril.h"
13 |
14 |
15 | class CyrilNoiseWarp : public Cyril {
16 | protected:
17 | Cyril* e;
18 | int s;
19 | public:
20 | CyrilNoiseWarp(Cyril* _e);
21 | CyrilNoiseWarp (const CyrilNoiseWarp &other);
22 | virtual ~CyrilNoiseWarp ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | virtual void update(CyrilState &);
28 | };
29 |
30 |
31 | #endif /* defined(__cyril__CyrilNoiseWarp__) */
32 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPalette.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPalette.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPalette.h"
10 |
11 | CyrilPalette::CyrilPalette(int _l, Cyril* _p) : loc(_l) {
12 | int sz = _p->size();
13 | //cout << "Palette size " << sz << endl;
14 | if (sz % 4 != 0) {
15 | yyerror("Palette command formatted incorrectly");
16 | valid = false;
17 | }
18 | else if (!_p->valid) {
19 | valid = false;
20 | }
21 | else {
22 | palette = new Palette();
23 | CyrilState _state;
24 | _state.stk = new stack;
25 | _state.ms = new ofMatrixStack(*ofGetWindowPtr());
26 | _state.ps = new vector;
27 | _state.sym = new map;
28 | _state.cs = new map;
29 | _state.img = new map;
30 | _state.parent = NULL;
31 |
32 | _p->eval(_state);
33 | float d, r, g, b;
34 | while (!_state.stk->empty()) {
35 | d = _state.stk->top(); _state.stk->pop();
36 | b = _state.stk->top(); _state.stk->pop();
37 | g = _state.stk->top(); _state.stk->pop();
38 | r = _state.stk->top(); _state.stk->pop();
39 | palette->addColor(d, r, g, b);
40 | }
41 | }
42 | }
43 |
44 |
45 | CyrilPalette::CyrilPalette (const CyrilPalette &other) {
46 | loc = other.loc;
47 | palette = other.palette->clone();
48 | }
49 | CyrilPalette::~CyrilPalette () {
50 | delete palette;
51 | }
52 |
53 | void CyrilPalette::print() {
54 | cout << "Palette" << endl;
55 | }
56 |
57 | Cyril* CyrilPalette::clone () {
58 | return new CyrilPalette (*this);
59 | }
60 |
61 | int CyrilPalette::size() {
62 | return 0;
63 | }
64 |
65 | void CyrilPalette::eval(CyrilState &_s) {
66 | (*_s.cs)[loc] = palette;
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPalette.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPalette.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPalette__
10 | #define __cyril2__CyrilPalette__
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 | #include "Palette.h"
16 |
17 | class CyrilPalette : public Cyril {
18 | int loc;
19 | Palette* palette;
20 | public:
21 | CyrilPalette(int _l, Cyril* _p);
22 | CyrilPalette (const CyrilPalette &other) ;
23 | virtual ~CyrilPalette ();
24 | void print();
25 | virtual Cyril *clone ();
26 | virtual int size();
27 | virtual void eval(CyrilState &);
28 | };
29 | #endif /* defined(__cyril2__CyrilPalette__) */
30 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPaletteItem.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPaletteItem.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPaletteItem.h"
10 |
11 | CyrilPaletteItem::CyrilPaletteItem(float _f, Cyril* _e) : d(_f), e(_e) {
12 | /*
13 | string converter(_s);
14 | stringstream sr(converter.substr(0,2));
15 | stringstream sg(converter.substr(2,2));
16 | stringstream sb(converter.substr(4,2));
17 | int ir, ig, ib;
18 | sr >> hex >> ir;
19 | sg >> hex >> ig;
20 | sb >> hex >> ib;
21 | r = ir; g = ig; b = ib;
22 | */
23 |
24 | int sz = _e->size();
25 | if (!(sz == 3)) {
26 | yyerror("Palette item requires 3 arguments");
27 | valid = false;
28 | }
29 | paletteCalc = false;
30 | }
31 |
32 | CyrilPaletteItem::CyrilPaletteItem (const CyrilPaletteItem &other) {
33 | d = other.d;
34 | r = other.r;
35 | g = other.g;
36 | b = other.b;
37 | }
38 | CyrilPaletteItem::~CyrilPaletteItem () {
39 |
40 | }
41 |
42 | void CyrilPaletteItem::print() {
43 |
44 | cout << "PaletteItem" << endl;
45 | }
46 |
47 |
48 | Cyril * CyrilPaletteItem::clone () {
49 | return new CyrilPaletteItem (*this);
50 | }
51 |
52 | int CyrilPaletteItem::size() {
53 | return 4;
54 | }
55 |
56 | void CyrilPaletteItem::eval(CyrilState &_s) {
57 | if (!paletteCalc) {
58 | e->eval(_s);
59 | b = _s.stk->top(); _s.stk->pop();
60 | g = _s.stk->top(); _s.stk->pop();
61 | r = _s.stk->top(); _s.stk->pop();
62 | paletteCalc = true;
63 | }
64 | _s.stk->push(r);
65 | _s.stk->push(g);
66 | _s.stk->push(b);
67 | _s.stk->push(d);
68 | }
69 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPaletteItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPaletteItem.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPaletteItem__
10 | #define __cyril2__CyrilPaletteItem__
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 | #include "Palette.h"
16 |
17 | class CyrilPaletteItem : public Cyril {
18 | Cyril* e;
19 | bool paletteCalc;
20 | float d,r,g,b;
21 | public:
22 | CyrilPaletteItem(float _f, Cyril* _e);
23 | CyrilPaletteItem (const CyrilPaletteItem &other) ;
24 | virtual ~CyrilPaletteItem ();
25 | void print();
26 | virtual Cyril *clone ();
27 | virtual int size();
28 | virtual void eval(CyrilState &);
29 | };
30 |
31 |
32 | #endif /* defined(__cyril2__CyrilPaletteItem__) */
33 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilParticle.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilParticle.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilParticle.h"
10 |
11 |
12 | CyrilParticle::CyrilParticle (const CyrilParticle &other) {
13 | e = other.e->clone();
14 | c = other.c->clone();
15 | }
16 | CyrilParticle::~CyrilParticle () {
17 | delete e;
18 | delete c;
19 | }
20 |
21 | void CyrilParticle::print() {
22 | e->print();
23 | c->print();
24 | cout << "Particle" << endl;
25 | }
26 |
27 | Cyril* CyrilParticle::clone () {
28 | return new CyrilParticle (*this);
29 | }
30 |
31 | int CyrilParticle::size() {
32 | return 0;
33 | }
34 |
35 | void CyrilParticle::eval(CyrilState &_s) {
36 | e->eval(_s);
37 | float x, y, z, w, h, d;
38 |
39 | switch (e->size()) {
40 | case 1:
41 | d = 0;
42 | h = 0;
43 | w = 0;
44 | x = _s.stk->top(); _s.stk->pop();
45 | break;
46 | case 4:
47 | d = _s.stk->top(); _s.stk->pop();
48 | h = _s.stk->top(); _s.stk->pop();
49 | w = _s.stk->top(); _s.stk->pop();
50 | x = _s.stk->top(); _s.stk->pop();
51 | break;
52 | }
53 | //cout << "Release particle at " << x << ", " << y << ", " << z << endl;
54 | //GLfloat matrix[16];
55 | //glGetFloatv (GL_MODELVIEW_MATRIX, matrix);
56 | //ofMatrix4x4 m(matrix);
57 | _s.ps->push_back(new Particle(_s.ms->getCurrentMatrix(), ofVec3f(x,0,0), ofVec3f(w,h,d),
58 | (*_s.sym)[REG_PARTICLE_HEALTH], (*_s.sym)[REG_PARTICLE_DECAY], c));
59 | }
60 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilParticle.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilParticle.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_CyrilParticle_h
10 | #define cyril2_CyrilParticle_h
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 | #include "Particle.h"
16 |
17 | class CyrilParticle : public Cyril {
18 | Cyril* e;
19 | Cyril* c;
20 | public:
21 | CyrilParticle(Cyril* _e, Cyril* _c) : e(_e), c(_c) {
22 | valid = e->valid && c->valid;
23 | int s = e->size();
24 | if (!(s == 1 || s == 4)) {
25 | yyerror("Particle command requires 1 or 4 arguments");
26 | valid = false;
27 | }
28 | }
29 | CyrilParticle (const CyrilParticle &other);
30 | virtual ~CyrilParticle ();
31 | void print();
32 | virtual Cyril *clone ();
33 | virtual int size();
34 | virtual void eval(CyrilState &);
35 | virtual int matchPushPop() { return c->matchPushPop(); }
36 | };
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPegOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPegOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPegOp.h"
10 |
11 | CyrilPegOp::CyrilPegOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 2)) {
14 | yyerror("Peg command requires 0, 1 or 2 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilPegOp::CyrilPegOp (const CyrilPegOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilPegOp::~CyrilPegOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilPegOp::print() {
27 | c->print();
28 | cout << "Peg" << endl;
29 | }
30 | Cyril * CyrilPegOp::clone () {
31 | return new CyrilPegOp (*this);
32 | }
33 | int CyrilPegOp::size() {
34 | return 0;
35 | }
36 | void CyrilPegOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r, h;
39 | switch (c->size()) {
40 | case 2:
41 | h = _s.stk->top(); _s.stk->pop();
42 | r = _s.stk->top(); _s.stk->pop();
43 | break;
44 | case 1:
45 | h = _s.stk->top(); _s.stk->pop();
46 | r = h;
47 | break;
48 | case 0:
49 | h = 1;
50 | r = 1;
51 | break;
52 | }
53 | ofDrawCylinder(r, h);
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPegOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPegOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPegOp__
10 | #define __cyril2__CyrilPegOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilPegOp : public CyrilOp {
16 | public:
17 | CyrilPegOp(Cyril* _c);
18 | CyrilPegOp (const CyrilPegOp &other);
19 | virtual ~CyrilPegOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilPegOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPopMatrixOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPopMatrix.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPopMatrixOp.h"
10 |
11 | CyrilPopMatrixOp::CyrilPopMatrixOp (Cyril* _c) : CyrilOp(_c) {
12 | if (_c->size() != 0) {
13 | yyerror("popMatrix command requires 0 arguments");
14 | valid = false;
15 | }
16 | }
17 |
18 | CyrilPopMatrixOp::CyrilPopMatrixOp (const CyrilPopMatrixOp &other) {
19 | c = other.c->clone ();
20 | }
21 | CyrilPopMatrixOp::~CyrilPopMatrixOp ()
22 | {
23 | delete c;
24 | }
25 | void CyrilPopMatrixOp::print() {
26 | c->print();
27 | cout << "PopMatrix" << endl;
28 | }
29 | Cyril * CyrilPopMatrixOp::clone () {
30 | return new CyrilPopMatrixOp (*this);
31 | }
32 | int CyrilPopMatrixOp::size() {
33 | return 0;
34 | }
35 | void CyrilPopMatrixOp::eval(CyrilState &_s) {
36 | ofPopMatrix();
37 | _s.ms->popMatrix();
38 | }
39 | int CyrilPopMatrixOp::matchPushPop() { return 1; }
40 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPopMatrixOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPopMatrix.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPopMatrix__
10 | #define __cyril2__CyrilPopMatrix__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilPopMatrixOp : public CyrilOp {
16 | public:
17 | CyrilPopMatrixOp(Cyril* _c);
18 | CyrilPopMatrixOp (const CyrilPopMatrixOp &other);
19 | virtual ~CyrilPopMatrixOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | virtual int matchPushPop();
25 | };
26 |
27 | #endif /* defined(__cyril2__CyrilPopMatrix__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPushMatrixOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPushMatrixOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilPushMatrixOp.h"
10 |
11 | CyrilPushMatrixOp::CyrilPushMatrixOp (Cyril* _c) : CyrilOp(_c) {
12 | if (_c->size() != 0) {
13 | yyerror("pushMatrix command requires 0 arguments");
14 | valid = false;
15 | }
16 | }
17 |
18 | CyrilPushMatrixOp::CyrilPushMatrixOp (const CyrilPushMatrixOp &other) {
19 | c = other.c->clone ();
20 | }
21 | CyrilPushMatrixOp::~CyrilPushMatrixOp ()
22 | {
23 | delete c;
24 | }
25 | void CyrilPushMatrixOp::print() {
26 | c->print();
27 | cout << "PushMatrix" << endl;
28 | }
29 | Cyril * CyrilPushMatrixOp::clone () {
30 | return new CyrilPushMatrixOp (*this);
31 | }
32 | int CyrilPushMatrixOp::size() {
33 | return 0;
34 | }
35 | void CyrilPushMatrixOp::eval(CyrilState &_s) {
36 | ofPushMatrix();
37 | _s.ms->pushMatrix();
38 | }
39 |
40 |
41 | int CyrilPushMatrixOp::matchPushPop() { return -1; }
42 |
43 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilPushMatrixOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilPushMatrixOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilPushMatrixOp__
10 | #define __cyril2__CyrilPushMatrixOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilPushMatrixOp : public CyrilOp {
16 | public:
17 | CyrilPushMatrixOp(Cyril* _c);
18 | CyrilPushMatrixOp (const CyrilPushMatrixOp &other);
19 | virtual ~CyrilPushMatrixOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | virtual int matchPushPop();
25 | };
26 |
27 | #endif /* defined(__cyril2__CyrilPushMatrixOp__) */
28 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilRectOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRectOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilRectOp.h"
10 |
11 | CyrilRectOp::CyrilRectOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 2)) {
14 | yyerror("Rect command requires 0, 1 or 2 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilRectOp::CyrilRectOp (const CyrilRectOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilRectOp::~CyrilRectOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilRectOp::print() {
27 | c->print();
28 | cout << "Rect" << endl;
29 | }
30 | Cyril * CyrilRectOp::clone () {
31 | return new CyrilRectOp (*this);
32 | }
33 | int CyrilRectOp::size() {
34 | return 0;
35 | }
36 | void CyrilRectOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float w, h;
39 | switch (c->size()) {
40 | case 2:
41 | h = _s.stk->top(); _s.stk->pop();
42 | w = _s.stk->top(); _s.stk->pop();
43 | break;
44 | case 1:
45 | h = _s.stk->top(); _s.stk->pop();
46 | w = h;
47 | break;
48 | case 0:
49 | h = 1;
50 | w = 1;
51 | break;
52 | }
53 | //ofDrawBox(w, h, 1);
54 | w = w / 2.0;
55 | h = h / 2.0;
56 | ofBeginShape();
57 | ofVertex(-w,-h);
58 | ofVertex(w,-h);
59 | ofVertex(w,h);
60 | ofVertex(-w,h);
61 | ofEndShape();
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilRectOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRectOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilRectOp__
10 | #define __cyril2__CyrilRectOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilRectOp : public CyrilOp {
16 | public:
17 | CyrilRectOp(Cyril* _c);
18 | CyrilRectOp (const CyrilRectOp &other);
19 | virtual ~CyrilRectOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilRectOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilRotateOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRotateOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilRotateOp.h"
10 |
11 | CyrilRotateOp::CyrilRotateOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1 || s == 3 || s == 4)) {
14 | yyerror("Rotate command requires 4, 3, 1 or 0 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilRotateOp::CyrilRotateOp (const CyrilRotateOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilRotateOp::~CyrilRotateOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilRotateOp::print() {
27 | c->print();
28 | cout << "Rotate" << endl;
29 | }
30 | Cyril * CyrilRotateOp::clone () {
31 | return new CyrilRotateOp (*this);
32 | }
33 | int CyrilRotateOp::size() {
34 | return 0;
35 | }
36 | void CyrilRotateOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float w, x, y, z;
39 | switch (c->size()) {
40 | case 4:
41 | z = _s.stk->top(); _s.stk->pop();
42 | y = _s.stk->top(); _s.stk->pop();
43 | x = _s.stk->top(); _s.stk->pop();
44 | w = _s.stk->top(); _s.stk->pop();
45 | ofRotate(w, x, y, z);
46 | _s.ms->rotate(w, x, y, z);
47 | break;
48 | case 3:
49 | y = _s.stk->top(); _s.stk->pop();
50 | x = _s.stk->top(); _s.stk->pop();
51 | w = _s.stk->top(); _s.stk->pop();
52 | ofRotateX(x);
53 | ofRotateY(y);
54 | ofRotateZ(z);
55 | _s.ms->rotate(x, 1, 0, 0);
56 | _s.ms->rotate(y, 0, 1, 0);
57 | _s.ms->rotate(z, 0, 0, 1);
58 | break;
59 | case 1:
60 | w = _s.stk->top(); _s.stk->pop();
61 | ofRotateZ(w);
62 | _s.ms->rotate(w, 0, 0, 1);
63 | break;
64 | default:
65 | w = (*_s.sym)[REG_TIME] / 36.0;
66 | ofRotate(w, 0, 1, 0.5);
67 | _s.ms->rotate(w, 0, 1, 0.5);/*
68 | w = (*_s.sym)[REG_TIME] / 64.0;
69 | ofRotate(w, 0, 0, 1);
70 | _s.ms->rotate(w, 0, 0, 1);*/
71 | break;
72 | }
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilRotateOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilRotateOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilRotateOp__
10 | #define __cyril2__CyrilRotateOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilRotateOp : public CyrilOp {
16 | public:
17 | CyrilRotateOp(Cyril* _c);
18 | CyrilRotateOp (const CyrilRotateOp &other);
19 | virtual ~CyrilRotateOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilRotateOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilScaleOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilScaleOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilScaleOp.h"
10 |
11 | CyrilScaleOp::CyrilScaleOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 1 || s == 3)) {
14 | yyerror("Scale command requires 1 or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilScaleOp::CyrilScaleOp (const CyrilScaleOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilScaleOp::~CyrilScaleOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilScaleOp::print() {
27 | c->print();
28 | cout << "Scale" << endl;
29 | }
30 | Cyril * CyrilScaleOp::clone () {
31 | return new CyrilScaleOp (*this);
32 | }
33 | int CyrilScaleOp::size() {
34 | return 0;
35 | }
36 | void CyrilScaleOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float x, y, z;
39 | switch (c->size()) {
40 | case 3:
41 | z = _s.stk->top(); _s.stk->pop();
42 | y = _s.stk->top(); _s.stk->pop();
43 | x = _s.stk->top(); _s.stk->pop();
44 | break;
45 | case 1:
46 | z = _s.stk->top(); _s.stk->pop();
47 | y = z;
48 | x = z;
49 | break;
50 | }
51 | ofScale(x, y, z);
52 | _s.ms->scale(x, y, z);
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilScaleOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilScaleOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilScaleOp__
10 | #define __cyril2__CyrilScaleOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilScaleOp : public CyrilOp {
16 | public:
17 | CyrilScaleOp(Cyril* _c);
18 | CyrilScaleOp (const CyrilScaleOp &other);
19 | virtual ~CyrilScaleOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilScaleOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilShape.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilShape.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilShape.h"
10 |
11 | CyrilShape::CyrilShape (Cyril* _e) : e(_e) {
12 |
13 | }
14 |
15 | CyrilShape::CyrilShape (const CyrilShape &other) {
16 | e = other.e->clone ();
17 | }
18 | CyrilShape::~CyrilShape ()
19 | {
20 | delete e;
21 | }
22 | void CyrilShape::print() {
23 | e->print();
24 | cout << "Shape" << endl;
25 | }
26 | Cyril * CyrilShape::clone () {
27 | return new CyrilShape (*this);
28 | }
29 | int CyrilShape::size() {
30 | return 0;
31 | }
32 | void CyrilShape::eval(CyrilState &_s) {
33 | ofBeginShape();
34 | e->eval(_s);
35 | ofEndShape();
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilShape.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilShape.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilShape__
10 | #define __Cyril__CyrilShape__
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 |
15 | class CyrilShape : public Cyril {
16 | Cyril* e;
17 | public:
18 | CyrilShape(Cyril* _e);
19 | CyrilShape (const CyrilShape &other);
20 | virtual ~CyrilShape ();
21 | virtual void print();
22 | virtual Cyril *clone ();
23 | virtual int size();
24 | virtual void eval(CyrilState &);
25 | };
26 |
27 |
28 |
29 |
30 | #endif /* defined(__Cyril__CyrilShape__) */
31 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilShapeList.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilShapeList.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilShapeList.h"
10 |
11 | CyrilShapeList::CyrilShapeList (Cyril* _c) : c(_c) {
12 | int sz = _c->size();
13 | if (!(sz == 2 || sz == 3)) {
14 | yyerror("Shape list point requires 2 or 3 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilShapeList::CyrilShapeList (const CyrilShapeList &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilShapeList::~CyrilShapeList ()
23 | {
24 | delete c;
25 | }
26 | void CyrilShapeList::print() {
27 | c->print();
28 | cout << "ShapeList point" << endl;
29 | }
30 | Cyril * CyrilShapeList::clone () {
31 | return new CyrilShapeList (*this);
32 | }
33 | int CyrilShapeList::size() {
34 | return 0;
35 | }
36 | void CyrilShapeList::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float x,y,z;
39 | switch (c->size()) {
40 | case 2:
41 | y = _s.stk->top(); _s.stk->pop();
42 | x = _s.stk->top(); _s.stk->pop();
43 | ofVertex(x,y);
44 | break;
45 | case 3:
46 | z = _s.stk->top(); _s.stk->pop();
47 | y = _s.stk->top(); _s.stk->pop();
48 | x = _s.stk->top(); _s.stk->pop();
49 | ofVertex(x,y,z);
50 | break;
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilShapeList.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilShapeList.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilShapeList__
10 | #define __Cyril__CyrilShapeList__
11 |
12 | #include "ofMain.h"
13 | #include "Cyril.h"
14 |
15 | class CyrilShapeList : public Cyril {
16 | Cyril* e;
17 | Cyril* c;
18 | public:
19 | CyrilShapeList(Cyril* _c);
20 | CyrilShapeList (const CyrilShapeList &other);
21 | virtual ~CyrilShapeList ();
22 | virtual void print();
23 | virtual Cyril *clone ();
24 | virtual int size();
25 | virtual void eval(CyrilState &);
26 | };
27 |
28 |
29 | #endif /* defined(__Cyril__CyrilShapeList__) */
30 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilSphereDetailOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSphereDetailOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilSphereDetailOp.h"
10 |
11 | CyrilSphereDetailOp::CyrilSphereDetailOp (Cyril* _c) : CyrilOp(_c) {
12 | if (_c->size() != 1) {
13 | yyerror("SphereDetail command requires 1 argument");
14 | valid = false;
15 | }
16 | }
17 |
18 | CyrilSphereDetailOp::CyrilSphereDetailOp (const CyrilSphereDetailOp &other) {
19 | c = other.c->clone ();
20 | }
21 | CyrilSphereDetailOp::~CyrilSphereDetailOp ()
22 | {
23 | delete c;
24 | }
25 | void CyrilSphereDetailOp::print() {
26 | c->print();
27 | cout << "SphereDetail" << endl;
28 | }
29 | Cyril * CyrilSphereDetailOp::clone () {
30 | return new CyrilSphereDetailOp (*this);
31 | }
32 | int CyrilSphereDetailOp::size() {
33 | return 0;
34 | }
35 | void CyrilSphereDetailOp::eval(CyrilState &_s) {
36 | c->eval(_s);
37 | float d = _s.stk->top();
38 | _s.stk->pop();
39 | ofSetSphereResolution(d);
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilSphereDetailOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSphereDetailOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilSphereDetailOp__
10 | #define __cyril2__CyrilSphereDetailOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilSphereDetailOp : public CyrilOp {
16 | public:
17 | CyrilSphereDetailOp(Cyril* _c);
18 | CyrilSphereDetailOp (const CyrilSphereDetailOp &other);
19 | virtual ~CyrilSphereDetailOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilSphereDetailOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilSphereOp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSphereOp.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilSphereOp.h"
10 |
11 | CyrilSphereOp::CyrilSphereOp (Cyril* _c) : CyrilOp(_c) {
12 | int s = c->size();
13 | if (!(s == 0 || s == 1)) {
14 | yyerror("Sphere command requires 0 or 1 argument");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilSphereOp::CyrilSphereOp (const CyrilSphereOp &other) {
20 | c = other.c->clone ();
21 | }
22 | CyrilSphereOp::~CyrilSphereOp ()
23 | {
24 | delete c;
25 | }
26 | void CyrilSphereOp::print() {
27 | c->print();
28 | cout << "Sphere" << endl;
29 | }
30 | Cyril * CyrilSphereOp::clone () {
31 | return new CyrilSphereOp (*this);
32 | }
33 | int CyrilSphereOp::size() {
34 | return 0;
35 | }
36 | void CyrilSphereOp::eval(CyrilState &_s) {
37 | c->eval(_s);
38 | float r;
39 | if (c->size() == 1) {
40 | r = _s.stk->top();
41 | _s.stk->pop();
42 | }
43 | else {
44 | r = 1;
45 | }
46 | ofDrawSphere(r);
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilSphereOp.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilSphereOp.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__CyrilSphereOp__
10 | #define __cyril2__CyrilSphereOp__
11 |
12 | #include "ofMain.h"
13 | #include "CyrilOp.h"
14 |
15 | class CyrilSphereOp : public CyrilOp {
16 | public:
17 | CyrilSphereOp(Cyril* _c);
18 | CyrilSphereOp (const CyrilSphereOp &other);
19 | virtual ~CyrilSphereOp ();
20 | virtual void print();
21 | virtual Cyril *clone ();
22 | virtual int size();
23 | virtual void eval(CyrilState &);
24 | };
25 |
26 | #endif /* defined(__cyril2__CyrilSphereOp__) */
27 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilTile.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilTileOp.cpp
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #include "CyrilTile.h"
10 |
11 | CyrilTile::CyrilTile (Cyril* _e, Cyril* _c) : e(_e), c(_c) {
12 | int s = e->size();
13 | if (!(s == 1 || s == 2 || s == 3)) {
14 | yyerror("Tile command takes 1, 2, 3 or 4 arguments");
15 | valid = false;
16 | }
17 | }
18 |
19 | CyrilTile::CyrilTile (const CyrilTile &other) {
20 | e = other.e->clone ();
21 | c = other.c->clone ();
22 | }
23 | CyrilTile::~CyrilTile ()
24 | {
25 | delete c;
26 | }
27 | void CyrilTile::print() {
28 | c->print();
29 | cout << "Tile" << endl;
30 | }
31 | Cyril * CyrilTile::clone () {
32 | return new CyrilTile (*this);
33 | }
34 | int CyrilTile::size() {
35 | return 0;
36 | }
37 | void CyrilTile::eval(CyrilState &_s) {
38 | float w,h,d;
39 | float step = 1;
40 | e->eval(_s);
41 | switch (e->size()) {
42 | case 1:
43 | d = 1;
44 | h = 1;
45 | w = _s.stk->top(); _s.stk->pop();
46 | break;
47 | case 2:
48 | d = 1;
49 | h = _s.stk->top(); _s.stk->pop();
50 | w = _s.stk->top(); _s.stk->pop();
51 | break;
52 | case 3:
53 | d = _s.stk->top(); _s.stk->pop();
54 | h = _s.stk->top(); _s.stk->pop();
55 | w = _s.stk->top(); _s.stk->pop();
56 | break;
57 | case 4:
58 | step = _s.stk->top(); _s.stk->pop();
59 | d = _s.stk->top(); _s.stk->pop();
60 | h = _s.stk->top(); _s.stk->pop();
61 | w = _s.stk->top(); _s.stk->pop();
62 | break;
63 | }
64 | float xMin = (step - (w * step)) / 2.0;
65 | float xMax = ((w * step) - step) / 2.0;
66 | float yMin = (step - (h * step)) / 2.0;
67 | float yMax = ((h * step) - step) / 2.0;
68 | float zMin = (step - (d * step)) / 2.0;
69 | float zMax = ((d * step) - step) / 2.0;
70 | for (float x = xMin; x <= xMax; x += step) {
71 | for (float y = yMin; y <= yMax; y += step) {
72 | for (float z = zMin; z <= zMax; z += step) {
73 | ofPushMatrix();
74 | ofTranslate(x, y, z);
75 | c->eval(_s);
76 | ofPopMatrix();
77 | }
78 | }
79 | }
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/src/Cyril/Ops/CyrilTile.h:
--------------------------------------------------------------------------------
1 | //
2 | // CyrilTileOp.h
3 | // Cyril
4 | //
5 | // Created by Darren Mothersele on 17/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __Cyril__CyrilTileOp__
10 | #define __Cyril__CyrilTileOp__
11 |
12 | #include "Cyril.h"
13 |
14 |
15 | class CyrilTile : public Cyril {
16 | protected:
17 | Cyril* e;
18 | Cyril* c;
19 | public:
20 | CyrilTile(Cyril* _e, Cyril* _c);
21 | CyrilTile (const CyrilTile &other);
22 | virtual ~CyrilTile ();
23 | virtual void print();
24 | virtual Cyril *clone ();
25 | virtual int size();
26 | virtual void eval(CyrilState &);
27 | virtual int matchPushPop() { return c->matchPushPop(); }
28 | };
29 |
30 | #endif /* defined(__Cyril__CyrilTileOp__) */
31 |
--------------------------------------------------------------------------------
/src/Cyril/cyril.lpp:
--------------------------------------------------------------------------------
1 | %{
2 | #define YY_DECL extern "C" int yylex()
3 | #include "y.tab.h"
4 | extern "C" int line_no;
5 | extern "C" int yyparse();
6 |
7 | %}
8 |
9 | %option noyywrap
10 | %%
11 | [ \t] ; // Ignore whitespace
12 | \/\/.*\n { line_no++;} // Ignore comments
13 | \( { return LEFT; }
14 | \) { return RIGHT; }
15 | \* { return MULT; }
16 | \/ { return DIV; }
17 | \+ { return PLUS; }
18 | \% { return MOD; }
19 | \- { return MINUS; }
20 | and|\&|\&\& { return AND; }
21 | or|\||\|\| { return OR; }
22 | \=|\=\= { return EQ; }
23 | \!= { return NOTEQ; }
24 | \< { return LESS; }
25 | \<= { return LESSEQ; }
26 | \> { return GR; }
27 | \>= { return GREQ; }
28 | \! { return NOT; }
29 | shape { return SHAPE; }
30 | tile { return TILE; }
31 | anim { return ANIM; }
32 | next { return NEXT; }
33 | particle { return PARTICLE; }
34 | palette { return PALETTE; }
35 | blink { return BLINK; }
36 | do { return DO; }
37 | for { return FOR; }
38 | to { return TO; }
39 | step { return STEP; }
40 | until { return UNTIL; }
41 | times { return TIMES; }
42 | if { return IF; }
43 | init { return INIT; }
44 | while { return WHILE; }
45 | end { return END; }
46 | (\#)([0-9A-Fa-f]{6}) {
47 | yylval.sval = strdup(yytext + 1);
48 | return HEX_COLOR;
49 | }
50 | (-)?[0-9]+(\.[0-9]+)? {
51 | yylval.fval = atof(yytext);
52 | return NUMBER;
53 | }
54 | fft|lerp|rgb|hsb|hsv|wave|sin|cos|tan|noise|rand|map|pal { yylval.sval = strdup(yytext);
55 | return FUNCTION;
56 | }
57 | die|vert|img|box|ball|sphere|line|rect|cone|peg|grid|move { yylval.sval = strdup(yytext);
58 | return KEYWORD;
59 | }
60 | debug|color|background|ballDetail|sphereDetail|light { yylval.sval = strdup(yytext);
61 | return KEYWORD;
62 | }
63 | fxK|fxNW|fxP|fxB|lightOn|lightOff|lightPosition|lightColor|lightHighlight { yylval.sval = strdup(yytext);
64 | return KEYWORD;
65 | }
66 | rotate|fill|stroke|push|pushMatrix|pop|popMatrix|scale|fill|noFill { yylval.sval = strdup(yytext);
67 | return KEYWORD;
68 | }
69 | white|gray|black|red|green|blue|cyan|magenta|yellow|aliceBlue|antiqueWhite|aqua|aquamarine|azure|beige|bisque|blanchedAlmond|blueViolet|brown|burlyWood|cadetBlue|chartreuse|chocolate|coral|cornflowerBlue|cornsilk|crimson|darkBlue|darkCyan|darkGoldenRod|darkGray|darkGrey|darkGreen|darkKhaki|darkMagenta|darkOliveGreen|darkorange|darkOrchid|darkRed|darkSalmon|darkSeaGreen|darkSlateBlue|darkSlateGray|darkSlateGrey|darkTurquoise|darkViolet|deepPink|deepSkyBlue|dimGray|dimGrey|dodgerBlue|fireBrick|floralWhite|forestGreen|fuchsia|gainsboro|ghostWhite|gold|goldenRod|grey|greenYellow|honeyDew|hotPink|indianRed|indigo|ivory|khaki|lavender|lavenderBlush|lawnGreen|lemonChiffon|lightBlue|lightCoral|lightCyan|lightGoldenRodYellow|lightGray|lightGrey|lightGreen|lightPink|lightSalmon|lightSeaGreen|lightSkyBlue|lightSlateGray|lightSlateGrey|lightSteelBlue|lightYellow|lime|limeGreen|linen|maroon|mediumAquaMarine|mediumBlue|mediumOrchid|mediumPurple|mediumSeaGreen|mediumSlateBlue|mediumSpringGreen|mediumTurquoise|mediumVioletRed|midnightBlue|mintCream|mistyRose|moccasin|navajoWhite|navy|oldLace|olive|oliveDrab|orange|orangeRed|orchid|paleGoldenRod|paleGreen|paleTurquoise|paleVioletRed|papayaWhip|peachPuff|peru|pink|plum|powderBlue|purple|rosyBrown|royalBlue|saddleBrown|salmon|sandyBrown|seaGreen|seaShell|sienna|silver|skyBlue|slateBlue|slateGray|slateGrey|snow|springGreen|steelBlue|blueSteel|tanC|teal|thistle|tomato|turquoise|violet|wheat|whiteSmoke|yellowGreen { yylval.sval = strdup(yytext);
70 | return COLOR_NAME;
71 | }
72 | \$[a-zA-Z0-9_]+ { yylval.sval = strdup(yytext);
73 | return PALETTE_NAME;
74 | }
75 | \#[a-zA-Z0-9_]+ { yylval.sval = strdup(yytext);
76 | return COLOR_VAR;
77 | }
78 | [a-zA-Z0-9_]+ { yylval.sval = strdup(yytext);
79 | return LABEL;
80 | }
81 | \n return ENDL;
82 | \: return ASSIGN;
83 | \, return COMMA;
84 | %%
85 |
86 | void scannerRestart() {
87 | YY_FLUSH_BUFFER;
88 | }
89 |
90 | int yycyrilParseString(const char *str) {
91 | line_no = 0;
92 | yy_scan_string(str);
93 | return yyparse();
94 | //printf(str);
95 | }
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/src/Cyril/cyril.ypp:
--------------------------------------------------------------------------------
1 | %{
2 | #include
3 | #include
4 | #include "ofMain.h"
5 | #include "cmds.h"
6 | #include "Cyril.h"
7 | #include "CyrilList.h"
8 | #include "CyrilAssign.h"
9 | #include "CyrilPush.h"
10 | #include "CyrilDo.h"
11 | #include "CyrilFor.h"
12 | #include "CyrilIf.h"
13 | #include "CyrilWhile.h"
14 | #include "CyrilHexColor.h"
15 | #include "CyrilNamedColor.h"
16 | #include "CyrilBinaryOp.h"
17 | #include "CyrilLoad.h"
18 | #include "CyrilColorLoad.h"
19 | #include "CyrilUnaryOp.h"
20 | #include "CyrilParticle.h"
21 | #include "CyrilPalette.h"
22 | #include "CyrilPaletteItem.h"
23 | #include "CyrilBlink.h"
24 | #include "CyrilTile.h"
25 |
26 | #include "CyrilOp.h"
27 | #include "CyrilDie.h"
28 | #include "CyrilBoxOp.h"
29 | #include "CyrilMoveOp.h"
30 | #include "CyrilRotateOp.h"
31 | #include "CyrilScaleOp.h"
32 | #include "CyrilPushMatrixOp.h"
33 | #include "CyrilPopMatrixOp.h"
34 | #include "CyrilLineOp.h"
35 | #include "CyrilBackgroundOp.h"
36 | #include "CyrilColorOp.h"
37 | #include "CyrilDebugOp.h"
38 | #include "CyrilBallOp.h"
39 | #include "CyrilSphereOp.h"
40 | #include "CyrilPegOp.h"
41 | #include "CyrilRectOp.h"
42 | #include "CyrilConeOp.h"
43 | #include "CyrilGridOp.h"
44 | #include "CyrilBallDetailOp.h"
45 | #include "CyrilSphereDetailOp.h"
46 | #include "CyrilImgOp.h"
47 | #include "CyrilLightOp.h"
48 | #include "CyrilFillOp.h"
49 | #include "CyrilNoFillOp.h"
50 | #include "CyrilInitOp.h"
51 | #include "CyrilKaleidoscope.h"
52 | #include "CyrilNoiseWarp.h"
53 | #include "CyrilPixelate.h"
54 | #include "CyrilBloom.h"
55 |
56 | #include "CyrilAnimation.h"
57 | #include "CyrilAnimStep.h"
58 | #include "CyrilShape.h"
59 | #include "CyrilShapeList.h"
60 |
61 | #include "CyrilFun.h"
62 | #include "CyrilWaveFun.h"
63 | #include "CyrilSinFun.h"
64 | #include "CyrilCosFun.h"
65 | #include "CyrilTanFun.h"
66 | #include "CyrilNoiseFun.h"
67 | #include "CyrilRandFun.h"
68 | #include "CyrilHsbFun.h"
69 | #include "CyrilMapFun.h"
70 | #include "CyrilLerpFun.h"
71 | #include "CyrilPaletteFun.h"
72 | #include "CyrilFftFun.h"
73 |
74 | using namespace std;
75 |
76 | extern "C" int yylex();
77 | extern "C" int yyparse();
78 | extern FILE *yyin;
79 |
80 | int line_no = 0;
81 | Cyril * pRoot;
82 |
83 | void yyerror(const char *s);
84 | map symTab;
85 | map paletteTab;
86 |
87 | int paletteFind(string _s) {
88 | if (paletteTab.find(_s) == paletteTab.end()) {
89 | int loc = paletteTab.size();
90 | paletteTab[_s] = loc;
91 | return loc;
92 | }
93 | return paletteTab[_s];
94 | }
95 |
96 | int regFind(string _s) {
97 | if ("TIME" == _s) return REG_TIME;
98 | if ("SECS" == _s) return REG_SECS;
99 | if ("FAST" == _s) return REG_FAST;
100 | if ("SLOW" == _s) return REG_SLOW;
101 | if ("FRAME" == _s) return REG_FRAME;
102 | if ("PI" == _s) return REG_PI;
103 | if ("TWO_PI" == _s) return REG_TWO_PI;
104 | if ("HEALTH" == _s) return REG_PARTICLE_HEALTH;
105 | if ("DECAY" == _s) return REG_PARTICLE_DECAY;
106 | if ("SIGNAL" == _s) return REG_MIND_SIGNAL;
107 | if ("ATTENTION" == _s) return REG_MIND_ATTENTION;
108 | if ("MEDITATION" == _s) return REG_MIND_MEDITATION;
109 | if ("DELTA" == _s) return REG_MIND_DELTA;
110 | if ("THETA" == _s) return REG_MIND_THETA;
111 | if ("LOWALPHA" == _s) return REG_MIND_LOWALPHA;
112 | if ("HIGHALPHA" == _s) return REG_MIND_HIGHALPHA;
113 | if ("LOWBETA" == _s) return REG_MIND_LOWBETA;
114 | if ("HIGHBETA" == _s) return REG_MIND_HIGHBETA;
115 | if ("LOWGAMMA" == _s) return REG_MIND_LOWGAMMA;
116 | if ("MIDGAMMA" == _s) return REG_MIND_MIDGAMMA;
117 | if ("KICK" == _s) return REG_BEAT_KICK;
118 | if ("SNARE" == _s) return REG_BEAT_SNARE;
119 | if ("HIHAT" == _s) return REG_BEAT_HIHAT;
120 | if ("PADX" == _s) return OSC_X;
121 | if ("PADY" == _s) return OSC_Y;
122 | if ("F1" == _s) return OSC_F1;
123 | if ("F2" == _s) return OSC_F2;
124 | if ("F3" == _s) return OSC_F3;
125 | if ("F4" == _s) return OSC_F4;
126 |
127 | if (symTab.find(_s) == symTab.end()) {
128 | int loc = symTab.size() + REG_COUNT;
129 | symTab[_s] = loc;
130 | return loc;
131 | }
132 | return symTab[_s];
133 | }
134 |
135 | Cyril * cyrilOpFactory(const char * _s, Cyril * _c) {
136 | if (strncmp("box", _s, 3) == 0) return new CyrilBoxOp(_c);
137 | if (strncmp("move", _s, 4) == 0) return new CyrilMoveOp(_c);
138 | if (strncmp("rotate", _s, 6) == 0) return new CyrilRotateOp(_c);
139 | if (strncmp("scale", _s, 5) == 0) return new CyrilScaleOp(_c);
140 | if (strncmp("pushMatrix", _s, 4) == 0) return new CyrilPushMatrixOp(_c);
141 | if (strncmp("popMatrix", _s, 3) == 0) return new CyrilPopMatrixOp(_c);
142 | if (strncmp("line", _s, 4) == 0) return new CyrilLineOp(_c);
143 | if (strncmp("background", _s, 10) == 0) return new CyrilBackgroundOp(_c);
144 | if (strncmp("color", _s, 5) == 0) return new CyrilColorOp(_c);
145 | if (strncmp("debug", _s, 5) == 0) return new CyrilDebugOp(_c);
146 | if (strncmp("peg", _s, 3) == 0) return new CyrilPegOp(_c);
147 | if (strncmp("rect", _s, 4) == 0) return new CyrilRectOp(_c);
148 | if (strncmp("cone", _s, 4) == 0) return new CyrilConeOp(_c);
149 | if (strncmp("grid", _s, 4) == 0) return new CyrilGridOp(_c);
150 | if (strncmp("ballDetail", _s, 10) == 0) return new CyrilBallDetailOp(_c);
151 | if (strncmp("sphereDetail", _s, 12) == 0) return new CyrilSphereDetailOp(_c);
152 | if (strncmp("ball", _s, 4) == 0) return new CyrilBallOp(_c);
153 | if (strncmp("sphere", _s, 6) == 0) return new CyrilSphereOp(_c);
154 | if (strncmp("img", _s, 3) == 0) return new CyrilImgOp(_c);
155 | if (strncmp("light", _s, 5) == 0) return new CyrilLightOp(_c);
156 | if (strncmp("lightColor", _s, 10) == 0) return new CyrilLightOp(_c);
157 | if (strncmp("noFill", _s, 6) == 0) return new CyrilNoFillOp(_c);
158 | if (strncmp("stroke", _s, 6) == 0) return new CyrilNoFillOp(_c);
159 | if (strncmp("fill", _s, 4) == 0) return new CyrilFillOp(_c);
160 | if (strncmp("vert", _s, 4) == 0) return new CyrilShapeList(_c);
161 | if (strncmp("fxK", _s, 3) == 0) return new CyrilKaleidoscope(_c);
162 | if (strncmp("fxNW", _s, 4) == 0) return new CyrilNoiseWarp(_c);
163 | if (strncmp("fxP", _s, 3) == 0) return new CyrilPixelate(_c);
164 | if (strncmp("fxB", _s, 3) == 0) return new CyrilBloom(_c);
165 | if (strncmp("die", _s, 3) == 0) return new CyrilDie(_c);
166 | return new CyrilOp(_c);
167 | }
168 |
169 | Cyril * cyrilFunFactory(const char * _s, Cyril * _c) {
170 | if (strncmp("wave", _s, 4) == 0) return new CyrilWaveFun(_c);
171 | if (strncmp("sin", _s, 3) == 0) return new CyrilSinFun(_c);
172 | if (strncmp("cos", _s, 3) == 0) return new CyrilCosFun(_c);
173 | if (strncmp("tan", _s, 3) == 0) return new CyrilTanFun(_c);
174 | if (strncmp("noise", _s, 5) == 0) return new CyrilNoiseFun(_c);
175 | if (strncmp("rand", _s, 4) == 0) return new CyrilRandFun(_c);
176 | if (strncmp("hsb", _s, 3) == 0) return new CyrilHsbFun(_c);
177 | if (strncmp("hsv", _s, 3) == 0) return new CyrilHsbFun(_c);
178 | if (strncmp("map", _s, 3) == 0) return new CyrilMapFun(_c);
179 | if (strncmp("lerp", _s, 4) == 0) return new CyrilLerpFun(_c);
180 | if (strncmp("pal", _s, 3) == 0) return new CyrilPaletteFun(_c);
181 | if (strncmp("fft", _s, 3) == 0) return new CyrilFftFun(_c);
182 | return new CyrilFun(_c);
183 | }
184 |
185 | %}
186 |
187 | %union {
188 | float fval;
189 | char *sval;
190 | class Cyril *ast;
191 | }
192 |
193 | %token ENDL COMMA LEFT RIGHT ASSIGN DO TIMES END UNTIL IF WHILE INIT
194 | %token FOR TO STEP PARTICLE PALETTE BLINK ANIM NEXT TILE SHAPE
195 | %token PLUS MINUS MOD MULT DIV EQ LESS LESSEQ GR GREQ NOTEQ NOT AND OR
196 | %token HEX_COLOR LABEL KEYWORD FUNCTION COLOR_VAR PALETTE_NAME COLOR_NAME
197 | %token NUMBER
198 |
199 | %left MULT PLUS MINUS DIV MOD EQ NOTEQ LESSEQ LESS GREQ GR
200 | %right NOT
201 |
202 | %type expr expr_list statement statement_list cyril palette_list anim_list
203 |
204 | %start cyril
205 | %%
206 |
207 | cyril: statement_list {
208 | pRoot = $1;
209 | }
210 |
211 | statement_list:
212 | statement
213 | {
214 | $$ = $1;
215 | }
216 | | statement_list statement
217 | {
218 | $$ = new CyrilList($1, $2);
219 |
220 | }
221 | ;
222 |
223 | statement:
224 | ENDL
225 | {
226 | $$ = new Cyril();
227 | line_no++;
228 | }
229 | | KEYWORD expr_list ENDL
230 | {
231 | $$ = cyrilOpFactory($1, $2);
232 | line_no++;
233 | }
234 | | KEYWORD ENDL
235 | {
236 | $$ = cyrilOpFactory($1, new Cyril());
237 | line_no++;
238 | }
239 | | LABEL ASSIGN expr ENDL
240 | {
241 | $$ = new CyrilAssign(regFind($1), $3);
242 | line_no++;
243 | }
244 | | COLOR_VAR ASSIGN expr ENDL
245 | {
246 | $$ = new CyrilAssign(regFind($1), $3);
247 | line_no++;
248 | }
249 | | DO expr TIMES ENDL statement_list END ENDL
250 | {
251 | $$ = new CyrilDo($2, $5);
252 | line_no += 2;
253 | }
254 | | FOR LABEL ASSIGN expr TO expr STEP expr ENDL statement_list END ENDL
255 | {
256 | $$ = new CyrilFor(regFind($2), $4, $6, $8, $10);
257 | line_no += 2;
258 | }
259 | | IF expr statement
260 | {
261 | $$ = new CyrilIf($2, $3);
262 | }
263 | | IF expr ENDL statement_list END ENDL
264 | {
265 | $$ = new CyrilIf($2, $4);
266 | line_no += 2;
267 | }
268 | | WHILE expr DO statement_list END ENDL
269 | {
270 | $$ = new CyrilWhile($2, $4);
271 | line_no += 2;
272 | }
273 | | PARTICLE expr_list ENDL statement_list END ENDL
274 | {
275 | $$ = new CyrilParticle($2, $4);
276 | line_no += 2;
277 | }
278 | | PALETTE PALETTE_NAME ENDL palette_list END ENDL
279 | {
280 | int pNum = paletteFind($2);
281 | $$ = new CyrilPalette(pNum, $4);
282 | line_no += 2;
283 | }
284 | | BLINK expr_list ENDL statement_list END ENDL
285 | {
286 | $$ = new CyrilBlink($2, $4);
287 | line_no += 2;
288 | }
289 | | ANIM anim_list END ENDL
290 | {
291 | $$ = new CyrilAnimation($2);
292 | line_no += 2;
293 | }
294 | | TILE expr_list ENDL statement_list END ENDL
295 | {
296 | $$ = new CyrilTile($2, $4);
297 | line_no += 2;
298 | }
299 | | SHAPE ENDL statement_list END ENDL
300 | {
301 | $$ = new CyrilShape($3);
302 | line_no += 2;
303 | }
304 | | INIT statement
305 | {
306 | $$ = new CyrilInitOp($2);
307 | line_no += 1;
308 | }
309 | ;
310 |
311 |
312 | anim_list:
313 | NUMBER ENDL statement_list
314 | {
315 | $$ = new CyrilAnimStep($1, $3, new Cyril());
316 | line_no++;
317 | }
318 | | anim_list NEXT NUMBER ENDL statement_list
319 | {
320 | $$ = new CyrilAnimStep($3, $5, $1);
321 | line_no++;
322 | }
323 | ;
324 |
325 | palette_list:
326 | NUMBER expr_list ENDL
327 | {
328 | $$ = new CyrilPaletteItem($1, $2);
329 | line_no++;
330 | }
331 | | palette_list NUMBER expr_list ENDL
332 | {
333 | $$ = new CyrilList($1, new CyrilPaletteItem($2, $3));
334 | line_no++;
335 | }
336 | ;
337 |
338 | expr_list:
339 | expr
340 | {
341 | $$ = $1;
342 | }
343 | | expr_list COMMA expr
344 | {
345 | $$ = new CyrilList($1, $3);
346 | }
347 | ;
348 |
349 | expr:
350 | COLOR_NAME
351 | {
352 | $$ = new CyrilNamedColor($1);
353 | }
354 | | HEX_COLOR
355 | {
356 | $$ = new CyrilHexColor($1);
357 | }
358 | | FUNCTION LEFT expr_list RIGHT
359 | {
360 | $$ = cyrilFunFactory($1, $3);
361 | }
362 | | FUNCTION LEFT RIGHT
363 | {
364 | $$ = cyrilFunFactory($1, new Cyril());
365 | }
366 | | NUMBER
367 | {
368 | $$ = new CyrilPush($1);
369 | }
370 | | COLOR_VAR
371 | {
372 | $$ = new CyrilColorLoad(regFind($1));
373 | }
374 | | PALETTE_NAME
375 | {
376 | $$ = new CyrilPush(paletteFind($1));
377 | }
378 | | LABEL
379 | {
380 | $$ = new CyrilLoad(regFind($1));
381 | }
382 | | expr MINUS expr
383 | {
384 | $$ = new CyrilBinaryOp("-", $1, $3);
385 | }
386 | | expr PLUS expr
387 | {
388 | $$ = new CyrilBinaryOp("+", $1, $3);
389 | }
390 | | expr MULT expr
391 | {
392 | $$ = new CyrilBinaryOp("*", $1, $3);
393 | }
394 | | expr DIV expr
395 | {
396 | $$ = new CyrilBinaryOp("/", $1, $3);
397 | }
398 | | expr MOD expr
399 | {
400 | $$ = new CyrilBinaryOp("%", $1, $3);
401 | }
402 | | expr EQ expr
403 | {
404 | $$ = new CyrilBinaryOp("==", $1, $3);
405 | }
406 | | expr NOTEQ expr
407 | {
408 | $$ = new CyrilBinaryOp("!=", $1, $3);
409 | }
410 | | expr GR expr
411 | {
412 | $$ = new CyrilBinaryOp(">", $1, $3);
413 | }
414 | | expr GREQ expr
415 | {
416 | $$ = new CyrilBinaryOp(">=", $1, $3);
417 | }
418 | | expr LESS expr
419 | {
420 | $$ = new CyrilBinaryOp("<", $1, $3);
421 | }
422 | | expr LESSEQ expr
423 | {
424 | $$ = new CyrilBinaryOp("<=", $1, $3);
425 | }
426 | | expr AND expr
427 | {
428 | $$ = new CyrilBinaryOp("&", $1, $3);
429 | }
430 | | expr OR expr
431 | {
432 | $$ = new CyrilBinaryOp("|", $1, $3);
433 | }
434 | | NOT expr
435 | {
436 | $$ = new CyrilUnaryOp("!", $2);
437 | }
438 | | LEFT expr RIGHT
439 | {
440 | $$ = $2;
441 | }
442 | %%
443 |
444 | void yyerror(const char *s) {
445 | cout << s << " at line " << (line_no + 1) << endl;
446 | }
447 |
--------------------------------------------------------------------------------
/src/Engine/Palette.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Palette.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #include "Palette.h"
10 |
11 | Palette::Palette() : total(0) {
12 |
13 | }
14 | void Palette::addColor(float _d, int _hex) {
15 | total += _d;
16 | colors.push_back(PaletteItem(_d, _hex));
17 | }
18 | void Palette::addColor(float _d, float _r, float _g, float _b) {
19 | total += _d;
20 | colors.push_back(PaletteItem(_d, _r, _g, _b));
21 | }
22 |
23 | void Palette::drawBackground() {
24 | // TODO: draw gradient background using palette variable
25 | //for (int y = 0; y < ofGetHeight(); y++) {
26 | //ofSetColor(lerp(y / ofGetHeight()));
27 | //ofLine(0, y, ofGetWidth(), y);
28 | //}
29 | }
30 |
31 | ofColor Palette::lerp(float _v) {
32 | PaletteItem first = colors.front();
33 | float newV = ofMap(ofClamp(_v, 0, 1), 0, 1, 0, total);
34 | float keepV = newV;
35 |
36 | bool findFirst = true;
37 | ofColor found, nextC;
38 | float prevD(0), nextD(0);
39 | for(vector::iterator it = colors.begin(); it != colors.end(); ++it){
40 | if (findFirst) {
41 | found = it->c;
42 | prevD += it->distance;
43 | newV -= it->distance;
44 | if (newV < 0) {
45 | findFirst = false;
46 | nextD = prevD;
47 | }
48 | }
49 | else {
50 | nextC = it->c;
51 | nextD += it->distance;
52 | break;
53 | }
54 | }
55 | if (prevD == nextD) {
56 | return colors.back().c;
57 | }
58 | return found.lerp(nextC, ofMap(keepV, prevD - first.distance, nextD, 0, 1));
59 | }
60 |
61 | ofColor Palette::getColor(float _v) {
62 | ofColor found;
63 | for(vector::iterator it = colors.begin(); it != colors.end(); ++it){
64 | found = it->c;
65 | _v -= it->distance;
66 | if (_v <= 0) break;
67 | }
68 | return found;
69 | }
70 | ofColor Palette::randomColor() {
71 | return getColor(ofRandom(total));
72 | }
73 | ofColor Palette::getColorAt(float _i) {
74 | return getColor(total * _i);
75 | }
76 |
77 | Palette::Palette (const Palette &other) {
78 | total = other.total;
79 | colors = * new vector(other.colors);
80 | }
81 | Palette::~Palette () {
82 |
83 | }
84 | Palette * Palette::clone () {
85 | return new Palette(* this);
86 | }
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/Engine/Palette.h:
--------------------------------------------------------------------------------
1 | //
2 | // Palette.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 06/11/2013.
6 | //
7 | //
8 |
9 | #ifndef __cyril2__Palette__
10 | #define __cyril2__Palette__
11 |
12 | #include "ofMain.h"
13 |
14 | class PaletteItem {
15 | public:
16 | ofColor c;
17 | float distance;
18 |
19 | PaletteItem(float _d, int _hex) {
20 | c = ofColor::fromHex(_hex);
21 | distance = _d;
22 | }
23 | PaletteItem(float _d, float _r, float _g, float _b) {
24 | c = ofColor(_r, _g, _b);
25 | distance = _d;
26 | }
27 | };
28 |
29 | class Palette {
30 | float total;
31 | vector colors;
32 | public:
33 | Palette();
34 | void addColor(float, int);
35 | void addColor(float, float, float, float);
36 | ofColor getColor(float);
37 | ofColor randomColor();
38 | ofColor getColorAt(float);
39 | ofColor lerp(float);
40 | Palette (const Palette &other) ;
41 | virtual ~Palette ();
42 | virtual Palette *clone ();
43 | void drawBackground();
44 | };
45 |
46 |
47 | #endif /* defined(__cyril2__Palette__) */
48 |
--------------------------------------------------------------------------------
/src/Engine/Particle.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Particle.cpp
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #include "Particle.h"
10 |
11 | Particle::~Particle() {
12 | delete shape;
13 | }
14 |
15 | void Particle::draw(CyrilState * _s) {
16 |
17 | ofPushMatrix();
18 | ofGetCurrentRenderer()->multMatrix(origin);
19 | ofGetCurrentRenderer()->multMatrix(location);
20 |
21 | _sub_state.parent = _s;
22 |
23 | shape->eval(_sub_state);
24 |
25 | ofPopMatrix();
26 |
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/src/Engine/Particle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Particle.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_Particle_h
10 | #define cyril2_Particle_h
11 |
12 | #include "ofMain.h"
13 | #include "cmds.h"
14 | #include "Cyril.h"
15 | #include "CyrilState.h"
16 |
17 | class Particle {
18 | public:
19 | ofMatrix4x4 origin;
20 | ofMatrix4x4 location;
21 | ofVec3f velocity;
22 | ofVec3f acceleration;
23 | float health;
24 | float decay;
25 | Cyril* shape;
26 | CyrilState _sub_state;
27 |
28 | Particle (ofMatrix4x4 _o, ofVec3f _v, ofVec3f _a, float _h, float _d, Cyril* _s) :
29 | origin(_o), velocity(_v), acceleration(_a), health(_h), decay(_d), shape(_s) {
30 |
31 | _sub_state.stk = new stack;
32 | _sub_state.ms = new ofMatrixStack(*ofGetWindowPtr());
33 | _sub_state.ps = new vector;
34 | _sub_state.sym = new map;
35 | _sub_state.cs = new map;
36 | _sub_state.img = new map;
37 | (*_sub_state.sym)[REG_PARTICLE_HEALTH] = health;
38 | (*_sub_state.sym)[REG_PARTICLE_DECAY] = decay;
39 | }
40 | ~Particle();
41 | void update() {
42 | velocity += acceleration;
43 | location.translate(velocity);
44 | health -= decay;
45 | }
46 | void draw(CyrilState * _s);
47 | static bool isDead(Particle *&p) {
48 | return p->health <= 0;
49 | }
50 | };
51 |
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/cmds.h:
--------------------------------------------------------------------------------
1 | //
2 | // cmds.h
3 | // cyril2
4 | //
5 | // Created by Darren Mothersele on 05/11/2013.
6 | //
7 | //
8 |
9 | #ifndef cyril2_cmds_h
10 | #define cyril2_cmds_h
11 |
12 | #define CMD_OP_COUNT 50
13 |
14 | #define CMD_LOAD 0
15 | #define CMD_SAVE 1
16 | #define CMD_SAVE_NOPOP 37
17 | #define CMD_PUSH 3
18 | #define CMD_JUMP 4
19 | #define CMD_IF 5
20 | #define CMD_JUMPNIF 33
21 | #define CMD_JUMPNIF_NOPOP 38
22 | #define CMD_DEC_F 34
23 | #define CMD_INC_F 39
24 |
25 | #define OP_DEBUG 41
26 | #define OP_MOVE 6
27 | #define OP_ROTATE 7
28 | #define OP_SCALE 46
29 | #define OP_PUSH_MATRIX 47
30 | #define OP_POP_MATRIX 48
31 |
32 | #define OP_BACKGROUND 44
33 | #define OP_COLOR 45
34 |
35 | #define OP_BOX 8
36 | #define OP_LINE 9
37 | #define OP_BALL 10
38 | #define OP_SPHERE 49
39 | #define OP_PEG 11
40 | #define OP_CONE 12
41 | #define OP_RECT 13
42 | #define OP_PARTICLE 14
43 | #define OP_GRID 43
44 |
45 | #define OP_PLUS 15
46 | #define OP_MINUS 16
47 | #define OP_DIV 17
48 | #define OP_MULT 18
49 | #define OP_MOD 19
50 |
51 | #define OP_EQ 20
52 | #define OP_NOTEQ 21
53 | #define OP_LESS 22
54 | #define OP_LESS_1POP 40
55 | #define OP_LESSEQ 23
56 | #define OP_GR 24
57 | #define OP_GREQ 25
58 | #define OP_GREQ_1POP 42
59 | #define OP_NOT 26
60 | #define OP_AND 35
61 | #define OP_OR 36
62 |
63 | #define FUN_WAVE 27
64 | #define FUN_SIN 28
65 | #define FUN_COS 29
66 | #define FUN_TAN 30
67 | #define FUN_NOISE 31
68 | #define FUN_RAND 32
69 |
70 | #define REG_COUNT 68
71 |
72 | #define REG_TIME 0
73 | #define REG_FRAME 1
74 | #define REG_PI 13
75 | #define REG_TWO_PI 14
76 | #define REG_X_MAX 17
77 | #define REG_Y_MAX 18
78 | #define REG_X_MID 19
79 | #define REG_Y_MID 20
80 | #define REG_SECS 28
81 | #define REG_FAST 29
82 | #define REG_SLOW 30
83 |
84 | #define REG_X_SCALE 21
85 | #define REG_Y_SCALE 22
86 | #define REG_Z_SCALE 23
87 |
88 | #define REG_PARTICLE_HEALTH 15
89 | #define REG_PARTICLE_DECAY 16
90 |
91 | #define REG_MIND_SIGNAL 2
92 | #define REG_MIND_ATTENTION 3
93 | #define REG_MIND_MEDITATION 4
94 | #define REG_MIND_DELTA 5
95 | #define REG_MIND_THETA 6
96 | #define REG_MIND_LOWALPHA 7
97 | #define REG_MIND_HIGHALPHA 8
98 | #define REG_MIND_LOWBETA 9
99 | #define REG_MIND_HIGHBETA 10
100 | #define REG_MIND_LOWGAMMA 11
101 | #define REG_MIND_MIDGAMMA 12
102 |
103 | #define REG_BEAT_KICK 24
104 | #define REG_BEAT_SNARE 25
105 | #define REG_BEAT_HIHAT 26
106 | #define REG_BEAT_MAGNITUDE 27
107 | #define REG_BEAT_FFT_START 35
108 | #define REG_BEAT_FFT_MAX 67
109 |
110 | #define REG_COLOR_WHITE 31
111 | #define REG_COLOR_GRAY 32
112 | #define REG_COLOR_BLACK 33
113 | #define REG_COLOR_RED 34
114 |
115 | #define OSC_X 68
116 | #define OSC_Y 69
117 | #define OSC_F1 70
118 | #define OSC_F2 71
119 | #define OSC_F3 72
120 | #define OSC_F4 73
121 |
122 |
123 | #endif
124 |
--------------------------------------------------------------------------------
/src/cyrilApp.cpp:
--------------------------------------------------------------------------------
1 | #include "cyrilApp.h"
2 |
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | string getIpAddress()
9 | {
10 | string output = "NOT FOUND";
11 | struct ifaddrs *myaddrs;
12 | struct ifaddrs *ifa;
13 | struct sockaddr_in *s4;
14 | int status;
15 |
16 | char buf[64];
17 |
18 | status = getifaddrs(&myaddrs);
19 | if (status != 0)
20 | {
21 | perror("getifaddrs");
22 |
23 | }
24 |
25 | for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)
26 | {
27 | if (ifa->ifa_addr == NULL) continue;
28 | if ((ifa->ifa_flags & IFF_UP) == 0) continue;
29 |
30 | if (ifa->ifa_addr->sa_family == AF_INET)
31 | {
32 | s4 = (struct sockaddr_in *)(ifa->ifa_addr);
33 | if (inet_ntop(ifa->ifa_addr->sa_family, (void *)&(s4->sin_addr), buf, sizeof(buf)) == NULL)
34 | {
35 | printf("%s: inet_ntop failed!\n", ifa->ifa_name);
36 | }
37 | else
38 | {
39 | if(ofToString(ifa->ifa_name) == "en0")
40 | {
41 | output = ofToString(buf);
42 | }
43 | }
44 | }
45 | }
46 |
47 | freeifaddrs(myaddrs);
48 | return output;
49 | }
50 |
51 |
52 |
53 | //--------------------------------------------------------------
54 | void cyrilApp::setup(){
55 | doResetTimers = true;
56 |
57 | ofSoundStreamSetup(0, 1, this, 44100, beat.getBufferSize(), 4);
58 |
59 | // Switch back to external data folder
60 | ofSetDataPathRoot("../../../data/");
61 |
62 | ofBackground(0);
63 | pauseProg = false;
64 | //lightsOn = true;
65 | lightsOn = true;
66 | isOrtho = false;
67 | fxOn = true;
68 |
69 | runningProg = false;
70 | running[0] = false;
71 | running[1] = false;
72 | running[2] = false;
73 | running[3] = false;
74 | running[4] = false;
75 | running[5] = false;
76 | running[6] = false;
77 | running[7] = false;
78 | running[8] = false;
79 | running[9] = false;
80 | error[0] = false;
81 | error[1] = false;
82 | error[2] = false;
83 | error[3] = false;
84 | error[4] = false;
85 | error[5] = false;
86 | error[6] = false;
87 | error[7] = false;
88 | error[8] = false;
89 | error[9] = false;
90 |
91 | #ifdef FULL_DEBUG
92 | ofSetLogLevel("ofxGLEditor", OF_LOG_VERBOSE);
93 | #endif
94 |
95 |
96 | editor.addCommand('z', this, &cyrilApp::toggleFx);
97 | editor.addCommand('f', this, &cyrilApp::toggleFullscreen);
98 | editor.addCommand('a', this, &cyrilApp::toggleEditor);
99 | editor.addCommand('d', this, &cyrilApp::toggleBackground);
100 | editor.addCommand('k', this, &cyrilApp::toggleLights);
101 | editor.addCommand('l', this, &cyrilApp::loadFile);
102 | editor.addCommand('s', this, &cyrilApp::saveFile);
103 | editor.addCommand('e', this, &cyrilApp::resetTimers);
104 | editor.addCommand('p', this, &cyrilApp::pauseProgram);
105 | editor.addCommand('r', this, &cyrilApp::runScript);
106 | editor.addCommand('o', this, &cyrilApp::toggleOrtho);
107 |
108 | editorVisible = true;
109 |
110 | lastSignalReport = -1;
111 |
112 | // Init evaluation stack to empty
113 | _state.stk = new stack;
114 | // Initialise our own matrix stack
115 | // TODO: replace with call to get from current renderer?
116 | _state.ms = new ofMatrixStack(*ofGetWindowPtr());
117 | // Initialise empty paticle system
118 | _state.ps = new vector;
119 | // Initialise empty variable/register map
120 | _state.sym = new map;
121 | // Initialise palettes
122 | _state.cs = new map;
123 | // Initialise sprites
124 | _state.img = new map;
125 | _state.parent = NULL;
126 | _state.light = new ofLight();
127 | //_state.light = NULL;
128 |
129 |
130 | (*_state.sym)[REG_X_MAX] = 640;
131 | (*_state.sym)[REG_Y_MAX] = 480;
132 | (*_state.sym)[REG_X_MID] = (*_state.sym)[REG_X_MAX] / 2.0;
133 | (*_state.sym)[REG_Y_MID] = (*_state.sym)[REG_Y_MAX] / 2.0;
134 |
135 | (*_state.sym)[REG_X_SCALE] = 100;
136 | (*_state.sym)[REG_Y_SCALE] = 100;
137 | (*_state.sym)[REG_Z_SCALE] = 100;
138 |
139 | (*_state.sym)[REG_PI] = PI;
140 | (*_state.sym)[REG_TWO_PI] = TWO_PI;
141 |
142 | (*_state.sym)[REG_PARTICLE_HEALTH] = 1;
143 | (*_state.sym)[REG_PARTICLE_DECAY] = 0.1;
144 |
145 | (*_state.sym)[OSC_X] = 0;
146 | (*_state.sym)[OSC_Y] = 0;
147 | (*_state.sym)[OSC_F1] = 0;
148 | (*_state.sym)[OSC_F2] = 0;
149 | (*_state.sym)[OSC_F3] = 0;
150 | (*_state.sym)[OSC_F4] = 0;
151 |
152 | // Reserve some space for Particle System
153 | _state.ps->reserve(2000);
154 |
155 | // Global settings
156 | ofEnableDepthTest();
157 | ofSetVerticalSync(true);
158 | if (lightsOn) {
159 | ofEnableLighting();
160 | _state.light->setAmbientColor(ofColor(0,0,0));
161 | _state.light->setDiffuseColor(ofColor(255,255,255));
162 | _state.light->setSpecularColor(ofColor(255,255,255));
163 | _state.light->setPointLight();
164 | _state.light->setAttenuation(1.f,0.f,0.f);
165 | }
166 |
167 | autoClearBg = true;
168 | ofSetBackgroundAuto(true);
169 |
170 | // changed this...
171 | cursorVisible = true;
172 | //ofHideCursor();
173 | #ifdef __APPLE__
174 | //CGDisplayHideCursor(NULL); // <- OK
175 | #endif
176 |
177 |
178 | (*_state.sym)[REG_FRAME] = 0;
179 |
180 | edBuf.allocate();
181 | edBuf.begin();
182 | ofClear(0,0,0,0);
183 | edBuf.end();
184 |
185 | ofEnableAlphaBlending();
186 | ofEnableAntiAliasing();
187 | ofEnableSmoothing();
188 |
189 | isFullScreen = false;
190 | //ofSetFullscreen(true);
191 |
192 | //mainOutputSyphonServer.setName("Cyril Main Output");
193 | //mClient.setup();
194 | //mClient.set("","Cyril Server");
195 |
196 | // listen on the given port
197 | cout << "listening for osc messages on " + getIpAddress() + ":" << PORT << endl;
198 | receiver.setup(PORT);
199 |
200 | // Configure the ofxPostProcessing effects
201 | _state.post = ofxPostProcessing();
202 | _state.post.init(ofGetWidth(), ofGetHeight());
203 | _state.post.setFlip(false);
204 | _state.kaleido = _state.post.createPass();
205 | _state.noisewarp = _state.post.createPass();
206 | _state.pixelate = _state.post.createPass();
207 | _state.bloom = _state.post.createPass();
208 |
209 | for (int i = 0; i < 10; ++i) {
210 | modTimes[i] = 0;
211 | }
212 | }
213 |
214 | //--------------------------------------------------------------
215 | void cyrilApp::update(){
216 | // check files for modifications
217 | for (int i = 0; i < 10; ++i) {
218 | // cout << "data/code/" + ofToString(i) + ".cy" << endl;
219 | ofFile f = ofFile("code/" + ofToString(i) + ".cy");
220 | if (f.exists()) {
221 | // cout << f.getPocoFile().getLastModified().epochTime() << endl;
222 | Poco::Timestamp t = f.getPocoFile().getLastModified();
223 | if (t > modTimes[i]) {
224 | modTimes[i] = t;
225 | reloadFileBuffer("code/" + ofToString(i) + ".cy");
226 | }
227 | }
228 | else {
229 | //cout << "file " + ofToString(i) << ".cy not found" << endl;
230 | }
231 | }
232 |
233 |
234 | // Disable all ofxPostProcessing effects so they only activate
235 | // if command is present in a running program
236 | _state.post[FX_KALEIDOSCOPE]->disable();
237 | _state.post[FX_NOISE_WARP]->disable();
238 | _state.post[FX_PIXELATE]->disable();
239 | _state.post[FX_BLOOM]->disable();
240 |
241 | for (int i = 0; i < 10; ++i) {
242 | if (running[i]) {
243 | if (prog[i]->valid) {
244 | prog[i]->update(_state);
245 | }
246 | }
247 | }
248 |
249 | if (doResetTimers) {
250 | (*_state.sym)[REG_FRAME] = 0;
251 | ofResetElapsedTimeCounter();
252 | doResetTimers = false;
253 | }
254 | else {
255 | (*_state.sym)[REG_FRAME]++;
256 | }
257 |
258 | (*_state.sym)[REG_TIME] = ofGetElapsedTimeMillis();
259 | (*_state.sym)[REG_SECS] = ofGetElapsedTimef();
260 | (*_state.sym)[REG_FAST] = ofGetElapsedTimef() * 10;
261 | (*_state.sym)[REG_SLOW] = ofGetElapsedTimef() * 2;
262 |
263 | // For beat detection
264 | beat.update((*_state.sym)[REG_TIME]);
265 | (*_state.sym)[REG_BEAT_MAGNITUDE] = beat.getMagnitude();
266 | (*_state.sym)[REG_BEAT_KICK] = beat.kick();
267 | (*_state.sym)[REG_BEAT_SNARE] = beat.snare();
268 | (*_state.sym)[REG_BEAT_HIHAT] = beat.hihat();
269 | for (int i = REG_BEAT_FFT_START; i < REG_BEAT_FFT_MAX; ++i) {
270 | (*_state.sym)[i] = beat.getBand(i - REG_BEAT_FFT_START);
271 | }
272 |
273 | for(vector::iterator it = _state.ps->begin(); it != _state.ps->end(); ++it){
274 | (*it)->update();
275 | }
276 | ofRemove(*_state.ps, Particle::isDead);
277 |
278 |
279 | // check for waiting OSC messages
280 | while(receiver.hasWaitingMessages()){
281 | // get the next message
282 | ofxOscMessage m;
283 | receiver.getNextMessage(&m);
284 | // Check for the toggle messages
285 | bool msgProcessed = false;
286 | for (int i = 1; i < 9; ++i) {
287 | if (m.getAddress() == ("/1/toggle" + ofToString(i))) {
288 | cout << "Process message " << ("/1/toggle" + ofToString(i)) << endl;
289 | if (m.getArgAsFloat(0) == 0) {
290 | toggleScript(i, false);
291 | }
292 | else if (m.getArgAsFloat(0) == 1) {
293 | toggleScript(i, true);
294 | }
295 | msgProcessed = true;
296 | }
297 | }
298 | if (m.getAddress() == "/1/xy1") {
299 | (*_state.sym)[OSC_X] = m.getArgAsFloat(0);
300 | (*_state.sym)[OSC_Y] = m.getArgAsFloat(1);
301 | msgProcessed = true;
302 | }
303 | else if (m.getAddress() == "/1/fader1") {
304 | (*_state.sym)[OSC_F1] = m.getArgAsFloat(0);
305 | msgProcessed = true;
306 | }
307 | else if (m.getAddress() == "/1/fader2") {
308 | (*_state.sym)[OSC_F2] = m.getArgAsFloat(0);
309 | msgProcessed = true;
310 | }
311 | else if (m.getAddress() == "/1/fader3") {
312 | (*_state.sym)[OSC_F3] = m.getArgAsFloat(0);
313 | msgProcessed = true;
314 | }
315 | else if (m.getAddress() == "/1/fader4") {
316 | (*_state.sym)[OSC_F4] = m.getArgAsFloat(0);
317 | msgProcessed = true;
318 | }
319 |
320 | if (!msgProcessed) {
321 | cout << "Unknown OSC message " << m.getAddress() << endl;
322 | }
323 |
324 | /*
325 | string msg_string;
326 | msg_string = m.getAddress();
327 | cout << msg_string << endl;
328 | cout << m.getArgAsFloat(0);
329 | */
330 | }
331 |
332 | }
333 |
334 | //--------------------------------------------------------------
335 | void cyrilApp::draw(){
336 |
337 | if (fxOn) {
338 | _state.post.begin();
339 | }
340 |
341 | ofEnableDepthTest();
342 |
343 | if (lightsOn) {
344 | _state.light->enable();
345 | // The default position of the light (apply z-scale)
346 | _state.light->setPosition(0,0,1000);
347 | }
348 | else {
349 | ofDisableLighting();
350 | }
351 |
352 | //ofEnableAlphaBlending();
353 |
354 | _state.ms->clearStacks();
355 | float X_MAX = (*_state.sym)[REG_X_MAX];
356 | float Y_MAX = (*_state.sym)[REG_Y_MAX];
357 | float X_MID = (*_state.sym)[REG_X_MID];
358 | float Y_MID = (*_state.sym)[REG_Y_MID];
359 | float X_SCALE = (*_state.sym)[REG_X_SCALE];
360 | float Y_SCALE = (*_state.sym)[REG_Y_SCALE];
361 | float Z_SCALE = (*_state.sym)[REG_Z_SCALE];
362 |
363 | for (int i = 0; i < 10; ++i) {
364 | if (running[i]) {
365 | if (prog[i]->valid) {
366 | ofPushMatrix();
367 | ofTranslate(X_MID, Y_MID);
368 | _state.ms->pushMatrix();
369 | _state.ms->translate(X_MID, Y_MID);
370 |
371 | ofScale(X_SCALE, Y_SCALE, Z_SCALE);
372 | _state.ms->scale(X_SCALE, Y_SCALE, Z_SCALE);
373 |
374 |
375 | prog[i]->eval(_state);
376 |
377 | _state.ms->popMatrix();
378 | ofPopMatrix();
379 | }
380 | }
381 | }
382 |
383 | for(vector::iterator it = _state.ps->begin(); it != _state.ps->end(); ++it){
384 | (*it)->draw(&_state);
385 | }
386 |
387 | if (lightsOn) {
388 | _state.light->disable();
389 | }
390 |
391 |
392 | if (fxOn) {
393 | _state.post.end();
394 | }
395 |
396 | //mainOutputSyphonServer.publishScreen();
397 |
398 | // Draw the editor if enabled
399 | if (editorVisible) {
400 | ofDisableDepthTest();
401 | ofPushMatrix();
402 | ofPushStyle();
403 | ofSetColor(255);
404 | ofFill();
405 | editor.draw();
406 | ofTranslate(X_MID - 50, 10);
407 | for (int i = 0; i < 10; ++i) {
408 | if (error[i]) {
409 | ofSetColor(255,0,0);
410 | }
411 | else if (running[i]) {
412 | ofSetColor(255);
413 | }
414 | else {
415 | ofSetColor(150);
416 | }
417 | ofRect(i * 10, 0, 8, 8);
418 | if (editor.currentBuffer == i) {
419 | ofSetColor(255);
420 | ofRect(i * 10, 10, 8, 5);
421 | }
422 | }
423 | ofPopStyle();
424 | ofPopMatrix();
425 | }
426 |
427 | }
428 |
429 | void cyrilApp::toggleFx(void * _o) {
430 | ((cyrilApp *)_o)->fxOn = !((cyrilApp *)_o)->fxOn;
431 | }
432 |
433 |
434 | void cyrilApp::toggleFullscreen(void * _o) {
435 | ((cyrilApp *)_o)->isFullScreen = !((cyrilApp *)_o)->isFullScreen;
436 | ofSetFullscreen(((cyrilApp *)_o)->isFullScreen);
437 |
438 | if (((cyrilApp *)_o)->isFullScreen) {
439 | ofHideCursor();
440 | #ifdef __APPLE__
441 | CGDisplayHideCursor(NULL);
442 | #endif
443 | }
444 | else {
445 | ofShowCursor();
446 | #ifdef __APPLE__
447 | CGDisplayShowCursor(NULL);
448 | #endif
449 | }
450 | }
451 | void cyrilApp::toggleEditor(void * _o) {
452 | ((cyrilApp *)_o)->editorVisible = !((cyrilApp *)_o)->editorVisible;
453 | }
454 | void cyrilApp::toggleOrtho(void * _o) {
455 | ((cyrilApp *)_o)->isOrtho = !((cyrilApp *)_o)->isOrtho;
456 | if (((cyrilApp *)_o)->isOrtho) {
457 | //ofSetupScreenOrtho();
458 | ofSetupScreenOrtho(1200,1200,0,10);
459 | }
460 | else {
461 | ofSetupScreenPerspective(1200,1200,0,0,0);
462 | }
463 | }
464 | void cyrilApp::toggleBackground(void * _o) {
465 | ((cyrilApp *)_o)->autoClearBg = !((cyrilApp *)_o)->autoClearBg;
466 | }
467 | void cyrilApp::toggleLights(void * _o) {
468 | ((cyrilApp *)_o)->lightsOn = !((cyrilApp *)_o)->lightsOn;
469 | ofEnableLighting();
470 | ofSetSmoothLighting(true);
471 | ((cyrilApp *)_o)->_state.light->setAmbientColor(ofColor(0,0,0));
472 | ((cyrilApp *)_o)->_state.light->setDiffuseColor(ofColor(255,255,255));
473 | ((cyrilApp *)_o)->_state.light->setSpecularColor(ofColor(255,255,255));
474 | ((cyrilApp *)_o)->_state.light->setPointLight();
475 | ((cyrilApp *)_o)->_state.light->setAttenuation(1.f,0.f,0.f);
476 | }
477 | void cyrilApp::loadFile(void * _o) {
478 | int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
479 | ((cyrilApp *)_o)->editor.loadFile("code/" + ofToString(whichEditor)+".cy", whichEditor);
480 | ((cyrilApp *)_o)->editor.update();
481 | }
482 | void cyrilApp::saveFile(void * _o) {
483 | int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
484 | ((cyrilApp *)_o)->editor.saveFile("code/" + ofToString(whichEditor)+".cy", whichEditor);
485 | }
486 | void cyrilApp::resetTimers(void * _o) {
487 | ((cyrilApp *)_o)->doResetTimers = true;
488 | }
489 | void cyrilApp::pauseProgram(void * _o) {
490 | if (((cyrilApp *)_o)->prog[((cyrilApp *)_o)->editor.currentBuffer] && ((cyrilApp *)_o)->prog[((cyrilApp *)_o)->editor.currentBuffer]->valid) {
491 | int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
492 | ((cyrilApp *)_o)->running[whichEditor] = !((cyrilApp *)_o)->running[whichEditor];
493 | }
494 | }
495 |
496 |
497 | void cyrilApp::runScript(void * _o) {
498 | int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
499 | #ifdef DEBUG_PRINT
500 | cout << "run script in editor " << whichEditor << endl;
501 | #endif
502 | Cyril* tempProg = CyrilParser::parseString(((cyrilApp *)_o)->editor.buf[whichEditor]->getText());
503 | if (tempProg->valid) {
504 | ((cyrilApp *)_o)->prog[whichEditor] = tempProg;
505 | ((cyrilApp *)_o)->runningProg = true;
506 | ((cyrilApp *)_o)->running[whichEditor] = true;
507 | ((cyrilApp *)_o)->error[whichEditor] = false;
508 | #ifdef DEBUG_PRINT
509 | ((cyrilApp *)_o)->prog[whichEditor]->print();
510 | #endif
511 | }
512 | else {
513 | ((cyrilApp *)_o)->error[whichEditor] = true;
514 | #ifdef DEBUG_PRINT
515 | cout << "Invalid program" << endl;
516 | #endif
517 | }
518 | ((cyrilApp *)_o)->reportError = true;
519 | }
520 |
521 | std::string removeExtension(const std::string filename) {
522 | size_t lastdot = filename.find_last_of(".");
523 | if (lastdot == std::string::npos) return filename;
524 | return filename.substr(0, lastdot);
525 | }
526 |
527 | void cyrilApp::toggleScript(int i, bool r) {
528 | if (r) {
529 | editor.loadFile("code/" + ofToString(i) + ".cy", i);
530 | editor.currentBuffer = i;
531 | runScript(this);
532 | }
533 | else {
534 | running[i] = false;
535 | }
536 | }
537 |
538 | void cyrilApp::reloadFileBuffer(std::string filePath) {
539 | //cout << "File = " << filePath << endl;
540 | ofFile file = ofFile(filePath);
541 | if (file.getExtension() == "cy") {
542 | int whichEditor = ofToInt(removeExtension(file.getFileName()));
543 | if (whichEditor >= 0 && whichEditor <= 9) {
544 | editor.loadFile(filePath, whichEditor);
545 | //editor.update();
546 | if (running[whichEditor]) {
547 | editor.currentBuffer = whichEditor;
548 | runScript(this);
549 | }
550 | }
551 | }
552 | if (file.getExtension() == "png") {
553 | //cout << "Loading image " << file.getFileName() << endl;
554 | int whichImg = ofToInt(removeExtension(file.getFileName()));
555 | (*_state.img)[whichImg] = new ofImage(filePath);
556 | //cout << "Loaded image type = " << ((*_state.img)[whichImg]->type) << endl;
557 | //(*_state.img)[whichImg]->setImageType(OF_IMAGE_COLOR_ALPHA);
558 | (*_state.img)[whichImg]->setAnchorPercent(0.5, 0.5);
559 | }
560 | }
561 |
562 |
563 |
564 | //--------------------------------------------------------------
565 | void cyrilApp::keyPressed(int key){
566 |
567 | }
568 |
569 | //--------------------------------------------------------------
570 | void cyrilApp::keyReleased(int key){
571 |
572 | }
573 |
574 | //--------------------------------------------------------------
575 | void cyrilApp::mouseMoved(int x, int y ){
576 |
577 | }
578 |
579 | //--------------------------------------------------------------
580 | void cyrilApp::mouseDragged(int x, int y, int button){
581 |
582 | }
583 |
584 | //--------------------------------------------------------------
585 | void cyrilApp::mousePressed(int x, int y, int button){
586 |
587 | }
588 |
589 | //--------------------------------------------------------------
590 | void cyrilApp::mouseReleased(int x, int y, int button){
591 |
592 | }
593 |
594 |
595 | //--------------------------------------------------------------
596 | void cyrilApp::windowResized(int w, int h){
597 | (*_state.sym)[REG_X_MAX] = w;
598 | (*_state.sym)[REG_Y_MAX] = h;
599 | (*_state.sym)[REG_X_MID] = w / 2.0;
600 | (*_state.sym)[REG_Y_MID] = h / 2.0;
601 | _state.post.setWidth(w);
602 | _state.post.setHeight(h);
603 | }
604 |
605 |
606 | //--------------------------------------------------------------
607 | void cyrilApp::gotMessage(ofMessage msg){
608 |
609 | }
610 |
611 | //--------------------------------------------------------------
612 | void cyrilApp::dragEvent(ofDragInfo dragInfo){
613 |
614 | }
615 |
616 |
617 | void cyrilApp::audioReceived(float* input, int bufferSize, int nChannels) {
618 | beat.audioReceived(input, bufferSize, nChannels);
619 | }
620 |
621 |
622 |
--------------------------------------------------------------------------------
/src/cyrilApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | // #define CYRIL_DEBUG
3 |
4 | #include "ofMain.h"
5 | #include "ofxXmlSettings.h"
6 | #include "Particle.h"
7 | #include "CyrilParser.h"
8 |
9 | #include "ofxEditor.h"
10 | #include "ofxBeat.h"
11 |
12 | #include "ofxSyphon.h"
13 |
14 | #include "ofxPostProcessing.h"
15 | #define FX_KALEIDOSCOPE 0
16 | #define FX_NOISE_WARP 1
17 | #define FX_PIXELATE 2
18 | #define FX_BLOOM 3
19 |
20 | #include "ofxOsc.h"
21 | // listen on port 12345
22 | #define PORT 12345
23 |
24 |
25 | class cyrilApp : public ofBaseApp{
26 |
27 | ofxEditor editor;
28 | ofxBeat beat;
29 |
30 | //ofxSyphonServer mainOutputSyphonServer;
31 | //ofxSyphonClient mClient;
32 |
33 | ofxOscReceiver receiver;
34 |
35 | //ofxXmlSettings settings;
36 | string fileName;
37 |
38 | Cyril *prog[10];
39 | Poco::Timestamp modTimes[10];
40 | bool running[10];
41 | bool error[10];
42 |
43 | CyrilState _state;
44 | vector progFiles;
45 | int currentProg;
46 | bool reportError;
47 |
48 | ofFbo edBuf;
49 |
50 | bool lightsOn;
51 | bool fxOn;
52 |
53 | bool autoClearBg;
54 | bool pauseProg;
55 | bool runningProg;
56 | bool overlay;
57 | bool editorVisible;
58 | bool cursorVisible;
59 | bool isFullScreen;
60 | bool doResetTimers;
61 | bool isOrtho;
62 |
63 | int lastSignalReport;
64 |
65 | void initPPFx();
66 |
67 | public:
68 |
69 | cyrilApp(): editor(10, "../Resources/DroidSansMono.ttf") {}
70 |
71 | void setup();
72 | void update();
73 | void draw();
74 |
75 | void keyPressed(int key);
76 | void keyReleased(int key);
77 | void mouseMoved(int x, int y );
78 | void mouseDragged(int x, int y, int button);
79 | void mousePressed(int x, int y, int button);
80 | void mouseReleased(int x, int y, int button);
81 | void windowResized(int w, int h);
82 | void dragEvent(ofDragInfo dragInfo);
83 | void gotMessage(ofMessage msg);
84 | void applyGlobalSettings();
85 | void reloadSettings();
86 | void runProgram();
87 |
88 | void audioReceived(float*, int, int);
89 |
90 | void reloadFileBuffer(std::string);
91 |
92 | // Editor command callbacks
93 | static void toggleFx(void *);
94 | static void toggleFullscreen(void *);
95 | static void toggleOrtho(void *);
96 | static void toggleEditor(void *);
97 | static void toggleBackground(void *);
98 | static void toggleLights(void *);
99 | static void loadFile(void *);
100 | static void saveFile(void *);
101 | static void resetTimers(void *);
102 | static void pauseProgram(void *);
103 | static void runScript(void *);
104 | void toggleScript(int i, bool r);
105 |
106 |
107 | };
108 |
109 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | //#define OS_PRE_DATA_PATH "data/"
2 | //#define OS_POST_DATA_PATH "../../../data/"
3 |
4 | #include "ofMain.h"
5 | #include "cyrilApp.h"
6 |
7 | map < string, ofColor > colorNameMap;
8 |
9 | int main( ){
10 | // Set this temporarily to load font from packaged Resources
11 | ofSetDataPathRoot("../Resources/data");
12 | ofSetEscapeQuitsApp(false);
13 |
14 | colorNameMap["white"] = ofColor::white;
15 | colorNameMap["gray"] = ofColor::gray;
16 | colorNameMap["black"] = ofColor::black;
17 | colorNameMap["red"] = ofColor::red;
18 | colorNameMap["green"] = ofColor::green;
19 | colorNameMap["blue"] = ofColor::blue;
20 | colorNameMap["cyan"] = ofColor::cyan;
21 | colorNameMap["magenta"] = ofColor::magenta;
22 | colorNameMap["yellow"] = ofColor::yellow;
23 | colorNameMap["aliceBlue"] = ofColor::aliceBlue;
24 | colorNameMap["antiqueWhite"] = ofColor::antiqueWhite;
25 | colorNameMap["aqua"] = ofColor::aqua;
26 | colorNameMap["aquamarine"] = ofColor::aquamarine;
27 | colorNameMap["azure"] = ofColor::azure;
28 | colorNameMap["beige"] = ofColor::beige;
29 | colorNameMap["bisque"] = ofColor::bisque;
30 | colorNameMap["blanchedAlmond"] = ofColor::blanchedAlmond;
31 | colorNameMap["blueViolet"] = ofColor::blueViolet;
32 | colorNameMap["brown"] = ofColor::brown;
33 | colorNameMap["burlyWood"] = ofColor::burlyWood;
34 | colorNameMap["cadetBlue"] = ofColor::cadetBlue;
35 | colorNameMap["chartreuse"] = ofColor::chartreuse;
36 | colorNameMap["chocolate"] = ofColor::chocolate;
37 | colorNameMap["coral"] = ofColor::coral;
38 | colorNameMap["cornflowerBlue"] = ofColor::cornflowerBlue;
39 | colorNameMap["cornsilk"] = ofColor::cornsilk;
40 | colorNameMap["crimson"] = ofColor::crimson;
41 | colorNameMap["darkBlue"] = ofColor::darkBlue;
42 | colorNameMap["darkCyan"] = ofColor::darkCyan;
43 | colorNameMap["darkGoldenRod"] = ofColor::darkGoldenRod;
44 | colorNameMap["darkGray"] = ofColor::darkGray;
45 | colorNameMap["darkGrey"] = ofColor::darkGrey;
46 | colorNameMap["darkGreen"] = ofColor::darkGreen;
47 | colorNameMap["darkKhaki"] = ofColor::darkKhaki;
48 | colorNameMap["darkMagenta"] = ofColor::darkMagenta;
49 | colorNameMap["darkOliveGreen"] = ofColor::darkOliveGreen;
50 | colorNameMap["darkorange"] = ofColor::darkorange;
51 | colorNameMap["darkOrchid"] = ofColor::darkOrchid;
52 | colorNameMap["darkRed"] = ofColor::darkRed;
53 | colorNameMap["darkSalmon"] = ofColor::darkSalmon;
54 | colorNameMap["darkSeaGreen"] = ofColor::darkSeaGreen;
55 | colorNameMap["darkSlateBlue"] = ofColor::darkSlateBlue;
56 | colorNameMap["darkSlateGray"] = ofColor::darkSlateGray;
57 | colorNameMap["darkSlateGrey"] = ofColor::darkSlateGrey;
58 | colorNameMap["darkTurquoise"] = ofColor::darkTurquoise;
59 | colorNameMap["darkViolet"] = ofColor::darkViolet;
60 | colorNameMap["deepPink"] = ofColor::deepPink;
61 | colorNameMap["deepSkyBlue"] = ofColor::deepSkyBlue;
62 | colorNameMap["dimGray"] = ofColor::dimGray;
63 | colorNameMap["dimGrey"] = ofColor::dimGrey;
64 | colorNameMap["dodgerBlue"] = ofColor::dodgerBlue;
65 | colorNameMap["fireBrick"] = ofColor::fireBrick;
66 | colorNameMap["floralWhite"] = ofColor::floralWhite;
67 | colorNameMap["forestGreen"] = ofColor::forestGreen;
68 | colorNameMap["fuchsia"] = ofColor::fuchsia;
69 | colorNameMap["gainsboro"] = ofColor::gainsboro;
70 | colorNameMap["ghostWhite"] = ofColor::ghostWhite;
71 | colorNameMap["gold"] = ofColor::gold;
72 | colorNameMap["goldenRod"] = ofColor::goldenRod;
73 | colorNameMap["grey"] = ofColor::grey;
74 | colorNameMap["greenYellow"] = ofColor::greenYellow;
75 | colorNameMap["honeyDew"] = ofColor::honeyDew;
76 | colorNameMap["hotPink"] = ofColor::hotPink;
77 | colorNameMap["indianRed "] = ofColor::indianRed ;
78 | colorNameMap["indigo "] = ofColor::indigo ;
79 | colorNameMap["ivory"] = ofColor::ivory;
80 | colorNameMap["khaki"] = ofColor::khaki;
81 | colorNameMap["lavender"] = ofColor::lavender;
82 | colorNameMap["lavenderBlush"] = ofColor::lavenderBlush;
83 | colorNameMap["lawnGreen"] = ofColor::lawnGreen;
84 | colorNameMap["lemonChiffon"] = ofColor::lemonChiffon;
85 | colorNameMap["lightBlue"] = ofColor::lightBlue;
86 | colorNameMap["lightCoral"] = ofColor::lightCoral;
87 | colorNameMap["lightCyan"] = ofColor::lightCyan;
88 | colorNameMap["lightGoldenRodYellow"] = ofColor::lightGoldenRodYellow;
89 | colorNameMap["lightGray"] = ofColor::lightGray;
90 | colorNameMap["lightGrey"] = ofColor::lightGrey;
91 | colorNameMap["lightGreen"] = ofColor::lightGreen;
92 | colorNameMap["lightPink"] = ofColor::lightPink;
93 | colorNameMap["lightSalmon"] = ofColor::lightSalmon;
94 | colorNameMap["lightSeaGreen"] = ofColor::lightSeaGreen;
95 | colorNameMap["lightSkyBlue"] = ofColor::lightSkyBlue;
96 | colorNameMap["lightSlateGray"] = ofColor::lightSlateGray;
97 | colorNameMap["lightSlateGrey"] = ofColor::lightSlateGrey;
98 | colorNameMap["lightSteelBlue"] = ofColor::lightSteelBlue;
99 | colorNameMap["lightYellow"] = ofColor::lightYellow;
100 | colorNameMap["lime"] = ofColor::lime;
101 | colorNameMap["limeGreen"] = ofColor::limeGreen;
102 | colorNameMap["linen"] = ofColor::linen;
103 | colorNameMap["maroon"] = ofColor::maroon;
104 | colorNameMap["mediumAquaMarine"] = ofColor::mediumAquaMarine;
105 | colorNameMap["mediumBlue"] = ofColor::mediumBlue;
106 | colorNameMap["mediumOrchid"] = ofColor::mediumOrchid;
107 | colorNameMap["mediumPurple"] = ofColor::mediumPurple;
108 | colorNameMap["mediumSeaGreen"] = ofColor::mediumSeaGreen;
109 | colorNameMap["mediumSlateBlue"] = ofColor::mediumSlateBlue;
110 | colorNameMap["mediumSpringGreen"] = ofColor::mediumSpringGreen;
111 | colorNameMap["mediumTurquoise"] = ofColor::mediumTurquoise;
112 | colorNameMap["mediumVioletRed"] = ofColor::mediumVioletRed;
113 | colorNameMap["midnightBlue"] = ofColor::midnightBlue;
114 | colorNameMap["mintCream"] = ofColor::mintCream;
115 | colorNameMap["mistyRose"] = ofColor::mistyRose;
116 | colorNameMap["moccasin"] = ofColor::moccasin;
117 | colorNameMap["navajoWhite"] = ofColor::navajoWhite;
118 | colorNameMap["navy"] = ofColor::navy;
119 | colorNameMap["oldLace"] = ofColor::oldLace;
120 | colorNameMap["olive"] = ofColor::olive;
121 | colorNameMap["oliveDrab"] = ofColor::oliveDrab;
122 | colorNameMap["orange"] = ofColor::orange;
123 | colorNameMap["orangeRed"] = ofColor::orangeRed;
124 | colorNameMap["orchid"] = ofColor::orchid;
125 | colorNameMap["paleGoldenRod"] = ofColor::paleGoldenRod;
126 | colorNameMap["paleGreen"] = ofColor::paleGreen;
127 | colorNameMap["paleTurquoise"] = ofColor::paleTurquoise;
128 | colorNameMap["paleVioletRed"] = ofColor::paleVioletRed;
129 | colorNameMap["papayaWhip"] = ofColor::papayaWhip;
130 | colorNameMap["peachPuff"] = ofColor::peachPuff;
131 | colorNameMap["peru"] = ofColor::peru;
132 | colorNameMap["pink"] = ofColor::pink;
133 | colorNameMap["plum"] = ofColor::plum;
134 | colorNameMap["powderBlue"] = ofColor::powderBlue;
135 | colorNameMap["purple"] = ofColor::purple;
136 | colorNameMap["rosyBrown"] = ofColor::rosyBrown;
137 | colorNameMap["royalBlue"] = ofColor::royalBlue;
138 | colorNameMap["saddleBrown"] = ofColor::saddleBrown;
139 | colorNameMap["salmon"] = ofColor::salmon;
140 | colorNameMap["sandyBrown"] = ofColor::sandyBrown;
141 | colorNameMap["seaGreen"] = ofColor::seaGreen;
142 | colorNameMap["seaShell"] = ofColor::seaShell;
143 | colorNameMap["sienna"] = ofColor::sienna;
144 | colorNameMap["silver"] = ofColor::silver;
145 | colorNameMap["skyBlue"] = ofColor::skyBlue;
146 | colorNameMap["slateBlue"] = ofColor::slateBlue;
147 | colorNameMap["slateGray"] = ofColor::slateGray;
148 | colorNameMap["slateGrey"] = ofColor::slateGrey;
149 | colorNameMap["snow"] = ofColor::snow;
150 | colorNameMap["springGreen"] = ofColor::springGreen;
151 | colorNameMap["steelBlue"] = ofColor::steelBlue;
152 | colorNameMap["tan"] = ofColor::tan;
153 | colorNameMap["teal"] = ofColor::teal;
154 | colorNameMap["thistle"] = ofColor::thistle;
155 | colorNameMap["tomato"] = ofColor::tomato;
156 | colorNameMap["turquoise"] = ofColor::turquoise;
157 | colorNameMap["violet"] = ofColor::violet;
158 | colorNameMap["wheat"] = ofColor::wheat;
159 | colorNameMap["whiteSmoke"] = ofColor::whiteSmoke;
160 | colorNameMap["yellowGreen"] = ofColor::yellowGreen;
161 |
162 | int X_MAX = 640;
163 | int Y_MAX = 480;
164 | //int X_MAX = 2048;
165 | //int Y_MAX = 768;
166 | ofSetupOpenGL(X_MAX, Y_MAX, OF_WINDOW);
167 |
168 | ofRunApp(new cyrilApp());
169 | }
170 |
--------------------------------------------------------------------------------