I’m trying to draw 2 images pulled from 2 select tags on my page with the following code:
<select id="badge1" class="badges" onchange="ReDraw()">
<option value="0001">1</option>
<option value="0002">2</option>
<option value="0003">3</option>
</select>
<select id="badge2" class="badges" onchange="ReDraw()">
<option value="0001">1</option>
<option value="0002">2</option>
<option value="0003">3</option>
</select>
let badge1Select = document.getElementById("badge1");
let badge2Select = document.getElementById("badge2");
Within my ReDraw()
:
let img2 = new Image();
img2.onload = () => {
ctx.drawImage(img2, 175 - img2.width / 2, renderGroup[0][1] - img2.height -5);
};
let img1 = new Image();
img1.onload = () => {
ctx.drawImage(img1, 175 - img1.width / 2, renderGroup[0][1] - img2.height -5 - img1.height);
};
img2.src = `Badges/${badge2Select.value}.png`;
img1.src = `Badges/${badge1Select.value}.png`;
The renderGroup[0][1]
is just a dynamic Y-Coordinate
that changes based on something else in my code. That part works fine.
My intention with this is that when 2 badges are selected, i’d like:
- badge2 to be drawn above
renderGroup[0][1]
with 5 pixels of buffer space. - badge1 to be drawn above badge2 with 5 pixels of buffer space.
My problem:
Is that when I run this code and select 2 badges, the badges are drawn on top of each other not as intended. However if I cycle back and forth on the select, they will be drawn properly above each other as intended. It’s so weird it’s like the first time I call an image, it does’t draw properly but cycling back and forth does…
I added a little console log to find out why the height is giving me issues:
console.log(img2.height);
console.log(img1.height);
Console:
app.js:217 0
app.js:218 66
I hope I put all the information clearly and as concise as I possibly could. I know it has something to do with preloading images I just can’t quite figure it out. I know the answer to this would be trivial to some but I’ve wasted an embarrassing amount of time trying to figure it out I’m turning to you guys.
Thanks
vardenafil online overnight delivery – order vardenafil online legally generic vardenafil review
stromectol 3mg cost – ivermectin and covid stromectol without prescription
cialis online generic – buy online tadalafil no rx pharmacy
stromectole online – site ivermectin for covid
lyrica 20 mg – cvs pharmacy online canadian pharmacy reviews
viagra rx – sildenafil 20 mg online india can you buy sildenafil over the counter
provigil cost – modafinil and birth control modafinil and weight loss
furosemide price comparison – lasix brand name in india lasix 90 20mg
purchase clomid – clomid online 25mg clomid price
buy sildenafil 100mg online – viagra 75 mg price viagra price in us
where to buy stromectol online – stromectol 6mg stromectol for sale
cheapest ed pills online – otcedpill.com vitality ed pills
buy ivermectin cream for humans – cost of stromectol medicine stromectol tablets for sale
best ed pills non prescription uk – medication search ed pills that work
generic ventolin price – ventolin pills ventolin inhalers
cytotec pills canada – cytotec 2017 misoprostol price
where can i buy doxycycline online – order doxycycline no prescription doxycycline no prescription
neurontin 30 mg – synthroid 112 levothyroxine 137 cost
viagra 50mg otc – sildenafil 48 tabs
buy cialis 5mg – cialis 1 mg
vardenafil online sales – mail order vardenafil buy vardenafil 20 mg
buy generic prednisone online – prednisone 20mg tablets where to buy prednisona 5mg
buy accutane online uk – accutane online singapore accutane 40mg
amoxicillin without a doctor’s prescription – avatar de price of amoxicillin without insurance order amoxil
online pharmacy methylprednisolone with no prescription – lyrica tablets for sale lyrica tablet cost
edit my paper – cheap essay help thesis writer
buy generic sildenafil online – Real viagra pharmacy prescription sildenafil 100mg tablets buy online
stromectol tablets for humans for sale – ivermectin cost in usa ivermectin buy online
prednisone online without a prescription – prednisone 12 mg buy prednisone online
ventolin price canada – albuterol nebulizer buy ventolin inhaler
doxycycline over the counter canada – prednisolone 10 mg buy online prednisolone 5 mg
ivermectin online pharmacy – ivermectin lotion ivermectin cream canada cost
ivermectin for covid – ivermectin 9 mg buy stromectol 3mg
online sildenafil prescription – sildepl sildenafil price
tadalafil cost – buy tadalafil online safely generic tadalafil online
ivermectin 500ml – stromectol buy uk ivermectin 6mg
amoxicillin and benadryl
viagra 50mg online in india – Cialis daily where can you buy cialis over the counter
propecia proscar
vardenafil lastgeneric vardenafil – canada drugs direct erectile dysfunction drugs
plaquenil brand name – plaquenil benefits prednisone pills