Giter Site home page Giter Site logo

Comments (11)

CuriousKit avatar CuriousKit commented on June 15, 2024

How goes the progress in fixing this?

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

I'm busy with other stuff so I'm not working on it (which is why I haven't assigned it to myself)

from graphics32.

CuriousKit avatar CuriousKit commented on June 15, 2024

That's fair. I saw that you made a commit related to the bug and thought initially that the bug had been fixed, but a closer look at the commit messages indicates that it's not all fixed yet. Still, these messages will indicate that the issue is still open.

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

For reference, what we need is a replacement for the current (broken) algorithm:

function MirrorPow2(Value, Max: Integer): Integer; overload;
begin
  if Value and (Max + 1) = 0 then
    Result := Value and Max
  else
    Result := Max - Value and Max;
end;

MirrorPow([0..13], 3)
Expected: 0123210123210
Actual: 0123210301232

from graphics32.

CuriousKit avatar CuriousKit commented on June 15, 2024

I'll take a study of the file myself at some point. I'm curious to know what the function is supposed to do exactly.

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

The Clamp, Wrap, and Mirror functions are primarily used when sampling bitmaps (e.g. resizing, rotating, transforming, etc). They specify how out of bounds pixel coordinates should be handled.
https://graphics32.github.io/Docs/Units/GR32/Types/TWrapMode.htm

from graphics32.

CuriousKit avatar CuriousKit commented on June 15, 2024

Ah I see, thank you. Having played with textures in OpenGL, I can definitely see the importance of getting this function correct then!

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

...and also used by some gradient functions: https://graphics32.github.io/Docs/Units/GR32_ColorGradients/Classes/TCustomGradientPolygonFiller/Properties/WrapMode.htm

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

I can definitely see the importance of getting this function correct then!

I would think so but the bug has been there since the functions introduction in 2007...

from graphics32.

lamdalili avatar lamdalili commented on June 15, 2024

Sorry I didn't notice that it was resolved in new branch

function Mirror(Value, Max: Integer): Integer;
var
Quotient: Integer;
begin
if Value < 0 then
Value := -Value;
Quotient := DivMod(Value, Max, Result);
if ((Quotient and 1) = 1) then
Result := Max - Result;
end;

Test on GradFills example :
Original mirror :

mirror 1

After correction

Mirror 2

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

@lamdalili Thanks but the Mirror function has already been fixed in the LowLevel.Mirror branch:

function Mirror(Value, Max: Integer): Integer;
var
Quotient: Integer;
begin
if Value < 0 then
Value := -Value;
Quotient := DivMod(Value, Max, Result);
if ((Quotient and 1) = 1) then
Result := Max - Result;
end;

What remains to be fixed is the MirrorPow2 function:

function MirrorPow2(Value, Max: Integer): Integer; overload;
begin
if Value < 0 then
Value := -Value;
if ((Value and (Max + 1)) = 0) then
Result := (Value ) and Max
else
Result := (Max - Value + Max) and Max;
end;

See: #291 (comment)

from graphics32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.