GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — libprocessing/examples/shapes.rs at python-api · processing/libprocessing Expand file tree/ Copy pathshapes.rsMore file actions 162 lines (142 loc) · 5.09 KB / Copy pathshapes.rsFile metadata and controls162 lines (142 loc) · 5.09 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 use processing_glfw::GlfwContext; use std::f32::consts::PI; use processing::prelude::*; use processing_render::render::command::DrawCommand; fn main() { sketch().unwrap(); exit(0).unwrap(); } fn sketch() -> error::Result<()> { let mut glfw_ctx = GlfwContext::new(600, 600, false)?; init(Config::default())?; let surface = glfw_ctx.create_surface(600, 600, false)?; let graphics = graphics_create(surface, 600, 600, TextureFormat::Rgba16Float)?; let mut t: f32 = 0.0; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; graphics_record_command( graphics, DrawCommand::BackgroundColor(bevy::color::Color::srgb(0.92, 0.90, 0.87)), )?; graphics_record_command( graphics, DrawCommand::Fill(bevy::color::Color::srgba(0.2, 0.3, 0.5, 0.25)), )?; graphics_record_command(graphics, DrawCommand::StrokeWeight(1.5))?; graphics_record_command( graphics, DrawCommand::StrokeColor(bevy::color::Color::srgb(0.15, 0.2, 0.35)), )?; let n = 8; graphics_record_command( graphics, DrawCommand::BeginShape { kind: ShapeKind::Polygon, }, )?; for i in 0..n + 3 { let idx = (i + n - 1) % n; let angle = idx as f32 * 2.0 * PI / n as f32; let r = 100.0 + 30.0 * (t * 2.0 + idx as f32 * 0.8).sin(); graphics_record_command( graphics, DrawCommand::ShapeCurveVertex { x: 170.0 + r * angle.cos(), y: 200.0 + r * angle.sin(), }, )?; } graphics_record_command(graphics, DrawCommand::EndShape { close: true })?; graphics_record_command( graphics, DrawCommand::Fill(bevy::color::Color::srgba(0.15, 0.5, 0.3, 0.2)), )?; graphics_record_command(graphics, DrawCommand::StrokeWeight(1.0))?; graphics_record_command( graphics, DrawCommand::StrokeColor(bevy::color::Color::srgb(0.1, 0.35, 0.2)), )?; let pcx = 430.0; let pcy = 200.0; let s = 70.0 + 10.0 * (t * 1.5).sin(); graphics_record_command( graphics, DrawCommand::BeginShape { kind: ShapeKind::Polygon, }, )?; graphics_record_command(graphics, DrawCommand::ShapeVertex { x: pcx, y: pcy - s })?; graphics_record_command( graphics, DrawCommand::ShapeBezierVertex { cx1: pcx + s, cy1: pcy - s, cx2: pcx + s, cy2: pcy + s, x: pcx, y: pcy + s, }, )?; graphics_record_command( graphics, DrawCommand::ShapeBezierVertex { cx1: pcx - s, cy1: pcy + s, cx2: pcx - s, cy2: pcy - s, x: pcx, y: pcy - s, }, )?; graphics_record_command(graphics, DrawCommand::EndShape { close: true })?; graphics_record_command( graphics, DrawCommand::Fill(bevy::color::Color::srgba(0.8, 0.35, 0.1, 0.15)), )?; graphics_record_command(graphics, DrawCommand::NoStroke)?; graphics_record_command( graphics, DrawCommand::BeginShape { kind: ShapeKind::TriangleFan, }, )?; graphics_record_command(graphics, DrawCommand::ShapeVertex { x: 170.0, y: 450.0 })?; for i in 0..=16 { let angle = i as f32 * 2.0 * PI / 16.0; let r = 60.0 + 20.0 * (t * 3.0 + angle * 2.0).sin(); graphics_record_command( graphics, DrawCommand::ShapeVertex { x: 170.0 + r * angle.cos(), y: 450.0 + r * angle.sin(), }, )?; } graphics_record_command(graphics, DrawCommand::EndShape { close: true })?; graphics_record_command( graphics, DrawCommand::Fill(bevy::color::Color::srgba(0.5, 0.2, 0.6, 0.2)), )?; graphics_record_command(graphics, DrawCommand::StrokeWeight(0.5))?; graphics_record_command( graphics, DrawCommand::StrokeColor(bevy::color::Color::srgba(0.3, 0.1, 0.4, 0.4)), )?; graphics_record_command( graphics, DrawCommand::BeginShape { kind: ShapeKind::TriangleStrip, }, )?; for i in 0..16 { let x = 320.0 + i as f32 * 17.0; let wave = 30.0 * (t * 2.0 + i as f32 * 0.4).sin(); graphics_record_command(graphics, DrawCommand::ShapeVertex { x, y: 420.0 + wave })?; graphics_record_command(graphics, DrawCommand::ShapeVertex { x, y: 480.0 + wave })?; } graphics_record_command(graphics, DrawCommand::EndShape { close: false })?; graphics_end_draw(graphics)?; t += 0.02; } Ok(()) } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |