September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,35 @@
|
|||
' version 01-09-2017
|
||||
' compile with: fbc -s console
|
||||
' or compile with: fbc -s gui
|
||||
' hit any key to stop
|
||||
|
||||
Dim As UInteger d, blocks, blocksize, ps, col, h, w, x, y1, y2
|
||||
|
||||
ScreenInfo w, h
|
||||
' create display size window, 8bit color (palette), no frame
|
||||
ScreenRes w, h, 8,, 8
|
||||
|
||||
For x = 0 To 255 ' create grayscale palette for
|
||||
Palette x, x, x, x ' the window we just opened
|
||||
Next
|
||||
|
||||
h = h \ 4 : y2 = h -1
|
||||
|
||||
If w Mod 64 <> 0 Then w -= (w Mod 64)
|
||||
blocks = 8 : blocksize = w \ 8
|
||||
|
||||
For ps = 1 To 4
|
||||
For x = 0 To blocks -1
|
||||
col = 255 * x \ (blocks -1) ' from black to white
|
||||
If (ps And 1) = 0 Then col = 255 - col ' from white to black
|
||||
Line (x * blocksize, y1) - (((x +1) * blocksize) -1, y2), col, bf
|
||||
Next
|
||||
y1 += h : y2 += h
|
||||
blocks *= 2 : blocksize \= 2
|
||||
Next
|
||||
|
||||
' empty keyboard buffer
|
||||
While Inkey <> "" : Wend
|
||||
|
||||
Sleep
|
||||
End
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Public Sub Form_Open()
|
||||
Dim iRow, iCol, iClr As Integer 'For Row, Column and Colour
|
||||
Dim iInc As Integer = 4 'To calculate RGB colour
|
||||
Dim h1Panel As Panel 'Panels to display colours
|
||||
|
||||
With Me 'Setup the Form
|
||||
.Arrangement = Arrange.Row 'Arrange children in rows
|
||||
.Border = False 'No Border
|
||||
.Height = Desktop.Height 'Fill the screen
|
||||
.Width = Desktop.Width 'Fill the screen
|
||||
.Fullscreen = True 'Set the Form to Fullscreen
|
||||
End With
|
||||
|
||||
For iRow = 1 To 4 'For each row..
|
||||
iInc += iInc 'Increase iInc by itself
|
||||
For iCol = 0 To iInc - 1 'For each column..
|
||||
iClr = iCol * (256 / iInc) 'Set the RGB colour
|
||||
If iRow = 2 Or iRow = 4 Then iClr = 255 - (iCol * (256 / iInc)) 'If row 2 or 4 then reverse the colours
|
||||
h1Panel = New Panel(Me) 'Create a new Panel
|
||||
With h1Panel 'With the Panel..
|
||||
.Width = Desktop.Width / iInc 'Set the width
|
||||
.Height = Desktop.Height / 4 'Set the height
|
||||
.Background = Color.RGB(iClr, iClr, iClr) 'Set the Background colour
|
||||
.Border = Border.Plain 'Set a Border (It's easier to see the colour changes)
|
||||
End With
|
||||
Next
|
||||
Next
|
||||
|
||||
End
|
||||
|
|
@ -16,21 +16,22 @@ public class Greybars extends JFrame {
|
|||
|
||||
public void paint ( Graphics g ) {
|
||||
int run = 0 ;
|
||||
int colorcomp = 0 ; //component of the color
|
||||
double colorcomp = 0.0 ; //component of the color
|
||||
for ( int columncount = 8 ; columncount < 128 ; columncount *= 2 ) {
|
||||
int colorgap = 255 / columncount ; //by this gap we change the background color
|
||||
double colorgap = 255.0 / (columncount - 1) ; //by this gap we change the background color
|
||||
int columnwidth = width / columncount ;
|
||||
int columnheight = height / 4 ;
|
||||
if ( run % 2 == 0 ) //switches color directions with every for loop
|
||||
colorcomp = 0 ;
|
||||
colorcomp = 0.0 ;
|
||||
else {
|
||||
colorcomp = 255 ;
|
||||
colorgap *= -1 ;
|
||||
colorcomp = 255.0 ;
|
||||
colorgap *= -1.0 ;
|
||||
}
|
||||
int ystart = 0 + columnheight * run ;
|
||||
int xstart = 0 ;
|
||||
for ( int i = 0 ; i < columncount ; i++ ) {
|
||||
Color nextColor = new Color( colorcomp, colorcomp, colorcomp ) ;
|
||||
int icolor = (int)Math.round(colorcomp) ; //round to nearer integer
|
||||
Color nextColor = new Color( icolor , icolor, icolor ) ;
|
||||
g.setColor( nextColor ) ;
|
||||
g.fillRect( xstart , ystart , columnwidth , columnheight ) ;
|
||||
xstart += columnwidth ;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// version 1.1
|
||||
|
||||
import java.awt.Color
|
||||
import java.awt.Graphics
|
||||
import javax.swing.JFrame
|
||||
|
||||
class GreyBars : JFrame("grey bars example!") {
|
||||
private val w: Int
|
||||
private val h: Int
|
||||
|
||||
init {
|
||||
w = 640
|
||||
h = 320
|
||||
setSize(w, h)
|
||||
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
override fun paint(g: Graphics) {
|
||||
var run = 0
|
||||
var colorComp: Double // component of the color
|
||||
var columnCount = 8
|
||||
while (columnCount < 128) {
|
||||
var colorGap = 255.0 / (columnCount - 1) // by this gap we change the background color
|
||||
val columnWidth = w / columnCount
|
||||
val columnHeight = h / 4
|
||||
if (run % 2 == 0) // switches color directions with each iteration of while loop
|
||||
colorComp = 0.0
|
||||
else {
|
||||
colorComp = 255.0
|
||||
colorGap *= -1.0
|
||||
}
|
||||
val ystart = columnHeight * run
|
||||
var xstart = 0
|
||||
for (i in 0 until columnCount) {
|
||||
val iColor = Math.round(colorComp).toInt()
|
||||
val nextColor = Color(iColor, iColor, iColor)
|
||||
g.color = nextColor
|
||||
g.fillRect(xstart, ystart, columnWidth, columnHeight)
|
||||
xstart += columnWidth
|
||||
colorComp += colorGap
|
||||
}
|
||||
run++
|
||||
columnCount *= 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
GreyBars()
|
||||
}
|
||||
70
Task/Greyscale-bars-Display/Phix/greyscale-bars-display.phix
Normal file
70
Task/Greyscale-bars-Display/Phix/greyscale-bars-display.phix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
--
|
||||
-- demo\rosetta\Greyscale_bars.exw
|
||||
--
|
||||
include pGUI.e
|
||||
|
||||
Ihandle dlg, canvas
|
||||
cdCanvas cddbuffer, cdcanvas
|
||||
|
||||
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
|
||||
cdCanvasActivate(cddbuffer)
|
||||
integer {width, height} = IupGetIntInt(canvas, "DRAWSIZE")
|
||||
integer h = ceil(height/4)
|
||||
for row=1 to 4 do
|
||||
integer x = 0, p2 = power(2,row+2), c = floor(255/(p2-1))
|
||||
for n=0 to p2-1 do
|
||||
integer colour = c*n*#010101
|
||||
if and_bits(row,1)=0 then colour = xor_bits(colour,#FFFFFF) end if
|
||||
cdCanvasSetForeground(cddbuffer, colour)
|
||||
integer nx = ceil(width*(n+1)/p2)
|
||||
cdCanvasBox(cddbuffer, x, nx, height-h, height)
|
||||
x = nx
|
||||
end for
|
||||
height -= h
|
||||
end for
|
||||
cdCanvasFlush(cddbuffer)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function map_cb(Ihandle ih)
|
||||
cdcanvas = cdCreateCanvas(CD_IUP, ih)
|
||||
cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function unmap_cb(Ihandle /*ih*/)
|
||||
cdKillCanvas(cddbuffer)
|
||||
cdKillCanvas(cdcanvas)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function esc_close(Ihandle /*ih*/, atom c)
|
||||
if c=K_ESC then return IUP_CLOSE end if
|
||||
return IUP_CONTINUE
|
||||
end function
|
||||
|
||||
procedure main()
|
||||
IupOpen()
|
||||
|
||||
canvas = IupCanvas(NULL)
|
||||
IupSetAttribute(canvas, "RASTERSIZE", "600x400")
|
||||
|
||||
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
|
||||
IupSetCallback(canvas, "UNMAP_CB", Icallback("unmap_cb"))
|
||||
|
||||
dlg = IupDialog(canvas)
|
||||
IupSetAttribute(dlg, "TITLE", "Greyscale bars")
|
||||
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
|
||||
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
|
||||
|
||||
IupMap(dlg)
|
||||
IupSetAttribute(canvas, "RASTERSIZE", NULL)
|
||||
|
||||
IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
|
||||
|
||||
IupMainLoop()
|
||||
|
||||
IupClose()
|
||||
end procedure
|
||||
|
||||
main()
|
||||
13
Task/Greyscale-bars-Display/Zkl/greyscale-bars-display.zkl
Normal file
13
Task/Greyscale-bars-Display/Zkl/greyscale-bars-display.zkl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
img:=PPM(640,480);
|
||||
foreach q in ([0..3]){ //quarter of screen
|
||||
n:=(8).shiftLeft(q); //number of bars
|
||||
w:=640/n; //width of bar (pixels)
|
||||
foreach b in ([0..n-1]){ //for each bar...
|
||||
c:=(255.0/(n-1).toFloat() * (if(q.isOdd) n-1-b else b)).toInt();
|
||||
c:=c.shiftLeft(16) + c.shiftLeft(8) + c; //RGB color = gray
|
||||
foreach y in ([(3-q)*120 .. (3-q+1)*120-1]){ // flip image vertically
|
||||
img.line(w*b,y, w*(b+1)-1,y, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
img.write(File("foo.ppm","wb"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue