Login | Register
Nerd ParadiseArtisanal tutorials since 1999
Python Code Golf
Current challenge:
"Determine if a sentence is a palindrome."

Current shortest code:
70 bytes

Current contest ends:
1579996800, F jS, g:i A
Give it a try
Post article ideas here. Can't guarantee they can be made into articles.

Also feature Ideas. Can't guarantee they can be made into features.


Forum Rules (Community Decided, Sorta) >>> RULES
  
Not necessarily an article idea, but more forums would be nice. Maybe, like, one for each group of topics. Make it match the sidebar navigation panel? And add a programmer-only recursion joke for the forum forums? Of course, Home and About would probably not be included.

Just spitballing. Also trying to populate the forums.
  
I am here for the MsPaint. The stretch -> dither -> shrink algorithm to blend pictures is super smart and haven't seen it elsewhere.

For what it's worth, one can still invert colors on Windows 7, using `Ctrl`+`Shift`+`I`, but it's no longer on the menu.

Couple of ideas for additional MsPaint article topics:
Rotation by arbitrary angles is possible, but it requires a bit of Trig on the side. From the derivation at https://math.stackexchange.com/questions/47255/math-behind-rotation-in-ms-paint/3148478#3148478

%Rh=100∗cos(θ)
%Rv=100/cos(θ)
DegSkh=arctan(sin(θ)cos(θ))
DegSkv=−θ

Dilation (and its complement, erosion) are commonly used in image processing algorithms. One can do crude dilation in MsPaint by transparent-selecting a 2-tone object and "stamp moving" the selection using `Shift`+`[LRUD]Arrow`. Stamp one pixel to the right, then one up, then two left, then two down, then two right, and voila.
To erode, one simply "dilates the background".
One useful application of this technique is creating text outlines. The main problem is text interpolates with the background it is placed on, so it doesn't qualify as 2-tone. One can get around this limitation by placing <r, g, b> = <0, 0, 0> (black) text on <0, 0, 1> (darkest possible blue) background, then transparent-select moving it elsewhere.

Another application is connecting detected edges. If one dilates then erodes, nearby edges will connect during the dilation and not disconnect during erosion.

An easy application of edge detection is edge sharpening.**
  • Edge-detect on image A to create image E
  • Copy A to create image B
  • Use transparent-select to paste just the white edges from E onto B
  • Blend A and B to create an edge-sharpened version of A
** This algorithm is actually just an approximation. Most edge detection is not 2-tone output, and sharpening adds to each pixel an amount of white that is proportional to its edgyness. This algorithm simply brightens edges, by blending them with white.
  
The Glass Button MsPaint Tutorial is solid gold. It is 90% of the way to producing a radial gradient.

A radial gradient has color as a distance from its center as C_r(r, thet) = f(r) = f(sqrt(x**2 + y**2))

A horizontal gradient blended with a vertical gradient has color function C(x, y) = (g(x) + h(y))/2

So with g(x) ~ x**2, and h(y) ~ y**2, the blend will look like a radial gradient with f(r) ~ r**2.

One can create a linear x**2 gradient by using the Bezier tool:
1) Canvas 199x99
2) Line (0, 0) to (100, 99)
3) Line (199, 0) to (100, 99) //These are guidelines
4) Bezier (0,0) to (199, 0). ControlPoint0@(66,66), ControlPoint1@(133,66)

The ControlPoints were chosen because they make a cubicBezier equivalent to quadraticBezier. See: https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Properties

This creates a parabola that will still be a parabola as you stretch and shrink it. Crop the canvas to 100 wide, and vertically to include exactly half the parabola.

Make it into a linear gradient, then stretch it out to 100x100px.
Create a rotated copy.
Blend the horizontal and the vertical and it creates one quadrant of a radial gradient. Copy and rotate 3 times (arrange as necessary) for a full radial gradient.
  
Forum > Website Topics > Article Ideas