cannot use correct size of backgroundImage
Closed this issue · 3 comments
Lxinyuelxy commented
hello,i want to ask a question. when i add the lib to draw a fountain, i found the size of my backgroundImage is incorrect. Before using the lib, it can show normally.Here is my code:
var backgroundImg;
var defs;
var of;
function setup() {
createCanvas(windowWidth, windowHeight);
backgroundImg = loadImage("assets/background.jpg");
var t =
'{ ' +
' "parts": [ ' +
' { ' +
' "name": "foo", ' +
' "color": ' +
' ["orange",[255,0,0],"yellow","white","white"], ' +
' "gravity": 0.1, ' +
' "sizePercent": 0.99, ' +
' "angle": [170,350], ' +
' "speed": 5.5, ' +
' "limit": 250, ' +
' "lifetime": 200, ' +
' "size": [4,12], ' +
' "x": 0.5, ' +
' "y": 0.5}]}';
defs = JSON.parse(t);
of = new Fountain(defs, 'foo');
}
function draw() {
clear();
background(backgroundImg);
of.Draw();
of.Create();
of.Step();
noStroke();
text(of.length, width/2, 20);
stroke(0);
}
bobcgausa commented
My code has nothing to do w background.
Try
Image(img,0,0,width,height) instead
Ps. Move load image to preload func
…Sent from my Windows 10 phone
From: popmusic<mailto:notifications@github.com>
Sent: Wednesday, December 14, 2016 9:39 AM
To: bobcgausa/cook-js<mailto:cook-js@noreply.github.com>
Subject: [bobcgausa/cook-js] cannot use correct size of backgroundImage (#2)
hello,i want to ask a question. when i add the lib to draw a fountain, i found the size of my backgroundImage is incorrect. Before using the lib, it can show normally.Here is my code:
var backgroundImg;
var defs;
var of;
function setup() {
createCanvas(windowWidth, windowHeight);
backgroundImg = loadImage("assets/background.jpg");
var t =
'{ ' +
' "parts": [ ' +
' { ' +
' "name": "foo", ' +
' "color": ' +
' ["orange",[255,0,0],"yellow","white","white"], ' +
' "gravity": 0.1, ' +
' "sizePercent": 0.99, ' +
' "angle": [170,350], ' +
' "speed": 5.5, ' +
' "limit": 250, ' +
' "lifetime": 200, ' +
' "size": [4,12], ' +
' "x": 0.5, ' +
' "y": 0.5}]}';
defs = JSON.parse(t);
of = new Fountain(defs, 'foo');
}
function draw() {
clear();
background(backgroundImg);
of.Draw();
of.Create();
of.Step();
noStroke();
text(of.length, width/2, 20);
stroke(0);
}
like this:
[screenshot]<https://camo.githubusercontent.com/c89f07bef0f5212861afe21eb19e422df61872cb/687474703a2f2f6f66736970317079722e626b742e636c6f7564646e2e636f6d2f2545362538442539352545382538452542373132332e504e47>
-
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#2>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACgphOwEwsp5lbXok7c1lIonZfHEBbBVks5rH_-sgaJpZM4LM_mw>.
Lxinyuelxy commented
Thanks for your reply. But it still cannot show correctly and using Image(img,0,0,width,height) instead, the img will hide the fountain.
var t =
'{ '
......
' "x": 0.5, ' +
' "y": 0.5}]}';
i noticed that the coordinate has been changed. Will it be related to this issue?
bobcgausa commented
Put image first then fountain Will draw on top.
…Sent from my Windows 10 phone
From: popmusic<mailto:notifications@github.com>
Sent: Thursday, December 15, 2016 2:16 AM
To: bobcgausa/cook-js<mailto:cook-js@noreply.github.com>
Cc: bobcgausa<mailto:bobcook47@hotmail.com>; Comment<mailto:comment@noreply.github.com>
Subject: Re: [bobcgausa/cook-js] cannot use correct size of backgroundImage (#2)
Thanks for your reply. But it still cannot show correctly and using Image(img,0,0,width,height) instead, the img will hide the fountain.
var t =
'{ '
......
' "x": 0.5, ' +
' "y": 0.5}]}';
i noticed that the coordinate has been changed. Will it be related to this issue?
-
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#2 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACgphEVBGdvPuXvZdW-IHr_YS59S79W6ks5rIOk_gaJpZM4LM_mw>.