File tree Expand file tree Collapse file tree 1 file changed +10
-30
lines changed Expand file tree Collapse file tree 1 file changed +10
-30
lines changed Original file line number Diff line number Diff line change 20
20
import p5 from '../src/app.js' ;
21
21
22
22
const sketch = function ( p ) {
23
- let myShader
24
- let tex
25
23
p . setup = function ( ) {
26
- p . createCanvas ( 20 , 10 , p . WEBGL ) ;
27
- p . background ( 255 ) ;
28
-
29
- myShader = p . baseMaterialShader ( ) . modify ( {
30
- uniforms : {
31
- 'sampler2D myTex' : undefined ,
32
- } ,
33
- 'Inputs getPixelInputs' : `(Inputs inputs) {
34
- inputs.color = texture(myTex, inputs.texCoord);
35
- return inputs;
36
- }`
37
- } )
38
-
39
- // Make a red texture
40
- tex = p . createFramebuffer ( ) ;
41
- tex . draw ( ( ) => p . background ( 'red' ) ) ;
42
-
43
- p . translate ( - p . width / 2 , - p . height / 2 )
44
- p . shader ( myShader ) ;
45
- p . noStroke ( ) ;
46
- myShader . setUniform ( 'myTex' , tex ) ;
47
-
48
- // Draw once to the left
49
- p . rect ( 0 , 0 , 10 , 10 ) ;
50
-
51
- // Draw once to the right
52
- p . rect ( 10 , 0 , 10 , 10 ) ;
53
- console . log ( p . canvas . toDataURL ( ) )
24
+ p . createCanvas ( 200 , 200 ) ;
25
+ } ;
26
+
27
+ p . draw = function ( ) {
28
+ p . background ( 0 , 50 , 50 ) ;
29
+ p . circle ( 100 , 100 , 50 ) ;
30
+
31
+ p . fill ( 'white' ) ;
32
+ p . textSize ( 30 ) ;
33
+ p . text ( 'hello' , 10 , 30 ) ;
54
34
} ;
55
35
} ;
56
36
You can’t perform that action at this time.
0 commit comments