<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with createimg() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=createimg%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:43:54 +0000</pubDate>
         <description>Tagged with createimg() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedcreateimg%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How do I load and draw an image once as opposed to every frame to display it in every frame?</title>
      <link>https://forum.processing.org/two/discussion/28119/how-do-i-load-and-draw-an-image-once-as-opposed-to-every-frame-to-display-it-in-every-frame</link>
      <pubDate>Tue, 18 Sep 2018 07:55:23 +0000</pubDate>
      <dc:creator>samuset</dc:creator>
      <guid isPermaLink="false">28119@/two/discussions</guid>
      <description><![CDATA[<p>My problem is this: I want to display an image in my p5js sketch, but when I display it, it has to draw it every single frame, which can slow down the page. I want to be able to put my image on the canvas and leave it there until further notice, as opposed to drawing it in every frame. Kind of like a noLoop() until further notice.</p>

<p>Edit: I do want the sketch to keep looping, though, that's the thing.</p>
]]></description>
   </item>
   <item>
      <title>Endless Scroll</title>
      <link>https://forum.processing.org/two/discussion/25987/endless-scroll</link>
      <pubDate>Tue, 16 Jan 2018 02:33:14 +0000</pubDate>
      <dc:creator>grumo</dc:creator>
      <guid isPermaLink="false">25987@/two/discussions</guid>
      <description><![CDATA[<p>I have a collection of images that I want to appear and move as the user scrolls with the mouse wheel. I did a version with the mouseWheel event (updating the position of the images) but the scroll is rather slow and not smooth at all (I think because the continuous refreshing in draw() of few images with different alpha values). I wonder if is possible to put the images fixed in the HTML structure, so the scroll happens in a normal web page but controlling the images files (with parameters as alpha) and other events/texts from p5.js. Any ideas or examples? Thanks a lot.</p>
]]></description>
   </item>
   <item>
      <title>how to loadImage() from createImg()-p5.dom or from base64</title>
      <link>https://forum.processing.org/two/discussion/25597/how-to-loadimage-from-createimg-p5-dom-or-from-base64</link>
      <pubDate>Sat, 16 Dec 2017 16:24:41 +0000</pubDate>
      <dc:creator>MarcoHeleno</dc:creator>
      <guid isPermaLink="false">25597@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I need some help with:</p>

<p><strong>loadImage() from createImg()-p5.dom</strong></p>

<p>or</p>

<p><strong>loadImage() from a data URI, such as "data:image/jpg;base64,{base 64 encoded data block}"</strong></p>

<p>The createImg() comes from an createFileInput(), and I want o be able to resize() that image.</p>

<p>Thanks for your help!</p>

<p><strong>Code below:</strong></p>

<pre><code>function setup() {
    createFileInput (handleFile);
    createCanvas (800, 400);
    background (245);
}

function draw() {
    strokeWeight (10);
    stroke (0, 255,0);
    line (pmouseX, pmouseY, mouseX, mouseY);
}

function handleFile (file) {
  if (file.type === 'image') {
    var img = createImg (file.data).hide();
    print (img);

    //img.resize (width, 0);
    image (img, 0, 0);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Chrome extensions with gif in canvas</title>
      <link>https://forum.processing.org/two/discussion/25534/chrome-extensions-with-gif-in-canvas</link>
      <pubDate>Tue, 12 Dec 2017 13:49:01 +0000</pubDate>
      <dc:creator>Layzfat</dc:creator>
      <guid isPermaLink="false">25534@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm follow Shiffman incredible lessons on using P5js with chrome extensions.</p>

<p>In the example of the Canvas sketch with chrome extensions I followed, I wanted to do some more. Add gifs in the canvas overlaying the top layer of the browser viewing.</p>

<p>My attempt was unsuccessful.. The gif doesn't play..</p>

<p>So what did I do. 
I used <a rel="nofollow" href="https://p5js.org/examples/image-load-and-display-image.html">this example</a> to import gif in to p5js 
put it in my sketch.js as this:</p>

<pre><code>console.log('sketch blah');

var s = function(sketch) {
var img; //declare image

sketch.setup = function() {
  document.body.style['userSelect'] = 'none';
  let h = document.body.clientHeight;
  let c = sketch.createCanvas(sketch.windowWidth, h);
  img = sketch.loadImage("https://" + "media.giphy.com/media/xUOxfnlpG1tsYGFI40/giphy.gif");
  c.position(0,0);
  c.style('pointer-events', 'none');
  sketch.clear();
}

sketch.draw = function() {
  console.log('sketch Looping');
  sketch.image(img, 0, 0);
  //sketch.background(0);
  }
};

var myp5 = new p5(s);
</code></pre>

<p>My manifest.json looks like this.</p>

<pre><code>  {
    "manifest_version": 2,
    "name": "Agent Extension",
    "version": "0.0002",
    "web_accessible_resources": [
      "gif/*.gif"
    ],
    "content_scripts": [
      {
        "matches": [
            "&lt;all_urls&gt;"
        ],
        "js": ["p5.js","p5.dom.js","p5.gif.js","p5.gif.min.js", "sketch.js"]

      }
    ],
    "background": {
      "scripts": ["background.js"]
    },
    "browser_action": {
      "default_icon": "img.png"
    }
  }
</code></pre>

<p>all the files are in the wright place.</p>

<p>I get this error in the browsers console</p>

<pre><code>sketch.js:18 Uncaught ReferenceError: image is not defined
    at sketch.draw (sketch.js:18)
    at p5.redraw (p5.js:50266)
    at p5.&lt;anonymous&gt; (p5.js:44917)
    at p5.&lt;anonymous&gt; (p5.js:44812)
sketch.draw @ sketch.js:18
p5.redraw @ p5.js:50266
(anonymous) @ p5.js:44917
(anonymous) @ p5.js:44812
</code></pre>

<p>I did define it, my guess it is not defined for the browsers standards</p>

<p>I want to have a few 'objects' on the canvas and other types of code taking over the content as end goal.</p>
]]></description>
   </item>
   <item>
      <title>How do I make my button an image?</title>
      <link>https://forum.processing.org/two/discussion/22244/how-do-i-make-my-button-an-image</link>
      <pubDate>Thu, 27 Apr 2017 14:06:03 +0000</pubDate>
      <dc:creator>BowDown097</dc:creator>
      <guid isPermaLink="false">22244@/two/discussions</guid>
      <description><![CDATA[<p>So I'm trying to make a main menu for a game I'm making, but I'll need images for the buttons. Unfortunately, when using the button() function and using all the appropriate stuff, the button works, but I can't make the button an image. If I try making the button an image, the button just displays "[Object] Object". Am I doing something wrong?</p>

<p>button = createButton(img5);
  button.position(100, 100);
 //test position, not final
  button.mousePressed(gotoGame);</p>
]]></description>
   </item>
   <item>
      <title>I can't display images dynamically loaded from web with p5.js - always a cross domain issue.</title>
      <link>https://forum.processing.org/two/discussion/11608/i-can-t-display-images-dynamically-loaded-from-web-with-p5-js-always-a-cross-domain-issue</link>
      <pubDate>Wed, 08 Jul 2015 04:47:08 +0000</pubDate>
      <dc:creator>_vk</dc:creator>
      <guid isPermaLink="false">11608@/two/discussions</guid>
      <description><![CDATA[<p>I'm testing in a host (meaning not local). What I can't understand is that html images do show fine though...</p>

<p>Any help on this? Thanks.</p>

<p>the test looks like this:</p>

<p><a rel="nofollow" href="http://kubrusly.com/twtest/imagesTest/">As you can see it shows the html image, the live canvas, but not the p5 Image. In console the cross-domain error</a></p>

<blockquote class="Quote">
  <p>Cross-origin image load denied by Cross-Origin Resource Sharing policy.</p>
</blockquote>

<p>the code goes like:</p>

<pre><code>var canvas;

// window size
var w , h ;

// canvas width and height
var cw, ch;

//canvas positioning
var cx, cy;

// % of w to be canvas size
var w_prop = 1.;
var h_prop = 1.;

//img url
var imgURL = 'http:'+'//www.clker.com/cliparts/9/0/f/5/1194986802274589086football_ball_brice_boye_01.svg.med.png';

var img;
var htmlImg;


function setup() {

  // window size
  w = windowWidth, h = windowHeight;

 // calc everything
 calcSizes();

 // create canvas
 canvas =  createCanvas(cw, 100);//thats temp hard number

 // positining
 canvas.position(cx, cy);

img =  loadImage(imgURL);

 // this works
 htmlImg = createImg(imgURL);



}



function draw() {
    background(frameCount%255, 130,0);

    //this don't
    image(img,100,100);


}



// if window is resized, recalc stuff.
function windowResized(){
    calcSizes();
    resizeCanvas(cw, ch);
    canvas.position(cx,cy);
}


// that's it
var calcSizes = function(){
    w = windowWidth, h = windowHeight;

    // canvas width and height
    cw = w * w_prop;
    ch = h * h_prop;

    //canvas positioning
     cx = 0;//(w - cw) / 2.0;
     cy = 0;//100.0;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to display GIF in the background?</title>
      <link>https://forum.processing.org/two/discussion/20792/how-to-display-gif-in-the-background</link>
      <pubDate>Tue, 14 Feb 2017 10:35:35 +0000</pubDate>
      <dc:creator>Berlina</dc:creator>
      <guid isPermaLink="false">20792@/two/discussions</guid>
      <description><![CDATA[<p>I would like to create a disco light effect on a dance gif. So the gif is on the bottom layer, then a rectangle is flashing on top according to framerate. But somehow the gif is alway on the top, even though I place it before the rectangle. Could someone help me review the code?</p>

<pre><code>var img;  
function preload() {   
img = createImg("dancegif.gif");
}

function setup(){
    createCanvas(window.innerWidth,window.innerHeight); 
}

function draw(){
    background(255);

  img.position(0,0);

    // flashing effect 
    noStroke();
    if(frameCount % 7 &lt; 3 ){
      noFill(); //pic 33%  12 
    } else if(frameCount % 7 &gt; random(3,4) ){
        fill(255);//white 33% 56 
    } else{
        fill(0);//black 34% 
    }
    rect(0,0,window.innerWidth,window.innerHeight);

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Defining where in the DOM CreateImg() creates its image.</title>
      <link>https://forum.processing.org/two/discussion/19188/defining-where-in-the-dom-createimg-creates-its-image</link>
      <pubDate>Mon, 21 Nov 2016 12:15:48 +0000</pubDate>
      <dc:creator>sai</dc:creator>
      <guid isPermaLink="false">19188@/two/discussions</guid>
      <description><![CDATA[<p>I am adding a gif to a p5js sketch using createImg() due to lack of native support for gifs and the p5.gif.js library unable to load external gifs.</p>

<p>How can I define where the img tag should be inserted into the DOM?</p>

<p>For example I'd like it to be inserted inside an existing div with the id of "img-container".</p>

<p>I googled the vanilla javascript way of doing this with appendChild(); however I got a "Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'" error.</p>
]]></description>
   </item>
   <item>
      <title>Accessing pixel data from an Image loaded in the browser</title>
      <link>https://forum.processing.org/two/discussion/15752/accessing-pixel-data-from-an-image-loaded-in-the-browser</link>
      <pubDate>Tue, 29 Mar 2016 16:11:52 +0000</pubDate>
      <dc:creator>craigson</dc:creator>
      <guid isPermaLink="false">15752@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,
I'm trying to access the pixel data of an Image that I'm uploading on the client-side using the drop() method.</p>

<p>Using createImg() creates a p5.dom img object, as opposed to a p5.image, so I attempted to use loadImage(file.data) where file.data is the src as opposed to a string pointing to a local file.  This returns a p5.image object, however the pixels[] array returns as 
<code>pixels: Uint8ClampedArray[4]</code> instead of 'pixels:Array[0]' when the same image is loaded in setup using <code>var img = loadImage("test.jpg");</code>, though my assumption is that there's no real difference between the two as it's just returning information about the buffer being used.</p>

<p>The interesting thing is that console logging the width and height of the image loaded in setup reads 1920 x 1080, whereas the width and height of the image loaded using drop() reads as 1 x 1, despite showing up in the debugger as having the same properties..</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/535/606KK8UVBC62.png" alt="Screen Shot 2016-03-29 at 12.39.41 PM" title="Screen Shot 2016-03-29 at 12.39.41 PM" /></p>

<p>Any thoughts?</p>
]]></description>
   </item>
   <item>
      <title>Dropped Image not showing in the draw loop.  (gotFile, createImg, image(...)  )</title>
      <link>https://forum.processing.org/two/discussion/13650/dropped-image-not-showing-in-the-draw-loop-gotfile-createimg-image</link>
      <pubDate>Wed, 25 Nov 2015 16:16:04 +0000</pubDate>
      <dc:creator>hellwood</dc:creator>
      <guid isPermaLink="false">13650@/two/discussions</guid>
      <description><![CDATA[<p>I still have my weird problem with a dropped image, but now I think I have a better description of the problem!
(And this time, it's not related with AdBlock)</p>

<p><em>Note: this used to work correctly in a previous version of the library (p5-v0.4.3 April 09, 2015)</em></p>

<p>To show you the problem, I started from the Drop example on the website (<a href="http://p5js.org/examples/examples/Dom_Drop.php" target="_blank" rel="nofollow">http://p5js.org/examples/examples/Dom_Drop.php</a>).</p>

<p>I modified the code just a little bit :</p>

<p>Changes:</p>

<p>1) now the image is draw in the draw loop 
<code>image(img, 0, 0, width, height);</code></p>

<p>2) the <code>noLoop()</code> was removed because I need the loop to perform an animation.</p>

<p>Problem: As you can see, the image is always hidden. 
If I remove the .hide(), the image is draw correctly in the loop but the original one is also not hidden and is displayed just below the canvas.</p>

<pre><code>    var img = null;
    function setup() {
      var c = createCanvas(710, 400);
      background(100);
      c.drop(gotFile);
    }

    function draw() {
      background(0);
      fill(255);
      noStroke();
      textSize(24);
      textAlign(CENTER);
      text('Drag an image file onto the canvas.', width/2, height/2);
      if(img){
        image(img, 0, 0, width, height);   
      }
    }

    function gotFile(file) {
      if (file.type === 'image') {
        img = createImg(file.data).hide();
      } else {
        println('Not an image file!');
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Animated GIF support in P5?</title>
      <link>https://forum.processing.org/two/discussion/12736/animated-gif-support-in-p5</link>
      <pubDate>Tue, 29 Sep 2015 21:17:51 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">12736@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm loading up an animated GIF and see that it loads just the first frame (doesn't play the animation). I'm assuming that animated GIFs aren't supported yet in P5 (but hoping I'm wrong!).</p>

<p>Other relevant links I found are: 
<a href="http://forum.processing.org/two/discussion/comment/42053/#Comment_42053" target="_blank" rel="nofollow">http://forum.processing.org/two/discussion/comment/42053/#Comment_42053</a>
<a href="http://extrapixel.github.io/gif-animation/" target="_blank" rel="nofollow">http://extrapixel.github.io/gif-animation/</a></p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>removing an image once it's drawn?</title>
      <link>https://forum.processing.org/two/discussion/12119/removing-an-image-once-it-s-drawn</link>
      <pubDate>Mon, 17 Aug 2015 08:37:42 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">12119@/two/discussions</guid>
      <description><![CDATA[<p>Hi there. P5 newbie here. Am trying to place an image and then remove it later (on user input). I can place it just fine,</p>

<p>image(myimages[imgselected], 0, 0);</p>

<p>But then, don't seem to be able to remove it. Don't see a remove image function available. And when I try to just move it offscreen, it seems to make a copy of it at the new location. Ie:</p>

<p>image(myimages[imgselected], -1000, -1000);</p>

<p>Just makes a copy of the image at -1000,-1000 and leaves the original in-tact at 0,0.</p>

<p>I have noLoop() turned on, in case this is an issue with not hitting the draw loop?</p>

<p>thx for any pointers.</p>
]]></description>
   </item>
   <item>
      <title>Using loadImage with p5 drop</title>
      <link>https://forum.processing.org/two/discussion/11924/using-loadimage-with-p5-drop</link>
      <pubDate>Sat, 01 Aug 2015 03:41:53 +0000</pubDate>
      <dc:creator>jonhaber</dc:creator>
      <guid isPermaLink="false">11924@/two/discussions</guid>
      <description><![CDATA[<p>More more question on images...</p>

<p>I have implemented the drop p5 example <a href="http://p5js.org/examples/examples/Dom_Drop.php" target="_blank" rel="nofollow">http://p5js.org/examples/examples/Dom_Drop.php</a></p>

<pre>
function setup() {
  // create canvas
  var c = createCanvas(710, 400);
  background(100);
  // Add an event for when a file is dropped onto the canvas
  c.drop(gotFile);
}

function draw() {
  fill(255);
  noStroke();
  textSize(24);
  textAlign(CENTER);
  text('Drag an image file onto the canvas.', width/2, height/2);
  noLoop();
}

function gotFile(file) {
  // If it's an image file
  if (file.type === 'image') {
    // Create an image DOM element but don't show it
    var img = createImg(file.data).hide();
    // Draw the image onto the canvas
    image(img, 0, 0, width, height);
  } else {
    println('Not an image file!');
  }
}
</pre>

<p>and I am trying to merge this code with some p5 image processing code that makes use of the loadImage() function:</p>

<p>eg.</p>

<pre>
img = loadImage("..\test.jpg");
</pre>

<p>because using loadImage lets me use the get() function</p>

<p>eg,</p>

<pre>
img.get()
</pre>

<p>using the drop example and createImage instead of loadImage doesn't allow me to use get()</p>

<p>how can I do droping of files but use the loadImage function with the data the example above gives me</p>

<p>put another way</p>

<p>if I try to use img.get() using the drop example I get the following error:</p>

<p>"Uncaught TypeError: img.get is not a function"</p>

<p>cheers!</p>
]]></description>
   </item>
   <item>
      <title>Not seeing correct colors?</title>
      <link>https://forum.processing.org/two/discussion/10955/not-seeing-correct-colors</link>
      <pubDate>Fri, 22 May 2015 22:36:37 +0000</pubDate>
      <dc:creator>jonhaber</dc:creator>
      <guid isPermaLink="false">10955@/two/discussions</guid>
      <description><![CDATA[<p>I have an image on my canvas but am getting some wacky color values when trying to read colour values under my mouse.</p>

<p>Using an image like this to test my program.:
<img src="http://forum.processing.org/two/uploads/imageupload/695/JUADTA7KBBW2.jpg" alt="test2" title="test2" /></p>

<p>When I move my mouse over parts of the blocks of colour I sometimes get weird value or move the mouse from one block to the next produced weird output. The only weird colour values if present should be where two colours meet and there is some colour blending, otherwise every pixel of each bar should be the same colour but getting results that say otherwise.</p>

<p>Ideas on this one???</p>

<pre>
var state = 0;

function setup() {
  // create canvas
  var c = createCanvas(710, 400);
  background(100);
  // Add an event for when a file is dropped onto the canvas
  c.drop(gotFile);
}

function draw() {
  fill(255);
  noStroke();
  textSize(24);
  textAlign(CENTER);
  if (state == 0){
  text('Drag an image file onto the canvas.', width/2, height/2);
  noLoop();
  }

}

function gotFile(file) {
  // If it's an image file
  if (file.type === 'image') {
    // Create an image DOM element but don't show it
    var img = createImg(file.data).hide();
    // Draw the image onto the canvas
    image(img, 0, 0, width, height);
    state = 0;
  } else {
    println('Not an image file!');
  }
}

function mouseMoved(){
    var color_under_mouse = get(mouseX, mouseY);
    println(mouseX);
    println(mouseY);
    println(color_under_mouse);
}
</pre>

<p>The values of the colours are being printed every time the mouse is moved using a standard print statement.</p>
]]></description>
   </item>
   </channel>
</rss>