Java Code Examples for processing.core.PShape#setFill()
The following examples show how to use
processing.core.PShape#setFill() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandLinePDFRenderTest.java From haxademic with MIT License | 6 votes |
protected void firstFrame() { // img = p.loadImage(FileUtil.getFile("images/bread.png")); PShape newShape = p.createShape(RECT, 0, 0, 80, 80); newShape.setFill(p.color(255)); _svgs = new ArrayList<PShape>(); _imgs = new ArrayList<PGraphics>(); _svgs.add( p.loadShape( FileUtil.haxademicDataPath() + "svg/nike/camo-m.svg" ) ); _svgs.add( p.loadShape( FileUtil.haxademicDataPath() + "svg/nike/camo-a.svg" ) ); _svgs.add( p.loadShape( FileUtil.haxademicDataPath() + "svg/nike/camo-k.svg" ) ); _svgs.add( p.loadShape( FileUtil.haxademicDataPath() + "svg/nike/camo-w.svg" ) ); // output args P.println("arguments length", arguments.length); for (String string : arguments) { P.println(string); } }
Example 2
Source File: Impeach.java From haxademic with MIT License | 6 votes |
public void addFillToShape(PShape shape, float oscMult) { for (int i = 0; i < shape.getVertexCount(); i++) { PVector vertex = shape.getVertex(i); float zFade = P.map(vertex.z, 50, -50, 1, 0); int fillReplace = P.p.color( (127 + 127f * P.sin(vertex.x * oscMult)) * zFade, (127 + 127f * P.sin(vertex.y * oscMult)) * zFade, (127 + 127f * P.sin(vertex.z * oscMult)) * zFade ); shape.setFill(i, fillReplace); shape.noStroke(); } for (int j = 0; j < shape.getChildCount(); j++) { addFillToShape(shape.getChild(j), oscMult); } }
Example 3
Source File: Skylight_Capture1.java From PixelFlow with MIT License | 5 votes |
public void createScene(){ int scale = 5; int src_w = pg_src.width; int src_h = pg_src.height; int num_x = src_w/scale; int num_y = src_h/scale; pg_src_small = (PGraphics2D) createGraphics(num_x, num_y, P2D); pg_src_small_tmp = (PGraphics2D) createGraphics(num_x, num_y, P2D); pg_src_small.loadPixels(); opticalflow.resize(src_w, src_h); pg_src_tmp = (PGraphics2D) createGraphics(src_w, src_h, P2D); tex_vel_small.resize(context, opticalflow.frameCurr.velocity); tex_vel_small.resize(context, num_x, num_y); pg_oflow = (PGraphics2D) createGraphics(src_w, src_h, P2D); group_cubes = createShape(GROUP); shp_cubes = new PShape[num_x * num_y]; for(int y = 0; y < num_y; y++){ for(int x = 0; x < num_x; x++){ int idx = y * num_x + x; PShape shp_cube = createShape(BOX, 1, 1, 1); shp_cube.setStroke(false); shp_cube.setStroke(color(0)); shp_cube.setFill(true); shp_cubes[idx] = shp_cube; group_cubes.addChild(shp_cube); } } }
Example 4
Source File: Skylight_BulletPhysics_Breakable_VideoExport.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 5
Source File: DwSoftGrid2D.java From PixelFlow with MIT License | 5 votes |
@Override public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){ PShape shp = pg.createShape(); displayGridXY(shp, texture_XYp); shp.setTexture(null); shp.setFill(false); shp.setStroke(true); shp.setStroke(style.stroke_color); shp.setStrokeWeight(style.stroke_weight); setShapeWireframe(pg.parent, shp); }
Example 6
Source File: Skylight_BulletPhysics_Breakable.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 7
Source File: Skylight_BulletPhysics_TowerDemolition.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 8
Source File: PShapeUtil.java From haxademic with MIT License | 5 votes |
public static void setMaterialColor(PShape shape, int newColor) { for (int i = 0; i < shape.getVertexCount(); i++) { shape.setFill(i, newColor); shape.setStroke(false); } for (int j = 0; j < shape.getChildCount(); j++) { setMaterialColor(shape.getChild(j), newColor); } }
Example 9
Source File: PShapeUtil.java From haxademic with MIT License | 5 votes |
public static PShape setBasicShapeStyles(PShape shape, int color, int stroke, float strokeWeight) { shape.setFill(color != 0); // boolean turn on/off shape.setFill(color); shape.setStroke(stroke != 0); // boolean turn on/off shape.setStroke(stroke); shape.setStrokeWeight(strokeWeight); return shape; }
Example 10
Source File: Skylight_BulletPhysics_Basic.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 11
Source File: Sampling_Poisson3D.java From PixelFlow with MIT License | 5 votes |
void addShape(MyPoissonSample sample){ PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z()); shp_point.setStroke(color(255)); shp_point.setStrokeWeight(3); shp_samples_points.addChild(shp_point); if(ifs == null){ ifs = new DwIcosahedron(2); verts_per_face = 3; // ifs = new DwCube(2); verts_per_face = 4; } PShape shp_sphere = createShape(PShape.GEOMETRY); shp_sphere.setStroke(false); shp_sphere.setFill(color(255)); shp_sphere.resetMatrix(); shp_sphere.translate(sample.x(), sample.y(), sample.z()); DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, true); shp_samples_spheres.addChild(shp_sphere); // PShape shp_sphere_normals = createShape(PShape.GEOMETRY); // shp_sphere_normals.setStroke(false); // shp_sphere_normals.setFill(color(255)); // shp_sphere_normals.resetMatrix(); // shp_sphere_normals.translate(sample.x(), sample.y(), sample.z()); // // DwMeshUtils.createPolyhedronShapeNormals(shp_sphere_normals, ifs, sample.rad(), 10); // // shp_samples_spheres.addChild(shp_sphere_normals); }
Example 12
Source File: HaxMapDrawingTool.java From haxademic with MIT License | 5 votes |
public void drawExistingShapes() { // draw already-drawn shapes p.noFill(); p.stroke(255); for (int i=0; i < _shapes.size(); i++) { // get shape and set audio-reactive fill -------------- PShape shape = _shapes.get(i); shape.setFill(p.color(255, AudioIn.audioFreq((i * 10 + 10)) * 2000)); p.shape( shape ); if( _debugging == true ) { // draw wireframe and handles ------------------------- PVector v = null; PVector nextV = null; int numVertices = shape.getVertexCount(); for (int j = 0; j < shape.getVertexCount(); j++) { v = shape.getVertex(j); p.ellipse( v.x, v.y, 6, 6 ); if( j < numVertices - 1 ) { nextV = shape.getVertex(j+1); p.line( v.x, v.y, nextV.x, nextV.y ); } } p.line( shape.getVertex(0).x, shape.getVertex(0).y, shape.getVertex(numVertices-1).x, shape.getVertex(numVertices-1).y ); } } }
Example 13
Source File: PShapeUtil.java From haxademic with MIT License | 5 votes |
public static void addTestFillToShape(PShape shape, float oscMult) { for (int i = 0; i < shape.getVertexCount(); i++) { PVector vertex = shape.getVertex(i); int fillReplace = P.p.color( 127 + 127f * P.sin(vertex.x * oscMult), 127 + 127f * P.sin(vertex.y * oscMult), 127 + 127f * P.sin(vertex.z * oscMult) ); shape.setFill(i, fillReplace); shape.noStroke(); } for (int j = 0; j < shape.getChildCount(); j++) { addTestFillToShape(shape.getChild(j), oscMult); } }
Example 14
Source File: Skylight_BulletPhysics_MengerSponge.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(int mode){ DISPLAY_WIREFRAME = mode; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null){ if(mode == 1){ if(name.contains("[wire1]")){ shp.setFill(false); shp.setStroke(true); } else { shp.setFill(true); shp.setStroke(false); } } else if(mode == 2){ if(name.contains("[wire2]")){ shp.setFill(false); shp.setStroke(true); } else { shp.setFill(true); shp.setStroke(false); } } else { shp.setFill(true); shp.setStroke(false); } } } skylight.reset(); }
Example 15
Source File: Skylight_BulletPhysics_CellFracture.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 16
Source File: Skylight_BulletPhysics_Cubes.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 17
Source File: DwSoftGrid3D.java From PixelFlow with MIT License | 5 votes |
@Override public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){ PShape shp = createShape(pg); shp.setTexture(null); shp.setFill(false); shp.setStroke(true); shp.setStroke(style.stroke_color); shp.setStrokeWeight(style.stroke_weight); setShapeWireframe(pg.parent, shp); }
Example 18
Source File: Skylight_BulletPhysics_Breakable3.java From PixelFlow with MIT License | 5 votes |
public void toggleDisplayWireFrame(){ DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME; for (BObject body : physics.rigidBodies) { PShape shp = body.displayShape; String name = shp.getName(); if(name != null && name.contains("[wire]")){ shp.setFill(!DISPLAY_WIREFRAME); shp.setStroke(DISPLAY_WIREFRAME); } } skylight.reset(); }
Example 19
Source File: Skylight_BulletPhysics_CellFracture.java From PixelFlow with MIT License | 4 votes |
public PShape createVoronoiCellShape(WB_VoronoiCell3D cell, Vector3f center_of_mass){ boolean[] on_bounds = cell.getVerticesOnBoundary(); PShape voronoi_cell = createShape(GROUP); WB_Mesh mesh = cell.getMesh(); int[][] faces = mesh.getFacesAsInt(); int on_boundary = 0; for(int j = 0; j < faces.length; j++){ int[] face = faces[j]; WB_Vector normal = mesh.getFaceNormal(j); PShape polygon = createShape(); polygon.beginShape(POLYGON); polygon.normal(normal.xf(), normal.yf(), normal.zf()); for(int k = 0; k < face.length; k++){ WB_Coord vtx = mesh.getVertex(face[k]); float x = vtx.xf() - center_of_mass.x; float y = vtx.yf() - center_of_mass.y; float z = vtx.zf() - center_of_mass.z; polygon.vertex(x,y,z); if(on_bounds[face[k]]){ on_boundary++; } } polygon.endShape(CLOSE); // polygon.setFill(true); // if(on_boundary == face.length){ // if(on_boundary > 0){ // polygon.setFill(color(8)); // } else { // polygon.setFill(color(255,0,0)); // } // // polygon.setStroke(false); voronoi_cell.addChild(polygon); } String wire = ""; voronoi_cell.setFill(true); // if(on_boundary == face.length){ if(on_boundary > 0){ voronoi_cell.setFill(color(32)); wire = "[wire]"; } else { voronoi_cell.setFill(color(255,8,0)); } voronoi_cell.setStroke(false); voronoi_cell.setStroke(color(64,4,0)); voronoi_cell.setName("[cvh] "+wire); return voronoi_cell; }
Example 20
Source File: Skylight_Capture1.java From PixelFlow with MIT License | 2 votes |
public void updateAnim(){ if(pg_src_small == null){ createScene(); } int num_x = pg_src_small.width; int num_y = pg_src_small.height; DwFilter.get(context).gaussblur.apply(pg_src, pg_src, pg_src_tmp, 3); pg_src_small.beginDraw(); pg_src_small.image(pg_src, 0, 0, num_x, num_y); pg_src_small.endDraw(); opticalflow.update(pg_src); DwFilter.get(context).copy.apply(opticalflow.frameCurr.velocity, tex_vel_small); flow = tex_vel_small.getFloatTextureData(flow); DwFilter.get(context).gaussblur.apply(pg_src_small, pg_src_small, pg_src_small_tmp, 3); pg_src_small.loadPixels(); float scene_dimx = bounds[3] - bounds[0]; float scene_dimy = bounds[4] - bounds[1]; float scene_dimz = bounds[5] - bounds[2]; float bounds_off = 100; float dimx = (scene_dimx - bounds_off*2) / num_x; float dimy = (scene_dimy - bounds_off*2) / num_y; float dim = min(dimx, dimy); float tx = -dim * num_x * 0.5f; float ty = -dim * num_y * 0.5f; float tz = 10; for(int y = 0; y < num_y; y++){ for(int x = 0; x < num_x; x++){ int idx = y * num_x + x; int rgb = pg_src_small.pixels[idx]; int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = (rgb >> 0) & 0xFF; int flow_idx = (num_y - y - 1) * num_x + x; float flows = 3; float flowx = flow[flow_idx * 2 + 0] * +flows; float flowy = flow[flow_idx * 2 + 1] * -flows; float flow_mm = flowx*flowx + flowy*flowy; float flow_m = (float) Math.pow(flow_mm, 0.5f); float gray = (r + g + b) / (3f * 255f); float px = x * dim; float py = y * dim; float pz = scene_dimz * gray * 0.25f + +flow_m; pz = max(pz, 0); PShape cube = shp_cubes[idx]; cube.resetMatrix(); cube.scale(dim); cube.translate(tx+px, ty+py, tz+pz); cube.setFill(rgb); } } }