Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Bottom left corner X*/
- y: 984, /*Bottom left corner Y*/
- width: 78, /*WIDTH OF IMAGE*/
- height: 62 /*HEIGHT OF IMAGE*/
- };
- var perfect_timeout = 60;
- // hooks
- var client;
- var canvasse;
- var jQuery;
- var currentDrawPosition = 0;
- var currentLoop = 0;
- r.placeModule("babaevski", function(e){
- client = e("client");
- canvasse = e("canvasse");
- jQuery = e("jQuery");
- for(var i=0; i<client.palette.length; i++){
- colorsABGR[i] = client.getPaletteColorABGR(i);
- }
- attempt();
- });
- function attempt(){
- console.log("tried to draw");
- tryDrawPixel();
- }
- function tryDrawPixel()
- {
- if(currentLoop < babaevski.width*babaevski.height)
- {
- currentLoop++;
- console.log("checking pixel " + currentDrawPosition);
- var targetPoint = getPoint(currentDrawPosition);
- setTimeout(function() {
- //wait an extra half second for reddits servers
- console.log("x" + targetPoint.x + " y"+ targetPoint.y);
- canvasse.drawTileAt(targetPoint.x, targetPoint.y, colorsABGR[colors[currentDrawPosition]]);
- client.setColor(colors[currentDrawPosition]);
- console.log("drew pixel at " + targetPoint.x + "/" + targetPoint.y);
- currentLoop = 0;
- var positionIncrease = Math.floor(Math.random() * (Math.min(0.2*currentLoop, 40))) + 1;
- currentDrawPosition += positionIncrease;
- //console.log("" + currentLoop + ", " +positionIncrease);
- if (currentDrawPosition >= babaevski.width*babaevski.height)
- currentDrawPosition = 0;
- tryDrawPixel(currentDrawPosition);
- }, 1);
- }
- else
- {
- var added_timeout = 0;
- if (currentLoop == babaevski.width*babaevski.height)
- currentLoop = 0;
- }
- }
- function drawTestRTC(){
- for(var i=0; i < babaevski.width*babaevski.height; i++){
- if(colors[i] === -1){
- continue;
- }
- var targetPoint = getPoint(i);
- canvasse.drawTileAt(targetPoint.x, targetPoint.y, colorsABGR[colors[i]]);
- }
- }
- function getPoint(i){
- var x = i % babaevski.width;
- return {
- x: babaevski.x + x,
- y: babaevski.y + (i - x) / babaevski.width - babaevski.height
- };
- }
- function getPixel(x, y){
- return canvasse.writeBuffer[canvasse.getIndexFromCoords(x, y)];
- }
- //Updated by haydnG (hayhay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement