tricolaire
08-18-2006, 06:40 PM
I wrote this simple applet, you can substitute the url image for w/e is most conveniant for you:
//
// image_tracer.java
// image tracer
//
// Created by Erik Schmidt on 8/17/06.
// Copyright (c) 2006 __MyCompanyName__. All rights reserved.
// A simple Java applet
//
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Image;
import java.net.*;
import java.awt.image.ImageObserver;
import java.util.*;
public class image_tracer extends Applet {
private Image image;
private ImageObserver ob;
int[] first,second;
public void init(){
try{
image=getImage(new URL("http://erik-schmidt90s-ibook-g4.local/~erikschmidt90/face.jpg"));
}catch(MalformedURLException ex){
//do nothing
}
setLayout(null);
first=new int[1];
second=new int[1];
first[0]=-1;
second[0]=-1;
}
public void paint(Graphics g){
resize(image.getWidth(ob),image.getHeight(ob));
g.drawImage(image,0,0,null,ob);
g.setColor(Color.black);
for(int i=0;i<first.length;i++){
g.fillOval(first[i],second[i],20,20);
}
}
public boolean mouseMove(Event evt, int x, int y){
int[] i=new int[first.length+1];
int[] j=new int[second.length+2];
int l=0;
for(int k : first){
i[l]=k;
l++;
}
l=0;
for(int k : second){
j[l]=k;
l++;
}
i[first.length]=x;
j[second.length]=y;
first=new int[i.length];
second=new int[j.length];
first=i;
second=j;
repaint();
return true;
}
}
so the problem I'm facing?
the ovals draw mostly correctly, though they're hard to control. sometimes the go in the opposite direction as the mouse, and also, there is this unrelated set of ovals being drawn at the top of the screen. any ideas?
//
// image_tracer.java
// image tracer
//
// Created by Erik Schmidt on 8/17/06.
// Copyright (c) 2006 __MyCompanyName__. All rights reserved.
// A simple Java applet
//
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Image;
import java.net.*;
import java.awt.image.ImageObserver;
import java.util.*;
public class image_tracer extends Applet {
private Image image;
private ImageObserver ob;
int[] first,second;
public void init(){
try{
image=getImage(new URL("http://erik-schmidt90s-ibook-g4.local/~erikschmidt90/face.jpg"));
}catch(MalformedURLException ex){
//do nothing
}
setLayout(null);
first=new int[1];
second=new int[1];
first[0]=-1;
second[0]=-1;
}
public void paint(Graphics g){
resize(image.getWidth(ob),image.getHeight(ob));
g.drawImage(image,0,0,null,ob);
g.setColor(Color.black);
for(int i=0;i<first.length;i++){
g.fillOval(first[i],second[i],20,20);
}
}
public boolean mouseMove(Event evt, int x, int y){
int[] i=new int[first.length+1];
int[] j=new int[second.length+2];
int l=0;
for(int k : first){
i[l]=k;
l++;
}
l=0;
for(int k : second){
j[l]=k;
l++;
}
i[first.length]=x;
j[second.length]=y;
first=new int[i.length];
second=new int[j.length];
first=i;
second=j;
repaint();
return true;
}
}
so the problem I'm facing?
the ovals draw mostly correctly, though they're hard to control. sometimes the go in the opposite direction as the mouse, and also, there is this unrelated set of ovals being drawn at the top of the screen. any ideas?