Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* * * IN DRRACKET ONLY * * * * My code has the first part which displays the first 3 polygons i just need
IN DRRACKET ONLY
My code has the first part which displays the first polygons i just need assitance with the last part. please dont add other libraries i only need racketdraw and colors:
#lang racket
require racketdraw ; graphics library
require colors
define imageWidth
define imageHeight
define target makebitmap imageWidth imageHeight ; A bitmap
define dc new bitmapdcbitmap target ; a drawing context
; Draw a rectangle that fills the screen with a background color
send dc setpen "transparent" 'solid ; set pen to transparent mode
send dc setbrush makecolor 'solid ; set fill color
send dc drawrectangle imageWidth imageHeight ; draw filled rectangle
define originalPolygon new dcpath
send originalPolygon moveto ; input points
send originalPolygon lineto
send originalPolygon lineto
send originalPolygon lineto
send originalPolygon close
send dc setpen "red" 'solid ; set pen color
send dc setbrush makecolor 'solid ; set fill color
; Draw the original polygon
send dc drawpath originalPolygon
; Define translation amounts
define dx ; translation in xdirection
define dy ; translation in ydirection
; Translate the original polygon and then draw it again
define translatedPolygon new dcpath
send translatedPolygon append originalPolygon
send translatedPolygon translate dx dy
send dc drawpath translatedPolygon
; Define scaling factors
define sx ; scale factor in xdirection
define sy ; scale factor in ydirection
; Scale the original polygon and then draw it a third time
define scaledPolygon new dcpath
send scaledPolygon append originalPolygon
send scaledPolygon scale sx sy
; Define translation amounts for the scaled polygon
define scaledDx ; translation in xdirection
define scaledDy ; translation in ydirection
; Translate the scaled polygon and then draw it a third time
define translatedScaledPolygon new dcpath
send translatedScaledPolygon append scaledPolygon
send translatedScaledPolygon translate scaledDx scaledDy
send dc drawpath translatedScaledPolygon
target ; show image
Construct a loop or recursive function that
Rotates the polygon
Sets the color
Draws the polygon
Rotate through degrees. in say polygons or so
Cycle through all of the colors in the color wheel.
Save your image
Display your image
Success should look like this: Success
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started