DIV ARENA FORUMS

Challenge #2 - Pixel Painter

MikeDX - 17-3-2016 at 05:23 PM

Create a simple paint program using the smallest code possible:

Requirements:

- visible cursor
- ability to change colours of pen
- ability to change pen size
- draw with mouse / mouse buttons (left - draw / right - erase)

whitespace (spaces, carriage returns, tabs) and comments do not count, so no need to minify your code)

you can use any graphics you like, but if you made them in the div editor, thats best ;)

Smallest code wins...


Putting that all inside one process is going to be totally awesome

iWizard - 17-3-2016 at 05:55 PM

Ability to change pen size is a requirement that's going to award you bonus points?

MikeDX - 17-3-2016 at 06:07 PM

well if its a tie between two, the one with the pen size will win


also i reckon you don't even need a process...


- edit

realise what i'd done. obviously i mean to have pen size optional.

Score: 310

MikeDX - 18-3-2016 at 03:29 AM

Here is my effort. Deliberately not too squashed to give you guys a chance ;)

Z - change cursor size
C - Change colour





Code:
program pixel; local a,b,c,d; s=1; begin graph=load_map("cursor.map"); loop x=mouse.x; y=mouse.y; size=s*100/3; if(mouse.left || mouse.right) for(a=0;a<s;a++) for(b=0;b<s;b++) put_pixel(x+a,y+b,c*mouse.left); end end end if (key(_z)) s=(s%10)+1; while(key(_z)) frame; end end if (key(_c)) c=(c+1)%255; while(key(_c)) frame; end end frame; end end


Can you do better? can we get it below 200?

Attachment: pixela.zip (2kB)
This file has been downloaded 3792 times

Ooh, I'm pretty sure I could easily double that. Derp.

iWizard - 18-3-2016 at 10:15 AM

Quote: Originally posted by MikeDX  
well if its a tie between two, the one with the pen size will win


also i reckon you don't even need a process...


- edit

realise what i'd done. obviously i mean to have pen size optional.

Dirty edit!

I haven't put a though on making this yet but what I ment by a process is the direction these are heading. And now it got extreme :s I'm not even remotely pissed off because Dennis uninvented DIV and shamed my 320 chars in the process. No, sir. :no:

Got a busy schedule today but should have time to have a look at this in the evening.

The Bestest Painting Program Ever Made v34.2a

iWizard - 18-3-2016 at 12:40 PM

Since you made that below 200 remark you MIGHT know how to get it below 200 but I'll still post this anyways. Pokerface.
Code:
Program a; global c,h,v,s; begin mouse.graph = load_map("m.MAP"); loop h = mouse.x; v = mouse.y; if( key(_a) ) c = h; s = v; end if( mouse.left ) draw(5, c, 9, 0, h, v, h+s, v+s); end if( mouse.right ) draw(5, 0, 9, 0, h, v, h+s, v+s); end Frame; end end

203. No bug reports please because they would be just false and ain't nobody got time for that.

edit: ooh, I just saw what you did with the mouse buttons :ninja:

MikeDX - 18-3-2016 at 01:16 PM

I think this could crash with too many draws..

And you could easily get rid of loads more code ;)

also where is m.MAP?

This isn't looking good is it.. million points?

iWizard - 18-3-2016 at 03:43 PM

The draw commands are nearly identical, so perhaps there what I've already suggested, but that's all the code there is! Put your money where those filthy things come out of. Tonight. After Dennis, Sandman and a mysterious third person have destroyed me. :cries:

And what did I say about bug reports!!!!!!!!!!!!!!!!! :cries:

MikeDX - 18-3-2016 at 05:33 PM

Quote: Originally posted by iWizard  
The draw commands are nearly identical, so perhaps there what I've already suggested, but that's all the code there is! Put your money where those filthy things come out of. Tonight. After Dennis, Sandman and a mysterious third person have destroyed me. :cries:

And what did I say about bug reports!!!!!!!!!!!!!!!!! :cries:


Yeah but since you failed, for multiple reasons, it is disqualified.

iWizard - 18-3-2016 at 06:56 PM

This is the worst competition like ever :love:

Score: 300

MikeDX - 19-3-2016 at 12:44 PM

Better version:





Code:
program p; local c=14,d,s=5; begin load_fpg("p"); draw(5,c,9,0,x,y,x,y); loop x=mouse; y=mouse.y; d=mouse.right; if (key(_z)) s=(s%50)+4; end if (key(_c)) c=(c+1)%255; end while(key(_c)|key(_z)) frame; end put_screen(0,2); frame; move_draw(1,c*(1-d)+1,15,x,y,x+s,y+s); if(mouse.left|d) screen_copy(0,0,2,0,0,320,200); end end end


Attachment: pixel.zip (2kB)
This file has been downloaded 4185 times


Dennis - 25-3-2016 at 12:01 PM

Quote: Originally posted by iWizard  
This is the worst competition like ever :love:






(Un)fortunately I will not participate in this one... I don't think I can do better than the last entry. :P