// Addon to Bitmap pixel access blocks extension // Mark Guzdial, November 2015 addExtension (authoringSpecs) 'Pixels' (array //(array 'r' 'self_pixelCount' 'pixels count : from _' 'bitmap') (array 'r' 'getX' 'get X-position from _' 'pixel' nil) (array 'r' 'getY' 'get Y-position from _' 'pixel' nil) (array ' ' 'self_saveCostume' 'save costume as image named _' 'string' 'image1') ) to self_saveCostume imageName { m = (morph (implicitReceiver)) bm = (costumeData m) proj = (projectForMorph m) setName bm imageName add (images proj) bm } method getX Pixel { //m = (morph (implicitReceiver)) bm = (costumeData targetMorph) indexless = (index - 1) if (index < (width bm)) {return 1} i = (toInteger (indexless % (width bm))) return (i + 1) } method getY Pixel { //m = (morph (implicitReceiver)) bm = (costumeData targetMorph) indexless = (index - 1) i = (toInteger (index / (width bm))) if ((i + 1) > (height bm)) {return (height bm)} return (i + 1) }