Functional Problem Solving (CSC 151 2015S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] - [Calendar]
Current: [Assignment] [EBoard am] [EBoard pm] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards am] [EBoards pm] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014F)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Book Office Hours] - [Issue Tracker (Course)]
Overview
Can we make the turtle choose its color based on its position?
Um ...
(turtle-set-color! turtle (irgb-complement (image-get-pixel (turtle-x turtle) (turtle-y turtle))))
Here's some code that almost works
(define turtle-oppose!
(lambda (turtle)
(turtle-set-color!
turtle
(irgb-complement
(image-get-pixel (turtle-world turtle)
(turtle-x turtle)
(turtle-y turtle))))))
How would one tilt the area of an ellipse?
Wait until tonight when Sam distributes the code he wrote this afternoon because he was predicting this question.
Can I select something more complex using a turtle?
image-select-polygon (in the tips) shows a technique, including using a turtle.
Once you've selected, you can also use gimp-selection-grow and gimp-selection-feather, both in the PDB list.
Can I draw offset nested circles?
Here's a start.
(define center-circle
(lambda (image x y radius)
(image-select-ellipse! image REPLACE
(- x radius)
(- y radius)
(+ radius radius)
(+ radius radius))
(image-stroke! image)
(image-select-nothing! image)))
(define off-center-circle
(lambda (image x y radius percent angle)
(let ([hyp (* percent radius)])
(center-circle image
(+ x (* hyp (sin angle)))
(+ y (* hyp (cos angle)))
radius))))
Main topics:
Likely quiz questions:
Sample
(define vector-sum
(lambda (vec)
(let kernel ([sum-so-far 0]
[index 0])
(if (< index (vector-length vec))
(kernel (+ sum-so-far (vector-ref vec index))
(+ index 1))
sum-so-far))))
sum-so-var.