From 0711309246f23f77cfbc1d110816c388f2ab3d64 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 22 Mar 2022 18:03:53 -0500 Subject: [PATCH] Add X vertex sort when grabbing new active edges. Was causing bugs without it. --- bin/sig/Color.class | Bin 1355 -> 1355 bytes bin/sig/Panel.class | Bin 5661 -> 5894 bytes bin/sig/PolygonFill.class | Bin 990 -> 861 bytes src/sig/Color.java | 2 +- src/sig/Panel.java | 115 ++++++++++++++++++++++---------------- src/sig/PolygonFill.java | 6 +- 6 files changed, 71 insertions(+), 52 deletions(-) diff --git a/bin/sig/Color.class b/bin/sig/Color.class index f642ad4aea2c40622a6fb1fe7e71d4fb3954d69d..35c63b2f104f26ad9381b244a5678ff6b492b589 100644 GIT binary patch delta 13 UcmX@jb((8~7%L;kWN}s#03GoIVgLXD delta 13 UcmX@jb((8~7%QW|WN}s#03I0wY5)KL diff --git a/bin/sig/Panel.class b/bin/sig/Panel.class index b5a3a6090987dfa28c20161b411606f8d9ebbb98..14c9c4206a29cc439b3ea2e38125c37f5a9a3908 100644 GIT binary patch literal 5894 zcmaJ_3w%{|9smB%eVn^{53m6jyulC=b-QB>QI|0^U?5J%BSzSu+Aeoz+l9M(=Y7DY zmT5CzWo166AVY1L6k2RRB;^aWhuMS5SC(0pWe`t>mY!0RIv#|p(vYZt6CjP*+~;#g^8PDTVh>R*{z9GTh#?F-0#Axk}*Qpr8anNd;p=9XDGOExC3D#kIfPPPDb>xX86<>{tu$*9&2Xz*-HfQ3xeEVr}-4 zd~2(nQ7Cp$Vq0@nbpj{C_zt~Vok_RkMO zTy46eGnPvbbHv;VrDf&s;f)~9#Uc|QRG6-nlmJ+siFLLo;@M@XEs0Dz)nTV{78YX( z{Yoxcq~o9{%pA?>I2bj;Y^jB1I8R{;NiDToWBDZgpRw)KQhQ4x&XAaPJSxs137n4$ zOfbl&zDrsM#lnTCcg*2ZuT7^~6K(knEt5_$h>u5p3=X-h#A*|(6lT1O%NR@xAHqU~ zaoYBU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f28830c4000a4 100644 GIT binary patch delta 132 zcmcb|ewU5w)W2Q(7#J9A8LT#P-DRBY%;dwyn90b%=s9^VQyJ%C24)5pptSj98D;}+ zW;^X|47wYEe5T2n%<9g93`Pt>3}y_%4BS95Er?160|rANkAp!UC~M5X2vniUV8UR^ Vzy##80#%y>&17V-0GYyI2>=vb6SV*U delta 262 zcmcc1c8{Iw)W2Q(7#J9A8JstA-DQkn1+qavgp0wL!IYiBgpolYE3qt5KPNFST|XqF zC^a#Khrx`&oRNXGI43o=fRTYk!%H)aoxzfkK@OqPGp{7IsHn7{BsImgB0067Br`v6 z@^eNXKHlJx#N=$>#Db8-q@2{rmP}=w2N;+cSb%mqPTs*}AgjHNL05#qUUy m& edges_sorted = new ArrayList(); for (int i=0;i=edges[i].min_y) { + edges_sorted.add(j,edges[i]); + inserted=true; + break; + } + } + if (!inserted) { + edges_sorted.add(edges[i]); + } + } + } + } + //System.out.println(edges_sorted); + List active_edges = new ArrayList(); + scanLine = edges_sorted.get(0).min_y-1; + nextScanLine = scanLine+1; + do { + for (int i=0;i=0) { + p[index]=col.getColor(); + } + } + } + List new_active_edges = new ArrayList(); + for (int i=0;iedges[i].min_y) { - edges_sorted.add(j,edges[i]); + for (int j=0;je.x_of_min_y) { + new_active_edges.add(j,e); inserted=true; break; - } else - if (e2.min_y==edges[i].min_y){ - if (e2.min_x>edges[i].min_x) { - edges_sorted.add(j,edges[i]); - inserted=true; - break; - } } } if (!inserted) { - edges_sorted.add(edges[i]); + new_active_edges.add(e); } } - } - List active_edges = new ArrayList(); - scanLine = edges_sorted.get(0).min_y-1; - nextScanLine = scanLine+1; - do { - if (active_edges.size()%2==0) { - for (int i=0;i=0) { - p[index]=col.getColor(); - } - } - } - for (int i=0;i0); } @@ -198,7 +218,8 @@ public class Panel extends JPanel implements Runnable { public void run() { while (true) { // request a JPanel re-drawing - repaint(); + repaint(); + //System.out.println("Repaint "+frameCount++); try {Thread.sleep(5);} catch (InterruptedException e) {} } } diff --git a/src/sig/PolygonFill.java b/src/sig/PolygonFill.java index ccfc6cc..47b7db6 100644 --- a/src/sig/PolygonFill.java +++ b/src/sig/PolygonFill.java @@ -14,9 +14,7 @@ public class PolygonFill { f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); - while (true) { - p.render(); - try {Thread.sleep(20);} catch (InterruptedException e) {} - } + int i=0; + p.render(); } }