Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Heart
Author | Message | ||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Not a lot to say. It should run on anything from a geek to cmm2 and MMB4W ' OPTION EXPLICIT OPTION DEFAULT INTEGER DIM INTEGER frame, c DIM FLOAT x, y, p, w = MM.HRES, h = MM.HRES, hw = w/2, hh = h/2,sz, ys = 40 FUNCTION sdHeart(x AS FLOAT,y AS FLOAT) AS FLOAT STATIC FLOAT a, b, c y = y + 0.5 : y = 1.0 - y : x = ABS(x) IF x + y > 1.0 THEN sdHeart = SQR((x - 0.25) * (x - 0.25) + (y - 0.75) * (y - 0.75)) - 0.35355 ELSE c = x + y IF c < 0 THEN c = 0.0 ENDIF a = x * x + (y - 1.0) * (y - 1.0) b = (x - 0.5 * c) * (x - 0.5 * c) + (y - 0.5 * c) * (y - 0.5 * c) IF a < b THEN sdHeart = SQR(a) * SGN(x-y) ELSE sdHeart = SQR(b) * SGN(x-y) ENDIF ENDIF END FUNCTION CLS FOR frame = 1 TO 250 FOR c = 1 TO 10 x = RND()*w y = RND()*h p = sdHeart((x - hw) / hh, (y - hh) / hh) * hh IF p < 0 THEN COLOUR RGB(150,20,10) sz = 1.5 ELSE COLOUR RGB(20,20,70) sz = 1.5 ENDIF p = ABS(p) CIRCLE x,y-ys,p NEXT c PAUSE 100 NEXT frame It needs the pause to see whats happening. Translated form PureBasic which was translated from https://www.shadertoy.com/view/dljyDc Jim VK7JH MMedit MMBasic Help |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 896 |
Looks good. Your title is probably going to get a lot of views considering the age of members on here.(and not just because Valentines day just passed) Gerry Latest F4 Latest H7 |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9306 |
I immediately thought of the 70's rock band! Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
I should have thought of that and made the PAUSE a random number to better match my rhythm. Jim VK7JH MMedit MMBasic Help |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Very Nice Jim, I guess you forgot to give your wife flowers and had to make amends? Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
ebbandflow Newbie Joined: 31/08/2023 Location: United StatesPosts: 19 |
<3 this! Thanks for sharing. |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1109 |
Line 6 includes "h = MM.HRES". Is that as intended? It works fine regardless. Visit Vegipete's *Mite Library for cool programs. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
That was the deliberate typo to see if anyone was looking. Either that or I should proofread my work better. As you probably assumed it should be MM.Vres and if you correct that, you will need to change the end of the line to ys = 0 Dim Float x, y, p, w = Mm.hres, h = Mm.vres, hw = w/2, hh = h/2,sz, ys = 0 ys was added to make it fit the geek but correcting h was the correct fix. Jim VK7JH MMedit MMBasic Help |
||||
Print this page |