How can i use an image inside of an simple point marker

edited July 2016 in Library Questions

Hi

Im really new in programming and im trying to use an image.png like a parameter of a draw() method of simplePointMarker (PGraphics pg, float x, float y) and i cant figure how i suppose to do it

i suppose there is a way to cast an image to a pgraphics

thanks for helping

Tagged:

Answers

  • edited July 2016

    Thanks Chrisir but i already read that info, ill be more specific

    I have two clases

    worldMap extends PApplet
    cityMarker extends AbstractMarker

    in cityMarker class i have this method

    public void drawMarker(PGraphics pg, float x, float y) {
    
        pg.pushStyle();
    
        //here i must to asign my png file to pg parameter
        // i used before an ellipse to the marker and worked fine
        // i just need to replace the ellipse with an png file  
    
        pg.popStyle();
    }
    
  • simplePointMarker - we don't know what this is
    AbstractMarker - or this

    it appears you are using unfolding maps.

  • Yes koogs im using unfolding maps and drawing markers with proccesing.org

    java.lang.Object extended by de.fhpotsdam.unfolding.marker.AbstractMarker extended by de.fhpotsdam.unfolding.marker.SimplePointMarker

    before i tried to use a png file like pgraphics i used this

    pg.fill(150, 30, 30); pg.triangle (x, y, x-5, y-10, x+5, y-10);

    and now i want to use: cityIcon.png instead a simple triangle

    so im tring to use loadImage() but i have troubles understanding this:

    "In most cases, load all images in setup() to preload them at the start of the program. Loading images inside draw() will reduce the speed of a program. Images cannot be loaded outside setup() unless they're inside a function that's called after setup() has already run."

    i already located my file in data folder, but something is mising to me

    thanks

  • I ... did not understand your problem.
    Basically, if you know where the .png file is from the starting, just loadImage(path.png) in the setup(). Otherwise you could call loadImage() inside of draw also, only it can cause great performance reductions(depends on your disk drive).

  • @o1bigdeal , Did you find any solution for this problem , I am stock at this same point , I need your help ASAP . Thanks

  • Please provide an MCVE to be able to address your questions properly. This is an unfolding map question and an example is required to understand the question, exactly what you want to accomplish.

    Kf

Sign In or Register to comment.