On Tuesday, June 21, 2016 at 6:26:28 AM UTC-4, Egon wrote: > > > > On Tuesday, 21 June 2016 12:50:16 UTC+3, Egon wrote: >> >> >> >> On Monday, 20 June 2016 18:02:53 UTC+3, blue...@gmail.com wrote: >>> >>> >>> <https://lh3.googleusercontent.com/-bPOQJTHF8Js/V2gEJqUg5jI/AAAAAAAAACI/lg6cWG0cJqo0tFl4wsuDYF2w4kycTbRPACLcB/s1600/blank.png> >>> >>> I am attempting to generate a random starfield, in go. This is something >>> that will need to printed on actual paper, but that is another issue and I >>> only mention it to give some context for what I am doing here: Using go to >>> create graphics to pair with something I'm already doing in go (I've been >>> through several iterations of trying to use the go parts I have with >>> numerous variations of tex/latex templates using asymptote, and I reached a >>> point of frustration where I figured why not just do it all in go, as it >>> seems less a problem than I originally thought -- but opens a new set of >>> problems to solve, one of the biggest is that I know nothing at all about >>> graphics, let alone how to apply graphics in go). >>> >>> Cosmic1 from: >>> https://gist.github.com/thrisp/1ed1785ac6a902585595fb8cb52f0a16, >>> generates the above it is the first thing that even roughly approximates >>> what I want to do. >>> >>> Any thoughts, or help cleaning that up. Maybe tell me why exactly I >>> can't directly translate an opengl shader to something cpu bound(which I >>> suspect is a thing, I may need to do more that I can't see right now). >>> >> >> As for the current code: >> >> Here you are picking a random rotation for each pixel: >> a1 := .5 + float64(float64(mr.Intn(size.X))/3)/float64(mr.Intn(size.X))*2 >> a2 := .8 + float64(float64(mr.Intn(size.X))/2)/float64(mr.Intn(size.Y))*2 >> >> This can change for every pixel (in shader the time is a constant for one >> frame): >> time := float64(time.Now().UTC().Unix())*speed + 0.25 >> >> In func toUint8(in float64) uint8 { you need to clamp the value between 0 >> and 255, otherwise the conversion overflows. >> >> Color adjusting code doesn't match the shader code. >> >> I suspect there are further issues in the iteration code. >> >> PS: often with such fragments you can simplify code and achieve a similar >> result with less details, e.g. >> https://gist.github.com/egonelbre/b5f41ac8946e609ce1a944631dd462ef >> > > Here's the minimal code for doing that: > https://gist.github.com/egonelbre/811d37e94dda69b6d92365a7e63a2eec > > + Egon >
thanks, that puts me further along than I was: https://github.com/thrisp/art/blob/master/cosmic.go -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.