Infinite Canvas

42 Replies
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Kouhai
Kouhai3y ago
You'll need to implement 2 systems 1- a system that renders cells based on an offset 2- a system that maps elements/cells from world coordinates to grid coordinates
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Thinker
Thinker3y ago
Again you should really not try to create any kind of notion of an "infinite" canvas
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Thinker
Thinker3y ago
nice, well done
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
You probably can't have an actual infinite canvas for a problem like this where each cell has state. I imagine there's a lot of scenarios where the "life" propagates infinitely...unless you're limiting the "universe's" lifetime to a few thousand time steps. There are some WPF infinite canvas libraries like https://github.com/mircea21S/RichCanvas, but they're more for art and less for computational units. I've done similar for a pixel art editor, but it's not really an infinite canvas when it comes to state either.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Thinker
Thinker3y ago
That sounds unnecessarily memory ineffective
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Kouhai
Kouhai3y ago
How much is the difference now?
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Kouhai
Kouhai3y ago
Oh 😅 I meant, surely making the canvas really large would incur more memory usage
amio
amio3y ago
You don't have to store stuff as contiguous arrays though, plenty of applications can use something like a Dictionary<(x, y), Whatever> - that way you essentially have a "space" to put things in but only if there's anything there. It's going to have limitations too though.
Thinker
Thinker3y ago
Specifically for Game of Life you can just use a hash set of all live cells since dead cells which do not have any live neighbors don't do anything.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
If it's general use, then you should provide approaches for both sparse (Dictionary is better here) and dense representations (contiguous types are better here).
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
Contiguous means all of the items are consecutive in memory. eg. Array and List<T> types are contiguous. Linked lists, dictionaries, (usually) trees are not. Dense representations mean that the data is dense with information...as opposed to being mostly zeros. An image would be dense, whereas Conway's Game of Life is relatively sparse.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
Why wouldn't a user be able to retrieve all placed cells? Those 3 operations can work for both List<T> and Dictionary<TKey, TValue> types.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
You can. You can also expose a slightly more convenient method if that's required.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
What do you mean separately? How is your Dictionary defined?
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
You shouldn't need ToTuple, just the Item1. You might be able to use a named tuple here instead, but I'm not sure. I'd probably prefer a Point type as key.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
It's not obvious unless you're familiar with C# tuples. 🤷‍♂️
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
Just disable the WPF designer and then there's no crash. goodthinking
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
TBH, I'm not even sure how your stuff is working. You aren't using dependency properties for InfiniteBoardControl. You're using standard properties.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
It's a lot to go through: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/dependency-properties-overview?view=netframeworkdesktop-4.8 Basically, it's a supercharged property that lets you use it from XAML properly with binding and automatic value converter support. propdp is the code snippet
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3y ago
zonedetec#9544
Name: Wpf Infinite Board Purpose: An infinite and fully customizable grid control where you can navigate and place cells Main Contributor : Me Source : https://github.com/zonetecde/WpfInfiniteBoard & https://www.nuget.org/packages/WpfInfiniteBoard/1.0.3
Embed Type
Article
Quoted by
<@!698293804897271809> from #showcase (click here)
From zonedetec#9544
React with ❌ to remove this embed.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Klarth
Klarth3y ago
First, BorderProperty there is misspelled. Second, you should already have a Background dp by deriving from Control, AFAIK.

Did you find this page helpful?