//------------------------------------------------------------------------ private void line_clip_y(rasterizer_cells_aa ras, int x1, int y1, int x2, int y2, int f1, int f2) { f1 &= 10; f2 &= 10; if ((f1 | f2) == 0) { // Fully visible ras.line(x1, y1, x2, y2); } else { if (f1 == f2) { // Invisible by Y return; } int tx1 = x1; int ty1 = y1; int tx2 = x2; int ty2 = y2; if ((f1 & 8) != 0) // y1 < clip.y1 { tx1 = x1 + mul_div(clipBox.Bottom - y1, x2 - x1, y2 - y1); ty1 = clipBox.Bottom; } if ((f1 & 2) != 0) // y1 > clip.y2 { tx1 = x1 + mul_div(clipBox.Top - y1, x2 - x1, y2 - y1); ty1 = clipBox.Top; } if ((f2 & 8) != 0) // y2 < clip.y1 { tx2 = x1 + mul_div(clipBox.Bottom - y1, x2 - x1, y2 - y1); ty2 = clipBox.Bottom; } if ((f2 & 2) != 0) // y2 > clip.y2 { tx2 = x1 + mul_div(clipBox.Top - y1, x2 - x1, y2 - y1); ty2 = clipBox.Top; } ras.line(tx1, ty1, tx2, ty2); } }
//-------------------------------------------------------------------- public ScanlineRasterizer(VectorClipper rasterizer_sl_clip) { m_outline = new rasterizer_cells_aa(); m_VectorClipper = rasterizer_sl_clip; m_filling_rule = filling_rule_e.fill_non_zero; m_auto_close = true; m_start_x = 0; m_start_y = 0; m_status = status.status_initial; for (int i = 0; i < (int)aa_scale_e.aa_scale; i++) { m_gamma[i] = i; } }
public rasterizer_compound_aa() { m_Rasterizer = new rasterizer_cells_aa(); m_VectorClipper = new VectorClipper(); m_filling_rule = agg_basics.filling_rule_e.fill_non_zero; m_layer_order = layer_order_e.layer_direct; m_styles = new VectorPOD <style_info>(); // Active Styles m_ast = new VectorPOD <int>(); // Active Style Table (unique values) m_asm = new VectorPOD <byte>(); // Active Style Mask m_cells = new VectorPOD <cell_aa>(); m_cover_buf = new VectorPOD <byte>(); m_master_alpha = new VectorPOD <int>(); m_min_style = (0x7FFFFFFF); m_max_style = (-0x7FFFFFFF); m_start_x = (0); m_start_y = (0); m_scan_y = (0x7FFFFFFF); m_sl_start = (0); m_sl_len = (0); }
public rasterizer_compound_aa() { m_Rasterizer = new rasterizer_cells_aa(); m_VectorClipper = new VectorClipper(); m_filling_rule = agg_basics.filling_rule_e.fill_non_zero; m_layer_order = layer_order_e.layer_direct; m_styles = new VectorPOD<style_info>(); // Active Styles m_ast = new VectorPOD<int>(); // Active Style Table (unique values) m_asm = new VectorPOD<byte>(); // Active Style Mask m_cells = new VectorPOD<cell_aa>(); m_cover_buf = new VectorPOD<byte>(); m_master_alpha = new VectorPOD<int>(); m_min_style = (0x7FFFFFFF); m_max_style = (-0x7FFFFFFF); m_start_x = (0); m_start_y = (0); m_scan_y = (0x7FFFFFFF); m_sl_start = (0); m_sl_len = (0); }
//-------------------------------------------------------------------- public void line_to(rasterizer_cells_aa ras, int x2, int y2) { if (m_clipping) { int f2 = ClipLiangBarsky.clipping_flags(x2, y2, clipBox); if ((m_f1 & 10) == (f2 & 10) && (m_f1 & 10) != 0) { // Invisible by Y m_x1 = x2; m_y1 = y2; m_f1 = f2; return; } int x1 = m_x1; int y1 = m_y1; int f1 = m_f1; int y3, y4; int f3, f4; switch (((f1 & 5) << 1) | (f2 & 5)) { case 0: // Visible by X line_clip_y(ras, x1, y1, x2, y2, f1, f2); break; case 1: // x2 > clip.x2 y3 = y1 + mul_div(clipBox.Right - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); line_clip_y(ras, x1, y1, clipBox.Right, y3, f1, f3); line_clip_y(ras, clipBox.Right, y3, clipBox.Right, y2, f3, f2); break; case 2: // x1 > clip.x2 y3 = y1 + mul_div(clipBox.Right - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); line_clip_y(ras, clipBox.Right, y1, clipBox.Right, y3, f1, f3); line_clip_y(ras, clipBox.Right, y3, x2, y2, f3, f2); break; case 3: // x1 > clip.x2 && x2 > clip.x2 line_clip_y(ras, clipBox.Right, y1, clipBox.Right, y2, f1, f2); break; case 4: // x2 < clip.x1 y3 = y1 + mul_div(clipBox.Left - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); line_clip_y(ras, x1, y1, clipBox.Left, y3, f1, f3); line_clip_y(ras, clipBox.Left, y3, clipBox.Left, y2, f3, f2); break; case 6: // x1 > clip.x2 && x2 < clip.x1 y3 = y1 + mul_div(clipBox.Right - x1, y2 - y1, x2 - x1); y4 = y1 + mul_div(clipBox.Left - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); f4 = ClipLiangBarsky.clipping_flags_y(y4, clipBox); line_clip_y(ras, clipBox.Right, y1, clipBox.Right, y3, f1, f3); line_clip_y(ras, clipBox.Right, y3, clipBox.Left, y4, f3, f4); line_clip_y(ras, clipBox.Left, y4, clipBox.Left, y2, f4, f2); break; case 8: // x1 < clip.x1 y3 = y1 + mul_div(clipBox.Left - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); line_clip_y(ras, clipBox.Left, y1, clipBox.Left, y3, f1, f3); line_clip_y(ras, clipBox.Left, y3, x2, y2, f3, f2); break; case 9: // x1 < clip.x1 && x2 > clip.x2 y3 = y1 + mul_div(clipBox.Left - x1, y2 - y1, x2 - x1); y4 = y1 + mul_div(clipBox.Right - x1, y2 - y1, x2 - x1); f3 = ClipLiangBarsky.clipping_flags_y(y3, clipBox); f4 = ClipLiangBarsky.clipping_flags_y(y4, clipBox); line_clip_y(ras, clipBox.Left, y1, clipBox.Left, y3, f1, f3); line_clip_y(ras, clipBox.Left, y3, clipBox.Right, y4, f3, f4); line_clip_y(ras, clipBox.Right, y4, clipBox.Right, y2, f4, f2); break; case 12: // x1 < clip.x1 && x2 < clip.x1 line_clip_y(ras, clipBox.Left, y1, clipBox.Left, y2, f1, f2); break; } m_f1 = f2; } else { ras.line(m_x1, m_y1, x2, y2); } m_x1 = x2; m_y1 = y2; }