Skip to content

Commit

Permalink
v3.0.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
cuinjune committed Aug 27, 2019
1 parent bab3440 commit 21e9768
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
v3.0.1: 20 Aug 2019

* added "examples/shader/geometryShader" example
* added more examples
* fixed type checking issue in "ofxOfeliaPdBindings.i"
* fixed bug when outputting a table with a string key using ofOutlet()
* ofArray's array elements can be accessed using square brackets
Expand Down
2 changes: 1 addition & 1 deletion ofelia/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
v3.0.1: 20 Aug 2019

* added "examples/shader/geometryShader" example
* added more examples
* fixed type checking issue in "ofxOfeliaPdBindings.i"
* fixed bug when outputting a table with a string key using ofOutlet()
* ofArray's array elements can be accessed using square brackets
Expand Down
Binary file added ofelia/examples/3d/3dPrimitives/data/texture.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions ofelia/examples/3d/3dPrimitives/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#N canvas 720 100 669 681 10;
#X declare -lib ofelia;
#X obj 28 114 ofWindow;
#X obj 28 150 ofSetup;
#X obj 512 29 declare -lib ofelia;
#X obj 28 769 ofDraw;
#X obj 28 790 ofRequire \$0-vars;
#X msg 28 93 setPosition 30 100 \, setSize 1024 768 \, create;
#X obj 28 811 ofelia f \; local spinX = math.sin(ofGetElapsedTimef()
* 0.35) \; local spinY = math.cos(ofGetElapsedTimef() * 0.075) \; ofEnableDepthTest()
\; ofEnableLighting() \; a.pointLight:enable() \; a.pointLight2:enable()
\; a.pointLight3:enable() \; a.material:beginMaterial() \; a.plane:rotateDeg(spinX
\, 1 \, 0 \, 0) \; a.plane:rotateDeg(spinY \, 0 \, 1 \, 0) \; a.plane:draw()
\; a.box:rotateDeg(spinX \, 1 \, 0 \, 0) \; a.box:rotateDeg(spinY \,
0 \, 1 \, 0) \; a.box:draw() \; a.sphere:rotateDeg(spinX \, 1 \, 0
\, 0) \; a.sphere:rotateDeg(spinY \, 0 \, 1 \, 0) \; a.sphere:draw()
\; a.icoSphere:rotateDeg(spinX \, 1 \, 0 \, 0) \; a.icoSphere:rotateDeg(spinY
\, 0 \, 1 \, 0) \; a.icoSphere:draw() \; a.cylinder:rotateDeg(spinX
\, 1 \, 0 \, 0) \; a.cylinder:rotateDeg(spinY \, 0 \, 1 \, 0) \; a.cylinder:draw()
\; a.cone:rotateDeg(spinX \, 1 \, 0 \, 0) \; a.cone:rotateDeg(spinY
\, 0 \, 1 \, 0) \; a.cone:draw() \; a.material:endMaterial() \; ofDisableLighting()
\; ofDisableDepthTest() \;;
#X obj 28 625 ofUpdate;
#X obj 28 646 ofRequire \$0-vars;
#X obj 28 72 loadbang;
#X obj 28 171 ofelia f \$0-vars \; ofBackground(20) \; ofSetSmoothLighting(true)
\; ofSetSphereResolution(24) \; local width \, height = ofGetWidth()
* 0.12 \, ofGetHeight() * 0.12 \; M.sphere = ofSpherePrimitive() \;
M.sphere:setRadius(width) \; M.icoSphere = ofIcoSpherePrimitive() \;
M.icoSphere:setRadius(width) \; M.plane = ofPlanePrimitive() \; M.plane:set(width*1.5
\, height*1.5) \; M.cylinder = ofCylinderPrimitive() \; M.cylinder:set(width*0.7
\, height*2.2) \; M.cone = ofConePrimitive() \; M.cone:set(width*0.75
\, height*2.2) \; M.box = ofBoxPrimitive() \; M.box:set(width*1.25)
\; local screenWidth \, screenHeight = ofGetWidth() \, ofGetHeight()
\; M.plane:setPosition(screenWidth * 0.2 \, screenHeight * 0.25 \,
0) \; M.box:setPosition(screenWidth * 0.5 \, screenHeight * 0.25 \,
0) \; M.sphere:setPosition(screenWidth * 0.8 \, screenHeight * 0.25
\, 0) \; M.icoSphere:setPosition(screenWidth * 0.2 \, screenHeight
* 0.75 \, 0) \; M.cylinder:setPosition(screenWidth * 0.5 \, screenHeight
* 0.75 \, 0) \; M.cone:setPosition(screenWidth * 0.8 \, screenHeight
* 0.75 \, 0) \; M.pointLight = ofLight() \; M.pointLight:setPointLight()
\; M.pointLight:setDiffuseColor(ofFloatColor(0.85 \, 0.85 \, 0.55))
\; M.pointLight:setSpecularColor(ofFloatColor(1 \, 1 \, 1)) \; M.pointLight2
= ofLight() \; M.pointLight2:setPointLight() \; M.pointLight2:setDiffuseColor(ofFloatColor(238/255
\, 57/255 \, 135/255)) \; M.pointLight2:setSpecularColor(ofFloatColor(0.8
\, 0.8 \, 0.9)) \; M.pointLight3 = ofLight() \; M.pointLight3:setPointLight()
\; M.pointLight3:setDiffuseColor(ofFloatColor(19/255 \, 94/255 \, 77/255))
\; M.pointLight3:setSpecularColor(ofFloatColor(18/255 \, 150/255 \,
135/255)) \; M.material = ofMaterial() \; M.material:setShininess(120)
\; M.material:setSpecularColor(ofFloatColor(1 \, 1 \, 1)) \;;
#X f 72;
#X text 25 23 this example shows how 3d primitives can be drawn on
the screen with the lights and material.;
#X text 331 1183 This example is based on the openFrameworks example
"3DPrimitivesExample";
#X obj 504 150 ofExit;
#X obj 504 171 ofRequire \$0-vars \;;
#X obj 504 192 ofelia f \; a.pointLight = nil \; a.pointLight2 = nil
\; a.pointLight3 = nil \; collectgarbage() \;;
#X obj 28 667 ofelia f \; local width \, height \, time = ofGetWidth()
\, ofGetHeight() \, ofGetElapsedTimef() \; a.pointLight:setPosition((width*0.5)
+ math.cos(time*0.5) * (width*0.3) \, height/2 \, 500) \; a.pointLight2:setPosition((width*0.5)
+ math.cos(time*0.15) * (width*0.3) \, height*0.5 + math.sin(time*0.7)
* height \, -300) \; a.pointLight3:setPosition(math.cos(time*1.5) *
width*0.5 \, math.sin(time*1.5) * width*0.5 \, math.cos(time*0.2) *
width) \;;
#X f 89;
#X connect 1 0 10 0;
#X connect 3 0 4 0;
#X connect 4 0 6 0;
#X connect 5 0 0 0;
#X connect 7 0 8 0;
#X connect 8 0 16 0;
#X connect 9 0 5 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
53 changes: 53 additions & 0 deletions ofelia/examples/3d/coloredCube/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#N canvas 720 100 665 681 10;
#X declare -lib ofelia;
#X obj 28 92 loadbang;
#X obj 28 134 ofWindow;
#X obj 28 170 ofSetup;
#X obj 338 211 ofDraw;
#X msg 28 113 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 512 29 declare -lib ofelia;
#X obj 338 253 ofExpr \; nil \; ofGetWidth() / 2 \; ofGetHeight() /
2 \; ofGetFrameNum() * 0.75 \;;
#X obj 338 318 ofTranslate;
#X obj 338 360 ofMesh \$0-mesh drawFaces;
#X obj 338 232 ofEnableDepthTest;
#X obj 338 381 ofDisableDepthTest;
#X obj 338 339 ofRotateDeg 0 1 1 1;
#X obj 28 212 ofelia f \$0-mesh \; M.mesh = ofMesh.box(120 \, 120 \,
120 \, 1 \, 1 \, 1) \; local colors = ofTable() \; for i=1 \, 24 do
\; colors[i] = ofFloatColor() \; end \; colors[1]:set(0 \, 0 \, 1)
\; colors[2]:set(1 \, 0 \, 1) \; colors[3]:set(0 \, 1 \, 1) \; colors[4]:set(1
\, 1 \, 1) \; colors[5]:set(1 \, 0 \, 1) \; colors[6]:set(1 \, 0 \,
0) \; colors[7]:set(1 \, 1 \, 1) \; colors[8]:set(1 \, 1 \, 0) \; colors[9]:set(0
\, 0 \, 0) \; colors[10]:set(0 \, 0 \, 1) \; colors[11]:set(0 \, 1
\, 0) \; colors[12]:set(0 \, 1 \, 1) \; colors[13]:set(1 \, 0 \, 0)
\; colors[14]:set(0 \, 0 \, 0) \; colors[15]:set(1 \, 1 \, 0) \; colors[16]:set(0
\, 1 \, 0) \; colors[17]:set(0 \, 0 \, 0) \; colors[18]:set(1 \, 0
\, 0) \; colors[19]:set(0 \, 0 \, 1) \; colors[20]:set(1 \, 0 \, 1)
\; colors[21]:set(0 \, 1 \, 1) \; colors[22]:set(1 \, 1 \, 1) \; colors[23]:set(0
\, 1 \, 0) \; colors[24]:set(1 \, 1 \, 0) \; for i=1 \, #colors do
\; M.mesh:addColor(colors[i]) \; end \;;
#X text 25 23 An ofMesh represents a set of vertices in 3D spaces \,
and normals at those points \, colors at those points \, and texture
coordinates at those points. Each of these different properties is
stored in a vector.;
#X obj 338 170 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 338 190 setEnabled \$1;
#X text 358 169 enable/disable rendering.;
#X obj 28 191 ofBackground 55;
#X connect 0 0 4 0;
#X connect 2 0 17 0;
#X connect 3 0 9 0;
#X connect 4 0 1 0;
#X connect 6 0 7 0;
#X connect 6 1 7 1;
#X connect 6 2 7 2;
#X connect 6 3 11 1;
#X connect 7 0 11 0;
#X connect 8 0 10 0;
#X connect 9 0 6 0;
#X connect 11 0 8 0;
#X connect 14 0 15 0;
#X connect 15 0 3 0;
#X connect 17 0 12 0;
34 changes: 34 additions & 0 deletions ofelia/examples/drawing/continuousLines/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#N canvas 720 100 665 659 10;
#X declare -lib ofelia;
#X obj 28 72 loadbang;
#X obj 28 114 ofWindow;
#X obj 28 150 ofSetup;
#X obj 28 171 ofBackground 102;
#X msg 28 93 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 511 28 declare -lib ofelia;
#X obj 28 207 ofMousePressed;
#X obj 149 207 ofMouseDragged;
#X obj 28 487 ofDraw;
#X obj 28 508 ofRequire \$0-vars;
#X obj 28 529 ofelia f \; for i=1 \, #a.polylines do \; a.polylines[i]:draw()
\; end \;;
#X msg 28 228 pressed \$1 \$2 \$3;
#X msg 149 228 dragged \$1 \$2 \$3;
#X obj 28 264 ofelia d \$0-vars \; M.polylines = ofTable() \; function
M.pressed(fv) \; if fv[3] == 0 then \; local pl = ofPolyline() \; pl:addVertex(fv[1]
\, fv[2]) \; M.polylines[#M.polylines + 1] = pl \; elseif fv[3] ==
2 then \; for k in pairs (M.polylines) do \; M.polylines[k] = nil \;
end \; end \; end \; function M.dragged(fv) \; if fv[3] == 0 then \;
M.polylines[#M.polylines]:curveTo(fv[1] \, fv[2]) \; end \; end \;
;
#X text 25 23 left click and drag the mouse to draw curves. right click
the mouse to clear the stored curves.;
#X connect 0 0 4 0;
#X connect 2 0 3 0;
#X connect 4 0 1 0;
#X connect 6 0 11 0;
#X connect 7 0 12 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 11 0 13 0;
#X connect 12 0 13 0;
31 changes: 31 additions & 0 deletions ofelia/examples/drawing/pattern/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#N canvas 720 100 665 558 10;
#X declare -lib ofelia;
#X obj 28 72 loadbang;
#X obj 28 114 ofWindow;
#X obj 28 150 ofSetup;
#X obj 28 171 ofBackground 102;
#X obj 28 192 ofSetCircleResolution 50;
#X msg 28 93 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 511 28 declare -lib ofelia;
#X text 325 454 This example was originally written in Processing.
https://processing.org/examples/pattern.html;
#X obj 28 213 ofSetBackgroundAuto 0;
#X obj 28 347 ofDraw;
#X obj 28 368 ofRequire \$0-var;
#X obj 28 389 ofelia f \; a.variableEllipse(ofGetMouseX() \, ofGetMouseY()
\, ofGetPreviousMouseX() \, ofGetPreviousMouseY());
#X f 93;
#X text 25 23 move the cursor over the window to draw circles which
responds to the speed of the mouse.;
#X obj 28 234 ofelia f \$0-var \; function M.variableEllipse(x \, y
\, px \, py) \; local speed = math.abs(x-px) + math.abs(y-py) \; ofSetColor(speed%255)
\; ofDrawEllipse(x \, y \, speed \, speed) \; ofSetColor(255) \; ofDrawEllipse(x
\, y \, speed-2 \, speed-2) \; end \;;
#X connect 0 0 5 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 8 0;
#X connect 5 0 1 0;
#X connect 8 0 13 0;
#X connect 9 0 10 0;
#X connect 10 0 11 0;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions ofelia/examples/image/pointillism/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#N canvas 695 100 670 724 10;
#X declare -lib ofelia;
#X obj 28 80 loadbang;
#X text 25 23 Mouse horizontal location controls size of dots. Creates
a simple pointillist effect using circles colored according to pixels
in an image.;
#X text 333 620 This example was originally written in Processing.
https://processing.org/examples/pointillism.html;
#X obj 28 122 ofWindow;
#X obj 28 158 ofSetup;
#X obj 28 179 ofSetBackgroundColor 255;
#X obj 28 200 ofSetBackgroundAuto 0;
#X obj 28 263 ofImage \$0-img;
#X obj 28 284 route load;
#X floatatom 28 305 5 0 0 0 - - -;
#X text 67 305 0: fail \, 1: success.;
#X obj 28 433 ofDraw;
#X text 116 329 Set small point size.;
#X msg 79 349 smallPoint \$1;
#X floatatom 79 329 5 0 0 0 - - -;
#X floatatom 259 329 5 0 0 0 - - -;
#X msg 259 349 largePoint \$1;
#X text 296 329 Set large point size.;
#X msg 28 101 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 28 375 ofelia f \$0-vars \; M.smallPoint = 2 \; M.largePoint
= 20 \;;
#X text 150 376 Variables used.;
#X obj 28 454 ofRequire \$0-img;
#X obj 28 475 ofRequire \$0-vars;
#X obj 28 496 ofelia f \; local img \, m = a[1].image \, a[2] \; local
pointillize = ofMap(ofGetMouseX() \, 0 \, ofGetWidth() \, m.smallPoint
\, m.largePoint) \; pointillize = ofClamp(pointillize \, m.smallPoint
\, m.largePoint) \; local x \, y = ofRandom(img:getWidth()) \, ofRandom(img:getHeight())
\; local pix = img:getColor(x \, y) \; ofSetColor(pix \, 128) \; ofDrawCircle(x
\, y \, pointillize) \;;
#X f 87;
#X obj 28 221 ofGetDir;
#X msg 28 242 load \$1/data/moonwalk.jpg;
#X text 196 242 Load an image from the path.;
#X text 135 454 Require the module that has the image.;
#X obj 522 29 declare -lib ofelia;
#X text 143 475 Require the module that has the variables.;
#X connect 0 0 18 0;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 6 0 24 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 19 0;
#X connect 11 0 21 0;
#X connect 13 0 19 0;
#X connect 14 0 13 0;
#X connect 15 0 16 0;
#X connect 16 0 19 0;
#X connect 18 0 3 0;
#X connect 21 0 22 0;
#X connect 22 0 23 0;
#X connect 24 0 25 0;
#X connect 25 0 7 0;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions ofelia/examples/image/transparency/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#N canvas 720 100 665 670 10;
#X declare -lib ofelia;
#X obj 28 80 loadbang;
#X text 333 571 This example was originally written in Processing.
https://processing.org/examples/transparency.html;
#X text 25 23 Move the pointer left and right across the image to change
its position. This program overlays one image over another by modifying
the alpha value of the image.;
#X obj 28 122 ofWindow;
#X obj 28 158 ofSetup;
#X obj 28 221 ofImage \$0-img;
#X obj 28 242 route load;
#X floatatom 28 263 5 0 0 0 - - -;
#X text 67 263 0: fail \, 1: success.;
#X obj 28 401 ofDraw;
#X msg 68 322 easing \$1;
#X floatatom 68 302 5 0 0 0 - - -;
#X obj 71 282 hsl 128 15 0.01 0.1 0 0 empty empty empty -2 -8 0 10
-262144 -1 -1 0 1;
#X text 211 281 Try changing the value.;
#X text 143 353 Variables used.;
#X msg 28 101 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 28 343 ofelia f \$0-vars \; M.offset = 0 \; M.easing = 0.05
\;;
#X obj 28 422 ofRequire \$0-img;
#X obj 28 443 ofRequire \$0-vars;
#X text 137 422 Require the module that has the image.;
#X text 138 443 Require the module that has the variables.;
#X obj 28 464 ofelia f \; local img \, v = a[1].image \, a[2] \; img:draw(0
\, 0) \; local dx = (ofGetMouseX() - img:getWidth()/2) - v.offset \;
v.offset = v.offset + (dx * v.easing) \; ofSetColor(255 \, 255 \, 255
\, 127) \; img:draw(v.offset \, 0) \;;
#X obj 28 179 ofGetDir;
#X msg 28 200 load \$1/data/moonwalk.jpg;
#X obj 512 29 declare -lib ofelia;
#X connect 0 0 15 0;
#X connect 4 0 22 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 7 0 16 0;
#X connect 9 0 17 0;
#X connect 10 0 16 0;
#X connect 11 0 10 0;
#X connect 12 0 11 0;
#X connect 15 0 3 0;
#X connect 17 0 18 0;
#X connect 18 0 21 0;
#X connect 22 0 23 0;
#X connect 23 0 5 0;
25 changes: 25 additions & 0 deletions ofelia/examples/math/distance2d/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#N canvas 720 100 665 501 10;
#X declare -lib ofelia;
#X obj 28 82 loadbang;
#X obj 28 124 ofWindow;
#X obj 28 160 ofSetup;
#X msg 28 103 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 511 28 declare -lib ofelia;
#X text 25 23 Move the mouse across the image to obscure and reveal
the matrix. Measures the distance from the mouse to each square and
sets the size proportionally.;
#X obj 28 239 ofDraw;
#X obj 28 181 ofelia f \$0-vars \; M.maxDist = ofDist(0 \, 0 \, ofGetWidth()
\, ofGetHeight()) \; ofBackground(0) \;;
#X obj 28 260 ofRequire \$0-vars;
#X obj 28 281 ofelia f \; for i=0 \, ofGetWidth() \, 20 do \; for j=0
\, ofGetHeight() \, 20 do \; local size = ofDist(ofGetMouseX() \, ofGetMouseY()
\, i \, j) \; size = size / a.maxDist * 33 \; ofDrawCircle(i \, j \,
size) \; end \; end \;;
#X text 325 404 This example was originally written in Processing.
https://processing.org/examples/distance2d.html;
#X connect 0 0 3 0;
#X connect 2 0 7 0;
#X connect 3 0 1 0;
#X connect 6 0 8 0;
#X connect 8 0 9 0;
28 changes: 28 additions & 0 deletions ofelia/examples/math/map/main.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#N canvas 720 100 665 513 10;
#X declare -lib ofelia;
#X obj 28 122 loadbang;
#X obj 28 164 ofWindow;
#X obj 28 200 ofSetup;
#X msg 28 143 setPosition 30 100 \, setSize 640 360 \, create;
#X obj 511 28 declare -lib ofelia;
#X obj 28 278 ofDraw;
#X obj 28 221 ofBackground 0;
#X obj 28 299 ofelia f \; local c = ofMap(ofGetMouseX() \, 0 \, ofGetWidth()
\, 0 \, 175) \; c = ofClamp(c \, 0 \, 175) \; local d = ofMap(ofGetMouseX()
\, 0 \, ofGetWidth() \, 20 \, 150) \; d = ofClamp(d \, 20 \, 150) \;
ofSetColor(255 \, c \, 0) \; ofDrawCircle(ofGetWidth()/2 \, ofGetHeight()/2
\, d) \;;
#X text 25 23 Use the ofMap() function to take any number and scale
it to a new number that is more useful for the project that you are
working on. For example \, use the numbers from the mouse position
to control the size or color of a shape. In this example \, the mouse’s
x-coordinate (numbers between 0 and 640) are scaled to new numbers
to define the color and size of a circle.;
#X text 325 405 This example was originally written in Processing.
https://processing.org/examples/map.html;
#X obj 28 242 ofSetCircleResolution 50;
#X connect 0 0 3 0;
#X connect 2 0 6 0;
#X connect 3 0 1 0;
#X connect 5 0 7 0;
#X connect 6 0 10 0;
Loading

0 comments on commit 21e9768

Please sign in to comment.