C
C#13mo ago
Boom

❔ Blazor Webassembly

Trying to put an image into a canvas so I can use coordinates to place images in different spots. Trying to use https://github.com/BlazorExtensions/Canvas but no success getting images to show up in it.
8 Replies
Boom
Boom13mo ago
code <div class="canvas" style="border-style: solid;width: 100%; height: 100%"> <BECanvas @ref="_canvasReference"> </BECanvas> </div> In OnAfterRenderAsync() { _context = await _canvasReference.CreateCanvas2DAsync(); await _context.DrawImageAsync(_planetImage, 0, 0, 400, 400); }
friedice
friedice13mo ago
What's context Do you have the full code
Boom
Boom13mo ago
Yeah I can post more just tried to keep it simple <div class="canvas" style="border-style: solid;width: 500px; height: 500px"> <BECanvas @ref="_canvasReference"> </BECanvas> </div> @code { ElementReference _planetImage; BECanvasComponent _canvasReference; Canvas2DContext _context; protected override async Task OnAfterRenderAsync(bool firstRender) { if(!firstRender) { return; } _context = await _canvasReference.CreateCanvas2DAsync(); await _context.DrawImageAsync(_planetImage, 0, 0, 400, 400); } } full repo is here in case you believe it's project issues https://github.com/mwsaari/NotAStarWarsSim But I believe I've pasted the relevant code. If there is a way of putting up multiple images from a list at arbitrary x,y coordinates that doesn't need a this canvas I'd be happy to hear taht too
friedice
friedice13mo ago
haven't used this library specifically, but scanning through it and your code I noticed you didn't add width and height to the BECanvas component
<BECanvas Width="300" Height="400" @ref="_canvasReference" ></BECanvas>
<BECanvas Width="300" Height="400" @ref="_canvasReference" ></BECanvas>
Not sure if this is the issue
Boom
Boom13mo ago
I've had that it doesn't seem to change anyhting
friedice
friedice13mo ago
have you tried just filling an empty rect just to see if this lib works?
Boom
Boom13mo ago
Actually got advice in web that I could set imagine locations just by settings the left and top in css like this <div @ref="@context.ElementReference" class="panzoom" style="border-style: solid;width: 1000px; height: 1000px"> <img style="position: absolute; left: 100; top: 100; width: 100px; height: 100px" src="/Planets/star_blue01.png" /> <img style="position: absolute; left: 200; top: 200; width: 100px; height: 100px" src="/Planets/star_blue01.png" /> </div> but only getting one image showing up weird nvm just missing the px
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Log into minecraft with xbox/microsoft apiI was wondering how to authenticate a Minecraft account with Microsofts new account system and if th❔ optimizationSincere question about optimization here... The RenderFirstTab() method is called in an infinite lo❔ How to instantiate derived class when base class requires args?Hey, I'll post the code below but I don't think it'll be necessary as I'm pretty sure I know what th❔ Not sure should I leave the automatic table alteration (postgres EF Core 3.0 to EF Core 6.0)You can see on the picture that EF Core has added some non intentional AlterColumn entries. I guess ❔ Writing VS Extension to Support Language with TextMate Grammar FileHello, I am trying to write extension to support BNF(Backus–Naur form) metalanguage files. I am try❔ Change trigger behavior from code behind(!)Hello again. I am still making a chess game using wpf&wcf. And the problem is that entire board is g❔ Getting SQL data from a relationship tableHello, for my school assignment I have to make a winforms app. Currently I have 3 tables in my SQL D❔ Fast Fourier Transform. I need to make app displaying image and result like ImageJImageJ: https://imagej.net/ij/ So i've chosen to make WPF app because im familiar with it and .NET i❔ ✅ I feel like I've gotten lost in what I'm doing right now, pls help.```cs public async Task DisplayUpdatedTicketsAsync(){ await UpdateTicketsAsync(); DisplayTic❔ How Configure Visual Studio to use webservice SOAP with .p12 certificateLet's see if someone can help me to connect SOAP with .pk certificate using visual studio, I'm alrea