zak
29-10-2011, 16:35
i have tried to port MathArt canvas (http://www.thinbasic.com/community/showthread.php?11272-math-Art-using-the-Canvas) version to delphi and lazarus, the same algorithm gives almost the same shape but the thinbasic shape are more beautifull than delphi, and the delphi shape have more details:
7573 7574
checking the first pixel color in thinbasic it is :
red,green,blue = -250, -85, 48 and the same for delphi
but thinbasic RGB convert the negative value to zero, so the above color will be 0,0,48 and delphi RGB convert the negative values like this:
RGB(-250+256, -85+256, 48 ) = RGB(6,171,48 )
so if we instruct delphi to behave like thinbasic ie to convert negatives to zero it will produce again beautifull shape.
there are many annoyances in pascal such as the extreme strict we must use, as an example integer variable = Cos(4.23); will produce an error "Incompatible types: 'Integer' and 'Extended'", other annoyance is the Round function, it behaves in the most bizzare way as explained here: http://www.festra.com/eng/tip-rounding.htm
he provide another function to correct the situation.
thinbasic code available in the above link
attached delphi 7.0 code with executable here ( there is no canvas_scale in delphi like that in thinbasic as in the top link second version)
the same code can be used for Lazarus
7573 7574
checking the first pixel color in thinbasic it is :
red,green,blue = -250, -85, 48 and the same for delphi
but thinbasic RGB convert the negative value to zero, so the above color will be 0,0,48 and delphi RGB convert the negative values like this:
RGB(-250+256, -85+256, 48 ) = RGB(6,171,48 )
so if we instruct delphi to behave like thinbasic ie to convert negatives to zero it will produce again beautifull shape.
there are many annoyances in pascal such as the extreme strict we must use, as an example integer variable = Cos(4.23); will produce an error "Incompatible types: 'Integer' and 'Extended'", other annoyance is the Round function, it behaves in the most bizzare way as explained here: http://www.festra.com/eng/tip-rounding.htm
he provide another function to correct the situation.
thinbasic code available in the above link
attached delphi 7.0 code with executable here ( there is no canvas_scale in delphi like that in thinbasic as in the top link second version)
the same code can be used for Lazarus