void LowLevelGraphicsPostScriptRenderer::clipToPath (const Path& path, const AffineTransform& transform) { writeClip(); Path p (path); p.applyTransform (transform.translated ((float) stateStack.getLast()->xOffset, (float) stateStack.getLast()->yOffset)); writePath (p); out << "clip\n"; }
void CtrlrTabsLF::drawTabButtonText (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const Rectangle<float> area (button.getTextArea().toFloat()); float length = area.getWidth(); float depth = area.getHeight(); if (button.getTabbedButtonBar().isVertical()) std::swap (length, depth); Font otherTabFont = owner.getOwner().getOwner().getOwner().getFontManager().getFontFromString (owner.getProperty(Ids::uiTabsTabFont)); Font activeTabFont = owner.getOwner().getOwner().getOwner().getFontManager().getFontFromString (owner.getProperty(Ids::uiTabsFrontTabFont)); otherTabFont.setUnderline (button.hasKeyboardFocus (false)); activeTabFont.setUnderline (button.hasKeyboardFocus (false)); GlyphArrangement textLayout; textLayout.addFittedText (button.isFrontTab() ? activeTabFont : otherTabFont, button.getButtonText().trim(), 0.0f, 0.0f, (float) length, (float) depth, Justification::centred, jmax<int> (1, depth / 12)); AffineTransform t; switch (button.getTabbedButtonBar().getOrientation()) { case TabbedButtonBar::TabsAtLeft: t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom()); break; case TabbedButtonBar::TabsAtRight: t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY()); break; case TabbedButtonBar::TabsAtTop: case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break; default: jassertfalse; break; } Colour col; if (button.isFrontTab() && (button.isColourSpecified (TabbedButtonBar::frontTextColourId) || isColourSpecified (TabbedButtonBar::frontTextColourId))) col = findColour (TabbedButtonBar::frontTextColourId); else if (button.isColourSpecified (TabbedButtonBar::tabTextColourId) || isColourSpecified (TabbedButtonBar::tabTextColourId)) col = findColour (TabbedButtonBar::tabTextColourId); else col = button.getTabBackgroundColour().contrasting(); const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; g.setColour (col.withMultipliedAlpha (alpha)); textLayout.draw (g, t); }
//============================================================================== void LowLevelGraphicsPostScriptRenderer::fillPath (const Path& path, const AffineTransform& t) { if (stateStack.getLast()->fillType.isColour()) { writeClip(); Path p (path); p.applyTransform (t.translated ((float) stateStack.getLast()->xOffset, (float) stateStack.getLast()->yOffset)); writePath (p); writeColour (stateStack.getLast()->fillType.colour); out << "fill\n"; } else if (stateStack.getLast()->fillType.isGradient()) { // this doesn't work correctly yet - it could be improved to handle solid gradients, but // postscript can't do semi-transparent ones. notPossibleInPostscriptAssert // you can disable this warning by setting the WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS flag at the top of this file writeClip(); out << "gsave "; { Path p (path); p.applyTransform (t.translated ((float) stateStack.getLast()->xOffset, (float) stateStack.getLast()->yOffset)); writePath (p); out << "clip\n"; } const Rectangle<int> bounds (stateStack.getLast()->clip.getBounds()); // ideally this would draw lots of lines or ellipses to approximate the gradient, but for the // time-being, this just fills it with the average colour.. writeColour (stateStack.getLast()->fillType.gradient->getColourAtPosition (0.5f)); out << bounds.getX() << ' ' << -bounds.getBottom() << ' ' << bounds.getWidth() << ' ' << bounds.getHeight() << " rectfill\n"; out << "grestore\n"; } }
AffineTransform getTransform() { const float hw = 0.5f * getWidth(); const float hh = 0.5f * getHeight(); AffineTransform t; if (controls.animateRotation.getToggleState()) t = t.rotated (rotation.getValue() * float_Pi * 2.0f); if (controls.animateSize.getToggleState()) t = t.scaled (0.3f + size.getValue() * 2.0f); if (controls.animatePosition.getToggleState()) t = t.translated (hw + hw * (offsetX.getValue() - 0.5f), hh + hh * (offsetY.getValue() - 0.5f)); else t = t.translated (hw, hh); if (controls.animateShear.getToggleState()) t = t.sheared (shear.getValue() * 2.0f - 1.0f, 0.0f); return t; }
AffineTransform PhaseChart::calcTransform () { const Rectangle<int> bounds = getLocalBounds (); const Rectangle<int> r = bounds.reduced (4, 4); AffineTransform t; // scale x from 0..1 to 0..getWidth(), and flip vertical t = AffineTransform::scale (float(r.getWidth()), -1.f); // move y down so 120 is at the top t = t.translated (0.f, 120.f); // scale y from phase to 0..1 bounds in r t = t.scaled (1.f, 1.f/(maxPhase - -maxPhase)); // scale y from 0..1 to getHeight() t = t.scaled (1.f, float(r.getHeight())); // translate t = t.translated (float(r.getX()), float(r.getY())); return t; }
AffineTransform BrickWallChart::calcTransform () { const Rectangle<int> bounds = getLocalBounds (); const Rectangle<int> r = bounds.reduced (4, 4); AffineTransform t; // scale x from 0..1 to 0..getWidth(), and flip vertical t = AffineTransform::scale (float(r.getWidth()), -1.f); // scale y from gain to 0..1 bounds in r t = t.scaled (1.f, m_scale_y); // scale y from 0..1 to getHeight() t = t.scaled (1.f, float(r.getHeight())); // translate t = t.translated (float(r.getX()), float(r.getBottom())); return t; }
void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, const AffineTransform& transform) { const int w = sourceImage.getWidth(); const int h = sourceImage.getHeight(); writeClip(); out << "gsave "; writeTransform (transform.translated ((float) stateStack.getLast()->xOffset, (float) stateStack.getLast()->yOffset) .scaled (1.0f, -1.0f)); RectangleList imageClip; sourceImage.createSolidAreaMask (imageClip, 0.5f); out << "newpath "; int itemsOnLine = 0; for (RectangleList::Iterator i (imageClip); i.next();) { if (++itemsOnLine == 6) { out << '\n'; itemsOnLine = 0; } const Rectangle<int>& r = *i.getRectangle(); out << r.getX() << ' ' << r.getY() << ' ' << r.getWidth() << ' ' << r.getHeight() << " pr "; } out << " clip newpath\n"; out << w << ' ' << h << " scale\n"; out << w << ' ' << h << " 8 [" << w << " 0 0 -" << h << ' ' << (int) 0 << ' ' << h << " ]\n"; writeImage (sourceImage, 0, 0, w, h); out << "false 3 colorimage grestore\n"; needToClip = true; }
void CtrlrLuaMethodEditorTabsLF::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const Rectangle<int> activeArea (button.getActiveArea()); const TabbedButtonBar::Orientation o = button.getTabbedButtonBar().getOrientation(); const Colour bkg (button.getTabBackgroundColour()); if (button.getToggleState()) { g.setColour (bkg); } else { Point<int> p1, p2; switch (o) { case TabbedButtonBar::TabsAtBottom: p1 = activeArea.getBottomLeft(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtTop: p1 = activeArea.getTopLeft(); p2 = activeArea.getBottomLeft(); break; case TabbedButtonBar::TabsAtRight: p1 = activeArea.getTopRight(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtLeft: p1 = activeArea.getTopLeft(); p2 = activeArea.getTopRight(); break; default: jassertfalse; break; } g.setGradientFill (ColourGradient (bkg.brighter (0.2f), (float) p1.x, (float) p1.y, bkg.darker (0.1f), (float) p2.x, (float) p2.y, false)); } g.fillRect (activeArea); g.setColour (button.findColour (TabbedButtonBar::tabOutlineColourId)); Rectangle<int> r (activeArea); if (o != TabbedButtonBar::TabsAtBottom) g.fillRect (r.removeFromTop (1)); if (o != TabbedButtonBar::TabsAtTop) g.fillRect (r.removeFromBottom (1)); if (o != TabbedButtonBar::TabsAtRight) g.fillRect (r.removeFromLeft (1)); if (o != TabbedButtonBar::TabsAtLeft) g.fillRect (r.removeFromRight (1)); const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; Colour col (bkg.contrasting().withMultipliedAlpha (alpha)); if (TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>()) { TabbedButtonBar::ColourIds colID = button.isFrontTab() ? TabbedButtonBar::frontTextColourId : TabbedButtonBar::tabTextColourId; if (bar->isColourSpecified (colID)) col = bar->findColour (colID); else if (isColourSpecified (colID)) col = findColour (colID); } const Rectangle<float> area (button.getTextArea().toFloat()); float length = area.getWidth(); float depth = area.getHeight(); if (button.getTabbedButtonBar().isVertical()) std::swap (length, depth); TextLayout textLayout; createTabTextLayout (button, length, depth, col, textLayout); AffineTransform t; switch (o) { case TabbedButtonBar::TabsAtLeft: t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom()); break; case TabbedButtonBar::TabsAtRight: t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY()); break; case TabbedButtonBar::TabsAtTop: case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break; default: jassertfalse; break; } g.addTransform (t); textLayout.draw (g, Rectangle<float> (length, depth)); }
void paint (Graphics& g) { const TwindyTabbedComponent* const t = (const TwindyTabbedComponent*) getParentComponent(); if (t != 0) { #if JUCE_NEW const Rectangle<int> thisBounds (0, 0, getWidth(), getHeight()); #else const Rectangle thisBounds (0, 0, getWidth(), getHeight()); #endif int i; for (i = 0; i < getNumChildComponents(); ++i) { TwindyTabbedComponentBasicTab* const c = (TwindyTabbedComponentBasicTab*) getChildComponent (i); if (c != (TwindyTabbedComponentBasicTab*)t->tabList [t->currentTab]) { const float indent = 2.0f; float x1 = (float)c->getX(); float y1 = (float)c->getY(); float x2 = x1 + c->getWidth(); float y2 = y1 + c->getHeight(); if (c->getBounds().intersects (thisBounds)) { if (t->orientation == TwindyTabbedComponent::TabsAtTop) { y1 += indent; y2 += 100.0f; } else if (t->orientation == TwindyTabbedComponent::TabsAtBottom) { y2 -= indent; y1 -= 100.0f; } else if (t->orientation == TwindyTabbedComponent::TabsAtLeft) { x1 += indent; x2 += 100.0f; } else if (t->orientation == TwindyTabbedComponent::TabsAtRight) { x2 -= indent; x1 -= 100.0f; } Path p; p.addRoundedRectangle (x1 + t->normalOutlineThickness, y1 + t->normalOutlineThickness, x2 - x1 - t->normalOutlineThickness* 2.0f, y2 - y1 - t->normalOutlineThickness * 2.0f, t->cornerSize); g.setColour (t->deselectedTabCol); g.fillPath (p); g.setColour (t->normalOutlineCol); g.strokePath (p, PathStrokeType (t->normalOutlineThickness)); } } } AffineTransform trans; trans = trans.translated ((float)t->getScreenX() - getScreenX(), (float)t->getScreenY() - getScreenY()); g.setColour (t->fillCol); g.fillPath (t->outlineShape, trans); g.setColour (t->selectedOutlineCol); g.fillPath (t->strokedOutline, trans); } }
void PoleZeroChart::paintContents (Graphics& g) { Colour cPole (0xd0ff0000); Colour cZero (0xd02020ff); Rectangle<int> bounds = getLocalBounds(); short size = short ((jmin (getWidth(), getHeight()) + 2) / 3); // scale the graph down if the pole/zeroes lie outside the unit disc AffineTransform t = AffineTransform::identity; { float margin = 0.2f; if (m_max > 1 + margin) { t = t.scaled (float(1/(m_max-margin)), float(1/(m_max-margin))); } } t = t.scaled (float(size), -float(size)); t = t.translated (float(bounds.getCentreX()), float(bounds.getCentreY())); g.setColour (m_cAxis); { Point<float> p = Point<float>(100000, 0).transformedBy (t); g.drawLine (-p.getX(), p.getY(), p.getX(), p.getY(), 1); } { Point<float> p = Point<float>(0, 100000).transformedBy (t); g.drawLine (p.getX(), -p.getY(), p.getX(), p.getY(), 1); } { Point<float> p0 = Point<float>(-1, -1).transformedBy (t); Point<float> p1 = Point<float>( 1, 1).transformedBy (t); g.drawEllipse (p0.getX(), p0.getY(), p1.getX()-p0.getX(), p1.getY()-p0.getY(), 1); } const float r = 3.5f; for (size_t i = 0; i < m_vpz.size(); ++i) { const Dsp::PoleZeroPair& pzp = m_vpz[i]; if (!pzp.is_nan()) { { Point<float> p (float(pzp.poles.first.real()), float(pzp.poles.first.imag())); p = p.transformedBy (t); g.setColour (cPole); g.drawLine (p.getX()-r, p.getY()-r, p.getX()+r, p.getY()+r); g.drawLine (p.getX()+r, p.getY()-r, p.getX()-r, p.getY()+r); } { Point<float> p (float(pzp.zeros.first.real()), float(pzp.zeros.first.imag())); p = p.transformedBy (t); g.setColour (cZero); g.drawEllipse (p.getX()-r, p.getY()-r, 2*r, 2*r, 1); } if (!pzp.isSinglePole()) { { Point<float> p (float(pzp.poles.second.real()), float(pzp.poles.second.imag())); p = p.transformedBy (t); g.setColour (cPole); g.drawLine (p.getX()-r, p.getY()-r, p.getX()+r, p.getY()+r); g.drawLine (p.getX()+r, p.getY()-r, p.getX()-r, p.getY()+r); } { Point<float> p (float(pzp.zeros.second.real()), float(pzp.zeros.second.imag())); p = p.transformedBy (t); g.setColour (cZero); g.drawEllipse (p.getX()-r, p.getY()-r, 2*r, 2*r, 1); } } } } }