Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -1,60 +1,52 @@
|
|||
import gintro/[glib, gobject, gtk, gio, cairo]
|
||||
import gtk2, glib2, gdk2, cairo
|
||||
|
||||
const
|
||||
Width = 420
|
||||
Height = 420
|
||||
|
||||
const Colors = [[255.0, 255.0, 255.0], [0.0, 0.0, 0.0]]
|
||||
const Colors = [(1.0, 1.0, 1.0), (0.0, 0.0, 0.0)]
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
|
||||
proc draw(area: DrawingArea; context: Context) =
|
||||
proc onExposeEvent(widget: PWidget; event: PEventExpose; data: Pgpointer): gboolean {.cdecl.} =
|
||||
## Draw the bars.
|
||||
|
||||
const lineHeight = Height div 4
|
||||
|
||||
let cr = cairo_create(widget.window)
|
||||
|
||||
var y = 0.0
|
||||
for lineWidth in [1.0, 2.0, 3.0, 4.0]:
|
||||
context.setLineWidth(lineWidth)
|
||||
cr.setLineWidth(lineWidth)
|
||||
var x = 0.0
|
||||
var colorIndex = 0
|
||||
while x < Width:
|
||||
context.setSource(Colors[colorIndex])
|
||||
context.moveTo(x, y)
|
||||
context.lineTo(x, y + lineHeight)
|
||||
context.stroke()
|
||||
let (r, g, b) = Colors[colorIndex]
|
||||
cr.setSourceRgb(r, g, b)
|
||||
cr.moveTo(x, y)
|
||||
cr.lineTo(x, y + lineHeight)
|
||||
cr.stroke()
|
||||
colorIndex = 1 - colorIndex
|
||||
x += lineWidth
|
||||
y += lineHeight
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
cr.destroy()
|
||||
|
||||
proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
|
||||
## Callback to draw/redraw the drawing area contents.
|
||||
|
||||
area.draw(context)
|
||||
result = true
|
||||
proc onDestroyEvent(widget: PWidget; data: Pgpointer): gboolean {.cdecl.} =
|
||||
## Quit the application.
|
||||
main_quit()
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
|
||||
proc activate(app: Application) =
|
||||
## Activate the application.
|
||||
nim_init()
|
||||
let window = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
window.set_title("Pinstripe")
|
||||
|
||||
let window = app.newApplicationWindow()
|
||||
window.setSizeRequest(Width, Height)
|
||||
window.setTitle("Color pinstripe")
|
||||
let drawingArea = drawing_area_new()
|
||||
window.add drawingArea
|
||||
drawingArea.set_size_request(Width, Height)
|
||||
|
||||
# Create the drawing area.
|
||||
let area = newDrawingArea()
|
||||
window.add(area)
|
||||
discard drawingArea.signal_connect("expose-event", SIGNAL_FUNC(onExposeEvent), nil)
|
||||
discard window.signal_connect("destroy", SIGNAL_FUNC(onDestroyEvent), nil)
|
||||
|
||||
# Connect the "draw" event to the callback to draw the bars.
|
||||
discard area.connect("draw", ondraw, pointer(nil))
|
||||
|
||||
window.showAll()
|
||||
|
||||
#———————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
let app = newApplication(Application, "Rosetta.Pinstripe")
|
||||
discard app.connect("activate", activate)
|
||||
discard app.run()
|
||||
window.show_all()
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue