From a8336fcff852757232e037ef08f387fb17538196 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 24 Aug 2015 09:51:41 +0200 Subject: Bitmaps & clipping mode in drawingframe -- StdFile doesn't play nice with debugging symbols, so -tst removed from Makefile --- Makefile | 2 +- drawingframe.icl | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 94cd5dd..e55296f 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ OBJECTIOCDIR=$(OBJECTIOLINUX)/Linux_C_12 CLM=clm CLM_LIBS=$$(for l in $$(pkg-config --libs gtk+-2.0); do echo -n "-l $$l "; done)-l -lpthread CLM_INC=-I $(OBJECTIO) -I $(OBJECTIOLINUX) -I $(CLEANLIB)/StdLib -CLM_OPTS=-tst +CLM_OPTS= APP_OPTS=-h 512M diff --git a/drawingframe.icl b/drawingframe.icl index 73164d7..09ff7e4 100644 --- a/drawingframe.icl +++ b/drawingframe.icl @@ -15,12 +15,15 @@ module drawingframe import StdEnv, StdIO Start :: *World -> *World -Start world = startIO SDI Void (snd o openWindow Void testwindow) [ProcessClose closeProcess] world +Start world +# (bitmap, world) = openBitmap "bitmap.bmp" world += startIO SDI Void (snd o openWindow Void (testwindow bitmap)) [ProcessClose closeProcess] world -testwindow = Window "Test Drawing (chapter 5)" NilLS [ +testwindow bitmap = Window "Test Drawing (chapter 5)" NilLS [ WindowViewSize size, WindowClose (noLS closeProcess), WindowLook True (\_ _ . example o (setPenColour Red) o (setPenBack Green)), + //WindowLook True (\_ _ . example bitmap), WindowViewDomain {corner1=origin,corner2=maxdomain} ] where @@ -29,15 +32,15 @@ where maxdomain = {x=origin.x+size.w,y=origin.y+size.h} // Rainbow -example pict = foldr id pict [fill {corner1={x=x1 * w,y=0},corner2={x=x1 * w + w,y=h}} o (setPenColour (rainbow (toReal x1 / 5.0))) \\ x1 <- [0..160]] -where - w = 5 - h = 100 - rainbow :: a -> Colour | toReal a - rainbow i = let i` = toReal i - f = 0.3 in RGB { r = toInt (sin (f * i` + 0.0) * 127.0) + 128, // http://krazydad.com/tutorials/makecolors.php - g = toInt (sin (f * i` + PI / 1.5) * 127.0) + 128, - b = toInt (sin (f * i` + PI / 0.75) * 127.0) + 128 } +//example pict = foldr id pict [fill {corner1={x=x1 * w,y=0},corner2={x=x1 * w + w,y=h}} o (setPenColour (rainbow (toReal x1 / 5.0))) \\ x1 <- [0..160]] +//where +// w = 5 +// h = 100 +// rainbow :: a -> Colour | toReal a +// rainbow i = let i` = toReal i +// f = 0.3 in RGB { r = toInt (sin (f * i` + 0.0) * 127.0) + 128, // http://krazydad.com/tutorials/makecolors.php +// g = toInt (sin (f * i` + PI / 1.5) * 127.0) + 128, +// b = toInt (sin (f * i` + PI / 0.75) * 127.0) + 128 } // Points //example = drawPointAt zero o (setPenSize 1) @@ -113,14 +116,16 @@ curve = { curve_oval = { oval_rx=5, oval_ry=3 }, //example = unfillAt zero {polygon_shape=[{vx=8,vy=0},{vx=(-8),vy=8},{vx=8,vy=0}]} // Bitmaps -//@todo +//example (Just bitmap) = draw bitmap +//example (Just bitmap) = draw (resizeBitmap {w=500,h=250} bitmap) // XOR mode -//@todo +//example pict = appXorPicture (draw {zero & corner2={x=49,y=49}}) (drawAt {x=23,y=23} {oval_rx=24,oval_ry=24} (setPenSize 2 pict)) // Hilite mode //example = hilite {corner1={x=0,y=2},corner2={x=24,y=(-10)}} o (drawAt zero "Pop") // Clipping mode -//@todo +//f = seq [drawLine {x=0,y=y} {x=50,y=y} \\ y <- [0,10..40]] o (setPenSize 2) +//example = appClipPicture (toRegion {polygon_pos=zero, polygon={polygon_shape=[{vx=50,vy=0},{vx=(-25),vy=50}]}}) f -- cgit v1.2.3