leviathan
leviathan
CC#
Created by leviathan on 8/14/2024 in #help
Adding a CommaToken in a code fix
No description
4 replies
CC#
Created by leviathan on 3/18/2023 in #help
Simple 2D graphics in C#
Thanks! That is exactly what I was looking for!
7 replies
CC#
Created by leviathan on 3/18/2023 in #help
Simple 2D graphics in C#
Indeed, it ins't straightforward at all. From what I read, I'd need to add a texture for every primitive I wanted. I'm looking for something that allows me to do something like:
Circle(new Vec(0,0), 5);
Polygon(new Vec(0,0), new Vec(2,2), new Vec(1,0));
Circle(new Vec(0,0), 5);
Polygon(new Vec(0,0), new Vec(2,2), new Vec(1,0));
(syntax is merely illustrative)
7 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
I've got it working!
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Unfortunately I have to go now. I'll try to integrate it at a later date (probably tomorrow). I'll let you know if I manage to do it (or if I have any more questions...). I can't thank you enough for your help!
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Sorry, what is MVVM?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
So I would add this to MainWindow and invoke it from RenderFrame, am I right?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Alright, I'll make it readonly and deal with it. That can be a future me problem.
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Then I'll try to get away with it being mutable, if I do get issues I'll change to immutable
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Well, I don't think I'll really need it, so I'll take it out. As for making it readonly, would it still allow for something like some_color.r+=0.1f?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
I've refactored it as such:
public struct Color
{
private float _r;
private float _g;
private float _b;

public float r => _r;
public float g => _g;
public float b => _b;

public float this[int index] {
get => index switch {
0 => _r,
1 => _g,
2 => _b,
_ => throw new ArgumentOutOfRangeException(nameof(index))
};
set => {
switch(value) {
case 0:
_r = value; break;
case 1:
_g = value; break;
case 2:
_b = value; break;
default:
throw new ArgumentOutOfRangeException(nameof(value));
}
}
}

public Color(float r = 0, float g = 0, float b = 0) {
this._r = r;
this._g = g;
this._b = b;
}
}
public struct Color
{
private float _r;
private float _g;
private float _b;

public float r => _r;
public float g => _g;
public float b => _b;

public float this[int index] {
get => index switch {
0 => _r,
1 => _g,
2 => _b,
_ => throw new ArgumentOutOfRangeException(nameof(index))
};
set => {
switch(value) {
case 0:
_r = value; break;
case 1:
_g = value; break;
case 2:
_b = value; break;
default:
throw new ArgumentOutOfRangeException(nameof(value));
}
}
}

public Color(float r = 0, float g = 0, float b = 0) {
this._r = r;
this._g = g;
this._b = b;
}
}
Is this fine? Or should I completely get rid of that indexer?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
There's no harm in keeping the indexer, is there?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Yes, it is
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
It's a colour - so I guess it is a single pixel.
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
I've of course looked at ColorScaleBitmapAdapter.Render, but I don't quite understand what's going on...
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
I'm not sure how I can convert my Image class to a WriteableBitmap... Could you please check the code at https://github.com/levi-gomes/RIRE and give me some clues?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
Fair enough
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
In this case, shouldn't it be
if (!Bitmap?.TryLock(new System.Windows.Duration(TimeSpan.FromMilliseconds(500))))
if (!Bitmap?.TryLock(new System.Windows.Duration(TimeSpan.FromMilliseconds(500))))
Using the null-forgiving member-access operator?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
if (!Bitmap!.TryLock(new System.Windows.Duration(TimeSpan.FromMilliseconds(500))))
if (!Bitmap!.TryLock(new System.Windows.Duration(TimeSpan.FromMilliseconds(500))))
What is the !. operator in this line?
113 replies
CC#
Created by leviathan on 10/22/2022 in #help
Rendering and updating a colormap
What's the purpose of a BitmapAdapter?
113 replies