Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:59:26+00:00 2026-05-24T23:59:26+00:00

Is it possible to move an image (or image object) without clearing the whole

  • 0

Is it possible to move an image (or image object) without clearing the whole background?

I wish to create an app that allows the user to “paint”, using a device that is not the mouse. I would like to have a cursor to follow the users movement with the input device, without having to clear the already painted picture.

Is this possible? And how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:59:27+00:00Added an answer on May 24, 2026 at 11:59 pm

    It depends how you handle drawing.
    I would suggest using PImage as a canvas to draw into and another PImage to store the pixels of your brush. The ‘brush’ can be a loaded image, or at the start of your sketch you could make the brush using drawing commands, then store those as a PImage using get().

    You will need to clear everything because you want to draw your cursor, but you will also draw your canvas, and you’ll store ‘brush strokes’ only when the mouse is pressed (or some device specific method) by using the copy() or the blend() function (depending on your brush PNG – with or without transparency, etc.)

    Here’s a quick sketch to illustrate this:

    PImage canvas;
    PImage brush;
    
    void setup(){
      size(800,800);
      stroke(128);
      smooth();
      canvas = createImage(width,height,ARGB);
      brush = loadImage("brush.png");
    }
    
    void draw(){
      background(255);
      image(canvas,0,0);
      //draw cursor
      line(mouseX-5,mouseY-5,mouseX+5,mouseY+5);
      line(mouseX+5,mouseY-5,mouseX-5,mouseY+5);
      //blend brush pixels into canvas if mouse is pressed
      if(mousePressed) canvas.blend(brush, 0, 0, brush.width, brush.width, (int)(mouseX-brush.width*.5), (int)(mouseY-brush.height*.5), brush.width, brush.width,MULTIPLY);
    }
    

    Note that you need an image into your sketch’s data folder.

    You can try it here:

    Brush Test

    You can run a javascript version bellow:

    var canvas;
    var brush;
    
    function setup(){
      createCanvas(800,800);
      stroke(128);strokeWeight(3);
      smooth();
      canvas = createImage(width,height);
      brush = getGradientImg(64,64,random(360),random(100),85);
    }
    
    function draw(){
      background(255);
      image(canvas,0,0);
      //draw cursor
      line(mouseX-5,mouseY-5,mouseX+5,mouseY+5);
      line(mouseX+5,mouseY-5,mouseX-5,mouseY+5);
      //blend brush pixels into canvas if mouse is pressed
      if(isMousePressed) canvas.blend(brush, 0, 0, brush.width, brush.width, (int)(mouseX-brush.width*.5), (int)(mouseY-brush.height*.5), brush.width, brush.width,MULTIPLY);
      //image(brush,mouseX,mouseY);
    }
    //*
    function getGradientImg(w,h,hue,satMax,brightness){
      push();//isolate drawing styles such as color Mode
        colorMode(HSB,360,100,100);
        var gradient = createImage(w,h);//create an image with an alpha channel
        var np = w * h;//total number of pixels
        var np4 = np*4;
        var cx = floor(gradient.width * 0.5);//center on x
        var cy = floor(gradient.height * 0.5);//center on y
        gradient.loadPixels();
        for(var i = 0 ; i < np4; i+=4){//for each pixel
          var id4 = floor(i * .25);
          var x = id4%gradient.width;//compute x from pixel index
          var y = floor(id4/gradient.width);//compute y from pixel index
          var d = dist(x,y,cx,cy);//compute distance from centre to current pixel
          //map the saturation and transparency based on the distance to centre
          gradient.pixels[i]   = hue;
          gradient.pixels[i+1] = map(d,0,cx,satMax,0);
          gradient.pixels[i+2] = brightness;
          gradient.pixels[i+3] = map(d,0,cx,255,0);
        }
        gradient.updatePixels();//finally update all the pixels
      pop();
      console.log(gradient);
      return gradient;
    }
    //*/
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.4/p5.min.js"></script>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible that I can create a margin/padding between the background image and
On a div, I'll like that the background image to move continuously from top
Would it be possible to write a program that can make an image, lets
Possible Duplicate: Android, move bitmap along a path? I want to move an image
It's possible to move a dynamic ctreated element or child? Example: Create childs: public
Is it possible to prevent the drag and drop(Move/Copy) image or any file on
I am making an app that uses a lot of fairly big image files.
Is it not possible to move between pages in the canvas on facebook? I'm
I was wondering if it is possible to move all rows of data from
I would like to know if it is possible to copy/move files to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.