text
stringlengths
0
15.7k
source
stringlengths
6
112
set colb to (round (256 * (blue in color)) rounding down)
raytracer.applescript
on writeColor(outfile, color)
raytracer.applescript
write ("" & colr & " " & colg & " " & colb & "
raytracer.applescript
") to outfile
raytracer.applescript
on writeColorInl(outfile, color)
raytracer.applescript
write (round (256 * (red in color)) rounding down) to outfile
raytracer.applescript
write " " to outfile
raytracer.applescript
write (round (256 * (green in color)) rounding down) to outfile
raytracer.applescript
write (round (256 * (blue in color)) rounding down) to outfile
raytracer.applescript
write "
raytracer.applescript
" to outfile
raytracer.applescript
on writeRGB(outfile, r,g,b)
raytracer.applescript
set colr to (round (256 * (r)) rounding down)
raytracer.applescript
set colg to (round (256 * (g)) rounding down)
raytracer.applescript
set colb to (round (256 * (b)) rounding down)
raytracer.applescript
on writePPMHeader(outfile,imageHeight,imageWidth)
raytracer.applescript
write "P3
raytracer.applescript
" & imageWidth & " " & imageHeight & "
raytracer.applescript
255
raytracer.applescript
on newImageData()
raytracer.applescript
script imagedata
raytracer.applescript
property pixels: {}
raytracer.applescript
on append(pixel)
raytracer.applescript
set end of my pixels to pixel
raytracer.applescript
return imagedata
raytracer.applescript
on writePPMTestImage(filename)
raytracer.applescript
set imageHeight to 256
raytracer.applescript
set imageWidth to 256
raytracer.applescript
set imagedata to newImageData()
raytracer.applescript
log "building outputList"
raytracer.applescript
set imgrow to imageHeight - 1
raytracer.applescript
repeat while imgrow >= 0
raytracer.applescript
log "rendering row " & imgrow
raytracer.applescript
set imgcol to 0
raytracer.applescript
repeat with imgcol from 0 to imageWidth-1
raytracer.applescript
set r to imgcol / (imageWidth-1)
raytracer.applescript
set g to imgrow / (imageHeight-1)
raytracer.applescript
set b to 0.25
raytracer.applescript
imagedata's append(makeColor(r, g, b))
raytracer.applescript
set imgrow to imgrow - 1 -- decr loop var
raytracer.applescript
log "writing output"
raytracer.applescript
set outfile to open for access filename with write permission
raytracer.applescript
writePPMHeader(outfile,imageHeight,imageWidth)
raytracer.applescript
set outputItems to count imagedata's pixels
raytracer.applescript
repeat with outputIndex from 1 to outputItems
raytracer.applescript
if outputIndex mod 1000 = 0
raytracer.applescript
log "wrote " & (round (outputIndex/outputItems)*100) & "%"
raytracer.applescript
writeColor(outfile, (item outputIndex of imagedata's pixels))
raytracer.applescript
log "done writing output"
raytracer.applescript
end writePPMTestImage
raytracer.applescript
on sqrt(x)
raytracer.applescript
x ^ 0.5
raytracer.applescript
if x > 0
raytracer.applescript
on sine_of(x)
raytracer.applescript
repeat until x >= 0 and x < 360
raytracer.applescript
if x >= 360 then
raytracer.applescript
set x to x - 360
raytracer.applescript
set x to x + 360
raytracer.applescript
set x to x * (2 * pi) / 360
raytracer.applescript
set answer to 0
raytracer.applescript
set numerator to x
raytracer.applescript
set denominator to 1
raytracer.applescript
set factor to -(x ^ 2)
raytracer.applescript
repeat with i from 3 to 40 by 2
raytracer.applescript
set answer to answer + numerator / denominator
raytracer.applescript
set numerator to numerator * factor
raytracer.applescript
set denominator to denominator * i * (i - 1)
raytracer.applescript
end sine_of
raytracer.applescript
on cosine_of(x)
raytracer.applescript
set numerator to 1
raytracer.applescript
repeat with i from 2 to 40 by 2
raytracer.applescript
end cosine_of
raytracer.applescript
on tan(x)
raytracer.applescript
set answer to sine_of(x) / (cosine_of(x))
raytracer.applescript
end tan
raytracer.applescript
on v3(x, y, z)
raytracer.applescript
{x:x,y:y,z:z}
raytracer.applescript
on v3add(self, other)
raytracer.applescript
{ ¬ x: x of self + x of other, ¬ y: y of self + y of other, ¬ z: z of self + z of other ¬ }
raytracer.applescript
on v3addMut(self, other)
raytracer.applescript
set x of self to x of self + x of other
raytracer.applescript
set y of self to y of self + y of other
raytracer.applescript
set z of self to z of self + z of other
raytracer.applescript
self
raytracer.applescript
on v3addScalar(self, scalar)
raytracer.applescript
{ ¬ x: x of self + scalar, ¬ y: y of self + scalar, ¬ z: z of self + scalar ¬ }
raytracer.applescript
on v3sub(self, other)
raytracer.applescript
{ ¬ x: x of self - x of other, ¬ y: y of self - y of other, ¬ z: z of self - z of other ¬ }
raytracer.applescript
on v3subScalar(self, scalar)
raytracer.applescript
{ ¬ x: x of self - scalar, ¬ y: y of self - scalar, ¬ z: z of self - scalar ¬ }
raytracer.applescript
on v3mul(self, other)
raytracer.applescript
{ ¬ x: x of self * x of other, ¬ y: y of self * y of other, ¬ z: z of self * z of other ¬ }
raytracer.applescript
on v3mulScalar(self, scalar)
raytracer.applescript
{ ¬ x: x of self * scalar, ¬ y: y of self * scalar, ¬ z: z of self * scalar ¬ }
raytracer.applescript
on v3div(self, other)
raytracer.applescript
{ ¬ x: x of self / x of other, ¬ y: y of self / y of other, ¬ z: z of self / z of other ¬ }
raytracer.applescript
on v3divScalar(self, scalar)
raytracer.applescript
{ ¬ x: x of self / scalar, ¬ y: y of self / scalar, ¬ z: z of self / scalar ¬ }
raytracer.applescript
on v3lengthSq(self)
raytracer.applescript
(x of self * x of self) + (y of self * y of self) + (z of self * z of self)
raytracer.applescript